veoflow 0.5.3 → 0.5.4

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.
@@ -333,8 +333,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
333
333
  `,` · `)},e.id))]}),(0,Y.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Calls between files`,children:[...e.calls??[],...e.callStubEdges??[]].map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`pick-node`,"data-link":!0,"data-id":e.id,tabIndex:-1,onClick:()=>n(e.id),children:[C(e.from),` calls `,C(e.to),`: `,e.calls,` calls, `,e.references,` references`]})},e.id))}),(0,Y.jsx)(`button`,{className:`fit`,onClick:()=>u.current&&oS(u.current),children:`Fit`})]})}function oS(e){e.fit(void 0,30);let t=e.zoom();if(t>1.2)e.zoom(1.2),e.center();else if(t<.75){let t=e.elements().boundingBox();e.zoom(.75),e.pan({x:30-t.x1*.75,y:30-t.y1*.75})}}function sS(){return[{selector:`node`,style:{shape:`round-rectangle`,width:160,height:50,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`144px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:X(`gray-26`),"background-color":X(`gray-100`),"border-width":1,"border-color":X(`gray-86`)}},{selector:`node.box`,style:{width:`data(w)`,height:`data(h)`,"background-color":X(`gray-98-5`),"border-color":X(`blue-87`),"border-width":2,"text-valign":`top`,"text-halign":`center`,"text-margin-y":22,"font-weight":`bold`,color:X(`blue-47`),events:`no`,"z-compound-depth":`bottom`,"z-index":0}},{selector:`node.folder`,style:{"background-color":X(`gray-97-3`),"border-style":`double`,"border-width":3}},{selector:`node.broken`,style:{"border-color":X(`amber-74`)}},{selector:`node.not-analyzed`,style:{color:X(`gray-66`),"border-style":`dashed`}},{selector:`node.stub`,style:{width:180,height:46,"border-style":`dashed`,"border-color":X(`blue-62`),color:X(`gray-26`)}},{selector:`node.stub.packages`,style:{"border-color":X(`gray-81`),color:X(`gray-44`)}},{selector:`node.stub.broken`,style:{"border-color":X(`amber-74`),"background-color":X(`gray-99-3`),color:X(`amber-43`)}},{selector:`node.stub.not-analyzed, node.stub.pending`,style:{"border-color":X(`gray-81`),"background-color":X(`gray-99`),color:X(`gray-51-2`)}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":X(`blue-70`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`blue-70`),"arrow-scale":.8,label:`data(label)`,"font-size":10,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1}},{selector:`edge.out`,style:{"line-style":`dashed`,"line-color":X(`blue-76`),"target-arrow-color":X(`blue-76`)}},{selector:`edge.imports, edge.out:not(.calls)`,style:{opacity:.35,width:1}},{selector:`edge.calls`,style:{width:`data(width)`,"line-color":X(`blue-49`),"target-arrow-color":X(`blue-49`),"line-style":`solid`,opacity:1}},{selector:`edge.calls.out`,style:{"line-style":`dashed`,"line-color":X(`blue-62`)}},{selector:`edge.out.broken`,style:{"line-color":X(`amber-74`),"target-arrow-color":X(`amber-74`)}},...Ze(),Ge,{selector:`node.picked`,style:{"border-width":2,"border-color":X(`blue-56`),"background-color":X(`gray-97`)}},{selector:`edge.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`),width:2.5}},{selector:`.faded`,style:{opacity:.3}}]}var cS=`veoflow.allCode`,lS=`veoflow-all-code`;function uS(){try{return localStorage.getItem(cS)===`1`}catch{return!1}}function dS(){let[e,t]=(0,y.useState)(uS);return(0,y.useEffect)(()=>{let e=()=>t(uS());return window.addEventListener(lS,e),()=>window.removeEventListener(lS,e)},[]),[e,e=>{try{localStorage.setItem(cS,e?`1`:`0`)}catch{}t(e),window.dispatchEvent(new Event(lS))}]}var fS=new Map,pS=`veoflow-groups-forget`;function mS(){for(let e of[...fS.keys()])e.startsWith(`["groups"`)&&fS.delete(e);window.dispatchEvent(new Event(pS))}function hS(e,t,n){let r=fS.get(e);return r||(r=n(),fS.set(e,r),r.then(n=>n.committedRun!==t&&fS.delete(e),()=>fS.delete(e)),fS.size>40&&fS.delete(fS.keys().next().value)),r}function gS(e,t,n,r,i){let[a,o]=(0,y.useState)({key:null,data:null,error:null});return(0,y.useEffect)(()=>{if(e===null)return;let r=!1;return hS(e,t,n).then(t=>!r&&o({key:e,scope:i,data:t,error:null}),t=>!r&&o({key:e,scope:i,data:null,error:t.message})),()=>{r=!0}},[e,r]),a.key===e?a:i!==void 0&&a.scope===i&&a.data?{data:a.data,error:null}:{data:null,error:null}}function _S(e,t,n=0,r=null){let[i,a]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=()=>a(e=>e+1);return window.addEventListener(pS,e),()=>window.removeEventListener(pS,e)},[]);let{data:o,error:s}=gS(e?JSON.stringify([`groups`,e,t,r]):null,t,()=>J.groups(e,r),`${n}:${i}`);return{groups:o,error:s}}function vS(e,t,n,r,i,a=0){let o=[...r].sort(),{data:s,error:c}=gS(e&&n?JSON.stringify([`group`,e,t,n,o,i]):null,t,()=>J.group(e,n,o,i),a,JSON.stringify([e,t,n]));return{group:s,error:c}}function yS(e,t,n){let{data:r,error:i}=gS(e&&n?JSON.stringify([`imports`,e,t,n]):null,t,()=>J.imports(e,n),0);return{imports:r,error:i}}function bS(e,t,n,r){let{data:i,error:a}=gS(e&&n?JSON.stringify([`reach`,e,t,n,r]):null,t,()=>J.reach(e,n,r),0);return{reach:i,error:a}}function xS(e,t,n){let{data:r,error:i}=gS(e&&n?JSON.stringify([`calls`,e,t,n]):null,t,()=>Promise.all([J.crossFileCalls(e,n,`out`),J.crossFileCalls(e,n,`in`)]).then(([e,t])=>({committedRun:e.committedRun,out:e,in:t})),0);return{calls:r,error:i}}var SS=null,CS=e=>({onMouseDown:e=>{SS={x:e.clientX,y:e.clientY}},onClick:t=>{let n=SS!==null&&Math.hypot(t.clientX-SS.x,t.clientY-SS.y)>3;SS=null;let r=window.getSelection();n&&r&&!r.isCollapsed&&t.currentTarget.contains(r.anchorNode)||e()}}),wS=(e,t)=>!t&&(e===null||e.kind===`source`),TS=100;function ES(e,t,n,r,i){let[a]=dS(),o=wS(n,a),s=JSON.stringify([e,n,r,o]),c=JSON.stringify([s,t,i]),[l,u]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(!e)return;let t=!1;return J.findings(e,r.length?r:[`broken`],n?.kind===`file`?{file:n.file,own:o}:n?.kind===`group`?{group:n.group,own:o}:n?.kind===`source`?{source:n.source,own:o}:{own:o},r.length?1e3:1).then(e=>!t&&u({key:c,same:s,data:e,error:null}),e=>!t&&u({key:c,same:s,data:null,error:e.message})),()=>{t=!0}},[c]),!l||l.same!==s?{data:null,error:null}:{data:l.data,error:l.key===c?l.error:null}}function DS({project:e,run:t,scope:n,wholeProject:r,canScope:i,showPending:a,refresh:o,filter:s,onFilter:c,onWholeProject:l,onTogglePending:u,onSelectSite:d,onOpenImport:f,onManageLicense:p}){let m=r?null:n,[h,g]=dS(),_=wS(m,h),{data:v}=ES(e,t,m,[],o),b=v?.counts,x=s??(b&&b.broken>0?`broken`:`open-call`),S=[x,...a&&x!==`open-call`?[`pending`]:[]],{data:C,error:w}=ES(e,t,m,S,o),[T,E]=(0,y.useState)(null),D=C&&T?.after===C?T.rows:[],O=[...C?.findings??[],...D],[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(``),N=()=>{C&&(A(!0),M(``),J.findings(e,S,m?.kind===`file`?{file:m.file,own:_}:m?.kind===`group`?{group:m.group,own:_}:m?.kind===`source`?{source:m.source,own:_}:{own:_},1e3,O.length).then(e=>E({after:C,rows:[...D,...e.findings]}),e=>M(e.message)).finally(()=>A(!1)))},{groups:P}=_S(e,t),F=(0,y.useMemo)(()=>new Map((P?.groups??[]).map(e=>[e.id,e])),[P]),I=e=>{let t=e.group?F.get(e.group):void 0,n=t&&t.kind!==`cluster`&&t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t?`${t.name} › `:``}${n}:${e.line}`},L=n?.kind===`group`?F.get(n.group)?.name??`this group`:``,R=i&&n&&(0,Y.jsxs)(`div`,{className:`scope`,role:`group`,"aria-label":`Findings scope`,children:[(0,Y.jsx)(`button`,{"aria-pressed":!r,onClick:()=>l(!1),"data-testid":`questions-scope-file`,children:n.kind===`file`?`This file`:n.kind===`group`?`This group (${L})`:`This repository (${n.name??n.source})`}),(0,Y.jsx)(`button`,{"aria-pressed":r,onClick:()=>l(!0),"data-testid":`questions-scope-project`,children:`Whole project`})]}),z=(e,t,n)=>(0,Y.jsxs)(`button`,{className:`chip`,"aria-pressed":x===e,"data-testid":`findings-filter-${e}`,"data-count":n??``,onClick:()=>c(e),children:[t,` `,(0,Y.jsx)(`small`,{children:n??`…`})]},e),B=O.filter(e=>e.kind===x),V=O.filter(e=>e.kind===`pending`);return(0,Y.jsxs)(`div`,{className:`findings-panel`,"data-testid":`findings-panel`,children:[(0,Y.jsx)(We,{project:e,run:t,refresh:o,onManage:p}),R,(0,Y.jsxs)(`div`,{className:`chips`,role:`group`,"aria-label":`Kinds of findings`,children:[z(`broken`,`Broken imports`,b?.broken),z(`not-analyzed`,`Imports not analyzed`,b?.notAnalyzed),z(`open-call`,`Open calls`,b?.openCalls)]}),(0,Y.jsxs)(`label`,{className:`toggle small muted`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:a,onChange:u}),`Show pending (waiting for another source)`,b?` · ${b.pending}`:``]}),(m===null||m.kind===`source`)&&(0,Y.jsxs)(`label`,{className:`toggle small muted`,title:`Own code first: findings in tests, installed libraries, generated output and tools' files are counted when this is on`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`findings-all-code`,checked:h,onChange:e=>g(e.target.checked)}),`Libraries and tests too`]}),w?(0,Y.jsx)(`p`,{className:`hint error`,children:w}):C?x===`open-call`?(0,Y.jsx)(jS,{rows:B,where:I,project:e,onSelect:d}):(0,Y.jsxs)(Y.Fragment,{children:[x===`not-analyzed`&&(!m||m.kind===`source`)&&(0,Y.jsx)(NS,{project:e,run:t,source:m?.source??null,refresh:o}),(0,Y.jsx)(kS,{rows:B,empty:x===`broken`?`No broken imports.`:`No imports of files left out of analysis.`,where:I,project:e,onOpen:f})]}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`}),C&&a&&x!==`open-call`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Pending (`,V.length,`)`]}),(0,Y.jsx)(kS,{rows:V,empty:`Nothing waits for another source.`,where:I,project:e,onOpen:f})]}),C&&C.total>O.length&&(0,Y.jsxs)(`p`,{className:`hint small`,"data-testid":`findings-truncated`,children:[`Showing `,O.length.toLocaleString(`en-US`),` of `,C.total.toLocaleString(`en-US`),`.`,` `,(0,Y.jsx)(`button`,{className:`link`,"data-testid":`findings-more`,disabled:k,onClick:N,children:k?`Loading…`:`Show more`}),j&&(0,Y.jsxs)(`span`,{className:`error`,children:[` `,j]})]})]})}function OS({project:e,id:t}){let[n,r]=(0,y.useState)(!1);return n?(0,Y.jsx)(Re,{project:e,id:t,start:!0}):(0,Y.jsx)(`button`,{className:`link small`,"data-command":`explain-finding`,onClick:()=>r(!0),children:`Explain`})}function kS({rows:e,empty:t,where:n,project:r,onOpen:i}){let[a,o]=(0,y.useState)(TS);return e.length===0?(0,Y.jsx)(`p`,{className:`hint`,children:t}):(0,Y.jsxs)(`ul`,{className:`questions finding-rows`,"data-testid":`finding-rows`,children:[e.slice(0,a).map(e=>(0,Y.jsxs)(`li`,{"data-kind":e.kind,children:[(0,Y.jsx)(`div`,{className:`qrow`,children:(0,Y.jsxs)(`button`,{"data-command":`open-finding`,"data-id":e.id,...CS(()=>i(e.file,e.id,e.group)),children:[(0,Y.jsx)(`code`,{children:e.text}),(0,Y.jsxs)(`small`,{children:[n(e),` · `,$x[e.reason]??e.reason,AS(e)]})]})}),(0,Y.jsx)(OS,{project:r,id:e.id})]},e.id)),e.length>a&&(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link`,onClick:()=>o(a+TS),children:[e.length-a,` more…`]})})]})}function AS(e){let t=e.impact;return!t||t.opens<=1?``:` · opens ${`${t.atLeast?`at least `:``}${t.opens} function${t.opens===1?``:`s`}`}${t.groups>1?` in ${t.groups} groups`:``}${t.shared?`, shared with ${t.shared} more`:``}`}function jS({rows:e,where:t,project:n,onSelect:r}){let[i,a]=(0,y.useState)(TS),[o,s]=(0,y.useState)(null),c=(0,y.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.text);e?e.push(n):t.set(n.text,[n])}let n=e=>Math.max(0,...e.map(e=>e.impact?.opens??0)),r=e=>Number(e.every(e=>e.mayBe?.projectFunctions===0));return[...t].sort(([e,t],[i,a])=>r(t)-r(a)||n(a)-n(t)||a.length-t.length||(e<i?-1:+(e>i)))},[e]),l=e=>e.id.startsWith(`resolution|`)?e.id.slice(11):e.id;return e.length===0?(0,Y.jsx)(`p`,{className:`hint`,children:`No open calls.`}):(0,Y.jsxs)(`ul`,{className:`questions`,"data-testid":`questions`,children:[c.slice(0,i).map(([e,i])=>{let a=i[0],c=new Set(i.map(e=>e.file)).size,u=i.length===1?t(a):`×${i.length}${c>1?` in ${c} files`:``}`;return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`div`,{className:`qrow`,children:[(0,Y.jsxs)(`button`,{"data-command":`select`,"data-kind":`site`,"data-count":i.length,title:e,...CS(()=>r(l(a),a.file)),children:[(0,Y.jsx)(`code`,{children:e}),(0,Y.jsxs)(`small`,{children:[u,` ·`,` `,a.candidates?a.exhaustive===!1?`${a.candidates} known function${a.candidates===1?``:`s`}, may not be all`:a.candidates===1?`one possible function`:`one of ${a.candidates} functions`:d(a.reason),a.mayBe&&(0,Y.jsxs)(`span`,{className:`may-be-builtin`,title:`Its receiver's type isn't known; ${a.mayBe.builtins.join(` or `)} is the standard library's${a.mayBe.projectFunctions?`, and ${a.mayBe.projectFunctions} of the project's functions share the name`:``}`,children:[` `,`· may be `,a.mayBe.builtins[0],a.mayBe.builtins.length>1?`…`:``]}),AS(i.reduce((e,t)=>(t.impact?.opens??0)>(e.impact?.opens??0)?t:e))]})]}),i.length>1&&(0,Y.jsx)(`button`,{className:`icon expand`,"aria-expanded":o===e,"aria-label":`Show all ${i.length}`,onClick:()=>s(o===e?null:e),children:o===e?`▾`:`▸`})]}),i.length===1&&(0,Y.jsx)(OS,{project:n,id:a.id}),o===e&&(0,Y.jsx)(`ul`,{className:`occurrences`,children:i.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{"data-command":`select`,"data-kind":`site`,...CS(()=>r(l(e),e.file)),children:t(e)}),(0,Y.jsx)(OS,{project:n,id:e.id})]},e.id))})]},e)}),c.length>i&&(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link`,onClick:()=>a(i+TS),children:[c.length-i,` more…`]})})]})}var MS={"language-not-analyzed":`language not analyzed yet`,"declaration-file":`type declarations`,"too-large":`over the size limit`,minified:`minified`,binary:`not text`,"invalid-utf8":`not UTF-8`,unreadable:`unreadable`,entitlement:`beyond the license`,frozen:`kept from an earlier analysis`,"parse-failure":`could not be parsed`,"internal-error":`the extractor failed`};function NS({project:e,run:t,source:n,refresh:r}){let i=`${e}|${t??``}|${n??``}`,[a,o]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=!1;return J.totals(e,0,n??void 0).then(e=>!t&&o({key:i,files:e.files}),()=>!t&&o(null)),()=>{t=!0}},[i,r]);let s=a?.key===i?a.files:null,c=s?.notAnalyzed.reduce((e,t)=>e+t.files,0)??0;if(!s||c===0)return null;let l=e=>e.toLocaleString(`en-US`);return(0,Y.jsxs)(`p`,{className:`small muted`,"data-testid":`unanalyzed-files`,children:[l(c),` of `,l(s.listed),` files aren't analyzed:`,` `,s.notAnalyzed.map(e=>`${l(e.files)} ${MS[e.reason]??e.reason}`).join(`, `),`. They're marked ⚠ in the file tree; below are imports that lead to such files.`]})}function PS(e,t,n=0){let r=e&&t?`${e}|${t.a}|${t.b}`:null,[i,a]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(!r||!e||!t)return;let n=!1;return J.diff(e,t.a,t.b).then(e=>!n&&a({key:r,data:e,error:null}),e=>!n&&a({key:r,data:null,error:e.message})),()=>{n=!0}},[r,n]),i&&i.key===r?{data:i.data,error:i.error}:{data:null,error:null}}var FS={added:`+`,removed:`−`,changed:`~`},IS={added:`added`,removed:`removed`,changed:`changed`};function LS(e){let t=e.fact,n=e=>String(e??``).slice(String(e??``).lastIndexOf(`:`)+1);switch(e.type){case`Function`:return`function ${String(t.qualifiedName??t.name??n(e.id))}`;case`File`:return`file ${String(t.path??e.id)}`;case`CALLS`:case`CALLS_CROSS_FILE`:return`call ${n(t.from)} → ${n(t.to)}`;case`IMPORTS`:return`import ${String(t.specifier??``)}`;case`UnresolvedImport`:return`import ${String(t.specifier??``)} (${String(t.outcome??``)}${t.reason?`: ${String(t.reason)}`:``})`;case`UnresolvedCallSite`:return`open call ${String(t.expression??``)}`;case`SiteResolution`:return`call ${String(t.site??``).split(`|`)[3]??``} (${String(t.status??``)})`;case`Group`:return`group ${String(t.name??e.id)}`;case`DEPENDS_ON`:return`dependency ${String(t.from??``)} → ${String(t.to??``)}`;case`ExternalPackage`:return`package ${String(t.name??e.id)}`;case`Finding`:return`finding: ${String(t.message??t.kind??``)}`;default:return`${e.type} ${e.id}`}}function RS(e){let t=[];for(let[n,r]of Object.entries({Function:`functions`,File:`files`,IMPORTS:`imports`,CALLS:`calls`,CALLS_CROSS_FILE:`cross-file calls`,UnresolvedImport:`unresolved imports`})){let i=e.byType[n];if(!i||i.added+i.removed+i.changed===0)continue;let a=[i.added?`+${i.added}`:``,i.removed?`−${i.removed}`:``,i.changed?`${i.changed} changed`:``].filter(Boolean);t.push(`${a.join(`, `)} ${r}`)}let{added:n,removed:r,changed:i}=e.total;return t.length?t.join(` · `):n+r+i===0?`No changes`:`${n+r+i} changes`}function zS(e,t){return e.type===`ExternalPackage`?!1:e.change===`removed`?e.file!==null&&e.type!==`File`&&!t.has(e.file):e.file!==null||e.type===`Group`||e.type===`DEPENDS_ON`}var BS=e=>e.startsWith(`sha256:`)?`folder`:e.slice(0,7),VS=e=>e?new Date(e).toLocaleString():``;function HS({run:e,previous:t,picked:n,viewing:r,onPick:i,onView:a}){let o=e.sources.filter(e=>!e.pinned),s=new Map((t?.sources??[]).map(e=>[e.sourceId,e.revision])),c=o.length?o:e.sources,l=t&&c.length>1?c.filter(e=>s.get(e.sourceId)!==e.revision):c,u=e=>[...e.reduce((e,t)=>{let n=`${BS(t.revision)}${t.branch?` (${t.branch})`:``}`;return e.set(n,[...e.get(n)??[],t.sourceId]),e},new Map).entries()].map(([e,t])=>`${t.join(`, `)} @ ${e}`),d=u(l),f=u(c).join(` · `),p=new Set(c.map(e=>e.revision)).size,m=l.length===0?`${p} repositories, none changed`:d.length>3?`${d.slice(0,3).join(` · `)} · +${d.length-3} more`:d.join(` · `),h=l.length>0&&l.length<c.length?`${l.length} of ${c.length} changed: `:``;return(0,Y.jsxs)(`li`,{className:`run-row${r?` viewing`:``}`,"data-run":e.runId,children:[(0,Y.jsx)(`label`,{className:`pick`,children:(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`compare-pick`,checked:n,onChange:e=>i(e.target.checked),"aria-label":`Compare run ${e.runId}`})}),(0,Y.jsxs)(`span`,{className:`what`,children:[(0,Y.jsxs)(`span`,{className:`title`,children:[(0,Y.jsxs)(`strong`,{children:[`Run `,e.runId]}),e.current?(0,Y.jsx)(`span`,{className:`badge`,children:`latest`}):null,e.kind===`branch`?(0,Y.jsx)(`span`,{className:`badge`,children:`branch`}):null,e.kind===`draft`?(0,Y.jsx)(`span`,{className:`badge`,children:`draft`}):null,e.kind===`debug`?(0,Y.jsxs)(`span`,{className:`badge`,"data-testid":`debug-badge`,children:[`debug · until `,e.until]}):null]}),(0,Y.jsxs)(`span`,{className:`commits`,title:f||void 0,children:[h,m||`no sources`]}),(0,Y.jsxs)(`span`,{className:`muted small`,children:[e.reused?.length?(0,Y.jsx)(`span`,{"data-testid":`run-reused`,children:`${e.reused.join(`, `)} reused · `}):null,e.trigger===`commit`?`commit hook`:e.trigger,` · +`,e.written.toLocaleString(`en-US`),` / −`,e.closed.toLocaleString(`en-US`),` facts · `,VS(e.finishedAt)]})]}),(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:a,disabled:r,children:r?`Viewing`:`View`})]})}function US({project:e,refresh:t,run:n,compare:r,diff:i,diffError:a,onView:o,onCompare:s,onClose:c,onLocate:l,stages:u=[],onDebug:d,onFrom:f}){let[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),_=u.slice(1),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(r?[r.a,r.b]:[]);(0,y.useEffect)(()=>{r&&w([r.a,r.b])},[r?.a,r?.b]);let[T,E]=(0,y.useState)(``);(0,y.useEffect)(()=>{let t=!1;return J.history(e).then(e=>!t&&(b(e),S(null)),e=>!t&&S(e.message)),()=>{t=!0}},[e,t]);let D=(e,t)=>w(n=>t?[...n.filter(t=>t!==e),e].slice(-2):n.filter(t=>t!==e)),O=C.length===2?{a:Math.min(...C),b:Math.max(...C)}:null,k=(0,y.useMemo)(()=>new Set((i?.items??[]).filter(e=>e.type===`File`&&e.change===`removed`).map(e=>e.id)),[i]),A=(0,y.useMemo)(()=>{if(!i)return[];let e=T.trim().toLowerCase(),t=new Map(i.files.map(e=>[e.file??`\0${e.source}`,e.group?.name??e.source])),n=new Map;for(let r of i.items){let i=LS(r);if(e&&!`${i} ${r.file??``} ${r.type}`.toLowerCase().includes(e))continue;let a=r.file??`\0${r.source}`,o=t.get(a)??r.source,s=n.get(o);s||n.set(o,s=new Map);let c=s.get(a);c||s.set(a,c=[]),c.push({item:r,words:i})}return[...n].sort(([e],[t])=>e<t?-1:1)},[i,T]);return(0,Y.jsxs)(`div`,{className:`history-panel`,"data-testid":`history-panel`,children:[(0,Y.jsxs)(`div`,{className:`history-head`,children:[(0,Y.jsx)(`strong`,{children:`History`}),(0,Y.jsx)(`button`,{className:`icon`,"data-command":`toggle-history`,"aria-label":`Close History`,onClick:c,children:`×`})]}),r?(0,Y.jsxs)(`section`,{className:`changes`,"aria-label":`Changes`,"data-testid":`change-list`,children:[(0,Y.jsxs)(`div`,{className:`compare-head`,children:[(0,Y.jsxs)(`span`,{children:[`Changes from run `,r.a,` to run `,r.b]}),(0,Y.jsx)(`button`,{className:`link`,"data-command":`compare-runs`,onClick:()=>s(null),children:`Stop comparing`})]}),a?(0,Y.jsx)(`p`,{className:`error`,children:a}):i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`summary`,"data-testid":`change-summary`,children:RS(i)}),(0,Y.jsxs)(`p`,{className:`legend muted small`,children:[`On the canvas:`,` `,(0,Y.jsxs)(`span`,{className:`change added`,children:[(0,Y.jsx)(`span`,{className:`sign`,children:`+`}),`added`]}),` `,`(solid blue border),`,` `,(0,Y.jsxs)(`span`,{className:`change removed`,children:[(0,Y.jsx)(`span`,{className:`sign`,children:`−`}),`removed`]}),` `,`(dashed orange),`,` `,(0,Y.jsxs)(`span`,{className:`change changed`,children:[(0,Y.jsx)(`span`,{className:`sign`,children:`~`}),`changed`]}),` `,`(double purple).`]}),i.latestOnly.length>0&&(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Not compared (plain folders have no history): `,i.latestOnly.join(`, `)]}),(0,Y.jsx)(`input`,{type:`search`,className:`filter`,placeholder:`Filter changes`,"aria-label":`Filter changes`,"data-testid":`change-filter`,value:T,onChange:e=>E(e.target.value)}),A.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`change-group`,children:[(0,Y.jsx)(`h4`,{children:e}),[...t].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`change-file`,children:[(0,Y.jsx)(`div`,{className:`file-name`,children:e.startsWith(`\0`)?`(the repository)`:e.slice(e.indexOf(`:`)+1)}),(0,Y.jsx)(`ul`,{children:t.map(({item:e,words:t})=>{let n=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`sign`,"aria-hidden":`true`,children:FS[e.change]}),(0,Y.jsxs)(`span`,{className:`visually-hidden`,children:[IS[e.change],`: `]}),t]});return(0,Y.jsx)(`li`,{className:`change ${e.change}`,children:zS(e,k)?(0,Y.jsx)(`button`,{className:`link`,"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,onClick:()=>l(e),children:n}):(0,Y.jsx)(`span`,{"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,children:n})},`${e.change}:${e.id}`)})})]},e))]},e)),i.truncated&&(0,Y.jsxs)(`p`,{className:`muted small`,children:[`The first `,i.items.length,` of`,` `,i.total.added+i.total.removed+i.total.changed,` changes are listed.`]})]}):(0,Y.jsx)(`p`,{className:`muted`,children:`Comparing…`})]}):null,x?(0,Y.jsx)(`p`,{className:`error`,children:x}):null,v?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`compare-bar`,children:[(0,Y.jsx)(`button`,{"data-command":`compare-runs`,disabled:!O,onClick:()=>O&&s(O),title:`Pick two runs to compare`,children:O?`Compare run ${O.a} with run ${O.b}`:`Pick two runs to compare`}),n!==null&&(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:()=>o(null),children:`Back to latest`})]}),(0,Y.jsxs)(`ol`,{className:`runs`,"aria-label":`Runs`,children:[v.draft&&(0,Y.jsx)(HS,{run:v.draft,picked:C.includes(v.draft.runId),viewing:n===v.draft.runId,onPick:e=>D(v.draft.runId,e),onView:()=>o(v.draft.runId)}),v.debug&&(0,Y.jsx)(HS,{run:v.debug,picked:C.includes(v.debug.runId),viewing:n===v.debug.runId,onPick:e=>D(v.debug.runId,e),onView:()=>o(v.debug.runId)}),v.runs.map((e,t)=>(0,Y.jsx)(HS,{run:e,previous:v.runs[t+1],picked:C.includes(e.runId),viewing:n===null?e.current:n===e.runId,onPick:t=>D(e.runId,t),onView:()=>o(e.current?null:e.runId)},e.runId))]}),v.hidden>0&&(0,Y.jsxs)(`p`,{className:`muted small`,children:[v.hidden,` older runs aren't shown: this license shows 30 days of history.`]}),v.latestOnly.length>0&&(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Not under version control, so latest only: `,v.latestOnly.join(`, `),`. History and diffs need git.`]}),d&&u.length>0&&v.runs.length>0&&(0,Y.jsxs)(`form`,{className:`debug-run`,onSubmit:e=>{e.preventDefault(),d(p||u[0])},children:[(0,Y.jsxs)(`label`,{className:`muted small`,children:[`Debug run: stop after`,` `,(0,Y.jsx)(`select`,{"data-testid":`debug-until`,value:p||u[0],onChange:e=>m(e.target.value),children:u.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]}),(0,Y.jsx)(`button`,{type:`submit`,"data-command":`analyze-debug`,"data-testid":`analyze-debug`,title:`Never committed: open it and compare it with the latest`,children:`Run`})]}),f&&_.length>0&&v.runs.length>0&&(0,Y.jsxs)(`form`,{className:`debug-run`,onSubmit:e=>{e.preventDefault(),f(h||_.at(-1))},children:[(0,Y.jsxs)(`label`,{className:`muted small`,children:[`Analyze again from`,` `,(0,Y.jsx)(`select`,{"data-testid":`from-stage`,value:h||_.at(-1),onChange:e=>g(e.target.value),children:_.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]}),(0,Y.jsx)(`button`,{type:`submit`,"data-command":`analyze-from`,"data-testid":`analyze-from`,title:`The stages before it are reused, when nothing they read has changed since the latest run`,children:`Run`})]}),(0,Y.jsxs)(`p`,{className:`muted small hook-note`,children:[`A run for each commit: `,(0,Y.jsx)(`code`,{children:`veoflow hook install`}),` in a repository.`]})]}):!x&&(0,Y.jsx)(`p`,{className:`muted`,children:`Loading…`})]})}var WS=e=>e.startsWith(`sha256:`)?``:e.slice(0,7),GS=e=>e.split(`
334
334
  `).map(e=>e.trim()).filter(Boolean);function KS({source:e,onSave:t,onCancel:n}){let[r,i]=(0,y.useState)(e.include.join(`
335
335
  `)),[a,o]=(0,y.useState)(e.exclude.join(`
336
- `));return(0,Y.jsxs)(`form`,{className:`rules-editor`,"data-testid":`rules-editor`,onSubmit:e=>{e.preventDefault(),t({include:GS(r),exclude:GS(a)})},children:[(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Glob patterns, one per line, relative to the repository (`,(0,Y.jsx)(`code`,{children:`src/legacy/`}),`,`,` `,(0,Y.jsx)(`code`,{children:`**/*.test.ts`}),`). Applied at the next analysis; files left out are closed in the graph and kept in history.`]}),(0,Y.jsxs)(`label`,{children:[`Include only`,(0,Y.jsx)(`textarea`,{"data-testid":`rules-include`,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Leave out`,(0,Y.jsx)(`textarea`,{"data-testid":`rules-exclude`,value:a,onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`actions`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`rules-save`,children:`Save and re-analyze`})]})]})}function qS({project:e,refresh:t,onAdd:n,onChooseFiles:r,onAnalyzeAll:i,onChanged:a,escape:o}){let[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)({top:0,right:0}),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(0);(0,y.useEffect)(()=>{let t=!1;return J.sources(e).then(e=>!t&&c(e.sources.map(e=>({...e,optIn:e.optIn??[]}))),e=>!t&&u(e.message)),()=>{t=!0}},[e,t,O]);let A=async(e,t,n)=>{D(!0),u(``),n&&f(n);try{await e(),f(t),a()}catch(e){f(``),u(e.message??String(e))}finally{D(!1),k(e=>e+1)}},j=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!S)return;j.current?.querySelector(`button`)?.focus();let e=e=>{e.type===`mousedown`&&j.current?.contains(e.target)||C(null)};return document.addEventListener(`mousedown`,e),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[S]),o.current=()=>{if(S){let e=S;return C(null),document.querySelector(`tr[data-source="${CSS.escape(e)}"] [data-testid="repo-more"]`)?.focus(),!0}return p?(m(null),!0):b?(x(null),!0):_?(v(null),!0):!1};let M=(0,y.useRef)(null);if((0,y.useEffect)(()=>{(_||b)&&(M.current?.scrollIntoView({block:`nearest`}),M.current?.querySelector(`textarea, button`)?.focus())},[_,b]),(0,y.useEffect)(()=>{s&&(_&&!s.some(e=>e.id===_)&&v(null),b&&!s.some(e=>e.id===b)&&x(null))},[s,_,b]),!s)return(0,Y.jsx)(`p`,{className:l?`error`:`muted`,children:l||`Loading…`});let N=_?s.find(e=>e.id===_):void 0;return(0,Y.jsxs)(`div`,{className:`repositories`,"data-testid":`repositories`,children:[(0,Y.jsxs)(`div`,{className:`repo-actions`,children:[(0,Y.jsx)(`button`,{"data-testid":`repo-add`,onClick:n,children:`+ Add folder`}),(0,Y.jsx)(`button`,{"data-testid":`repo-analyze-all`,disabled:E,onClick:i,children:`Re-analyze all`})]}),l&&(0,Y.jsx)(`p`,{className:`error`,role:`alert`,children:l}),d&&(0,Y.jsx)(`p`,{className:`muted small`,role:`status`,"data-testid":`repo-status`,children:d}),(0,Y.jsxs)(`table`,{className:`repo-table`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{children:`Repository`}),(0,Y.jsx)(`th`,{children:`Branch and commit`}),(0,Y.jsx)(`th`,{children:`Analyzed`}),(0,Y.jsx)(`th`,{children:`Files`}),(0,Y.jsx)(`th`,{children:`Left out`}),(0,Y.jsx)(`th`,{children:(0,Y.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,Y.jsx)(`tbody`,{children:s.map(t=>{let n=t.analysis,i=t.include.length+t.exclude.length;return(0,Y.jsxs)(`tr`,{"data-source":t.id,children:[(0,Y.jsxs)(`td`,{children:[p===t.id?(0,Y.jsx)(`form`,{onSubmit:n=>{n.preventDefault(),m(null),A(()=>J.updateSource(e,t.id,{name:h}),`Renamed ${t.id} to ${h||t.id}.`)},onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&m(null),children:(0,Y.jsx)(`input`,{autoFocus:!0,"aria-label":`New name for ${t.id}`,"data-testid":`repo-name`,value:h,onChange:e=>g(e.target.value)})}):(0,Y.jsx)(`strong`,{className:`repo-name`,children:t.name??t.id}),(0,Y.jsx)(`div`,{className:`muted small path`,children:t.root}),n?.notices.map(e=>(0,Y.jsx)(`div`,{className:`notice-line small`,children:e},e))]}),(0,Y.jsx)(`td`,{className:`mono small`,children:n?n.kind===`plain`?`plain folder (latest only)`:`${n.branch??`detached`} · ${WS(n.revision)}${n.pinned?` (kept)`:``}`:`not analyzed yet`}),(0,Y.jsx)(`td`,{className:`small`,children:n?we(n.analyzedAt):``}),(0,Y.jsx)(`td`,{className:`small`,children:n?n.files:``}),(0,Y.jsx)(`td`,{className:`small`,children:i?`${i} rule${i===1?``:`s`}`:`defaults`}),(0,Y.jsxs)(`td`,{className:`row-actions`,children:[(0,Y.jsx)(`button`,{className:`link`,"data-testid":`repo-analyze`,"aria-label":`Re-analyze ${t.name??t.id}`,disabled:E,onClick:()=>void A(()=>J.analyzeSource(e,t.id),`Analyzing ${t.name??t.id} again (the others stay at their commits)…`,`Starting an analysis of ${t.name??t.id}…`),children:`Re-analyze`}),(0,Y.jsx)(`button`,{className:`link`,"data-testid":`repo-choose`,"aria-label":`Choose files in ${t.name??t.id}`,onClick:()=>r(t.id),children:`Choose files…`}),(0,Y.jsxs)(`span`,{className:`menu-wrap`,children:[(0,Y.jsx)(`button`,{className:`icon`,"aria-label":`More for ${t.name??t.id}`,"aria-expanded":S===t.id,"data-testid":`repo-more`,disabled:E,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();T({top:n.bottom+2,right:window.innerWidth-n.right}),C(S===t.id?null:t.id)},children:`⋯`}),S===t.id&&(0,Y.jsxs)(`span`,{className:`menu`,role:`menu`,ref:j,style:{top:w.top,right:w.right},children:[(0,Y.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rename`,onClick:()=>{C(null),g(t.name??t.id),m(t.id)},children:`Rename`}),(0,Y.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rules`,onClick:()=>{C(null),v(t.id)},children:`Edit rules`}),(0,Y.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-remove`,onClick:()=>{C(null),x(t.id)},children:`Remove…`})]})]})]})]},t.id)})})]}),s.length===0&&(0,Y.jsx)(`p`,{className:`muted`,children:`No repositories yet: + Add folder adds one.`}),N&&(0,Y.jsx)(`div`,{ref:M,children:(0,Y.jsx)(KS,{source:N,onCancel:()=>v(null),onSave:t=>{let n=N.id;v(null),A(async()=>{await J.updateSource(e,n,t),await J.analyzeSource(e,n)},`Rules saved; analyzing ${n} again…`)}},N.id)}),b&&(0,Y.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`remove-title`,"data-testid":`repo-remove-confirm`,children:[(0,Y.jsx)(`p`,{id:`remove-title`,children:(0,Y.jsxs)(`strong`,{children:[`Remove `,s.find(e=>e.id===b)?.name??b,` from this project?`]})}),(0,Y.jsx)(`p`,{className:`muted small`,children:`Its files and links leave the current graph. History keeps the analysis: earlier runs still show it, and adding the folder again analyzes it afresh. The folder itself is not touched.`}),(0,Y.jsxs)(`div`,{className:`actions`,children:[(0,Y.jsx)(`button`,{onClick:()=>x(null),"data-testid":`repo-remove-cancel`,children:`Cancel`}),(0,Y.jsx)(`button`,{className:`danger`,"data-testid":`repo-remove-yes`,disabled:E,onClick:()=>{let t=b;x(null),A(()=>J.removeSource(e,t),`Removed ${t}; history keeps its analysis.`,`Removing ${t} (a run closes its facts)…`)},children:`Remove`})]})]})]})}function JS({project:e}){let[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(null);return(0,y.useEffect)(()=>{J.projectSettings(e).then(e=>n(String(e.settings.maxFileMB)),e=>i({ok:!1,text:e.message}))},[e]),(0,Y.jsxs)(`form`,{className:`analysis-settings`,onSubmit:n=>{n.preventDefault();let r=Number(t);if(!(r>0&&r<=64))return i({ok:!1,text:`The size limit is more than 0 and at most 64 MB.`});J.saveProjectSettings(e,{maxFileMB:r}).then(e=>i({ok:!0,text:`Saved: files over ${e.settings.maxFileMB} MB are left out at the next analysis.`}),e=>i({ok:!1,text:e.message}))},children:[(0,Y.jsxs)(`label`,{children:[`Size limit per file (MB)`,(0,Y.jsx)(`input`,{type:`number`,min:.1,max:64,step:.1,required:!0,"data-testid":`analysis-max-mb`,value:t,onChange:e=>n(e.target.value)})]}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Larger files are listed but not analyzed, unless you choose them in Choose files. Folders of installed libraries, generated output and tools' workspaces (`,(0,Y.jsx)(`code`,{children:`node_modules`}),`, `,(0,Y.jsx)(`code`,{children:`dist`}),`,`,` `,(0,Y.jsx)(`code`,{children:`build`}),`, …) are left out by default; Choose files shows them and can add them.`]}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`analysis-save`,children:`Save`}),r&&(0,Y.jsx)(`p`,{className:r.ok?`muted small`:`error`,role:r.ok?`status`:`alert`,children:r.text})]})}function YS({project:e,projectName:t,refresh:n,onClose:r,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,covered:c=!1,initialTab:l=`repositories`}){let[u,d]=(0,y.useState)(l),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=(0,y.useRef)(null);return(0,y.useEffect)(()=>{let e=document.activeElement;return p.current?.focus(),()=>e?.focus?.()},[]),(0,y.useEffect)(()=>{if(c)return;let e=e=>{if(e.key===`Escape`)e.stopPropagation(),m.current?.()||r();else if(e.key===`Tab`&&f.current){let t=[...f.current.querySelectorAll(`button:not([disabled]), input, textarea, select`)],n=t[0],r=t[t.length-1];f.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[c,r]),(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&r(),children:(0,Y.jsxs)(`div`,{className:`modal wide`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`project-settings-title`,"data-testid":`project-settings-dialog`,ref:f,children:[(0,Y.jsxs)(`div`,{className:`modal-head`,children:[(0,Y.jsxs)(`h2`,{id:`project-settings-title`,children:[t,`: settings`]}),(0,Y.jsx)(`button`,{className:`icon`,"aria-label":`Close`,onClick:r,ref:p,children:`×`})]}),(0,Y.jsx)(`div`,{className:`segmented`,role:`tablist`,"aria-label":`Project settings`,children:[`repositories`,`analysis`,`license`].map(e=>(0,Y.jsx)(`button`,{role:`tab`,"aria-selected":u===e,"data-testid":`project-tab-${e}`,onClick:()=>d(e),children:e===`repositories`?`Repositories`:e===`analysis`?`Analysis`:`License`},e))}),u===`repositories`?(0,Y.jsx)(qS,{project:e,refresh:n,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,escape:m}):u===`analysis`?(0,Y.jsx)(JS,{project:e}):(0,Y.jsx)(Ue,{onChanged:s})]})})}var XS={library:`installed library code`,generated:`generated or built output`,tool:`a tool's or coding agent's workspace (settings, history, worktrees)`};function ZS(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var QS=(e,t)=>`${e}\0${t}`,$S=(e,t)=>JSON.stringify([e.include,e.exclude,e.optIn??[]])===JSON.stringify([t?.include??[],t?.exclude??[],t?.optIn??[]]);function eC({project:e,files:t,run:n,onAnalyze:r,onClose:i,only:a,at:o}){let[s,c]=(0,y.useState)([]),[l,u]=(0,y.useState)(new Map),[d,f]=(0,y.useState)(new Set),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(new Map),[S,C]=(0,y.useState)(new Map),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(``),O=(0,y.useRef)(new Set),k=s.length>1,A=(0,y.useCallback)(e=>n?.sources.find(t=>t.sourceId===e),[n]),j=(0,y.useCallback)(async(t,n)=>{let{entries:r}=await J.browse(e,t,n);O.current.add(QS(t,n)),u(e=>new Map(e).set(QS(t,n),r))},[e]),M=(0,y.useCallback)(async()=>{await Promise.all([...O.current].map(e=>{let[t,n]=e.split(`\0`);return j(t,n).catch(()=>O.current.delete(e))}))},[j]);(0,y.useEffect)(()=>{let t=!1;return(async()=>{try{let[{sources:n},{settings:r}]=await Promise.all([J.sources(e),J.projectSettings(e)]);if(t)return;let i=n.map(e=>({...e,optIn:e.optIn??[]})).filter(e=>a===void 0||e.id===a);c(i),T(r.maxFileMB),D(String(r.maxFileMB)),await Promise.all(i.map(e=>j(e.id,``)))}catch(e){t||m(e.message??String(e))}})(),()=>{t=!0}},[e,j,a]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(h?g(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h,i]),(0,y.useEffect)(()=>{if(!o||!a||s.length===0)return;let e=o.split(`/`).filter(Boolean),t=e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`));f(e=>new Set([...e,...t.map(e=>QS(a,e))])),Promise.all(t.filter(e=>!O.current.has(QS(a,e))).map(e=>j(a,e))).then(()=>requestAnimationFrame(()=>document.querySelector(`.picker-row[data-path="${CSS.escape(o)}"]`)?.scrollIntoView({block:`center`})),e=>m(e.message))},[o,a,s.length,j]);let N=(e,t)=>{let n=QS(e,t);f(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),O.current.has(n)||j(e,t).catch(e=>m(e.message))},P=(0,y.useMemo)(()=>{let e=[],t=(n,r,i)=>{for(let a of l.get(QS(n,r))??[]){if(a.kind===`file`&&!a.language&&!a.path.toLowerCase().endsWith(`.html`))continue;let r=a.kind===`dir`&&d.has(QS(n,a.path));e.push({source:n,entry:a,depth:i,open:r}),r&&t(n,a.path,i+1)}};for(let e of s)t(e.id,``,+!!k);return e},[l,d,s,k]),F=(e,t)=>{if(t.kind!==`dir`)return!1;let n=e=>e.replace(/^\/+/,``).startsWith(`${t.path}/`),r=l.get(QS(e.id,t.path));if(t.excludedBy)return e.optIn.some(n)?!0:!!r?.some(e=>!e.excludedBy);if(r?.some(e=>e.excludedBy&&(e.kind===`dir`||e.language))||e.exclude.some(e=>e.startsWith(`/`)&&n(e)))return!0;let i=A(e.id),a=t=>e.optIn.some(e=>t===e||t.startsWith(`${e}/`));return i?.defaultExcluded?.some(e=>n(e.path)&&!a(e.path))?!0:$S(e,i?.filter)&&!!i?.ruleExcluded?.some(e=>n(e.path)&&!a(e.path))},I=(e,n,r)=>{if(!r)return-t.filter(t=>t.source===e&&(t.path===n.path||t.path.startsWith(`${n.path}/`))).length;if(n.kind===`file`)return 1;let i=A(e);return i?.defaultExcluded?.find(e=>e.path===n.path)?.files??i?.ruleExcluded?.find(e=>e.path===n.path)?.files??null},L=async(t,n,r)=>{v(!0),m(``),x(e=>new Map(e).set(QS(t,n.path),r));try{let{source:i}=await J.select(e,t,[n.path],r);c(e=>e.map(e=>e.id===t?{...i,optIn:i.optIn??[]}:e)),C(e=>{let i=new Map(e),a=QS(t,n.path);return i.has(a)?i.delete(a):i.set(a,I(t,n,r)),i}),await M()}catch(e){m(e.message??String(e))}finally{x(e=>{let r=new Map(e);return r.delete(QS(t,n.path)),r}),v(!1)}},R=(e,t,n)=>{if(!_){if(n&&t.excludedBy&&t.excludedBy!==`rule`){let n=t.path.slice(t.path.lastIndexOf(`/`)+1),r=A(e)?.defaultExcluded?.find(e=>e.path===t.path),i=t.kind===`dir`&&r?.files?` It has ${r.files.toLocaleString(`en-US`)} file${r.files===1?``:`s`}.`:``;if(t.excludedBy===`too-large`)g({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${ZS(t.size??0)}, over the ${w??10} MB size limit. Files this large are usually generated or bundled code (minified builds, vendored bundles, source maps), and they slow analysis down. Files over 64 MB are never analyzed.`});else if(t.excludedBy===`minified`)g({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} looks minified: most of it is on very long lines, as in a library build. A build adds thousands of functions that aren't your project's own code. Analyze it if it is your code.`});else{let r=XS[t.excludedBy]??XS.generated;g({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${r}, not your project's own code.${i} Analyzing it makes analysis slower and the graph larger. Its files will be marked as ${t.excludedBy} code and left out of "largest files" and "most called".`})}return}L(e,t,n)}},z=async()=>{let t=Number(E);if(!Number.isFinite(t)||t<=0||t>64){m(`The size limit must be a number of megabytes between 0 and 64.`);return}try{let{settings:n}=await J.saveProjectSettings(e,{maxFileMB:t});T(n.maxFileMB),C(e=>new Map(e).set(`\0limit`,null)),await M()}catch(e){m(e.message??String(e))}},B=S.size>0||s.some(e=>!$S(e,A(e.id)?.filter))||w!==null&&n?.sources[0]?.maxFileBytes!==void 0&&n.sources[0].maxFileBytes!==w*1048576,V=0,H=0,U=!1;for(let[e,t]of S)e!==`\0limit`&&(t===null?U=!0:t>0?V+=t:H-=t);let W=e=>`${e} file${e===1?``:`s`}`,ee=[U?V?`${V}+ files added`:`files added`:V?`${W(V)} added`:``,H?`${W(H)} removed`:``].filter(Boolean).join(`, `);return(0,Y.jsxs)(`div`,{className:`picker`,"data-testid":`file-picker`,children:[(0,Y.jsxs)(`div`,{className:`picker-head`,children:[(0,Y.jsx)(`strong`,{children:`Choose files`}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{onClick:i,"data-testid":`picker-done`,children:`Done`})]}),(0,Y.jsx)(`p`,{className:`muted small picker-help`,children:`Unchecked files are left out of the graph. Greyed folders are left out by default: libraries and generated output.`}),(0,Y.jsxs)(`label`,{className:`picker-limit`,children:[`Skip files over`,(0,Y.jsx)(`input`,{type:`number`,min:1,max:64,step:1,value:E,"data-testid":`size-limit`,"aria-label":`Size limit in MB`,onChange:e=>D(e.target.value),onBlur:()=>E!==String(w)&&void z(),onKeyDown:e=>e.key===`Enter`&&void z()}),`MB`]}),p&&(0,Y.jsx)(`p`,{className:`error small`,role:`alert`,children:p}),B&&(0,Y.jsxs)(`div`,{className:`picker-pending`,"data-testid":`picker-pending`,children:[(0,Y.jsxs)(`span`,{children:[ee?(0,Y.jsx)(`strong`,{children:ee[0].toUpperCase()+ee.slice(1)}):`Changes`,` at the next analysis`]}),(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`picker-apply`,disabled:_,onClick:()=>{C(new Map),r()},children:`Apply & re-analyze`})]}),(0,Y.jsxs)(`div`,{className:`picker-list`,role:`tree`,"aria-label":`Choose files`,children:[s.map(e=>k?(0,Y.jsx)(`div`,{className:`picker-row source`,title:e.root,children:(0,Y.jsx)(`strong`,{children:e.id})},`s:${e.id}`):null),P.map(({source:e,entry:t,depth:n,open:r})=>{let i=s.find(t=>t.id===e),a=b.get(QS(e,t.path))??!t.excludedBy,c=F(i,t),l=t.path.slice(t.path.lastIndexOf(`/`)+1),u=t.notAnalyzable?t.notAnalyzable===`declaration-file`?`type declarations`:t.notAnalyzable===`symlink`?`link`:`${ZS(t.size??0)} · over 64 MB`:t.excludedBy===`library`?`library`:t.excludedBy===`generated`||t.excludedBy===`tool`?t.excludedBy:t.excludedBy===`too-large`?`${ZS(t.size??0)} · too large`:t.excludedBy===`minified`?`minified`:t.excludedBy===`rule`?`excluded`:null,d=t.optedIn?t.origin??null:null;return(0,Y.jsxs)(`div`,{className:`picker-row ${t.kind} ${a?``:`excluded`}${t.path===o?` target`:``}`,style:{paddingLeft:8+n*14},role:`treeitem`,"aria-expanded":t.kind===`dir`?r:void 0,"aria-level":n+1,"data-path":t.path,children:[t.kind===`dir`?(0,Y.jsx)(`button`,{className:`caret`,"aria-label":`${r?`Close`:`Open`} ${l}`,onClick:()=>N(e,t.path),children:r?`▾`:`▸`}):(0,Y.jsx)(`span`,{className:`caret`}),t.kind===`dir`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,"aria-label":`Analyze ${l}`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>R(e,t,n.target.checked)}),(0,Y.jsx)(`button`,{className:`name button-link`,"data-command":`open-folder`,onClick:()=>N(e,t.path),children:l})]}):(0,Y.jsxs)(`label`,{children:[t.notAnalyzable?(0,Y.jsx)(`span`,{className:`caret`}):(0,Y.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>R(e,t,n.target.checked)}),(0,Y.jsx)(`span`,{className:`name`,children:l})]}),u&&(0,Y.jsx)(`small`,{className:`reason`,children:u}),d&&(0,Y.jsx)(`small`,{className:`origin ${d}`,children:d})]},QS(e,t.path))}),s.length>0&&P.length===0&&!p&&(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`})]}),h&&(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&g(null),children:(0,Y.jsxs)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pick-warning-title`,"data-testid":`pick-warning`,children:[(0,Y.jsx)(`h2`,{id:`pick-warning-title`,children:h.title}),(0,Y.jsx)(`p`,{children:h.text}),(0,Y.jsxs)(`div`,{className:`buttons`,children:[(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{autoFocus:!0,onClick:()=>g(null),children:`Cancel`}),(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`pick-warning-confirm`,onClick:()=>{let e=h;g(null),L(e.source,e.entry,!0)},children:`Analyze anyway`})]})]})})]})}var tC=e=>e.toLocaleString(`en-US`);function nC(e){if(e.sites===0)return null;let t=e.sites-e.open,n=Math.floor(t/e.sites*100);return e.open>0?Math.min(n,99):n}function rC(e){let t=nC(e);return t===null?`No calls found`:`Paths: ${t}% of ${tC(e.sites)} call site${e.sites===1?``:`s`} go somewhere known${e.open?` · ${tC(e.open)} stop short`:``}`}function iC(e){return[{label:`within files`,count:e.withinFiles},{label:`across files`,count:e.acrossFiles},{label:`leave the project`,count:e.external},{label:`to one known body`,count:e.candidates.one},{label:`to a set of candidates`,count:e.candidates.several},{label:`stop short`,count:e.open}]}function aC({projects:e,progress:t=new Map,loading:n=!1,onOpen:r,onCreated:i,onAddFolder:a,onDeleted:o}){let[s]=dS(),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!1),x=e=>{_({id:e}),J.projectDisk(e).then(({bytes:t})=>_(n=>n?.id===e?{...n,bytes:t}:n),()=>void 0)},S=async e=>{if(!v){b(!0);try{await J.deleteProject(e),_(null),o(e)}catch(t){_(n=>n?.id===e?{...n,error:t.message??String(t)}:n)}finally{b(!1)}}},C=()=>{l(!1),d(``),p(``)},w=async()=>{if(!m){h(!0),p(``);try{let{project:e}=await J.createProject(u.trim());C(),i(e.id)}catch(e){p(e.message??String(e))}finally{h(!1)}}};return(0,Y.jsxs)(`section`,{className:`home`,"data-testid":`home`,"aria-labelledby":`home-title`,children:[(0,Y.jsxs)(`div`,{className:`home-head`,children:[(0,Y.jsx)(`h1`,{id:`home-title`,children:`Projects`}),(0,Y.jsxs)(`div`,{className:`home-actions`,children:[(0,Y.jsx)(`button`,{"data-testid":`new-project`,onClick:()=>l(!0),children:`+ New project`}),(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`home-add-folder`,onClick:a,children:`Add folder`})]})]}),c&&(0,Y.jsxs)(`form`,{className:`new-project`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,Y.jsxs)(`label`,{children:[`Name`,(0,Y.jsx)(`input`,{autoFocus:!0,"data-testid":`new-project-name`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.key===`Escape`&&C()})]}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!u.trim()||m,"data-testid":`new-project-create`,children:`Create`}),(0,Y.jsx)(`button`,{type:`button`,onClick:C,children:`Cancel`}),f&&(0,Y.jsx)(`p`,{className:`error`,role:`alert`,children:f})]}),n?(0,Y.jsx)(`p`,{className:`muted`,children:`Loading…`}):e.length===0?(0,Y.jsx)(`p`,{className:`muted`,children:`No projects yet. Add a folder to analyze its code.`}):(0,Y.jsx)(`ul`,{className:`project-cards`,children:e.map(e=>{let n=!s&&e.ownFindings||e.findings,i=n?n.broken+n.notAnalyzed+n.openCalls:0;return(0,Y.jsxs)(`li`,{"data-project":e.id,children:[(0,Y.jsxs)(`button`,{className:`project-card`,"data-testid":`open-project`,onClick:()=>r(e.id),children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`span`,{className:`muted small`,"data-testid":`project-sources`,children:e.repositories===void 0?`${e.sources} source${e.sources===1?``:`s`}`:[e.repositories?`${e.repositories} repositor${e.repositories===1?`y`:`ies`}`:``,e.folders?`${e.folders} folder${e.folders===1?``:`s`}`:``].filter(Boolean).join(` · `)||`no sources`}),e.error?(0,Y.jsxs)(`span`,{className:`error small`,"data-testid":`project-error`,children:[`Can't be read: `,e.error]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`small`,children:e.latest?e.latest.status===`running`?t.get(e.id)?T(t.get(e.id)).text:`Analyzing…`:e.latest.status===`failed`?e.latest.errorCode===`cancelled`?`Last analysis cancelled`:`Last analysis failed`:`Analyzed${e.latest.finishedAt?` ${we(e.latest.finishedAt)}`:``}`:`Not analyzed yet`}),e.analysis?.outdated.length?(0,Y.jsx)(`span`,{className:`small outdated-note`,"data-testid":`project-outdated`,children:e.analysis.outdated.every(e=>e.was===null)?`Made before veoflow recorded its version: analyze again to see what this version finds`:`Made by ${e.analysis.veoflow?`veoflow ${e.analysis.veoflow}`:`another veoflow`}: analyze again to see what this version finds`}):null,!n&&e.findingsPending&&(0,Y.jsx)(`span`,{className:`muted small`,"data-testid":`findings-pending`,children:`Counting findings…`}),e.files&&e.files.analyzed<e.files.listed&&(0,Y.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:e.files.analyzed===0?`None of ${e.files.listed.toLocaleString(`en-US`)} files analyzed`:`${(e.files.listed-e.files.analyzed).toLocaleString(`en-US`)} of ${e.files.listed.toLocaleString(`en-US`)} files not analyzed`}),e.files?.listed===0&&(0,Y.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:`No files veoflow analyzes`}),e.completeness&&!(e.files&&e.files.analyzed===0)&&(0,Y.jsx)(`span`,{className:`small`,"data-testid":`project-paths`,children:rC(e.completeness)}),n&&!(e.files&&e.files.analyzed===0)&&(0,Y.jsx)(`span`,{className:`muted small`,children:i===0?`No findings`:[n.broken?`${n.broken} broken import${n.broken===1?``:`s`}`:``,n.notAnalyzed?`${n.notAnalyzed} import${n.notAnalyzed===1?``:`s`} not analyzed`:``,n.openCalls?`${n.openCalls.toLocaleString(`en-US`)} open call${n.openCalls===1?``:`s`}`:``].filter(Boolean).join(` · `)})]})]}),(0,Y.jsx)(`button`,{className:`project-delete`,"data-testid":`project-delete`,"aria-label":`Delete ${e.name}`,title:`Delete this project`,onClick:()=>x(e.id),children:`Delete…`}),g?.id===e.id&&(0,Y.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`delete-${e.id}`,"data-testid":`project-delete-confirm`,onKeyDown:e=>e.key===`Escape`&&_(null),children:[(0,Y.jsx)(`p`,{id:`delete-${e.id}`,children:(0,Y.jsxs)(`strong`,{children:[`Delete `,e.name,`?`]})}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Its graph, history and evidence`,g.bytes===void 0?``:` (${oC(g.bytes)})`,` are deleted, and the commit hooks veoflow installed for it. The folders it analyzed are not touched. This can't be undone.`]}),g.error&&(0,Y.jsx)(`p`,{className:`error small`,role:`alert`,children:g.error}),(0,Y.jsxs)(`div`,{className:`actions`,children:[(0,Y.jsx)(`button`,{autoFocus:!0,onClick:()=>_(null),"data-testid":`project-delete-cancel`,children:`Cancel`}),(0,Y.jsx)(`button`,{className:`danger`,"data-testid":`project-delete-yes`,disabled:v,onClick:()=>void S(e.id),children:`Delete project`})]})]})]},e.id)})})]})}function oC(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}function sC({title:e,entries:t,x:n,y:r,onClose:i}){let a=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=document.activeElement;a.current?.querySelector(`button`)?.focus();let t=e=>{e.type===`mousedown`&&a.current?.contains(e.target)||i()},n=e=>{if(e.key===`Escape`){e.stopPropagation(),i();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let t=[...a.current?.querySelectorAll(`button`)??[]],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},r=e=>{a.current?.contains(e.relatedTarget)||i()},o=a.current;return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,t),document.addEventListener(`scroll`,t,!0),window.addEventListener(`keydown`,n,!0),o?.addEventListener(`focusout`,r),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,t),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`keydown`,n,!0),o?.removeEventListener(`focusout`,r),e&&e!==document.body&&document.contains(e)&&e.focus()}},[i]);let o=Math.max(4,Math.min(n,window.innerWidth-260)),s=Math.max(4,Math.min(r,window.innerHeight-40-t.length*30));return(0,Y.jsxs)(`div`,{ref:a,className:`context-menu`,role:`menu`,"aria-label":e,"data-testid":`context-menu`,style:{left:o,top:s},children:[(0,Y.jsx)(`div`,{className:`context-title`,"aria-hidden":`true`,children:e}),t.map(e=>(0,Y.jsx)(`button`,{role:`menuitem`,tabIndex:-1,"data-command-name":e.command,onClick:()=>{i(),e.run()},children:e.label},e.label))]})}function cC(e,t){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return i;let a=0,o=0;for(let e of r)if(e===n[a]?a++:a>0&&o++,a===n.length)return 100+o;return null}function lC(e,t,n){return n===0?[]:t.map((t,n)=>({item:t,i:n,score:cC(e,t.label)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).slice(0,n).map(e=>e.item)}function uC(e,t){let{view:n,command:r}=t,i=e.trim(),a=[];if(n.project){let e=lC(i,t.files.map(e=>({...e,label:e.path})),i?5:0);for(let i of e)a.push({key:`file:${i.id}`,group:`Files`,label:i.path,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:i.id}):r(`openFile`,{file:i.id})}),e.length<=2&&(n.tab===`imports`&&n.group!==null&&!n.fileLevel&&a.push({key:`only:${i.id}`,group:`Files`,label:`Show only links of ${i.path}`,run:()=>r(`showOnlyLinks`,{id:i.id})}),a.push({key:`leave:${i.id}`,group:`Files`,label:`Leave ${i.path} out of analysis…`,run:()=>t.action(`chooseFiles`,{source:i.id.slice(0,i.id.indexOf(`:`)),path:i.path})}));for(let e of lC(i,t.groups.map(e=>({...e,label:e.name})),i?4:0))a.push({key:`group:${e.id}`,group:`Groups`,label:e.name,detail:`open the group`,run:()=>r(`openGroup`,{group:e.id})}),a.push({key:`only:${e.id}`,group:`Groups`,label:`Show only links of ${e.name}`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}}),a.push({key:`pick:${e.id}`,group:`Groups`,label:`Details of ${e.name}`,detail:`on the project map`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`pickNode`,{id:e.id})}})}let o=[],s=(e,t,n,r)=>o.push({label:e,run:t,...n?{detail:n}:{},...r?{key:r}:{}});if(n.project){s(n.history?`Close History`:`History: runs by commit`,()=>r(`toggleHistory`)),n.compare&&s(`Stop comparing`,()=>r(`compareRuns`,{}));let e=/^(?:compare\s+)?(?:run\s*)?(\d+)\s*(?:\.\.|with|vs|and|,|\s)\s*(?:run\s*)?(\d+)$/i.exec(i);if(e){let[t,n]=[Number(e[1]),Number(e[2])];s(`Compare run ${Math.min(t,n)} with run ${Math.max(t,n)}`,()=>r(`compareRuns`,{a:t,b:n}))}n.run!==null&&s(`Back to latest`,()=>r(`openRun`,{}));let a=/^(?:view\s+)?run\s*(\d+)$/i.exec(i);a&&s(`View run ${a[1]}`,()=>r(`openRun`,{run:Number(a[1])})),s(`File tab`,()=>r(`showTab`,{tab:`file`}),`functions and calls inside a file`),s(`Imports tab`,()=>r(`showTab`,{tab:`imports`}),`how files depend on each other`),s(`Project map`,()=>r(`openArea`,{}),`the Imports tab from the top: the whole map`),s(`Show the code`,()=>r(`showPanel`,{panel:`evidence`})),s(`Show Findings`,()=>r(`showPanel`,{panel:`questions`})),s(n.showPending?`Hide pending imports`:`Show pending imports`,()=>r(`togglePending`)),s(n.showUnresolved?`Hide unresolved call sites`:`Show unresolved call sites`,()=>r(`toggleUnresolved`)),n.selection&&s(`Clear the selection`,()=>r(`clearSelection`));let o=n.selection?.kind===`function`?n.selection.id:null,c=o??n.file;if(c){let e=o?o.slice(o.indexOf(`:`,o.indexOf(`:`)+1)+1):c.slice(c.indexOf(`:`)+1);s(`Reach from ${e}`,()=>r(`openReach`,{root:c,direction:`forward`}),`what paths from it reach`),s(`What reaches ${e}`,()=>r(`openReach`,{root:c,direction:`backward`}),`the paths that lead to it`)}n.reach&&n.tab!==`reach`&&s(`Reach tab`,()=>r(`showTab`,{tab:`reach`})),n.only&&s(`Show everything again`,()=>r(`showOnlyLinks`,{}),`not only one item's links`);for(let e of t.sources)s(`Re-analyze ${e.name??e.id}`,()=>t.action(`analyzeSource`,{source:e.id}),`this repository only`,`analyze:${e.id}`);if(t.sources.length>1){n.source&&s(`Scope: all repositories`,()=>r(`scopeSource`,{}));for(let e of t.sources)e.id!==n.source&&s(`Scope: ${e.name??e.id}`,()=>r(`scopeSource`,{source:e.id}),`one repository only`,`scope:${e.id}`)}n.group&&i.includes(`/`)&&s(`Open or close folder ${i}`,()=>r(`toggleFolder`,{path:i.replace(/^\.?\//,``).replace(/\/$/,``)})),s(`Re-analyze the project`,()=>t.action(`analyze`)),t.canDraft&&s(`Analyze uncommitted edits`,()=>t.action(`analyzeDraft`),`a draft beside the graph`);for(let e of(t.stages??[]).slice(1))s(`Analyze again from ${e}`,()=>t.action(`analyzeFrom`,{from:e}),`the stages before it reused, when nothing they read changed`,`from:${e}`);for(let e of t.stages??[])s(`Debug run: stop after ${e}`,()=>t.action(`analyzeDebug`,{until:e}),`never committed; compare it with the latest`,`debug:${e}`);s(`Repositories…`,()=>t.action(`openProjectSettings`),`re-analyze, choose files, rename, remove`),s(`License…`,()=>t.action(`openProjectSettings`,{tab:`license`}),`what the license includes; add or replace a key`)}n.project&&s(`All projects (home)`,()=>r(`goHome`),`every project and its last run`),s(`Add a folder…`,()=>t.action(`addFolder`)),s(`Settings…`,()=>t.action(`openSettings`),`the model for questions`);for(let e of t.projects)e.id!==n.project&&s(`Switch to project ${e.name}`,()=>r(`selectProject`,{project:e.id}),void 0,`project:${e.id}`);let c=o.filter(e=>/^(Compare run|View run|Open or close folder)/.test(e.label)),l=lC(i,o.filter(e=>!c.includes(e)),i?6:0);for(let e of[...c,...l])a.push({key:`cmd:${e.key??e.label}`,group:`Commands`,label:e.label,run:e.run,...e.detail?{detail:e.detail}:{}});return a}var dC=e=>e.slice(e.lastIndexOf(`/`)+1),fC=20;function pC({project:e,file:t,run:n,onOpen:r,onShowImports:i}){let{calls:a,error:o}=xS(e,n,t);if(o)return(0,Y.jsx)(`p`,{className:`small muted`,children:`Calls to and from other files couldn't be loaded.`});if(!a||a.out.total===0&&a.in.total===0)return null;let s=(e,t)=>{if(e.total===0)return null;let n=new Map;for(let r of e.calls){let e=t===`out`?r.from:r.to,i=t===`out`?r.to:r.from,a=n.get(i.id)??{there:i,here:new Set,n:0,line:r.evidence.span.start.line};a.here.add(Se(e)),a.n++,n.set(i.id,a)}let i=[...n.values()].sort((e,t)=>t.n-e.n||(e.there.path<t.there.path?-1:1)),a=e.total-e.calls.length;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[t===`out`?`Calls into other files`:`Called from other files`,` (`,e.total,n.size!==e.total&&a===0?`, ${n.size} function${n.size===1?``:`s`}`:``,`)`]}),(0,Y.jsx)(`ul`,{className:`cross-calls`,"data-testid":`file-cross-calls-${t}`,children:i.slice(0,fC).map(({there:e,here:n,n:i,line:a})=>{let o=[...n],s=`${o.slice(0,2).join(`, `)}${o.length>2?` and ${o.length-2} more`:``}`;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link-row`,"data-command":`open-cross-file`,title:`Open ${Se(e)} in ${e.path}`,onClick:()=>r({id:e.id,file:e.file}),children:[(0,Y.jsxs)(`span`,{className:`name`,children:[(0,Y.jsxs)(`span`,{className:`muted`,children:[dC(e.path),` › `]}),Se(e),i>1&&(0,Y.jsxs)(`span`,{className:`times`,children:[` ×`,i]})]}),(0,Y.jsxs)(`small`,{children:[t===`out`?`from ${s}`:`calls ${s}`,i===1?` · line ${a}`:``]})]})},e.id)})}),(i.length>fC||a>0)&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[i.length>fC?`${(i.length-fC).toLocaleString(`en-US`)} more functions`:`${a.toLocaleString(`en-US`)} more calls`,`: select a function to see its own.`]})]})};return(0,Y.jsxs)(`div`,{className:`file-cross-calls`,"data-testid":`file-cross-calls`,children:[i&&(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`cross-calls-in-imports`,onClick:i,children:`⇄ See them drawn on the Imports tab`}),s(a.out,`out`),s(a.in,`in`)]})}var mC=`area|`,hC=`singles|`,gC=e=>e.root,_C=(e,t)=>t===``||e===t||e.startsWith(`${t}/`),vC=()=>({broken:0,notAnalyzed:0,pending:0,openCalls:0});function yC(e){let t=e.indexOf(`|`);return t<0?{source:e,path:``}:{source:e.slice(0,t),path:e.slice(t+1)}}function bC(e,t,n,r,i,a){let o=vC();for(let e of a)o.broken+=e.findings.broken,o.notAnalyzed+=e.findings.notAnalyzed,o.pending+=e.findings.pending,o.openCalls+=e.findings.openCalls;return{id:e,name:t,kind:n,source:r,root:i,files:a.reduce((e,t)=>e+t.files,0),functions:a.reduce((e,t)=>e+t.functions,0),externalPackages:0,findings:o,members:a.length}}function xC(e,t){let n=new Map,r=new Map;for(let i of e){let e=t.get(i.from),a=t.get(i.to);if(!e||!a||e===a)continue;let o=`${e}->${a}`,s=n.get(o);if(s){let e=(s.references??0)+(i.references??0),{carrying:t,references:r,...a}=s;n.set(o,{...a,imports:s.imports+i.imports,calls:s.calls+i.calls,...e?{references:e}:{},...s.carrying!==void 0&&i.carrying!==void 0?{carrying:s.carrying+i.carrying}:{}})}else n.set(o,{...i,id:o,from:e,to:a});if(l(i)){let e=r.get(o)??{from:new Set,to:new Set};e.from.add(i.from),e.to.add(i.to),r.set(o,e)}}return[...n.values()].map(e=>{let t=r.get(e.id),n=!e.from.startsWith(`group|`)||!e.to.startsWith(`group|`);return t&&n?{...e,groups:{from:t.from.size,to:t.to.size}}:e}).sort((e,t)=>e.id<t.id?-1:1)}function SC(e,t){let n=yC(t);return e.groups.filter(e=>e.source===n.source&&_C(gC(e),n.path))}function CC(e,t,n=new Set){let r=[...new Set(e.groups.map(e=>e.source))].sort(),i=t?yC(t):null,a=i?e.groups.filter(e=>e.source===i.source&&_C(gC(e),i.path)):e.groups,o=new Map,s=[],c=[],l=!1;if(a.length>30){let u=new Map;for(let e of a){let t,n,a;if(!i&&r.length>1)t=`${e.source}|`,n=e.source,a=``;else{let r=i?.path??``,o=r===``?gC(e):gC(e).slice(r.length+1),s=o.split(`/`)[0]??``;if(o===``||s===``){c.push(e);continue}a=r===``?s:`${r}/${s}`,t=`${e.source}|${a}`,n=`${a}/`}let o=u.get(t)??{name:n,source:e.source,root:a,members:[]};o.members.push(e),u.set(t,o)}if(u.size===1&&c.length===0){let[r]=u.keys();if(r!==t)return CC(e,r,n)}for(let[e,t]of u){if(t.members.length===1){c.push(t.members[0]);continue}l=!0;let n=`${mC}${e}`;s.push(bC(n,t.name,`area`,t.source,t.root,t.members));for(let e of t.members)o.set(e.id,n)}}else c.push(...a);let u=new Map;for(let e of c)if(e.kind===`cluster`&&e.files===1){let t=`${e.source}|${gC(e)}`;u.set(t,[...u.get(t)??[],e])}for(let e of c){let t=`${e.source}|${gC(e)}`;e.kind===`cluster`&&e.files===1&&u.get(t).length>1&&!n.has(t)||(s.push(e),o.set(e.id,e.id))}for(let[e,t]of u){if(t.length<2||n.has(e))continue;let r=`${hC}${e}`,{source:i,path:a}=yC(e);s.push(bC(r,`${a?`${a}/`:`(top)`}`,`singles`,i,a,t));for(let e of t)o.set(e.id,r)}return s.sort((e,t)=>e.id<t.id?-1:1),{area:t,summary:l,map:{...e,groups:s,dependsOn:xC(e.dependsOn,o)}}}function wC(e,t){let{source:n,path:r}=yC(e),i=t?[{area:`${n}|`,label:n}]:[],a=r?r.split(`/`):[];for(let e=1;e<=a.length;e++)i.push({area:`${n}|${a.slice(0,e).join(`/`)}`,label:a[e-1]});return i}var TC=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function EC({project:e,run:t,source:n,group:r,file:i,fileLevel:a,expand:o,showPending:s,onOpenGroup:c,onCloseGroup:l,onOpenFile:u,onToggleFolder:d,onCollapse:f,onMenu:p,sources:m=[],onScope:h,area:g=null,onAllGroups:_}){let[v,b]=(0,y.useState)(``),{groups:x,error:S}=_S(e,t,0,n),C=a&&i!==null,{imports:w}=yS(e,t,C?i:null),T=C?w?.file.group??null:r??(x&&x.total===1?x.groups[0]?.id??null:null),{group:E}=vS(e,t,T,C?[]:o,s),D=(0,y.useMemo)(()=>{let e=v.trim().toLowerCase(),t=new Map;for(let n of x?g&&!T?SC(x,g):x.groups:[])(!e||n.name.toLowerCase().includes(e)||n.id===T)&&t.set(n.source,[...t.get(n.source)??[],n]);for(let e of t.values())e.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));return[...t].sort((e,t)=>e[0]<t[0]?-1:1)},[x,v,T,g]),O=D.length,k=e=>{let t=e.id===T,n=t&&!C&&r===e.id,a=e.findings.broken;return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{className:`outline-group${t?` current`:``}`,"data-command":`outline-group`,"data-id":e.id,"aria-expanded":t,title:`${e.name}: ${TC(e.files,`file`)}, ${TC(e.functions,`function`)}${a?`, ${TC(a,`broken import`)}`:``}${n?` (close it)`:``}`,onClick:()=>n?l():c(e.id),onContextMenu:p&&(t=>{t.preventDefault(),p({kind:`group`,id:e.id,data:{label:e.name},x:t.clientX,y:t.clientY})}),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:t?`▾`:`▸`}),(0,Y.jsx)(`span`,{className:`name`,children:e.name}),a>0&&(0,Y.jsx)(`small`,{className:`badge broken`,title:TC(a,`broken import`),children:a}),(0,Y.jsx)(`small`,{className:`count`,children:e.files})]}),t&&E&&(0,Y.jsxs)(`ul`,{className:`outline-files`,children:[!C&&o.map(t=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`outline-folder open`,"data-command":`outline-folder`,"data-path":t,"aria-expanded":`true`,title:`${t}/: open on the canvas (close it)`,onClick:()=>d(t),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:`▾`}),(0,Y.jsxs)(`span`,{className:`name`,children:[iS(t,e.root),`/`]})]})},`open:${t}`)),E.nodes.map(t=>t.kind===`folder`?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`outline-folder`,"data-command":`outline-folder`,"data-path":t.path,"aria-expanded":`false`,title:`${t.path}/: ${TC(t.files,`file`)} (open it on the canvas)`,onClick:()=>C?c(e.id,t.path):d(t.path),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:`▸`}),(0,Y.jsxs)(`span`,{className:`name`,children:[iS(t.path,e.root),`/`]}),(0,Y.jsx)(`small`,{className:`count`,children:t.files})]})},t.id):(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`outline-file${t.id===i&&C?` current`:``}`,"data-command":`outline-file`,"data-file":t.id,title:t.path,onClick:()=>u(t.id,e.id),onContextMenu:p&&(e=>{e.preventDefault(),p({kind:`file`,id:t.id,data:{},x:e.clientX,y:e.clientY})}),children:[(0,Y.jsx)(`span`,{className:`name`,children:iS(t.path,e.root)}),t.findings.broken>0&&(0,Y.jsx)(`small`,{className:`badge broken`,children:t.findings.broken})]})},t.id))]})]},e.id)},[A,j]=(0,y.useState)(new Set),M=e=>{let t=e=>e.kind===`cluster`&&e.files===1,n=new Map;for(let r of e)t(r)&&n.set(r.root,[...n.get(r.root)??[],r]);let r=[],i=new Set;for(let a of e){let e=n.get(a.root);if(!t(a)||!e||e.length<2)r.push({type:`group`,g:a});else if(!i.has(a.root)){i.add(a.root);let t=`${a.source}|${a.root}`,n=A.has(t)||v.trim()!==``||e.some(e=>e.id===T);r.push({type:`singles`,key:t,root:a.root,members:e,open:n})}}return r};return(0,Y.jsxs)(`nav`,{className:`nav outline`,"aria-label":`Groups`,"data-testid":`group-outline`,children:[(0,Y.jsxs)(`div`,{className:`nav-head`,children:[(m.length>1||n)&&(0,Y.jsxs)(`label`,{className:`nav-scope`,children:[(0,Y.jsx)(`span`,{className:`small muted`,children:`Scope`}),(0,Y.jsxs)(`select`,{"data-command":`scope-source`,value:n??``,onChange:e=>h?.(e.target.value||null),children:[(0,Y.jsx)(`option`,{value:``,children:`All repositories`}),m.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`outline-head`,children:[(0,Y.jsx)(`input`,{className:`nav-filter`,placeholder:`Filter ${x?TC(x.total,`group`):`groups`}…`,"aria-label":`Filter groups`,"data-testid":`outline-filter`,value:v,onChange:e=>b(e.target.value)}),(0,Y.jsx)(`button`,{className:`icon`,title:`Hide this pane ( [ )`,"aria-label":`Hide the groups pane`,onClick:f,children:`⟨`})]}),(0,Y.jsx)(`button`,{className:`outline-map${!T&&!C?` current`:``}`,"data-command":`outline-project-map`,onClick:()=>c(),title:`The project map: every group`,children:`⌂ Project map`})]}),(0,Y.jsxs)(`div`,{className:`nav-list outline-list`,children:[S&&(0,Y.jsx)(`p`,{className:`hint error`,children:S}),x&&g&&!T&&(0,Y.jsxs)(`p`,{className:`small muted outline-area`,"data-testid":`outline-area`,children:[g.slice(g.indexOf(`|`)+1)?`In ${g.slice(g.indexOf(`|`)+1)}/:`:`In the ${g.slice(0,g.indexOf(`|`))} repository:`,` `,TC(SC(x,g).length,`group`),` ·`,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>(_??(()=>c()))(),children:`all groups`})]}),x&&!x.stage2&&(0,Y.jsx)(`p`,{className:`hint`,children:`Groups come from import analysis (Stage 2), which hasn't run for this project.`}),D.map(([e,t])=>(0,Y.jsxs)(`section`,{children:[O>1&&(0,Y.jsx)(`h4`,{className:`outline-source`,children:e}),(0,Y.jsx)(`ul`,{children:M(t).map(e=>e.type===`group`?k(e.g):(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{className:`outline-singles`,"data-command":`outline-singles`,"aria-expanded":e.open,title:`${e.members.length} groups of one file each in ${e.root||`the top folder`}`,onClick:()=>j(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n}),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:e.open?`▾`:`▸`}),(0,Y.jsxs)(`span`,{className:`name`,children:[e.root?`${e.root}/`:`(top)`,` · `,e.members.length,` single files`]}),(0,Y.jsx)(`small`,{className:`count`,children:e.members.length})]}),e.open&&(0,Y.jsx)(`ul`,{className:`outline-singles-list`,children:e.members.map(k)})]},e.key))})]},e))]})]})}function DC(e){switch(e.context){case`argument`:return`to ${e.handedTo} (argument ${(e.argument??0)+1})`;case`jsx-attribute`:return`as ${e.handedTo}`;case`property`:return`as ${e.handedTo} in an object`;case`array-element`:return`in an array`;case`return`:return`as its result`;default:return`to ${e.handedTo}`}}function OC({project:e,fn:t,run:n,onOpen:r}){let[i,a]=(0,y.useState)(null);if((0,y.useEffect)(()=>{let n=!1;return Promise.all([J.references(e,t,`out`),J.references(e,t,`in`)]).then(([e,r])=>!n&&a({fn:t,out:e,in:r}),()=>!n&&a(`error`)),()=>{n=!0}},[e,t,n]),i===`error`||i===null||i.fn!==t||i.out.total===0&&i.in.total===0)return null;let o=e=>e.evidence.span.start.line,s=e=>e.truncated?`${e.total}; the first ${e.references.length} shown`:`${e.total}`;return(0,Y.jsxs)(`div`,{className:`imported-calls handed-on`,"data-testid":`handed-on`,children:[i.out.references.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Hands on (`,s(i.out),`)`]}),i.out.references.map(e=>(0,Y.jsxs)(`div`,{className:`imported-call`,"data-testid":`handed-on-out`,children:[(0,Y.jsxs)(`span`,{className:`mono small`,children:[e.to.name,` · line `,o(e)]}),(0,Y.jsxs)(`span`,{className:`small`,children:[`passes `,(0,Y.jsx)(`strong`,{children:e.to.name}),e.to.file!==e.from.file&&(0,Y.jsxs)(Y.Fragment,{children:[` `,`in `,(0,Y.jsx)(`span`,{className:`mono`,children:e.to.path})]}),` `,DC(e),`; whatever receives it may call it`]}),e.to.file!==e.from.file&&(0,Y.jsx)(`span`,{className:`small links`,children:(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`open-handed-on`,onClick:()=>r({id:e.to.id,file:e.to.file}),children:`Open that file`})})]},e.id))]}),i.in.references.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Handed on by (`,s(i.in),`)`]}),i.in.references.map(e=>(0,Y.jsxs)(`div`,{className:`imported-call`,"data-testid":`handed-on-in`,children:[(0,Y.jsxs)(`span`,{className:`small`,children:[(0,Y.jsx)(`strong`,{children:e.from.name}),` in `,(0,Y.jsx)(`span`,{className:`mono`,children:e.from.path}),` passes it`,` `,DC(e),` · line `,o(e)]}),(0,Y.jsx)(`span`,{className:`small links`,children:(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`open-handed-on`,onClick:()=>r({id:e.from.id,file:e.from.file}),children:`Open`})})]},e.id))]})]})}var kC=e=>e.reason===`imported-symbol`||e.reason===`template-reference`;function AC(e){let t=e.group;if(!t)return e.path;let n=t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t.name} › ${n}`}var jC={broken:`its import is broken`,pending:`its import waits for another source`,"not-analyzed":`its import leads to a file not analyzed`};function MC({project:e,graph:t,fn:n,onOpen:r,onShowImports:i}){let[a,o]=(0,y.useState)(null),s=t.file.id,c=t.unresolved.some(kC);(0,y.useEffect)(()=>{if(!c)return;let t=!1;return J.siteLinks(e,s).then(e=>!t&&o({file:s,byId:new Map(e.links.map(e=>[e.site,e]))}),()=>!t&&o({file:s,byId:`error`})),()=>{t=!0}},[e,s,t.committedRun,c]);let l=t.unresolved.filter(e=>e.enclosingFn===n&&kC(e)&&!e.component).sort((e,t)=>e.evidence.span.start.offset-t.evidence.span.start.offset);if(l.length===0)return null;let u=a?.file===s?a.byId:null,d=u===`error`?null:u;return(0,Y.jsxs)(`div`,{className:`imported-calls`,"data-testid":`imported-calls`,children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Calls into other files (`,l.length,`)`]}),u===`error`&&(0,Y.jsx)(`p`,{className:`small muted`,children:`Where these calls lead couldn't be loaded.`}),l.map(e=>{let t=d?.get(e.id),n=e.importSpecifier?`imported from ${e.importSpecifier}`:`defined in another file`;return(0,Y.jsxs)(`div`,{className:`imported-call`,"data-testid":`imported-call`,"data-site":e.id,children:[(0,Y.jsxs)(`span`,{className:`mono small`,children:[e.expression,` · line `,e.evidence.span.start.line]}),u===`error`?(0,Y.jsx)(`span`,{className:`small muted`,children:n}):d===null?(0,Y.jsxs)(`span`,{className:`small muted`,children:[n,`…`]}):t?.status===`linked`&&t.target?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`small`,children:[`calls `,(0,Y.jsx)(`strong`,{children:t.target.name}),` in`,` `,(0,Y.jsx)(`span`,{className:`mono`,children:AC(t.target)}),`, found by`,` `,t.via===`import`||e.reason===`imported-symbol`?`import analysis`:`component linking`]}),(0,Y.jsxs)(`span`,{className:`small links`,children:[(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`open-imported`,onClick:()=>r({id:t.target.id,file:t.target.file}),children:`Open that file`}),(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`show-in-imports`,onClick:i,children:`Show in Imports`})]})]}):t?.status===`external`?(0,Y.jsxs)(`span`,{className:`small`,children:[`calls into the external package `,(0,Y.jsx)(`strong`,{children:t.package?.name})]}):t?(0,Y.jsxs)(`span`,{className:`small`,children:[n,`, not linked`,t.importOutcome?`: ${jC[t.importOutcome]}`:t.candidates?.length?t.exhaustive===!1?`: ${t.candidates.length} known function${t.candidates.length===1?``:`s`} could run (may not be all)`:`: it could be any of ${t.candidates.length} functions`:t.reason?`: ${t.reason}`:``]}):(0,Y.jsxs)(`span`,{className:`small muted`,children:[n,`, not linked yet`]})]},e.id)})]})}var NC=(e,t)=>{let n=xe(e).name;return n.length>t?`${n.slice(0,t-1)}…`:n},PC=6;function FC(e,t,n,r){let i=e=>e.slice(e.indexOf(`:`)+1),a=e=>e.split(`/`).slice(-2).join(`/`),o=r.calls?t.out.calls:[],s=r.calls?t.in.calls:[],c=new Map,l=e=>{let t=xe(e).unnamed;c.set(e.id,{label:t?NC(e,34):`ƒ ${NC(e,32)}`,line:e.line??0})};for(let e of o)l(e.from);for(let e of s)l(e.to);let u=[...c].sort((e,t)=>e[1].line-t[1].line||(e[1].label<t[1].label?-1:+(e[1].label>t[1].label))).map(([e])=>e),d=(e,t)=>({id:`${e}|${t.id}`,file:t.file,label:`${a(t.path)} ›\n${NC(t,28)}`}),f=new Map(s.map(e=>[e.from.id,d(`caller`,e.from)])),p=new Map(o.map(e=>[e.to.id,d(`callee`,e.to)])),m=new Map,h=new Map;if(r.imports&&n){for(let t of n.imports)t.outcome===`file`&&t.file&&t.file.id!==e&&!h.has(t.file.id)&&h.set(t.file.id,{id:`imported|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimported`,edge:t.id});for(let t of n.importedBy.files)t.file.id!==e&&!m.has(t.file.id)&&m.set(t.file.id,{id:`importer|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimports this file`,edge:t.id})}let g=e=>[...e.values()].sort((e,t)=>e.label<t.label?-1:+(e.label>t.label)),_=[...g(f),...g(m)],v=[...g(p),...g(h)],y=Math.max(u.length,1),b=e=>-((e-1)*58)/2,x=[{data:{id:`box`,kind:`box`,label:i(e),w:210,h:y*58+50},position:{x:0,y:0},classes:`box`},...u.map((e,t)=>({data:{id:e,kind:`function`,label:c.get(e).label},position:{x:0,y:b(u.length)+t*58+12},classes:`function`})),..._.map((e,t)=>({data:{id:e.id,kind:`port`,side:`left`,file:e.file,label:e.label},position:{x:-330,y:b(_.length)+t*58},classes:e.id.startsWith(`importer|`)?`port file`:`port`})),...v.map((e,t)=>({data:{id:e.id,kind:`port`,side:`right`,file:e.file,label:e.label},position:{x:330,y:b(v.length)+t*58},classes:e.id.startsWith(`imported|`)?`port file`:`port`}))],S=new Map,C=(e,t,n)=>{let r=`${e}->${t}`,i=S.get(r);i?i.calls.push(n):S.set(r,{id:n,source:e,target:t,calls:[n]})};for(let e of o)C(e.from.id,`callee|${e.to.id}`,e.id);for(let e of s)C(`caller|${e.from.id}`,e.to.id,e.id);for(let e of S.values())x.push({data:{id:e.id,kind:`call`,source:e.source,target:e.target,calls:e.calls,label:e.calls.length>1?`×${e.calls.length}`:``},classes:`call`});let w=h.size+m.size<=PC?`imports`:``;for(let e of h.values())x.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:`box`,target:e.id,label:w},classes:`import`});for(let e of m.values())x.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:e.id,target:`box`,label:w},classes:`import`});return x}function IC({file:e,calls:t,imports:n,show:r,pick:i,onPick:a,onOpenFile:o,onClear:s,marks:c=null,onContext:l}){let u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=Je();(0,y.useEffect)(()=>{d.current?.style(LC())},[f]);let p=(0,y.useRef)(c);p.current=c;let m=(0,y.useRef)(l);m.current=l,(0,y.useEffect)(()=>{d.current&&Qe(d.current,c)},[c]);let h=(0,y.useRef)({onPick:a,onOpenFile:o,onClear:s});h.current={onPick:a,onOpenFile:o,onClear:s};let g=(0,y.useMemo)(()=>FC(e,t,n,r),[e,t,n,r.calls,r.imports]);(0,y.useEffect)(()=>{if(!u.current)return;let e=q_({container:u.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.15,maxZoom:2.5,style:LC()});return e.on(`tap`,`node`,e=>{e.target.data(`kind`)===`port`&&h.current.onOpenFile(e.target.data(`file`))}),e.on(`tap`,`edge`,e=>h.current.onPick(e.target.data(`edge`)??e.target.id())),e.on(`tap`,t=>{t.target===e&&h.current.onClear()}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),d.current=e,Qe(e,p.current),e.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`port`&&t.file?`file`:t.kind===`call`||t.kind===`import`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),()=>{d.current=null,e.destroy()}},[g]),(0,y.useEffect)(()=>{let e=d.current;e&&(e.elements().removeClass(`picked`),i&&e.edges().filter(e=>(e.data(`calls`)??[]).includes(i)||e.data(`edge`)===i).addClass(`picked`))},[i,g]);let _=e=>g.filter(t=>t.data.kind===`port`&&t.data.side===e).map(e=>e.data.id).join(` `),v=[t.in,t.out].filter(e=>e.truncated),b=(r.calls?t.out.calls.length+t.in.calls.length:0)===0,x=[...new Map([...t.in.calls.map(e=>e.from),...t.out.calls.map(e=>e.to)].map(e=>[e.file,e])).values()];return(0,Y.jsxs)(`div`,{className:`graph-wrap`,children:[b&&r.calls&&(0,Y.jsx)(`p`,{className:`hint overlay`,"data-testid":`no-cross-file-calls`,children:`No calls cross into or out of this file.`}),(0,Y.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`file-canvas`,"data-calls":g.filter(e=>e.data.kind===`call`).length,"data-imports":g.filter(e=>e.data.kind===`import`).length,"data-ports-left":_(`left`),"data-ports-right":_(`right`)}),v.length>0&&(0,Y.jsxs)(`p`,{className:`hint small overlay`,"data-testid":`calls-truncated`,children:[v.map(e=>`Showing ${e.calls.length} of ${e.total} calls ${e.direction===`in`?`into`:`out of`} this file`).join(`; `),`.`]}),(0,Y.jsxs)(`details`,{className:`graph-key`,"data-testid":`imports-file-key`,children:[(0,Y.jsx)(`summary`,{children:`Key`}),(0,Y.jsxs)(`ul`,{children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node`}),(0,Y.jsx)(`span`,{children:`a function in this file that calls or is called across files`})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node port`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`code`,{children:`file ›`}),` a function in another file: callers on the left, what this file calls on the right`]})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line call`}),(0,Y.jsx)(`span`,{children:`calls: one function calls the other (×2: two calls)`})]}),r.imports&&(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node port file`}),(0,Y.jsx)(`span`,{children:`another file: one this file imports (right) or one importing it (left)`})]}),r.imports&&(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line import`}),(0,Y.jsx)(`span`,{children:`imports: a file imports another (the one this file imports, or one importing it)`})]})]})]}),(0,Y.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Cross-file calls`,children:[t.in.calls.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`in`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.path,` › `,Se(e.from),` calls `,Se(e.to)]})},e.id)),t.out.calls.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`out`,tabIndex:-1,onClick:()=>a(e.id),children:[Se(e.from),` calls `,e.to.path,` › `,Se(e.to)]})},e.id)),x.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.file,tabIndex:-1,onClick:()=>o(e.file),children:[`Open `,e.path]})},e.file))]}),(0,Y.jsx)(`button`,{className:`fit`,onClick:()=>d.current?.fit(void 0,30),children:`Fit`})]})}function LC(){return[{selector:`node`,style:{shape:`round-rectangle`,width:170,height:36,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:X(`gray-26`),"background-color":X(`gray-100`),"border-width":1,"border-color":X(`gray-86`),"z-index-compare":`manual`,"z-index":2}},{selector:`node.box`,style:{"background-color":X(`gray-98-5`),"border-color":X(`blue-87`),"border-width":2,"text-valign":`top`,"text-margin-y":18,color:X(`blue-47`),"font-weight":`bold`,width:`data(w)`,height:`data(h)`,events:`no`,"z-index":0}},{selector:`node.function`,style:{height:40,"text-max-width":`156px`,"text-overflow-wrap":`anywhere`}},{selector:`node.port`,style:{width:210,height:42,"border-style":`dashed`,"border-color":X(`blue-62`)}},{selector:`node.port.file`,style:{"border-color":X(`gray-81`),color:X(`gray-44`)}},{selector:`edge`,style:{"z-index-compare":`manual`,"z-index":1,width:1.5,"curve-style":`bezier`,"line-color":X(`blue-62`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`blue-62`),"arrow-scale":.8,label:`data(label)`,"font-size":10,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1}},{selector:`edge.import`,style:{"line-color":X(`gray-66`),"line-style":`dashed`,"target-arrow-shape":`vee`,"target-arrow-color":X(`gray-51-2`),"arrow-scale":1.2,"font-size":9}},...Ze(),{selector:`.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`),width:3}}]}var RC=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`;function zC(e){let t=`(${RC(e.imports,`import`)})`;return e.calls===0&&!e.references?`no calls linked ${t}`:[e.calls?RC(e.calls,`call`):``,e.references?RC(e.references,`reference`):``].filter(Boolean).join(`, `).concat(` ${t}`)}var BC=e=>!e.startsWith(`group|`);function VC(e,t){let n=zC(e),r=e.groups;return r?`${BC(e.from)?`${RC(r.from,`group`)} in ${t(e.from)}`:t(e.from)} ${BC(e.from)&&r.from!==1?`call`:`calls`} into ${BC(e.to)?BC(e.from)?`${r.to.toLocaleString()} in ${t(e.to)}`:`${RC(r.to,`group`)} in ${t(e.to)}`:t(e.to)}: ${n}`:`${t(e.from)} calls into ${t(e.to)}: ${n}`}var HC={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`,area:`folder`,singles:`single files`},UC=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`,WC=.55;function GC(e){return e.resize(),e.elements().empty()?1:(e.fit(void 0,40),e.zoom()>1.2&&(e.zoom(1.2),e.center()),e.zoom())}function KC(e){let{members:t,kind:n}=e;if(t!==void 0)return n===`singles`?`${UC(t,`single file`)} · open them`:`${UC(t,`group`)} · open it`}var qC=(e,t=30)=>e.length>t?`${e.slice(0,t-1)}…`:e;function JC(e,t){if(!e||!t)return 0;let n=Math.abs(t.x-e.x)/290;return n>1.2||t.x<e.x?-(84*.9+12*Math.min(4,n)):0}var YC=(e,t)=>1+6*Math.sqrt(e/Math.max(1,t));function XC(e,t){return e.startsWith(`group|`)&&t.startsWith(`group|`)?`DEPENDS_ON|${e}|${t}`:`arrow|${encodeURIComponent(e)}|${encodeURIComponent(t)}`}function ZC({map:e,layoutKey:t,pick:n,showPackages:r,onPick:i,onOpen:a,onClear:o,marks:s=null,only:c=null,onContext:u}){let d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=Je();(0,y.useEffect)(()=>{f.current?.style(QC())},[p]);let[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(null),x=(0,y.useRef)(!1),S=(0,y.useRef)(c);S.current=c;let C=(0,y.useRef)(u);C.current=u,(0,y.useEffect)(()=>{f.current&&Ke(f.current,c)},[c]);let w=(0,y.useRef)(s);w.current=s,(0,y.useEffect)(()=>{f.current&&Qe(f.current,s)},[s]);let T=(0,y.useRef)({x:0,y:0}),E=(0,y.useRef)({onPick:i,onOpen:a,onClear:o});return E.current={onPick:i,onOpen:a,onClear:o},(0,y.useEffect)(()=>{if(!d.current)return;let n=Xx(t,e.groups,e.dependsOn.map(e=>({from:e.from,to:e.to,weight:e.imports+e.calls}))),r=e.dependsOn.flatMap(e=>{let t=l(e);return t?[{d:e,weight:t.weight}]:[]}),i=Math.max(1,...r.map(e=>e.weight)),a=new Map(e.groups.map(e=>[e.id,e.name])),o=e=>a.get(e)??e;T.current=n.packages;let s=new Set(e.groups.map(e=>e.source)).size>1,c=[...e.groups.map(e=>{let t=e.findings.broken;return{data:{id:e.id,kind:`group`,label:[qC(e.name),KC(e)??qC(s?`${e.source} · ${HC[e.kind]??e.kind}`:HC[e.kind]??e.kind),t>0?`${UC(e.files,`file`)} · ${UC(t,`broken import`)}`:`${UC(e.files,`file`)} · ${UC(e.functions,`function`)}`].join(`
336
+ `));return(0,Y.jsxs)(`form`,{className:`rules-editor`,"data-testid":`rules-editor`,onSubmit:e=>{e.preventDefault(),t({include:GS(r),exclude:GS(a)})},children:[(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Glob patterns, one per line, relative to the repository (`,(0,Y.jsx)(`code`,{children:`src/legacy/`}),`,`,` `,(0,Y.jsx)(`code`,{children:`**/*.test.ts`}),`). Applied at the next analysis; files left out are closed in the graph and kept in history.`]}),(0,Y.jsxs)(`label`,{children:[`Include only`,(0,Y.jsx)(`textarea`,{"data-testid":`rules-include`,value:r,onChange:e=>i(e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Leave out`,(0,Y.jsx)(`textarea`,{"data-testid":`rules-exclude`,value:a,onChange:e=>o(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`actions`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`rules-save`,children:`Save and re-analyze`})]})]})}function qS({project:e,refresh:t,onAdd:n,onChooseFiles:r,onAnalyzeAll:i,onChanged:a,escape:o}){let[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)({top:0,right:0}),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(0);(0,y.useEffect)(()=>{let t=!1;return J.sources(e).then(e=>!t&&c(e.sources.map(e=>({...e,optIn:e.optIn??[]}))),e=>!t&&u(e.message)),()=>{t=!0}},[e,t,O]);let A=async(e,t,n)=>{D(!0),u(``),n&&f(n);try{await e(),f(t),a()}catch(e){f(``),u(e.message??String(e))}finally{D(!1),k(e=>e+1)}},j=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!S)return;j.current?.querySelector(`button`)?.focus();let e=e=>{e.type===`mousedown`&&j.current?.contains(e.target)||C(null)};return document.addEventListener(`mousedown`,e),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[S]),o.current=()=>{if(S){let e=S;return C(null),document.querySelector(`tr[data-source="${CSS.escape(e)}"] [data-testid="repo-more"]`)?.focus(),!0}return p?(m(null),!0):b?(x(null),!0):_?(v(null),!0):!1};let M=(0,y.useRef)(null);if((0,y.useEffect)(()=>{(_||b)&&(M.current?.scrollIntoView({block:`nearest`}),M.current?.querySelector(`textarea, button`)?.focus())},[_,b]),(0,y.useEffect)(()=>{s&&(_&&!s.some(e=>e.id===_)&&v(null),b&&!s.some(e=>e.id===b)&&x(null))},[s,_,b]),!s)return(0,Y.jsx)(`p`,{className:l?`error`:`muted`,children:l||`Loading…`});let N=_?s.find(e=>e.id===_):void 0;return(0,Y.jsxs)(`div`,{className:`repositories`,"data-testid":`repositories`,children:[(0,Y.jsxs)(`div`,{className:`repo-actions`,children:[(0,Y.jsx)(`button`,{"data-testid":`repo-add`,onClick:n,children:`+ Add folder`}),(0,Y.jsx)(`button`,{"data-testid":`repo-analyze-all`,disabled:E,onClick:i,children:`Re-analyze all`})]}),l&&(0,Y.jsx)(`p`,{className:`error`,role:`alert`,children:l}),d&&(0,Y.jsx)(`p`,{className:`muted small`,role:`status`,"data-testid":`repo-status`,children:d}),(0,Y.jsxs)(`table`,{className:`repo-table`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{children:`Repository`}),(0,Y.jsx)(`th`,{children:`Branch and commit`}),(0,Y.jsx)(`th`,{children:`Analyzed`}),(0,Y.jsx)(`th`,{children:`Files`}),(0,Y.jsx)(`th`,{children:`Left out`}),(0,Y.jsx)(`th`,{children:(0,Y.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,Y.jsx)(`tbody`,{children:s.map(t=>{let n=t.analysis,i=t.include.length+t.exclude.length;return(0,Y.jsxs)(`tr`,{"data-source":t.id,children:[(0,Y.jsxs)(`td`,{children:[p===t.id?(0,Y.jsx)(`form`,{onSubmit:n=>{n.preventDefault(),m(null),A(()=>J.updateSource(e,t.id,{name:h}),`Renamed ${t.id} to ${h||t.id}.`)},onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&m(null),children:(0,Y.jsx)(`input`,{autoFocus:!0,"aria-label":`New name for ${t.id}`,"data-testid":`repo-name`,value:h,onChange:e=>g(e.target.value)})}):(0,Y.jsx)(`strong`,{className:`repo-name`,children:t.name??t.id}),(0,Y.jsx)(`div`,{className:`muted small path`,children:t.root}),n?.notices.map(e=>(0,Y.jsx)(`div`,{className:`notice-line small`,children:e},e))]}),(0,Y.jsx)(`td`,{className:`mono small`,children:n?n.kind===`plain`?`plain folder (latest only)`:`${n.branch??`detached`} · ${WS(n.revision)}${n.pinned?` (kept)`:``}`:`not analyzed yet`}),(0,Y.jsx)(`td`,{className:`small`,children:n?we(n.analyzedAt):``}),(0,Y.jsx)(`td`,{className:`small`,children:n?n.files:``}),(0,Y.jsx)(`td`,{className:`small`,children:i?`${i} rule${i===1?``:`s`}`:`defaults`}),(0,Y.jsxs)(`td`,{className:`row-actions`,children:[(0,Y.jsx)(`button`,{className:`link`,"data-testid":`repo-analyze`,"aria-label":`Re-analyze ${t.name??t.id}`,disabled:E,onClick:()=>void A(()=>J.analyzeSource(e,t.id),`Analyzing ${t.name??t.id} again (the others stay at their commits)…`,`Starting an analysis of ${t.name??t.id}…`),children:`Re-analyze`}),(0,Y.jsx)(`button`,{className:`link`,"data-testid":`repo-choose`,"aria-label":`Choose files in ${t.name??t.id}`,onClick:()=>r(t.id),children:`Choose files…`}),(0,Y.jsxs)(`span`,{className:`menu-wrap`,children:[(0,Y.jsx)(`button`,{className:`icon`,"aria-label":`More for ${t.name??t.id}`,"aria-expanded":S===t.id,"data-testid":`repo-more`,disabled:E,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();T({top:n.bottom+2,right:window.innerWidth-n.right}),C(S===t.id?null:t.id)},children:`⋯`}),S===t.id&&(0,Y.jsxs)(`span`,{className:`menu`,role:`menu`,ref:j,style:{top:w.top,right:w.right},children:[(0,Y.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rename`,onClick:()=>{C(null),g(t.name??t.id),m(t.id)},children:`Rename`}),(0,Y.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rules`,onClick:()=>{C(null),v(t.id)},children:`Edit rules`}),(0,Y.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-remove`,onClick:()=>{C(null),x(t.id)},children:`Remove…`})]})]})]})]},t.id)})})]}),s.length===0&&(0,Y.jsx)(`p`,{className:`muted`,children:`No repositories yet: + Add folder adds one.`}),N&&(0,Y.jsx)(`div`,{ref:M,children:(0,Y.jsx)(KS,{source:N,onCancel:()=>v(null),onSave:t=>{let n=N.id;v(null),A(async()=>{await J.updateSource(e,n,t),await J.analyzeSource(e,n)},`Rules saved; analyzing ${n} again…`)}},N.id)}),b&&(0,Y.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`remove-title`,"data-testid":`repo-remove-confirm`,children:[(0,Y.jsx)(`p`,{id:`remove-title`,children:(0,Y.jsxs)(`strong`,{children:[`Remove `,s.find(e=>e.id===b)?.name??b,` from this project?`]})}),(0,Y.jsx)(`p`,{className:`muted small`,children:`Its files and links leave the current graph. History keeps the analysis: earlier runs still show it, and adding the folder again analyzes it afresh. The folder itself is not touched.`}),(0,Y.jsxs)(`div`,{className:`actions`,children:[(0,Y.jsx)(`button`,{onClick:()=>x(null),"data-testid":`repo-remove-cancel`,children:`Cancel`}),(0,Y.jsx)(`button`,{className:`danger`,"data-testid":`repo-remove-yes`,disabled:E,onClick:()=>{let t=b;x(null),A(()=>J.removeSource(e,t),`Removed ${t}; history keeps its analysis.`,`Removing ${t} (a run closes its facts)…`)},children:`Remove`})]})]})]})}function JS({project:e}){let[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null);return(0,y.useEffect)(()=>{J.projectSettings(e).then(e=>{n(String(e.settings.maxFileMB)),i(e.settings.closedWorld)},e=>o({ok:!1,text:e.message}))},[e]),(0,Y.jsxs)(`form`,{className:`analysis-settings`,onSubmit:n=>{n.preventDefault();let i=Number(t);if(!(i>0&&i<=64))return o({ok:!1,text:`The size limit is more than 0 and at most 64 MB.`});J.saveProjectSettings(e,{maxFileMB:i,closedWorld:r}).then(e=>o({ok:!0,text:`Saved: files over ${e.settings.maxFileMB} MB are left out at the next analysis${e.settings.closedWorld?`, which treats the analyzed code as the whole program`:``}.`}),e=>o({ok:!1,text:e.message}))},children:[(0,Y.jsxs)(`label`,{children:[`Size limit per file (MB)`,(0,Y.jsx)(`input`,{type:`number`,min:.1,max:64,step:.1,required:!0,"data-testid":`analysis-max-mb`,value:t,onChange:e=>n(e.target.value)})]}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Larger files are listed but not analyzed, unless you choose them in Choose files. Folders of installed libraries, generated output and tools' workspaces (`,(0,Y.jsx)(`code`,{children:`node_modules`}),`, `,(0,Y.jsx)(`code`,{children:`dist`}),`,`,` `,(0,Y.jsx)(`code`,{children:`build`}),`, …) are left out by default; Choose files shows them and can add them.`]}),(0,Y.jsxs)(`label`,{className:`checkbox`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`analysis-closed-world`,checked:r,onChange:e=>i(e.target.checked)}),`Treat the analyzed code as the whole program (closed world)`]}),(0,Y.jsx)(`p`,{className:`muted small`,children:`For an application, not a library: the callers of a function and the classes of a type that analysis sees are taken to be all there are, so more calls are linked. Each link this settles says “closed world”. Off by default.`}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`analysis-save`,children:`Save`}),a&&(0,Y.jsx)(`p`,{className:a.ok?`muted small`:`error`,role:a.ok?`status`:`alert`,children:a.text})]})}function YS({project:e,projectName:t,refresh:n,onClose:r,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,covered:c=!1,initialTab:l=`repositories`}){let[u,d]=(0,y.useState)(l),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=(0,y.useRef)(null);return(0,y.useEffect)(()=>{let e=document.activeElement;return p.current?.focus(),()=>e?.focus?.()},[]),(0,y.useEffect)(()=>{if(c)return;let e=e=>{if(e.key===`Escape`)e.stopPropagation(),m.current?.()||r();else if(e.key===`Tab`&&f.current){let t=[...f.current.querySelectorAll(`button:not([disabled]), input, textarea, select`)],n=t[0],r=t[t.length-1];f.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[c,r]),(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&r(),children:(0,Y.jsxs)(`div`,{className:`modal wide`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`project-settings-title`,"data-testid":`project-settings-dialog`,ref:f,children:[(0,Y.jsxs)(`div`,{className:`modal-head`,children:[(0,Y.jsxs)(`h2`,{id:`project-settings-title`,children:[t,`: settings`]}),(0,Y.jsx)(`button`,{className:`icon`,"aria-label":`Close`,onClick:r,ref:p,children:`×`})]}),(0,Y.jsx)(`div`,{className:`segmented`,role:`tablist`,"aria-label":`Project settings`,children:[`repositories`,`analysis`,`license`].map(e=>(0,Y.jsx)(`button`,{role:`tab`,"aria-selected":u===e,"data-testid":`project-tab-${e}`,onClick:()=>d(e),children:e===`repositories`?`Repositories`:e===`analysis`?`Analysis`:`License`},e))}),u===`repositories`?(0,Y.jsx)(qS,{project:e,refresh:n,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,escape:m}):u===`analysis`?(0,Y.jsx)(JS,{project:e}):(0,Y.jsx)(Ue,{onChanged:s})]})})}var XS={library:`installed library code`,generated:`generated or built output`,tool:`a tool's or coding agent's workspace (settings, history, worktrees)`};function ZS(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var QS=(e,t)=>`${e}\0${t}`,$S=(e,t)=>JSON.stringify([e.include,e.exclude,e.optIn??[]])===JSON.stringify([t?.include??[],t?.exclude??[],t?.optIn??[]]);function eC({project:e,files:t,run:n,onAnalyze:r,onClose:i,only:a,at:o}){let[s,c]=(0,y.useState)([]),[l,u]=(0,y.useState)(new Map),[d,f]=(0,y.useState)(new Set),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(new Map),[S,C]=(0,y.useState)(new Map),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(``),O=(0,y.useRef)(new Set),k=s.length>1,A=(0,y.useCallback)(e=>n?.sources.find(t=>t.sourceId===e),[n]),j=(0,y.useCallback)(async(t,n)=>{let{entries:r}=await J.browse(e,t,n);O.current.add(QS(t,n)),u(e=>new Map(e).set(QS(t,n),r))},[e]),M=(0,y.useCallback)(async()=>{await Promise.all([...O.current].map(e=>{let[t,n]=e.split(`\0`);return j(t,n).catch(()=>O.current.delete(e))}))},[j]);(0,y.useEffect)(()=>{let t=!1;return(async()=>{try{let[{sources:n},{settings:r}]=await Promise.all([J.sources(e),J.projectSettings(e)]);if(t)return;let i=n.map(e=>({...e,optIn:e.optIn??[]})).filter(e=>a===void 0||e.id===a);c(i),T(r.maxFileMB),D(String(r.maxFileMB)),await Promise.all(i.map(e=>j(e.id,``)))}catch(e){t||m(e.message??String(e))}})(),()=>{t=!0}},[e,j,a]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(h?g(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h,i]),(0,y.useEffect)(()=>{if(!o||!a||s.length===0)return;let e=o.split(`/`).filter(Boolean),t=e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`));f(e=>new Set([...e,...t.map(e=>QS(a,e))])),Promise.all(t.filter(e=>!O.current.has(QS(a,e))).map(e=>j(a,e))).then(()=>requestAnimationFrame(()=>document.querySelector(`.picker-row[data-path="${CSS.escape(o)}"]`)?.scrollIntoView({block:`center`})),e=>m(e.message))},[o,a,s.length,j]);let N=(e,t)=>{let n=QS(e,t);f(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),O.current.has(n)||j(e,t).catch(e=>m(e.message))},P=(0,y.useMemo)(()=>{let e=[],t=(n,r,i)=>{for(let a of l.get(QS(n,r))??[]){if(a.kind===`file`&&!a.language&&!a.path.toLowerCase().endsWith(`.html`))continue;let r=a.kind===`dir`&&d.has(QS(n,a.path));e.push({source:n,entry:a,depth:i,open:r}),r&&t(n,a.path,i+1)}};for(let e of s)t(e.id,``,+!!k);return e},[l,d,s,k]),F=(e,t)=>{if(t.kind!==`dir`)return!1;let n=e=>e.replace(/^\/+/,``).startsWith(`${t.path}/`),r=l.get(QS(e.id,t.path));if(t.excludedBy)return e.optIn.some(n)?!0:!!r?.some(e=>!e.excludedBy);if(r?.some(e=>e.excludedBy&&(e.kind===`dir`||e.language))||e.exclude.some(e=>e.startsWith(`/`)&&n(e)))return!0;let i=A(e.id),a=t=>e.optIn.some(e=>t===e||t.startsWith(`${e}/`));return i?.defaultExcluded?.some(e=>n(e.path)&&!a(e.path))?!0:$S(e,i?.filter)&&!!i?.ruleExcluded?.some(e=>n(e.path)&&!a(e.path))},I=(e,n,r)=>{if(!r)return-t.filter(t=>t.source===e&&(t.path===n.path||t.path.startsWith(`${n.path}/`))).length;if(n.kind===`file`)return 1;let i=A(e);return i?.defaultExcluded?.find(e=>e.path===n.path)?.files??i?.ruleExcluded?.find(e=>e.path===n.path)?.files??null},L=async(t,n,r)=>{v(!0),m(``),x(e=>new Map(e).set(QS(t,n.path),r));try{let{source:i}=await J.select(e,t,[n.path],r);c(e=>e.map(e=>e.id===t?{...i,optIn:i.optIn??[]}:e)),C(e=>{let i=new Map(e),a=QS(t,n.path);return i.has(a)?i.delete(a):i.set(a,I(t,n,r)),i}),await M()}catch(e){m(e.message??String(e))}finally{x(e=>{let r=new Map(e);return r.delete(QS(t,n.path)),r}),v(!1)}},R=(e,t,n)=>{if(!_){if(n&&t.excludedBy&&t.excludedBy!==`rule`){let n=t.path.slice(t.path.lastIndexOf(`/`)+1),r=A(e)?.defaultExcluded?.find(e=>e.path===t.path),i=t.kind===`dir`&&r?.files?` It has ${r.files.toLocaleString(`en-US`)} file${r.files===1?``:`s`}.`:``;if(t.excludedBy===`too-large`)g({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${ZS(t.size??0)}, over the ${w??10} MB size limit. Files this large are usually generated or bundled code (minified builds, vendored bundles, source maps), and they slow analysis down. Files over 64 MB are never analyzed.`});else if(t.excludedBy===`minified`)g({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} looks minified: most of it is on very long lines, as in a library build. A build adds thousands of functions that aren't your project's own code. Analyze it if it is your code.`});else{let r=XS[t.excludedBy]??XS.generated;g({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${r}, not your project's own code.${i} Analyzing it makes analysis slower and the graph larger. Its files will be marked as ${t.excludedBy} code and left out of "largest files" and "most called".`})}return}L(e,t,n)}},z=async()=>{let t=Number(E);if(!Number.isFinite(t)||t<=0||t>64){m(`The size limit must be a number of megabytes between 0 and 64.`);return}try{let{settings:n}=await J.saveProjectSettings(e,{maxFileMB:t});T(n.maxFileMB),C(e=>new Map(e).set(`\0limit`,null)),await M()}catch(e){m(e.message??String(e))}},B=S.size>0||s.some(e=>!$S(e,A(e.id)?.filter))||w!==null&&n?.sources[0]?.maxFileBytes!==void 0&&n.sources[0].maxFileBytes!==w*1048576,V=0,H=0,U=!1;for(let[e,t]of S)e!==`\0limit`&&(t===null?U=!0:t>0?V+=t:H-=t);let W=e=>`${e} file${e===1?``:`s`}`,ee=[U?V?`${V}+ files added`:`files added`:V?`${W(V)} added`:``,H?`${W(H)} removed`:``].filter(Boolean).join(`, `);return(0,Y.jsxs)(`div`,{className:`picker`,"data-testid":`file-picker`,children:[(0,Y.jsxs)(`div`,{className:`picker-head`,children:[(0,Y.jsx)(`strong`,{children:`Choose files`}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{onClick:i,"data-testid":`picker-done`,children:`Done`})]}),(0,Y.jsx)(`p`,{className:`muted small picker-help`,children:`Unchecked files are left out of the graph. Greyed folders are left out by default: libraries and generated output.`}),(0,Y.jsxs)(`label`,{className:`picker-limit`,children:[`Skip files over`,(0,Y.jsx)(`input`,{type:`number`,min:1,max:64,step:1,value:E,"data-testid":`size-limit`,"aria-label":`Size limit in MB`,onChange:e=>D(e.target.value),onBlur:()=>E!==String(w)&&void z(),onKeyDown:e=>e.key===`Enter`&&void z()}),`MB`]}),p&&(0,Y.jsx)(`p`,{className:`error small`,role:`alert`,children:p}),B&&(0,Y.jsxs)(`div`,{className:`picker-pending`,"data-testid":`picker-pending`,children:[(0,Y.jsxs)(`span`,{children:[ee?(0,Y.jsx)(`strong`,{children:ee[0].toUpperCase()+ee.slice(1)}):`Changes`,` at the next analysis`]}),(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`picker-apply`,disabled:_,onClick:()=>{C(new Map),r()},children:`Apply & re-analyze`})]}),(0,Y.jsxs)(`div`,{className:`picker-list`,role:`tree`,"aria-label":`Choose files`,children:[s.map(e=>k?(0,Y.jsx)(`div`,{className:`picker-row source`,title:e.root,children:(0,Y.jsx)(`strong`,{children:e.id})},`s:${e.id}`):null),P.map(({source:e,entry:t,depth:n,open:r})=>{let i=s.find(t=>t.id===e),a=b.get(QS(e,t.path))??!t.excludedBy,c=F(i,t),l=t.path.slice(t.path.lastIndexOf(`/`)+1),u=t.notAnalyzable?t.notAnalyzable===`declaration-file`?`type declarations`:t.notAnalyzable===`symlink`?`link`:`${ZS(t.size??0)} · over 64 MB`:t.excludedBy===`library`?`library`:t.excludedBy===`generated`||t.excludedBy===`tool`?t.excludedBy:t.excludedBy===`too-large`?`${ZS(t.size??0)} · too large`:t.excludedBy===`minified`?`minified`:t.excludedBy===`rule`?`excluded`:null,d=t.optedIn?t.origin??null:null;return(0,Y.jsxs)(`div`,{className:`picker-row ${t.kind} ${a?``:`excluded`}${t.path===o?` target`:``}`,style:{paddingLeft:8+n*14},role:`treeitem`,"aria-expanded":t.kind===`dir`?r:void 0,"aria-level":n+1,"data-path":t.path,children:[t.kind===`dir`?(0,Y.jsx)(`button`,{className:`caret`,"aria-label":`${r?`Close`:`Open`} ${l}`,onClick:()=>N(e,t.path),children:r?`▾`:`▸`}):(0,Y.jsx)(`span`,{className:`caret`}),t.kind===`dir`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,"aria-label":`Analyze ${l}`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>R(e,t,n.target.checked)}),(0,Y.jsx)(`button`,{className:`name button-link`,"data-command":`open-folder`,onClick:()=>N(e,t.path),children:l})]}):(0,Y.jsxs)(`label`,{children:[t.notAnalyzable?(0,Y.jsx)(`span`,{className:`caret`}):(0,Y.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>R(e,t,n.target.checked)}),(0,Y.jsx)(`span`,{className:`name`,children:l})]}),u&&(0,Y.jsx)(`small`,{className:`reason`,children:u}),d&&(0,Y.jsx)(`small`,{className:`origin ${d}`,children:d})]},QS(e,t.path))}),s.length>0&&P.length===0&&!p&&(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`})]}),h&&(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&g(null),children:(0,Y.jsxs)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pick-warning-title`,"data-testid":`pick-warning`,children:[(0,Y.jsx)(`h2`,{id:`pick-warning-title`,children:h.title}),(0,Y.jsx)(`p`,{children:h.text}),(0,Y.jsxs)(`div`,{className:`buttons`,children:[(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{autoFocus:!0,onClick:()=>g(null),children:`Cancel`}),(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`pick-warning-confirm`,onClick:()=>{let e=h;g(null),L(e.source,e.entry,!0)},children:`Analyze anyway`})]})]})})]})}var tC=e=>e.toLocaleString(`en-US`);function nC(e){if(e.sites===0)return null;let t=e.sites-e.open,n=Math.floor(t/e.sites*100);return e.open>0?Math.min(n,99):n}function rC(e){let t=nC(e);return t===null?`No calls found`:`Paths: ${t}% of ${tC(e.sites)} call site${e.sites===1?``:`s`} go somewhere known${e.open?` · ${tC(e.open)} stop short`:``}`}function iC(e){return[{label:`within files`,count:e.withinFiles},{label:`across files`,count:e.acrossFiles},{label:`leave the project`,count:e.external},{label:`to one known body`,count:e.candidates.one},{label:`to a set of candidates`,count:e.candidates.several},{label:`stop short`,count:e.open}]}function aC({projects:e,progress:t=new Map,loading:n=!1,onOpen:r,onCreated:i,onAddFolder:a,onDeleted:o}){let[s]=dS(),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!1),x=e=>{_({id:e}),J.projectDisk(e).then(({bytes:t})=>_(n=>n?.id===e?{...n,bytes:t}:n),()=>void 0)},S=async e=>{if(!v){b(!0);try{await J.deleteProject(e),_(null),o(e)}catch(t){_(n=>n?.id===e?{...n,error:t.message??String(t)}:n)}finally{b(!1)}}},C=()=>{l(!1),d(``),p(``)},w=async()=>{if(!m){h(!0),p(``);try{let{project:e}=await J.createProject(u.trim());C(),i(e.id)}catch(e){p(e.message??String(e))}finally{h(!1)}}};return(0,Y.jsxs)(`section`,{className:`home`,"data-testid":`home`,"aria-labelledby":`home-title`,children:[(0,Y.jsxs)(`div`,{className:`home-head`,children:[(0,Y.jsx)(`h1`,{id:`home-title`,children:`Projects`}),(0,Y.jsxs)(`div`,{className:`home-actions`,children:[(0,Y.jsx)(`button`,{"data-testid":`new-project`,onClick:()=>l(!0),children:`+ New project`}),(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`home-add-folder`,onClick:a,children:`Add folder`})]})]}),c&&(0,Y.jsxs)(`form`,{className:`new-project`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,Y.jsxs)(`label`,{children:[`Name`,(0,Y.jsx)(`input`,{autoFocus:!0,"data-testid":`new-project-name`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.key===`Escape`&&C()})]}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!u.trim()||m,"data-testid":`new-project-create`,children:`Create`}),(0,Y.jsx)(`button`,{type:`button`,onClick:C,children:`Cancel`}),f&&(0,Y.jsx)(`p`,{className:`error`,role:`alert`,children:f})]}),n?(0,Y.jsx)(`p`,{className:`muted`,children:`Loading…`}):e.length===0?(0,Y.jsx)(`p`,{className:`muted`,children:`No projects yet. Add a folder to analyze its code.`}):(0,Y.jsx)(`ul`,{className:`project-cards`,children:e.map(e=>{let n=!s&&e.ownFindings||e.findings,i=n?n.broken+n.notAnalyzed+n.openCalls:0;return(0,Y.jsxs)(`li`,{"data-project":e.id,children:[(0,Y.jsxs)(`button`,{className:`project-card`,"data-testid":`open-project`,onClick:()=>r(e.id),children:[(0,Y.jsx)(`strong`,{children:e.name}),(0,Y.jsx)(`span`,{className:`muted small`,"data-testid":`project-sources`,children:e.repositories===void 0?`${e.sources} source${e.sources===1?``:`s`}`:[e.repositories?`${e.repositories} repositor${e.repositories===1?`y`:`ies`}`:``,e.folders?`${e.folders} folder${e.folders===1?``:`s`}`:``].filter(Boolean).join(` · `)||`no sources`}),e.error?(0,Y.jsxs)(`span`,{className:`error small`,"data-testid":`project-error`,children:[`Can't be read: `,e.error]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`small`,children:e.latest?e.latest.status===`running`?t.get(e.id)?T(t.get(e.id)).text:`Analyzing…`:e.latest.status===`failed`?e.latest.errorCode===`cancelled`?`Last analysis cancelled`:`Last analysis failed`:`Analyzed${e.latest.finishedAt?` ${we(e.latest.finishedAt)}`:``}`:`Not analyzed yet`}),e.analysis?.outdated.length?(0,Y.jsx)(`span`,{className:`small outdated-note`,"data-testid":`project-outdated`,children:e.analysis.outdated.every(e=>e.was===null)?`Made before veoflow recorded its version: analyze again to see what this version finds`:`Made by ${e.analysis.veoflow?`veoflow ${e.analysis.veoflow}`:`another veoflow`}: analyze again to see what this version finds`}):null,!n&&e.findingsPending&&(0,Y.jsx)(`span`,{className:`muted small`,"data-testid":`findings-pending`,children:`Counting findings…`}),e.files&&e.files.analyzed<e.files.listed&&(0,Y.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:e.files.analyzed===0?`None of ${e.files.listed.toLocaleString(`en-US`)} files analyzed`:`${(e.files.listed-e.files.analyzed).toLocaleString(`en-US`)} of ${e.files.listed.toLocaleString(`en-US`)} files not analyzed`}),e.files?.listed===0&&(0,Y.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:`No files veoflow analyzes`}),e.completeness&&!(e.files&&e.files.analyzed===0)&&(0,Y.jsx)(`span`,{className:`small`,"data-testid":`project-paths`,children:rC(e.completeness)}),n&&!(e.files&&e.files.analyzed===0)&&(0,Y.jsx)(`span`,{className:`muted small`,children:i===0?`No findings`:[n.broken?`${n.broken} broken import${n.broken===1?``:`s`}`:``,n.notAnalyzed?`${n.notAnalyzed} import${n.notAnalyzed===1?``:`s`} not analyzed`:``,n.openCalls?`${n.openCalls.toLocaleString(`en-US`)} open call${n.openCalls===1?``:`s`}`:``].filter(Boolean).join(` · `)})]})]}),(0,Y.jsx)(`button`,{className:`project-delete`,"data-testid":`project-delete`,"aria-label":`Delete ${e.name}`,title:`Delete this project`,onClick:()=>x(e.id),children:`Delete…`}),g?.id===e.id&&(0,Y.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`delete-${e.id}`,"data-testid":`project-delete-confirm`,onKeyDown:e=>e.key===`Escape`&&_(null),children:[(0,Y.jsx)(`p`,{id:`delete-${e.id}`,children:(0,Y.jsxs)(`strong`,{children:[`Delete `,e.name,`?`]})}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Its graph, history and evidence`,g.bytes===void 0?``:` (${oC(g.bytes)})`,` are deleted, and the commit hooks veoflow installed for it. The folders it analyzed are not touched. This can't be undone.`]}),g.error&&(0,Y.jsx)(`p`,{className:`error small`,role:`alert`,children:g.error}),(0,Y.jsxs)(`div`,{className:`actions`,children:[(0,Y.jsx)(`button`,{autoFocus:!0,onClick:()=>_(null),"data-testid":`project-delete-cancel`,children:`Cancel`}),(0,Y.jsx)(`button`,{className:`danger`,"data-testid":`project-delete-yes`,disabled:v,onClick:()=>void S(e.id),children:`Delete project`})]})]})]},e.id)})})]})}function oC(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}function sC({title:e,entries:t,x:n,y:r,onClose:i}){let a=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=document.activeElement;a.current?.querySelector(`button`)?.focus();let t=e=>{e.type===`mousedown`&&a.current?.contains(e.target)||i()},n=e=>{if(e.key===`Escape`){e.stopPropagation(),i();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let t=[...a.current?.querySelectorAll(`button`)??[]],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},r=e=>{a.current?.contains(e.relatedTarget)||i()},o=a.current;return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,t),document.addEventListener(`scroll`,t,!0),window.addEventListener(`keydown`,n,!0),o?.addEventListener(`focusout`,r),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,t),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`keydown`,n,!0),o?.removeEventListener(`focusout`,r),e&&e!==document.body&&document.contains(e)&&e.focus()}},[i]);let o=Math.max(4,Math.min(n,window.innerWidth-260)),s=Math.max(4,Math.min(r,window.innerHeight-40-t.length*30));return(0,Y.jsxs)(`div`,{ref:a,className:`context-menu`,role:`menu`,"aria-label":e,"data-testid":`context-menu`,style:{left:o,top:s},children:[(0,Y.jsx)(`div`,{className:`context-title`,"aria-hidden":`true`,children:e}),t.map(e=>(0,Y.jsx)(`button`,{role:`menuitem`,tabIndex:-1,"data-command-name":e.command,onClick:()=>{i(),e.run()},children:e.label},e.label))]})}function cC(e,t){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return i;let a=0,o=0;for(let e of r)if(e===n[a]?a++:a>0&&o++,a===n.length)return 100+o;return null}function lC(e,t,n){return n===0?[]:t.map((t,n)=>({item:t,i:n,score:cC(e,t.label)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).slice(0,n).map(e=>e.item)}function uC(e,t){let{view:n,command:r}=t,i=e.trim(),a=[];if(n.project){let e=lC(i,t.files.map(e=>({...e,label:e.path})),i?5:0);for(let i of e)a.push({key:`file:${i.id}`,group:`Files`,label:i.path,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:i.id}):r(`openFile`,{file:i.id})}),e.length<=2&&(n.tab===`imports`&&n.group!==null&&!n.fileLevel&&a.push({key:`only:${i.id}`,group:`Files`,label:`Show only links of ${i.path}`,run:()=>r(`showOnlyLinks`,{id:i.id})}),a.push({key:`leave:${i.id}`,group:`Files`,label:`Leave ${i.path} out of analysis…`,run:()=>t.action(`chooseFiles`,{source:i.id.slice(0,i.id.indexOf(`:`)),path:i.path})}));for(let e of lC(i,t.groups.map(e=>({...e,label:e.name})),i?4:0))a.push({key:`group:${e.id}`,group:`Groups`,label:e.name,detail:`open the group`,run:()=>r(`openGroup`,{group:e.id})}),a.push({key:`only:${e.id}`,group:`Groups`,label:`Show only links of ${e.name}`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}}),a.push({key:`pick:${e.id}`,group:`Groups`,label:`Details of ${e.name}`,detail:`on the project map`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`pickNode`,{id:e.id})}})}let o=[],s=(e,t,n,r)=>o.push({label:e,run:t,...n?{detail:n}:{},...r?{key:r}:{}});if(n.project){s(n.history?`Close History`:`History: runs by commit`,()=>r(`toggleHistory`)),n.compare&&s(`Stop comparing`,()=>r(`compareRuns`,{}));let e=/^(?:compare\s+)?(?:run\s*)?(\d+)\s*(?:\.\.|with|vs|and|,|\s)\s*(?:run\s*)?(\d+)$/i.exec(i);if(e){let[t,n]=[Number(e[1]),Number(e[2])];s(`Compare run ${Math.min(t,n)} with run ${Math.max(t,n)}`,()=>r(`compareRuns`,{a:t,b:n}))}n.run!==null&&s(`Back to latest`,()=>r(`openRun`,{}));let a=/^(?:view\s+)?run\s*(\d+)$/i.exec(i);a&&s(`View run ${a[1]}`,()=>r(`openRun`,{run:Number(a[1])})),s(`File tab`,()=>r(`showTab`,{tab:`file`}),`functions and calls inside a file`),s(`Imports tab`,()=>r(`showTab`,{tab:`imports`}),`how files depend on each other`),s(`Project map`,()=>r(`openArea`,{}),`the Imports tab from the top: the whole map`),s(`Show the code`,()=>r(`showPanel`,{panel:`evidence`})),s(`Show Findings`,()=>r(`showPanel`,{panel:`questions`})),s(n.showPending?`Hide pending imports`:`Show pending imports`,()=>r(`togglePending`)),s(n.showUnresolved?`Hide unresolved call sites`:`Show unresolved call sites`,()=>r(`toggleUnresolved`)),n.selection&&s(`Clear the selection`,()=>r(`clearSelection`));let o=n.selection?.kind===`function`?n.selection.id:null,c=o??n.file;if(c){let e=o?o.slice(o.indexOf(`:`,o.indexOf(`:`)+1)+1):c.slice(c.indexOf(`:`)+1);s(`Reach from ${e}`,()=>r(`openReach`,{root:c,direction:`forward`}),`what paths from it reach`),s(`What reaches ${e}`,()=>r(`openReach`,{root:c,direction:`backward`}),`the paths that lead to it`)}n.reach&&n.tab!==`reach`&&s(`Reach tab`,()=>r(`showTab`,{tab:`reach`})),n.only&&s(`Show everything again`,()=>r(`showOnlyLinks`,{}),`not only one item's links`);for(let e of t.sources)s(`Re-analyze ${e.name??e.id}`,()=>t.action(`analyzeSource`,{source:e.id}),`this repository only`,`analyze:${e.id}`);if(t.sources.length>1){n.source&&s(`Scope: all repositories`,()=>r(`scopeSource`,{}));for(let e of t.sources)e.id!==n.source&&s(`Scope: ${e.name??e.id}`,()=>r(`scopeSource`,{source:e.id}),`one repository only`,`scope:${e.id}`)}n.group&&i.includes(`/`)&&s(`Open or close folder ${i}`,()=>r(`toggleFolder`,{path:i.replace(/^\.?\//,``).replace(/\/$/,``)})),s(`Re-analyze the project`,()=>t.action(`analyze`)),t.canDraft&&s(`Analyze uncommitted edits`,()=>t.action(`analyzeDraft`),`a draft beside the graph`);for(let e of(t.stages??[]).slice(1))s(`Analyze again from ${e}`,()=>t.action(`analyzeFrom`,{from:e}),`the stages before it reused, when nothing they read changed`,`from:${e}`);for(let e of t.stages??[])s(`Debug run: stop after ${e}`,()=>t.action(`analyzeDebug`,{until:e}),`never committed; compare it with the latest`,`debug:${e}`);s(`Repositories…`,()=>t.action(`openProjectSettings`),`re-analyze, choose files, rename, remove`),s(`License…`,()=>t.action(`openProjectSettings`,{tab:`license`}),`what the license includes; add or replace a key`)}n.project&&s(`All projects (home)`,()=>r(`goHome`),`every project and its last run`),s(`Add a folder…`,()=>t.action(`addFolder`)),s(`Settings…`,()=>t.action(`openSettings`),`the model for questions`);for(let e of t.projects)e.id!==n.project&&s(`Switch to project ${e.name}`,()=>r(`selectProject`,{project:e.id}),void 0,`project:${e.id}`);let c=o.filter(e=>/^(Compare run|View run|Open or close folder)/.test(e.label)),l=lC(i,o.filter(e=>!c.includes(e)),i?6:0);for(let e of[...c,...l])a.push({key:`cmd:${e.key??e.label}`,group:`Commands`,label:e.label,run:e.run,...e.detail?{detail:e.detail}:{}});return a}var dC=e=>e.slice(e.lastIndexOf(`/`)+1),fC=20;function pC({project:e,file:t,run:n,onOpen:r,onShowImports:i}){let{calls:a,error:o}=xS(e,n,t);if(o)return(0,Y.jsx)(`p`,{className:`small muted`,children:`Calls to and from other files couldn't be loaded.`});if(!a||a.out.total===0&&a.in.total===0)return null;let s=(e,t)=>{if(e.total===0)return null;let n=new Map;for(let r of e.calls){let e=t===`out`?r.from:r.to,i=t===`out`?r.to:r.from,a=n.get(i.id)??{there:i,here:new Set,n:0,line:r.evidence.span.start.line};a.here.add(Se(e)),a.n++,n.set(i.id,a)}let i=[...n.values()].sort((e,t)=>t.n-e.n||(e.there.path<t.there.path?-1:1)),a=e.total-e.calls.length;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[t===`out`?`Calls into other files`:`Called from other files`,` (`,e.total,n.size!==e.total&&a===0?`, ${n.size} function${n.size===1?``:`s`}`:``,`)`]}),(0,Y.jsx)(`ul`,{className:`cross-calls`,"data-testid":`file-cross-calls-${t}`,children:i.slice(0,fC).map(({there:e,here:n,n:i,line:a})=>{let o=[...n],s=`${o.slice(0,2).join(`, `)}${o.length>2?` and ${o.length-2} more`:``}`;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link-row`,"data-command":`open-cross-file`,title:`Open ${Se(e)} in ${e.path}`,onClick:()=>r({id:e.id,file:e.file}),children:[(0,Y.jsxs)(`span`,{className:`name`,children:[(0,Y.jsxs)(`span`,{className:`muted`,children:[dC(e.path),` › `]}),Se(e),i>1&&(0,Y.jsxs)(`span`,{className:`times`,children:[` ×`,i]})]}),(0,Y.jsxs)(`small`,{children:[t===`out`?`from ${s}`:`calls ${s}`,i===1?` · line ${a}`:``]})]})},e.id)})}),(i.length>fC||a>0)&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[i.length>fC?`${(i.length-fC).toLocaleString(`en-US`)} more functions`:`${a.toLocaleString(`en-US`)} more calls`,`: select a function to see its own.`]})]})};return(0,Y.jsxs)(`div`,{className:`file-cross-calls`,"data-testid":`file-cross-calls`,children:[i&&(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`cross-calls-in-imports`,onClick:i,children:`⇄ See them drawn on the Imports tab`}),s(a.out,`out`),s(a.in,`in`)]})}var mC=`area|`,hC=`singles|`,gC=e=>e.root,_C=(e,t)=>t===``||e===t||e.startsWith(`${t}/`),vC=()=>({broken:0,notAnalyzed:0,pending:0,openCalls:0});function yC(e){let t=e.indexOf(`|`);return t<0?{source:e,path:``}:{source:e.slice(0,t),path:e.slice(t+1)}}function bC(e,t,n,r,i,a){let o=vC();for(let e of a)o.broken+=e.findings.broken,o.notAnalyzed+=e.findings.notAnalyzed,o.pending+=e.findings.pending,o.openCalls+=e.findings.openCalls;return{id:e,name:t,kind:n,source:r,root:i,files:a.reduce((e,t)=>e+t.files,0),functions:a.reduce((e,t)=>e+t.functions,0),externalPackages:0,findings:o,members:a.length}}function xC(e,t){let n=new Map,r=new Map;for(let i of e){let e=t.get(i.from),a=t.get(i.to);if(!e||!a||e===a)continue;let o=`${e}->${a}`,s=n.get(o);if(s){let e=(s.references??0)+(i.references??0),{carrying:t,references:r,...a}=s;n.set(o,{...a,imports:s.imports+i.imports,calls:s.calls+i.calls,...e?{references:e}:{},...s.carrying!==void 0&&i.carrying!==void 0?{carrying:s.carrying+i.carrying}:{}})}else n.set(o,{...i,id:o,from:e,to:a});if(l(i)){let e=r.get(o)??{from:new Set,to:new Set};e.from.add(i.from),e.to.add(i.to),r.set(o,e)}}return[...n.values()].map(e=>{let t=r.get(e.id),n=!e.from.startsWith(`group|`)||!e.to.startsWith(`group|`);return t&&n?{...e,groups:{from:t.from.size,to:t.to.size}}:e}).sort((e,t)=>e.id<t.id?-1:1)}function SC(e,t){let n=yC(t);return e.groups.filter(e=>e.source===n.source&&_C(gC(e),n.path))}function CC(e,t,n=new Set){let r=[...new Set(e.groups.map(e=>e.source))].sort(),i=t?yC(t):null,a=i?e.groups.filter(e=>e.source===i.source&&_C(gC(e),i.path)):e.groups,o=new Map,s=[],c=[],l=!1;if(a.length>30){let u=new Map;for(let e of a){let t,n,a;if(!i&&r.length>1)t=`${e.source}|`,n=e.source,a=``;else{let r=i?.path??``,o=r===``?gC(e):gC(e).slice(r.length+1),s=o.split(`/`)[0]??``;if(o===``||s===``){c.push(e);continue}a=r===``?s:`${r}/${s}`,t=`${e.source}|${a}`,n=`${a}/`}let o=u.get(t)??{name:n,source:e.source,root:a,members:[]};o.members.push(e),u.set(t,o)}if(u.size===1&&c.length===0){let[r]=u.keys();if(r!==t)return CC(e,r,n)}for(let[e,t]of u){if(t.members.length===1){c.push(t.members[0]);continue}l=!0;let n=`${mC}${e}`;s.push(bC(n,t.name,`area`,t.source,t.root,t.members));for(let e of t.members)o.set(e.id,n)}}else c.push(...a);let u=new Map;for(let e of c)if(e.kind===`cluster`&&e.files===1){let t=`${e.source}|${gC(e)}`;u.set(t,[...u.get(t)??[],e])}for(let e of c){let t=`${e.source}|${gC(e)}`;e.kind===`cluster`&&e.files===1&&u.get(t).length>1&&!n.has(t)||(s.push(e),o.set(e.id,e.id))}for(let[e,t]of u){if(t.length<2||n.has(e))continue;let r=`${hC}${e}`,{source:i,path:a}=yC(e);s.push(bC(r,`${a?`${a}/`:`(top)`}`,`singles`,i,a,t));for(let e of t)o.set(e.id,r)}return s.sort((e,t)=>e.id<t.id?-1:1),{area:t,summary:l,map:{...e,groups:s,dependsOn:xC(e.dependsOn,o)}}}function wC(e,t){let{source:n,path:r}=yC(e),i=t?[{area:`${n}|`,label:n}]:[],a=r?r.split(`/`):[];for(let e=1;e<=a.length;e++)i.push({area:`${n}|${a.slice(0,e).join(`/`)}`,label:a[e-1]});return i}var TC=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function EC({project:e,run:t,source:n,group:r,file:i,fileLevel:a,expand:o,showPending:s,onOpenGroup:c,onCloseGroup:l,onOpenFile:u,onToggleFolder:d,onCollapse:f,onMenu:p,sources:m=[],onScope:h,area:g=null,onAllGroups:_}){let[v,b]=(0,y.useState)(``),{groups:x,error:S}=_S(e,t,0,n),C=a&&i!==null,{imports:w}=yS(e,t,C?i:null),T=C?w?.file.group??null:r??(x&&x.total===1?x.groups[0]?.id??null:null),{group:E}=vS(e,t,T,C?[]:o,s),D=(0,y.useMemo)(()=>{let e=v.trim().toLowerCase(),t=new Map;for(let n of x?g&&!T?SC(x,g):x.groups:[])(!e||n.name.toLowerCase().includes(e)||n.id===T)&&t.set(n.source,[...t.get(n.source)??[],n]);for(let e of t.values())e.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));return[...t].sort((e,t)=>e[0]<t[0]?-1:1)},[x,v,T,g]),O=D.length,k=e=>{let t=e.id===T,n=t&&!C&&r===e.id,a=e.findings.broken;return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{className:`outline-group${t?` current`:``}`,"data-command":`outline-group`,"data-id":e.id,"aria-expanded":t,title:`${e.name}: ${TC(e.files,`file`)}, ${TC(e.functions,`function`)}${a?`, ${TC(a,`broken import`)}`:``}${n?` (close it)`:``}`,onClick:()=>n?l():c(e.id),onContextMenu:p&&(t=>{t.preventDefault(),p({kind:`group`,id:e.id,data:{label:e.name},x:t.clientX,y:t.clientY})}),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:t?`▾`:`▸`}),(0,Y.jsx)(`span`,{className:`name`,children:e.name}),a>0&&(0,Y.jsx)(`small`,{className:`badge broken`,title:TC(a,`broken import`),children:a}),(0,Y.jsx)(`small`,{className:`count`,children:e.files})]}),t&&E&&(0,Y.jsxs)(`ul`,{className:`outline-files`,children:[!C&&o.map(t=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`outline-folder open`,"data-command":`outline-folder`,"data-path":t,"aria-expanded":`true`,title:`${t}/: open on the canvas (close it)`,onClick:()=>d(t),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:`▾`}),(0,Y.jsxs)(`span`,{className:`name`,children:[iS(t,e.root),`/`]})]})},`open:${t}`)),E.nodes.map(t=>t.kind===`folder`?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`outline-folder`,"data-command":`outline-folder`,"data-path":t.path,"aria-expanded":`false`,title:`${t.path}/: ${TC(t.files,`file`)} (open it on the canvas)`,onClick:()=>C?c(e.id,t.path):d(t.path),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:`▸`}),(0,Y.jsxs)(`span`,{className:`name`,children:[iS(t.path,e.root),`/`]}),(0,Y.jsx)(`small`,{className:`count`,children:t.files})]})},t.id):(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`outline-file${t.id===i&&C?` current`:``}`,"data-command":`outline-file`,"data-file":t.id,title:t.path,onClick:()=>u(t.id,e.id),onContextMenu:p&&(e=>{e.preventDefault(),p({kind:`file`,id:t.id,data:{},x:e.clientX,y:e.clientY})}),children:[(0,Y.jsx)(`span`,{className:`name`,children:iS(t.path,e.root)}),t.findings.broken>0&&(0,Y.jsx)(`small`,{className:`badge broken`,children:t.findings.broken})]})},t.id))]})]},e.id)},[A,j]=(0,y.useState)(new Set),M=e=>{let t=e=>e.kind===`cluster`&&e.files===1,n=new Map;for(let r of e)t(r)&&n.set(r.root,[...n.get(r.root)??[],r]);let r=[],i=new Set;for(let a of e){let e=n.get(a.root);if(!t(a)||!e||e.length<2)r.push({type:`group`,g:a});else if(!i.has(a.root)){i.add(a.root);let t=`${a.source}|${a.root}`,n=A.has(t)||v.trim()!==``||e.some(e=>e.id===T);r.push({type:`singles`,key:t,root:a.root,members:e,open:n})}}return r};return(0,Y.jsxs)(`nav`,{className:`nav outline`,"aria-label":`Groups`,"data-testid":`group-outline`,children:[(0,Y.jsxs)(`div`,{className:`nav-head`,children:[(m.length>1||n)&&(0,Y.jsxs)(`label`,{className:`nav-scope`,children:[(0,Y.jsx)(`span`,{className:`small muted`,children:`Scope`}),(0,Y.jsxs)(`select`,{"data-command":`scope-source`,value:n??``,onChange:e=>h?.(e.target.value||null),children:[(0,Y.jsx)(`option`,{value:``,children:`All repositories`}),m.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`outline-head`,children:[(0,Y.jsx)(`input`,{className:`nav-filter`,placeholder:`Filter ${x?TC(x.total,`group`):`groups`}…`,"aria-label":`Filter groups`,"data-testid":`outline-filter`,value:v,onChange:e=>b(e.target.value)}),(0,Y.jsx)(`button`,{className:`icon`,title:`Hide this pane ( [ )`,"aria-label":`Hide the groups pane`,onClick:f,children:`⟨`})]}),(0,Y.jsx)(`button`,{className:`outline-map${!T&&!C?` current`:``}`,"data-command":`outline-project-map`,onClick:()=>c(),title:`The project map: every group`,children:`⌂ Project map`})]}),(0,Y.jsxs)(`div`,{className:`nav-list outline-list`,children:[S&&(0,Y.jsx)(`p`,{className:`hint error`,children:S}),x&&g&&!T&&(0,Y.jsxs)(`p`,{className:`small muted outline-area`,"data-testid":`outline-area`,children:[g.slice(g.indexOf(`|`)+1)?`In ${g.slice(g.indexOf(`|`)+1)}/:`:`In the ${g.slice(0,g.indexOf(`|`))} repository:`,` `,TC(SC(x,g).length,`group`),` ·`,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>(_??(()=>c()))(),children:`all groups`})]}),x&&!x.stage2&&(0,Y.jsx)(`p`,{className:`hint`,children:`Groups come from import analysis (Stage 2), which hasn't run for this project.`}),D.map(([e,t])=>(0,Y.jsxs)(`section`,{children:[O>1&&(0,Y.jsx)(`h4`,{className:`outline-source`,children:e}),(0,Y.jsx)(`ul`,{children:M(t).map(e=>e.type===`group`?k(e.g):(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{className:`outline-singles`,"data-command":`outline-singles`,"aria-expanded":e.open,title:`${e.members.length} groups of one file each in ${e.root||`the top folder`}`,onClick:()=>j(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n}),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:e.open?`▾`:`▸`}),(0,Y.jsxs)(`span`,{className:`name`,children:[e.root?`${e.root}/`:`(top)`,` · `,e.members.length,` single files`]}),(0,Y.jsx)(`small`,{className:`count`,children:e.members.length})]}),e.open&&(0,Y.jsx)(`ul`,{className:`outline-singles-list`,children:e.members.map(k)})]},e.key))})]},e))]})]})}function DC(e){switch(e.context){case`argument`:return`to ${e.handedTo} (argument ${(e.argument??0)+1})`;case`jsx-attribute`:return`as ${e.handedTo}`;case`property`:return`as ${e.handedTo} in an object`;case`array-element`:return`in an array`;case`return`:return`as its result`;default:return`to ${e.handedTo}`}}function OC({project:e,fn:t,run:n,onOpen:r}){let[i,a]=(0,y.useState)(null);if((0,y.useEffect)(()=>{let n=!1;return Promise.all([J.references(e,t,`out`),J.references(e,t,`in`)]).then(([e,r])=>!n&&a({fn:t,out:e,in:r}),()=>!n&&a(`error`)),()=>{n=!0}},[e,t,n]),i===`error`||i===null||i.fn!==t||i.out.total===0&&i.in.total===0)return null;let o=e=>e.evidence.span.start.line,s=e=>e.truncated?`${e.total}; the first ${e.references.length} shown`:`${e.total}`;return(0,Y.jsxs)(`div`,{className:`imported-calls handed-on`,"data-testid":`handed-on`,children:[i.out.references.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Hands on (`,s(i.out),`)`]}),i.out.references.map(e=>(0,Y.jsxs)(`div`,{className:`imported-call`,"data-testid":`handed-on-out`,children:[(0,Y.jsxs)(`span`,{className:`mono small`,children:[e.to.name,` · line `,o(e)]}),(0,Y.jsxs)(`span`,{className:`small`,children:[`passes `,(0,Y.jsx)(`strong`,{children:e.to.name}),e.to.file!==e.from.file&&(0,Y.jsxs)(Y.Fragment,{children:[` `,`in `,(0,Y.jsx)(`span`,{className:`mono`,children:e.to.path})]}),` `,DC(e),`; whatever receives it may call it`]}),e.to.file!==e.from.file&&(0,Y.jsx)(`span`,{className:`small links`,children:(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`open-handed-on`,onClick:()=>r({id:e.to.id,file:e.to.file}),children:`Open that file`})})]},e.id))]}),i.in.references.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Handed on by (`,s(i.in),`)`]}),i.in.references.map(e=>(0,Y.jsxs)(`div`,{className:`imported-call`,"data-testid":`handed-on-in`,children:[(0,Y.jsxs)(`span`,{className:`small`,children:[(0,Y.jsx)(`strong`,{children:e.from.name}),` in `,(0,Y.jsx)(`span`,{className:`mono`,children:e.from.path}),` passes it`,` `,DC(e),` · line `,o(e)]}),(0,Y.jsx)(`span`,{className:`small links`,children:(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`open-handed-on`,onClick:()=>r({id:e.from.id,file:e.from.file}),children:`Open`})})]},e.id))]})]})}var kC=e=>e.reason===`imported-symbol`||e.reason===`template-reference`;function AC(e){let t=e.group;if(!t)return e.path;let n=t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t.name} › ${n}`}var jC={broken:`its import is broken`,pending:`its import waits for another source`,"not-analyzed":`its import leads to a file not analyzed`};function MC({project:e,graph:t,fn:n,onOpen:r,onShowImports:i}){let[a,o]=(0,y.useState)(null),s=t.file.id,c=t.unresolved.some(kC);(0,y.useEffect)(()=>{if(!c)return;let t=!1;return J.siteLinks(e,s).then(e=>!t&&o({file:s,byId:new Map(e.links.map(e=>[e.site,e]))}),()=>!t&&o({file:s,byId:`error`})),()=>{t=!0}},[e,s,t.committedRun,c]);let l=t.unresolved.filter(e=>e.enclosingFn===n&&kC(e)&&!e.component).sort((e,t)=>e.evidence.span.start.offset-t.evidence.span.start.offset);if(l.length===0)return null;let u=a?.file===s?a.byId:null,d=u===`error`?null:u;return(0,Y.jsxs)(`div`,{className:`imported-calls`,"data-testid":`imported-calls`,children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Calls into other files (`,l.length,`)`]}),u===`error`&&(0,Y.jsx)(`p`,{className:`small muted`,children:`Where these calls lead couldn't be loaded.`}),l.map(e=>{let t=d?.get(e.id),n=e.importSpecifier?`imported from ${e.importSpecifier}`:`defined in another file`;return(0,Y.jsxs)(`div`,{className:`imported-call`,"data-testid":`imported-call`,"data-site":e.id,children:[(0,Y.jsxs)(`span`,{className:`mono small`,children:[e.expression,` · line `,e.evidence.span.start.line]}),u===`error`?(0,Y.jsx)(`span`,{className:`small muted`,children:n}):d===null?(0,Y.jsxs)(`span`,{className:`small muted`,children:[n,`…`]}):t?.status===`linked`&&t.target?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`small`,children:[`calls `,(0,Y.jsx)(`strong`,{children:t.target.name}),` in`,` `,(0,Y.jsx)(`span`,{className:`mono`,children:AC(t.target)}),`, found by`,` `,t.via===`import`||e.reason===`imported-symbol`?`import analysis`:`component linking`]}),(0,Y.jsxs)(`span`,{className:`small links`,children:[(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`open-imported`,onClick:()=>r({id:t.target.id,file:t.target.file}),children:`Open that file`}),(0,Y.jsx)(`button`,{className:`button-link`,"data-command":`show-in-imports`,onClick:i,children:`Show in Imports`})]})]}):t?.status===`external`?(0,Y.jsxs)(`span`,{className:`small`,children:[`calls into the external package `,(0,Y.jsx)(`strong`,{children:t.package?.name})]}):t?(0,Y.jsxs)(`span`,{className:`small`,children:[n,`, not linked`,t.importOutcome?`: ${jC[t.importOutcome]}`:t.candidates?.length?t.exhaustive===!1?`: ${t.candidates.length} known function${t.candidates.length===1?``:`s`} could run (may not be all)`:`: it could be any of ${t.candidates.length} functions`:t.reason?`: ${t.reason}`:``]}):(0,Y.jsxs)(`span`,{className:`small muted`,children:[n,`, not linked yet`]})]},e.id)})]})}var NC=(e,t)=>{let n=xe(e).name;return n.length>t?`${n.slice(0,t-1)}…`:n},PC=6;function FC(e,t,n,r){let i=e=>e.slice(e.indexOf(`:`)+1),a=e=>e.split(`/`).slice(-2).join(`/`),o=r.calls?t.out.calls:[],s=r.calls?t.in.calls:[],c=new Map,l=e=>{let t=xe(e).unnamed;c.set(e.id,{label:t?NC(e,34):`ƒ ${NC(e,32)}`,line:e.line??0})};for(let e of o)l(e.from);for(let e of s)l(e.to);let u=[...c].sort((e,t)=>e[1].line-t[1].line||(e[1].label<t[1].label?-1:+(e[1].label>t[1].label))).map(([e])=>e),d=(e,t)=>({id:`${e}|${t.id}`,file:t.file,label:`${a(t.path)} ›\n${NC(t,28)}`}),f=new Map(s.map(e=>[e.from.id,d(`caller`,e.from)])),p=new Map(o.map(e=>[e.to.id,d(`callee`,e.to)])),m=new Map,h=new Map;if(r.imports&&n){for(let t of n.imports)t.outcome===`file`&&t.file&&t.file.id!==e&&!h.has(t.file.id)&&h.set(t.file.id,{id:`imported|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimported`,edge:t.id});for(let t of n.importedBy.files)t.file.id!==e&&!m.has(t.file.id)&&m.set(t.file.id,{id:`importer|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimports this file`,edge:t.id})}let g=e=>[...e.values()].sort((e,t)=>e.label<t.label?-1:+(e.label>t.label)),_=[...g(f),...g(m)],v=[...g(p),...g(h)],y=Math.max(u.length,1),b=e=>-((e-1)*58)/2,x=[{data:{id:`box`,kind:`box`,label:i(e),w:210,h:y*58+50},position:{x:0,y:0},classes:`box`},...u.map((e,t)=>({data:{id:e,kind:`function`,label:c.get(e).label},position:{x:0,y:b(u.length)+t*58+12},classes:`function`})),..._.map((e,t)=>({data:{id:e.id,kind:`port`,side:`left`,file:e.file,label:e.label},position:{x:-330,y:b(_.length)+t*58},classes:e.id.startsWith(`importer|`)?`port file`:`port`})),...v.map((e,t)=>({data:{id:e.id,kind:`port`,side:`right`,file:e.file,label:e.label},position:{x:330,y:b(v.length)+t*58},classes:e.id.startsWith(`imported|`)?`port file`:`port`}))],S=new Map,C=(e,t,n)=>{let r=`${e}->${t}`,i=S.get(r);i?i.calls.push(n):S.set(r,{id:n,source:e,target:t,calls:[n]})};for(let e of o)C(e.from.id,`callee|${e.to.id}`,e.id);for(let e of s)C(`caller|${e.from.id}`,e.to.id,e.id);for(let e of S.values())x.push({data:{id:e.id,kind:`call`,source:e.source,target:e.target,calls:e.calls,label:e.calls.length>1?`×${e.calls.length}`:``},classes:`call`});let w=h.size+m.size<=PC?`imports`:``;for(let e of h.values())x.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:`box`,target:e.id,label:w},classes:`import`});for(let e of m.values())x.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:e.id,target:`box`,label:w},classes:`import`});return x}function IC({file:e,calls:t,imports:n,show:r,pick:i,onPick:a,onOpenFile:o,onClear:s,marks:c=null,onContext:l}){let u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=Je();(0,y.useEffect)(()=>{d.current?.style(LC())},[f]);let p=(0,y.useRef)(c);p.current=c;let m=(0,y.useRef)(l);m.current=l,(0,y.useEffect)(()=>{d.current&&Qe(d.current,c)},[c]);let h=(0,y.useRef)({onPick:a,onOpenFile:o,onClear:s});h.current={onPick:a,onOpenFile:o,onClear:s};let g=(0,y.useMemo)(()=>FC(e,t,n,r),[e,t,n,r.calls,r.imports]);(0,y.useEffect)(()=>{if(!u.current)return;let e=q_({container:u.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.15,maxZoom:2.5,style:LC()});return e.on(`tap`,`node`,e=>{e.target.data(`kind`)===`port`&&h.current.onOpenFile(e.target.data(`file`))}),e.on(`tap`,`edge`,e=>h.current.onPick(e.target.data(`edge`)??e.target.id())),e.on(`tap`,t=>{t.target===e&&h.current.onClear()}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),d.current=e,Qe(e,p.current),e.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`port`&&t.file?`file`:t.kind===`call`||t.kind===`import`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),()=>{d.current=null,e.destroy()}},[g]),(0,y.useEffect)(()=>{let e=d.current;e&&(e.elements().removeClass(`picked`),i&&e.edges().filter(e=>(e.data(`calls`)??[]).includes(i)||e.data(`edge`)===i).addClass(`picked`))},[i,g]);let _=e=>g.filter(t=>t.data.kind===`port`&&t.data.side===e).map(e=>e.data.id).join(` `),v=[t.in,t.out].filter(e=>e.truncated),b=(r.calls?t.out.calls.length+t.in.calls.length:0)===0,x=[...new Map([...t.in.calls.map(e=>e.from),...t.out.calls.map(e=>e.to)].map(e=>[e.file,e])).values()];return(0,Y.jsxs)(`div`,{className:`graph-wrap`,children:[b&&r.calls&&(0,Y.jsx)(`p`,{className:`hint overlay`,"data-testid":`no-cross-file-calls`,children:`No calls cross into or out of this file.`}),(0,Y.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`file-canvas`,"data-calls":g.filter(e=>e.data.kind===`call`).length,"data-imports":g.filter(e=>e.data.kind===`import`).length,"data-ports-left":_(`left`),"data-ports-right":_(`right`)}),v.length>0&&(0,Y.jsxs)(`p`,{className:`hint small overlay`,"data-testid":`calls-truncated`,children:[v.map(e=>`Showing ${e.calls.length} of ${e.total} calls ${e.direction===`in`?`into`:`out of`} this file`).join(`; `),`.`]}),(0,Y.jsxs)(`details`,{className:`graph-key`,"data-testid":`imports-file-key`,children:[(0,Y.jsx)(`summary`,{children:`Key`}),(0,Y.jsxs)(`ul`,{children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node`}),(0,Y.jsx)(`span`,{children:`a function in this file that calls or is called across files`})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node port`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`code`,{children:`file ›`}),` a function in another file: callers on the left, what this file calls on the right`]})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line call`}),(0,Y.jsx)(`span`,{children:`calls: one function calls the other (×2: two calls)`})]}),r.imports&&(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node port file`}),(0,Y.jsx)(`span`,{children:`another file: one this file imports (right) or one importing it (left)`})]}),r.imports&&(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line import`}),(0,Y.jsx)(`span`,{children:`imports: a file imports another (the one this file imports, or one importing it)`})]})]})]}),(0,Y.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Cross-file calls`,children:[t.in.calls.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`in`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.path,` › `,Se(e.from),` calls `,Se(e.to)]})},e.id)),t.out.calls.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`out`,tabIndex:-1,onClick:()=>a(e.id),children:[Se(e.from),` calls `,e.to.path,` › `,Se(e.to)]})},e.id)),x.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.file,tabIndex:-1,onClick:()=>o(e.file),children:[`Open `,e.path]})},e.file))]}),(0,Y.jsx)(`button`,{className:`fit`,onClick:()=>d.current?.fit(void 0,30),children:`Fit`})]})}function LC(){return[{selector:`node`,style:{shape:`round-rectangle`,width:170,height:36,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:X(`gray-26`),"background-color":X(`gray-100`),"border-width":1,"border-color":X(`gray-86`),"z-index-compare":`manual`,"z-index":2}},{selector:`node.box`,style:{"background-color":X(`gray-98-5`),"border-color":X(`blue-87`),"border-width":2,"text-valign":`top`,"text-margin-y":18,color:X(`blue-47`),"font-weight":`bold`,width:`data(w)`,height:`data(h)`,events:`no`,"z-index":0}},{selector:`node.function`,style:{height:40,"text-max-width":`156px`,"text-overflow-wrap":`anywhere`}},{selector:`node.port`,style:{width:210,height:42,"border-style":`dashed`,"border-color":X(`blue-62`)}},{selector:`node.port.file`,style:{"border-color":X(`gray-81`),color:X(`gray-44`)}},{selector:`edge`,style:{"z-index-compare":`manual`,"z-index":1,width:1.5,"curve-style":`bezier`,"line-color":X(`blue-62`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`blue-62`),"arrow-scale":.8,label:`data(label)`,"font-size":10,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1}},{selector:`edge.import`,style:{"line-color":X(`gray-66`),"line-style":`dashed`,"target-arrow-shape":`vee`,"target-arrow-color":X(`gray-51-2`),"arrow-scale":1.2,"font-size":9}},...Ze(),{selector:`.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`),width:3}}]}var RC=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`;function zC(e){let t=`(${RC(e.imports,`import`)})`;return e.calls===0&&!e.references?`no calls linked ${t}`:[e.calls?RC(e.calls,`call`):``,e.references?RC(e.references,`reference`):``].filter(Boolean).join(`, `).concat(` ${t}`)}var BC=e=>!e.startsWith(`group|`);function VC(e,t){let n=zC(e),r=e.groups;return r?`${BC(e.from)?`${RC(r.from,`group`)} in ${t(e.from)}`:t(e.from)} ${BC(e.from)&&r.from!==1?`call`:`calls`} into ${BC(e.to)?BC(e.from)?`${r.to.toLocaleString()} in ${t(e.to)}`:`${RC(r.to,`group`)} in ${t(e.to)}`:t(e.to)}: ${n}`:`${t(e.from)} calls into ${t(e.to)}: ${n}`}var HC={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`,area:`folder`,singles:`single files`},UC=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`,WC=.55;function GC(e){return e.resize(),e.elements().empty()?1:(e.fit(void 0,40),e.zoom()>1.2&&(e.zoom(1.2),e.center()),e.zoom())}function KC(e){let{members:t,kind:n}=e;if(t!==void 0)return n===`singles`?`${UC(t,`single file`)} · open them`:`${UC(t,`group`)} · open it`}var qC=(e,t=30)=>e.length>t?`${e.slice(0,t-1)}…`:e;function JC(e,t){if(!e||!t)return 0;let n=Math.abs(t.x-e.x)/290;return n>1.2||t.x<e.x?-(84*.9+12*Math.min(4,n)):0}var YC=(e,t)=>1+6*Math.sqrt(e/Math.max(1,t));function XC(e,t){return e.startsWith(`group|`)&&t.startsWith(`group|`)?`DEPENDS_ON|${e}|${t}`:`arrow|${encodeURIComponent(e)}|${encodeURIComponent(t)}`}function ZC({map:e,layoutKey:t,pick:n,showPackages:r,onPick:i,onOpen:a,onClear:o,marks:s=null,only:c=null,onContext:u}){let d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=Je();(0,y.useEffect)(()=>{f.current?.style(QC())},[p]);let[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(null),x=(0,y.useRef)(!1),S=(0,y.useRef)(c);S.current=c;let C=(0,y.useRef)(u);C.current=u,(0,y.useEffect)(()=>{f.current&&Ke(f.current,c)},[c]);let w=(0,y.useRef)(s);w.current=s,(0,y.useEffect)(()=>{f.current&&Qe(f.current,s)},[s]);let T=(0,y.useRef)({x:0,y:0}),E=(0,y.useRef)({onPick:i,onOpen:a,onClear:o});return E.current={onPick:i,onOpen:a,onClear:o},(0,y.useEffect)(()=>{if(!d.current)return;let n=Xx(t,e.groups,e.dependsOn.map(e=>({from:e.from,to:e.to,weight:e.imports+e.calls}))),r=e.dependsOn.flatMap(e=>{let t=l(e);return t?[{d:e,weight:t.weight}]:[]}),i=Math.max(1,...r.map(e=>e.weight)),a=new Map(e.groups.map(e=>[e.id,e.name])),o=e=>a.get(e)??e;T.current=n.packages;let s=new Set(e.groups.map(e=>e.source)).size>1,c=[...e.groups.map(e=>{let t=e.findings.broken;return{data:{id:e.id,kind:`group`,label:[qC(e.name),KC(e)??qC(s?`${e.source} · ${HC[e.kind]??e.kind}`:HC[e.kind]??e.kind),t>0?`${UC(e.files,`file`)} · ${UC(t,`broken import`)}`:`${UC(e.files,`file`)} · ${UC(e.functions,`function`)}`].join(`
337
337
  `)},position:n.groups[e.id]??{x:0,y:0},classes:t>0?`group broken`:`group`}}),...r.map(({d:e,weight:t})=>({data:{bend:JC(n.groups[e.from],n.groups[e.to]),id:e.id,kind:`depends`,source:e.from,target:e.to,width:YC(t,i),count:t*3>=i&&t>1?String(t):``,label:t*3>=i&&t>1?String(t):``,sentence:VC(e,o)},classes:t===0?`depends unlinked`:`depends`}))],u=q_({container:d.current,elements:c,layout:{name:`preset`},autounselectify:!0,minZoom:.1,maxZoom:2.5,style:QC()});u.on(`tap`,`node`,e=>{e.target.data(`kind`)===`group`&&E.current.onPick(e.target.id())}),u.on(`dbltap`,`node`,e=>{e.target.data(`kind`)===`group`&&E.current.onOpen(e.target.id())}),u.on(`tap`,`edge`,e=>{e.target.data(`kind`)===`depends`&&E.current.onPick(XC(e.target.data(`source`),e.target.data(`target`)))}),u.on(`tap`,e=>{e.target===u&&E.current.onClear()}),u.on(`mouseover`,`edge`,e=>{let t=e.target.data(`sentence`),n=e.renderedPosition??{x:0,y:0};t&&b({text:t,x:n.x,y:n.y})}),u.on(`mouseout`,`edge`,()=>b(null)),u.on(`pan zoom`,()=>b(null)),x.current=!1,h(GC(u)<WC),u.on(`scrollzoom pinchzoom dragpan`,()=>{x.current=!0});let p=new ResizeObserver(()=>{x.current?u.resize():h(GC(u)<WC)});return d.current&&p.observe(d.current),f.current=u,d.current&&(d.current.veoCy=u),Ke(u,S.current),u.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`group`?`group`:t.kind===`depends`?`edge`:null;if(!n||!d.current)return;let r=d.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};C.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),Qe(u,w.current),()=>{p.disconnect(),b(null),f.current=null,u.destroy()}},[e,t]),(0,y.useEffect)(()=>{let t=f.current;if(!t||(t.remove(`#packages, .uses`),!r||e.externalPackages.total===0))return;let n=[],i=e.externalPackages.top.slice(0,4).map(e=>e.name),a=e.externalPackages.total-i.length;n.push({data:{id:`packages`,kind:`packages`,label:[`External packages`,i.join(`, `),a>0?`+ ${a} more`:``].filter(Boolean).join(`
338
- `)},position:T.current,classes:`packages`});for(let t of e.groups)t.externalPackages>0&&n.push({data:{id:`packages|${t.id}`,kind:`uses`,source:t.id,target:`packages`,width:1,label:``,bend:0},classes:`uses`});t.add(n),x.current||h(GC(t)<WC)},[e,t,r]),(0,y.useEffect)(()=>{let e=f.current;e&&e.batch(()=>{e.elements().removeClass(`picked faded role-into role-from`),e.edges(`[kind = "depends"]`).forEach(e=>{e.data(`label`,e.data(`count`))});let t=(n?.startsWith(`DEPENDS_ON|`)||n?.startsWith(`arrow|`)?e.edges().filter(e=>XC(e.data(`source`),e.data(`target`))===n):null)??(n?e.getElementById(n):null);if(t&&t.nonempty()&&t.isEdge()){let n=t.union(t.connectedNodes());n.addClass(`picked`),e.elements().not(n).addClass(`faded`)}else if(t&&t.nonempty()){let n=t.connectedEdges(`[kind = "depends"]`);t.addClass(`picked`),n.forEach(e=>{let n=e.data(`source`)===t.id();e.addClass(n?`role-into`:`role-from`);let r=e.data(`count`);e.data(`label`,n?`▶${r?` ${r}`:``}`:`◀${r?` ${r}`:``}`)});let r=t.union(n);e.elements().not(r).not(r.connectedNodes()).addClass(`faded`)}})},[n,e,t,r]),(0,Y.jsxs)(`div`,{className:`graph-wrap`,children:[(0,Y.jsx)(`div`,{ref:d,className:`graph map`,"data-testid":`project-map`,tabIndex:0,role:`application`,"aria-label":`Project map: arrow keys move between groups, Enter opens one`,onKeyDown:t=>{let r=e.groups.map(e=>e.id);if(r.length===0)return;let s=n?r.indexOf(n):-1;if(t.key===`ArrowRight`||t.key===`ArrowDown`)i(r[(s+1)%r.length]);else if(t.key===`ArrowLeft`||t.key===`ArrowUp`)i(r[(s-1+r.length)%r.length]);else if(t.key===`Enter`&&n)a(n);else if(t.key===`Escape`)o();else return;t.preventDefault()}}),(0,Y.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Groups`,children:e.groups.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{"data-command":`pick-node`,"data-id":e.id,tabIndex:-1,onClick:()=>i(e.id),children:e.name}),(0,Y.jsxs)(`button`,{"data-command":`open-group`,"data-id":e.id,tabIndex:-1,onClick:()=>a(e.id),children:[`Open `,e.name]})]},e.id))}),(0,Y.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Arrows`,children:e.dependsOn.filter(e=>l(e)).map(t=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{"data-command":`pick-node`,"data-arrow":!0,"data-id":XC(t.from,t.to),tabIndex:-1,onClick:()=>i(XC(t.from,t.to)),children:VC(t,t=>e.groups.find(e=>e.id===t)?.name??t)})},t.id))}),v&&!g&&(0,Y.jsx)(`div`,{className:`map-hover`,"data-testid":`arrow-hover`,role:`status`,style:{left:v.x+12,top:v.y+12},children:v.text}),!g&&(0,Y.jsx)(`p`,{className:`overlay map-key small muted`,"data-testid":`map-key`,children:`A ──▶ B: A calls into B · callers left, what they call right`}),g&&(0,Y.jsx)(`ul`,{className:`map-list`,"data-testid":`map-list`,"aria-label":`Groups`,children:e.groups.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link-row${e.id===n?` picked`:``}`,"data-command":`list-group`,"data-id":e.id,onClick:()=>i(e.id),onDoubleClick:()=>a(e.id),title:`${e.name}: ${e.source} · ${HC[e.kind]??e.kind} (double-click or Enter opens it)`,onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),a(e.id))},children:[(0,Y.jsx)(`span`,{className:`name`,children:e.name}),(0,Y.jsxs)(`small`,{children:[e.source,` · `,HC[e.kind]??e.kind,` · `,UC(e.files,`file`),e.findings.broken>0?` · ${UC(e.findings.broken,`broken import`)}`:``]})]})},e.id))}),!g&&m&&(0,Y.jsxs)(`p`,{className:`overlay bottom small muted map-note`,"data-testid":`map-too-small`,children:[`All `,e.groups.length,` groups are shown, zoomed out: scroll to zoom in, or`,` `,(0,Y.jsx)(`button`,{className:`button-link`,onClick:()=>_(!0),children:`see them as a list`}),`.`]}),(0,Y.jsxs)(`div`,{className:`map-controls`,children:[(0,Y.jsx)(`button`,{"data-command":`map-as-list`,"aria-pressed":g,onClick:()=>_(!g),title:`The groups as a list`,children:g?`Map`:`List`}),!g&&(0,Y.jsx)(`button`,{className:`fit`,"data-command":`fit-map`,onClick:()=>{f.current&&(x.current=!1,h(GC(f.current)<WC))},children:`Fit`})]})]})}function QC(){return[{selector:`node`,style:{shape:`round-rectangle`,width:210,height:84,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`190px`,"text-valign":`center`,"text-halign":`center`,"font-size":13,"line-height":1.45,color:X(`gray-26`),"background-color":X(`gray-98-3`),"border-width":1,"border-color":X(`gray-86`)}},{selector:`node.broken`,style:{"border-color":X(`amber-74`)}},{selector:`node.packages`,style:{"background-color":X(`gray-100`),"border-style":`dashed`,"border-color":X(`gray-81`),color:X(`gray-44`)}},{selector:`edge`,style:{width:`data(width)`,"curve-style":`unbundled-bezier`,"control-point-distances":`data(bend)`,"control-point-weights":.5,"line-color":X(`gray-72`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`gray-72`),"arrow-scale":.8,label:`data(label)`,"font-size":11,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.unlinked`,style:{"line-style":`dashed`}},{selector:`edge.uses`,style:{"line-style":`dashed`,"line-color":X(`gray-86`),"target-arrow-shape":`none`}},...Ze(),Ge,{selector:`node.picked`,style:{"border-width":2,"border-color":X(`blue-56`),"background-color":X(`gray-97`)}},{selector:`edge.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`)}},{selector:`edge.role-into`,style:{"line-color":X(`blue-52-2`),"target-arrow-color":X(`blue-52-2`),color:X(`blue-52-2`)}},{selector:`edge.role-from`,style:{"line-color":X(`orange-59`),"target-arrow-color":X(`orange-59`),color:X(`orange-59`)}},{selector:`.faded`,style:{opacity:.25}}]}var $C=e=>e.toLocaleString(`en-US`),ew=(e,t)=>`${$C(e)} ${t}${e===1?``:`s`}`;function tw(e,t=!0){return[t&&e.withinFile?`${ew(e.withinFile,`call`)} within it`:``,e.intoOtherFiles?`${$C(e.intoOtherFiles)} into other files`:``,e.leaveProject?`${$C(e.leaveProject)} leave the project`:``,e.candidates?`${$C(e.candidates)} narrowed to candidates`:``].filter(Boolean)}var nw=e=>e.map((e,t)=>(0,Y.jsxs)(y.Fragment,{children:[t>0&&` · `,e]},t));function rw({project:e,file:t,version:n,onImports:r,onFindings:i}){let[a,o]=(0,y.useState)(null),s=a?.file===t&&a.project===e?a:null;if((0,y.useEffect)(()=>{let n=!0;return J.fileSummary(e,t).then(e=>n&&o(e)).catch(()=>n&&o(null)),()=>{n=!1}},[e,t,n]),!s)return null;let{alone:c,acrossFiles:l}=s;if(c.sites===0&&(!l||l.imports.files+l.imports.packages+l.imports.unresolved===0))return null;let u=[...tw(c),c.open?`${$C(c.open)} open`:`none open`],d=[];if(l){let e=l.open?`${$C(l.open)} stop short`:`none stop short`,t=l.imports.files+l.imports.packages,n=t+l.imports.unresolved>0?`${ew(t,`import`)}${l.imports.unresolved?`, ${$C(l.imports.unresolved)} unresolved`:``}`:null;d=[...tw(l,!1),l.open&&i?(0,Y.jsx)(`button`,{className:`link`,"data-testid":`file-summary-open`,title:`Findings for this file: its open calls (with those narrowed to candidates) and its imports that didn't resolve`,onClick:i,children:e}):e,...n?[r?(0,Y.jsx)(`button`,{className:`link`,"data-testid":`file-summary-imports`,onClick:r,children:n}):n]:[]]}return(0,Y.jsxs)(`p`,{className:`file-summary small muted`,"data-testid":`file-summary`,title:`Of its ${ew(c.sites,`call`)}: what reading this file on its own found, and what linking it to the rest of the project added`,children:[(0,Y.jsxs)(`span`,{"data-testid":`file-summary-alone`,children:[(0,Y.jsx)(`strong`,{children:`Reading this file alone:`}),` `,u.join(` · `)]}),(0,Y.jsx)(`span`,{"data-testid":`file-summary-across`,children:l?(0,Y.jsxs)(Y.Fragment,{children:[` → `,(0,Y.jsx)(`strong`,{children:`across files:`}),` `,nw(d)]}):` · cross-file analysis didn't run`})]})}function iw({project:e,projectName:t,run:n,group:r,source:i=null,pick:a,file:o,fileLevel:s,expand:c,showPending:l,tabs:u,onPick:d,onOpenGroup:f,onOpenFile:p,onToggleFolder:m,onTogglePending:h,onClear:g,onFileFindings:_,marks:v=null,only:b=null,onContext:x,area:S=null,onOpenArea:C=()=>{}}){let[w,T]=(0,y.useState)(0),{groups:E,error:D}=_S(e,n,w,i),[O,k]=(0,y.useState)(!1),[A,j]=dS(),M=s&&o!==null,{imports:N}=yS(e,n,M?o:null),{calls:P,error:F}=xS(e,n,M?o:null),[I,L]=(0,y.useState)({calls:!0,imports:!0}),R=M?N?N.file.group:null:r??(E&&E.total===1?E.groups[0].id:null),z=R?E?.groups.find(e=>e.id===R):void 0,[B,V]=(0,y.useState)(0),{group:H,error:U}=vS(e,n,M?null:R,c,l,B),[W,ee]=(0,y.useState)(new Set),G=(0,y.useMemo)(()=>E&&!R&&!M?CC(E,S,W):null,[E,R,M,S,W]),te=(0,y.useMemo)(()=>new Set(E?.groups.map(e=>e.source)).size>1,[E]),K=G?.area??S,q=K?wC(K,te):[],ne=q.map(e=>[(0,Y.jsx)(`span`,{className:`muted`,children:`›`},`s:${e.area}`),(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-area`,onClick:()=>C(e.area),children:e.label},e.area)]),J=e=>{e.startsWith(`area|`)?C(e.slice(mC.length)):e.startsWith(`singles|`)?ee(t=>new Set([...t,e.slice(hC.length)])):f(e)},re=e=>e.startsWith(`area|`)||e.startsWith(`singles|`),ie=(0,Y.jsxs)(`div`,{className:`toolbar`,children:[u,(0,Y.jsx)(`nav`,{className:`breadcrumb`,"aria-label":`Zoom`,"data-testid":`breadcrumb`,children:R?(0,Y.jsxs)(Y.Fragment,{children:[E?.total===1?(0,Y.jsx)(`span`,{children:t}):(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(),children:t}),!M&&ne,(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),M?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(R),children:z?.name??R}),(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),(0,Y.jsx)(`strong`,{className:`mono`,title:ow(o),children:Te(iS(ow(o),sw(z)),48)})]}):(0,Y.jsx)(`strong`,{children:z?.name??R})]}):M?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(),children:t}),(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),(0,Y.jsx)(`strong`,{className:`mono`,title:ow(o),children:Te(ow(o),48)})]}):q.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(),children:t}),ne.slice(0,-1),(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),(0,Y.jsx)(`strong`,{children:q[q.length-1].label})]}):(0,Y.jsx)(`strong`,{children:t})}),(R||M||q.length>0)&&E&&E.total>1&&(0,Y.jsx)(`button`,{className:`small`,"data-command":`go-project-map`,title:`Back to the project map: every group, nothing picked`,onClick:()=>f(),children:`⌂ Project map`}),E&&!R&&E.stage2&&(0,Y.jsx)(`span`,{className:`small muted toolbar-note`,children:G?.area?(()=>{let e=G.map.groups.reduce((e,t)=>e+(t.members??1),0);return`folder · ${e.toLocaleString()} group${e===1?``:`s`} of ${E.total.toLocaleString()}`})():`project map · ${E.total} group${E.total===1?``:`s`}`}),H&&!M&&(0,Y.jsxs)(`span`,{className:`small muted toolbar-note`,children:[`group · `,H.group.files,` file`,H.group.files===1?``:`s`,` · `,H.group.source]}),R&&!M&&c.length>0&&(0,Y.jsx)(`span`,{className:`open-folders small`,children:c.map(e=>(0,Y.jsxs)(`span`,{className:`chip`,children:[iS(e,sw(z)),`/`,(0,Y.jsx)(`button`,{className:`icon`,"data-command":`toggle-folder`,"data-testid":`close-folder`,"data-path":e,"aria-label":`Close the folder ${e}`,onClick:()=>m(e),children:`×`})]},e))}),M&&(0,Y.jsx)(`span`,{className:`small muted toolbar-note`,children:`its imports and cross-file calls`}),(0,Y.jsx)(`span`,{className:`spacer`}),M&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`label`,{className:`toggle`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-calls`,checked:I.calls,onChange:e=>L({...I,calls:e.target.checked})}),`Cross-file calls`]}),(0,Y.jsxs)(`label`,{className:`toggle`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-imports`,checked:I.imports,onChange:e=>L({...I,imports:e.target.checked})}),`Imports`]})]}),R&&!M&&(0,Y.jsxs)(`label`,{className:`toggle`,title:`Imports waiting for another source to be added`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:l,onChange:h}),`Pending imports`]}),E&&!R&&E.externalPackages.total>0&&(0,Y.jsxs)(`label`,{className:`toggle`,title:`External packages are hidden by default: nearly every group imports the same few`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-packages`,checked:O,onChange:e=>k(e.target.checked)}),`External packages`]})]});if(D)return(0,Y.jsxs)(Y.Fragment,{children:[ie,(0,Y.jsxs)(`p`,{className:`hint error`,children:[D,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>T(e=>e+1),children:`Try again`})]})]});if(!E)return(0,Y.jsxs)(Y.Fragment,{children:[ie,(0,Y.jsx)(`p`,{className:`hint`,children:`Loading the imports…`})]});if(!E.stage2)return(0,Y.jsxs)(Y.Fragment,{children:[ie,(0,Y.jsx)(`p`,{className:`hint`,"data-testid":`imports-no-stage2`,children:`Imports haven't been analyzed in this project yet: Stage 2, which follows imports across files, hasn't run. Analyze the project again to see them.`})]});let ae=E.stats.own,oe=ae.files!==E.stats.files,se=S&&G?.area?SC(E,G.area):null,ce=se?new Set(se.map(e=>e.id)):null,le=se?{files:se.reduce((e,t)=>e+t.files,0),functions:se.reduce((e,t)=>e+t.functions,0),crossFileCalls:E.dependsOn.filter(e=>ce.has(e.from)&&ce.has(e.to)).reduce((e,t)=>e+t.calls,0),brokenImports:se.reduce((e,t)=>e+t.findings.broken,0),openCalls:se.reduce((e,t)=>e+t.findings.openCalls,0)}:A||!oe?E.stats:{files:ae.files,functions:ae.functions,crossFileCalls:ae.crossFileCalls,brokenImports:ae.brokenImports??E.stats.brokenImports,openCalls:ae.openCalls??E.stats.openCalls};return(0,Y.jsxs)(Y.Fragment,{children:[ie,M&&o&&(0,Y.jsx)(rw,{project:e,file:o,version:`${n}:${P?.out.committedRun??``}`,onFindings:_}),M?F?(0,Y.jsx)(`p`,{className:`hint error`,children:F}):P?(0,Y.jsx)(`div`,{className:`group-level`,"data-testid":`file-level`,children:(0,Y.jsx)(IC,{marks:v,onContext:x,file:o,calls:P,imports:N,show:I,pick:a,onPick:d,onOpenFile:e=>p(e),onClear:g})}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading the file…`}):R?U?(0,Y.jsxs)(`p`,{className:`hint error`,children:[U,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>V(e=>e+1),children:`Try again`})]}):H?(0,Y.jsxs)(`div`,{className:`group-level`,"data-testid":`group-level`,children:[H.truncated&&(0,Y.jsxs)(`p`,{className:`hint small`,children:[`Showing `,H.nodes.length,` of `,H.total,` files and folders.`]}),(0,Y.jsx)(aS,{marks:v,onContext:x,only:b,reply:H,pick:a,onPick:d,onOpenFile:e=>p(e,R),onToggleFolder:m,onClear:g})]}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading the group…`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`dl`,{className:`map-stats`,"data-testid":`map-stats`,children:[(0,Y.jsx)(aw,{n:le.files,label:`files`}),(0,Y.jsx)(aw,{n:le.functions,label:`functions`}),(0,Y.jsx)(aw,{n:le.crossFileCalls,label:se?`calls between its groups`:`cross-file calls`}),(0,Y.jsx)(aw,{n:le.brokenImports,label:`broken imports`,tone:le.brokenImports>0?`warn`:void 0}),(0,Y.jsx)(aw,{n:le.openCalls,label:`open calls`}),!se&&(0,Y.jsx)(aw,{n:E.externalPackages.total,label:O?`external packages`:`external packages (hidden)`}),oe&&!se&&(0,Y.jsxs)(`label`,{className:`toggle stats-scope`,title:`Own code: ${ae.files.toLocaleString()} of ${E.stats.files.toLocaleString()} files. The rest are tests, installed libraries, generated output or tools' files.`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`stats-all-code`,checked:A,onChange:e=>j(e.target.checked)}),`Libraries and tests too`]})]}),E.total===0?(0,Y.jsx)(`p`,{className:`hint`,children:`No groups: nothing was analyzed.`}):(0,Y.jsx)(ZC,{marks:v,onContext:x&&(e=>re(e.id)?void 0:x(e)),only:b,map:G?.map??E,layoutKey:`${e}|${E.committedRun}|${i??``}|${G?.area??``}|${[...W].join(`,`)}`,pick:a,showPackages:O,onPick:e=>re(e)?J(e):d(e),onOpen:J,onClear:g}),E.truncated&&(0,Y.jsxs)(`p`,{className:`hint small`,children:[`Showing `,E.groups.length,` of `,E.total,` groups.`]})]})]})}function aw({n:e,label:t,tone:n}){return(0,Y.jsxs)(`div`,{className:n,children:[(0,Y.jsx)(`dd`,{children:e.toLocaleString()}),(0,Y.jsx)(`dt`,{children:t})]})}var ow=e=>e.slice(e.indexOf(`:`)+1);function sw(e){return!e||e.kind===`cluster`?``:e.root}var cw=(e,t=34)=>e.length>t?`${e.slice(0,t-1)}…`:e,lw=e=>e.slice(e.lastIndexOf(`/`)+1);function uw(e){let t=[e.name,e.member].filter(Boolean).join(`.`)||`?`;return`${e.packageName??`runtime`}: ${t}`}function dw(e){let t=e.direction===`forward`?1:-1,n=[],r=new Map,i=[],a=e=>{let t=r.get(e)??0;r.set(e,t+1);let n={position:{x:0,y:0},depth:e,row:t};return i.push(n),n.position},o=new Map(e.functions.map(e=>[e.id,e.depth])),s=new Set(e.starts.map(e=>e.function));for(let t of e.functions)n.push({group:`nodes`,data:{id:t.id,kind:`function`,label:`${cw(t.name,26)}${s.has(t.id)?` ▸ start`:``}\n${cw(lw(t.path),28)}`,path:t.path,line:t.line,depth:t.depth},position:a(t.depth),classes:[`function`,...t.depth===0?[`root`]:[],...s.has(t.id)?[`start`]:[]].join(` `)});e.edges.forEach((e,t)=>{o.has(e.from)&&o.has(e.to)&&n.push({group:`edges`,data:{id:`hop|${t}`,source:e.from,target:e.to,kind:e.kind,label:e.kind===`call`||e.kind===`cross-file`?``:e.kind,path:e.evidence.file.slice(e.evidence.file.indexOf(`:`)+1),line:e.evidence.span.start.line,file:e.evidence.file},classes:e.trust===`candidate`?`hop candidate`:`hop`})});let c=new Map;for(let t of e.gaps){let e=`gap|${t.in}|${t.expression}|${t.reason}`,n=c.get(e);n?n.count++:c.set(e,{id:e,in:t.in,label:`? ${cw(t.expression,26)}\n${t.reason}`,kind:`gap`,count:1,file:t.evidence.file,line:t.evidence.span.start.line})}for(let t of e.exits){let e=uw(t.exit),n=`exit|${t.in}|${e}`,r=c.get(n);r?r.count++:c.set(n,{id:n,in:t.in,label:cw(e,30),kind:`exit`,count:1,file:t.evidence.file,line:t.evidence.span.start.line})}for(let e of[...c.values()].sort((e,t)=>e.id<t.id?-1:1)){let t=o.get(e.in);t!==void 0&&(n.push({group:`nodes`,data:{id:e.id,kind:e.kind,label:e.count>1?`${e.label} ×${e.count}`:e.label,file:e.file,line:e.line},position:a(t+1),classes:`port ${e.kind}`}),n.push({group:`edges`,data:{id:`to|${e.id}`,source:e.in,target:e.id,kind:e.kind,label:``,file:e.file,line:e.line},classes:`stop ${e.kind}`}))}let l=Math.max(0,...r.keys()),u=[],d=0;for(let e=0;e<=l;e++)u[e]=d,d+=Math.ceil((r.get(e)??1)/24)*270;for(let e of i)e.position.x=t*(u[e.depth]+Math.floor(e.row/24)*270),e.position.y=e.row%24*62;return n}var fw=e=>e.slice(e.indexOf(`:`)+1),pw=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function mw({project:e,run:t,root:n,direction:r,onDirection:i,onReach:a,onOpenFile:o,onContext:s}){let{reach:c,error:l}=bS(e,t,n,r),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=Je();(0,y.useEffect)(()=>{p.current?.style(hw())},[m]);let h=(0,y.useRef)({onReach:a,onContext:s});h.current={onReach:a,onContext:s};let g=(0,y.useMemo)(()=>c?dw(c):[],[c]);(0,y.useEffect)(()=>d(null),[n,r]),(0,y.useEffect)(()=>{if(!f.current||g.length===0)return;let e=q_({container:f.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.1,maxZoom:2.5,style:hw()});return e.on(`tap`,`edge`,t=>{e.elements().removeClass(`picked`),t.target.addClass(`picked`),d(t.target.data())}),e.on(`tap`,`node`,e=>{let t=e.target.data();t.kind===`function`?h.current.onReach(t.id):d(t)}),e.on(`cxttap`,`node`,e=>{let t=e.target.data();if(t.kind!==`function`||!f.current)return;let n=f.current.getBoundingClientRect(),r=e.renderedPosition??{x:0,y:0};h.current.onContext?.({kind:`function`,id:t.id,data:t,x:n.left+r.x,y:n.top+r.y})}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),p.current=e,()=>{p.current=null,e.destroy()}},[g]);let _=new Map((c?.functions??[]).map(e=>[e.id,e.name])),v=e=>_.get(e)??e,b=c?.counts,x=b?`in ${pw(b.files,`file`)} across ${pw(b.groups,`group`)}`:``,S=c?.functions.find(e=>e.id===n)?.name??fw(n);return(0,Y.jsxs)(`div`,{className:`reach`,"data-testid":`reach`,children:[(0,Y.jsxs)(`div`,{className:`toolbar`,children:[(0,Y.jsx)(`span`,{className:`file-title`,title:n,children:S}),(0,Y.jsx)(`div`,{className:`segmented`,role:`group`,"aria-label":`Direction`,children:[`forward`,`backward`].map(e=>(0,Y.jsx)(`button`,{"aria-pressed":r===e,"data-command":`open-reach`,"data-direction":e,title:e===`forward`?`What paths from it reach`:`What reaches it`,onClick:()=>i(e),children:e===`forward`?`Reaches →`:`← Reached by`},e))}),b&&(0,Y.jsx)(`span`,{className:`reach-counts`,"data-testid":`reach-counts`,children:r===`forward`?`${b.functions?`reaches ${pw(b.functions,`function`)} ${x}`:`reaches no other function`} · ${pw(b.gaps,`gap`)} · ${pw(b.exits,`exit`)}`:`${b.functions?`reached by ${pw(b.functions,`function`)} ${x}`:`nothing reaches it`}${c.starts.length?` · ${pw(c.starts.length,`start candidate`)}`:``}`}),c?.truncated&&(0,Y.jsxs)(`span`,{className:`badge degraded`,"data-testid":`reach-truncated`,children:[`stopped at the `,c.truncated.reason,` budget, `,pw(c.truncated.depth,`step`),` out`]})]}),l&&(0,Y.jsx)(`div`,{className:`error`,children:l}),(0,Y.jsx)(`div`,{className:`graph-wrap`,children:(0,Y.jsx)(`div`,{className:`graph map`,ref:f,"data-testid":`reach-canvas`})}),u&&(0,Y.jsxs)(`div`,{className:`reach-hop`,"data-testid":`reach-hop`,children:[(0,Y.jsxs)(`span`,{children:[String(u.kind),` · `,String(u.file??``).slice(String(u.file??``).indexOf(`:`)+1),`:`,String(u.line??``)]}),typeof u.file==`string`&&(0,Y.jsx)(`button`,{"data-command":`open-file`,onClick:()=>o(u.file,u.line),children:`Open`})]}),c&&(0,Y.jsxs)(`details`,{className:`reach-list`,"data-testid":`reach-list`,children:[(0,Y.jsx)(`summary`,{children:`As a list`}),(0,Y.jsx)(`ol`,{children:c.functions.map(e=>(0,Y.jsxs)(`li`,{"data-depth":e.depth,children:[` `.repeat(e.depth),(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-reach`,title:`Reach from this function instead`,onClick:()=>a(e.id),children:e.name}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[e.path,`:`,e.line]})]},e.id))}),(0,Y.jsx)(`ul`,{"data-testid":`reach-hops`,children:c.edges.map((e,t)=>(0,Y.jsxs)(`li`,{"data-kind":e.kind,"data-trust":e.trust,children:[(0,Y.jsxs)(`button`,{"data-command":`reach-hop`,onClick:()=>d({kind:e.kind,file:e.evidence.file,line:e.evidence.span.start.line}),children:[v(e.from),` → `,v(e.to)]}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[e.kind,e.trust===`candidate`?` (candidate)`:``]})]},t))}),c.gaps.length>0&&(0,Y.jsx)(`ul`,{"data-testid":`reach-gaps`,children:c.gaps.map(e=>(0,Y.jsxs)(`li`,{children:[`? `,e.expression,` `,(0,Y.jsx)(`span`,{className:`muted`,children:e.reason}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[fw(e.evidence.file),`:`,e.evidence.span.start.line]})]},e.site))}),c.exits.length>0&&(0,Y.jsx)(`ul`,{"data-testid":`reach-exits`,children:c.exits.map(e=>(0,Y.jsxs)(`li`,{children:[e.expression,` `,(0,Y.jsx)(`span`,{className:`muted`,children:e.exit.packageName??`runtime`}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[fw(e.evidence.file),`:`,e.evidence.span.start.line]})]},e.id))})]})]})}function hw(){return[{selector:`node`,style:{shape:`round-rectangle`,width:210,height:48,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":14,color:X(`gray-26`),"background-color":X(`gray-100`),"border-width":1,"border-color":X(`gray-86`)}},{selector:`node.root`,style:{"border-color":X(`blue-56`),"border-width":2,"font-weight":`bold`}},{selector:`node.start`,style:{"border-color":X(`green-57`),"border-width":2}},{selector:`node.port.gap`,style:{"border-style":`dotted`,"border-color":X(`red-54`),color:X(`red-44`),"background-color":X(`gray-98-9`)}},{selector:`node.port.exit`,style:{"border-style":`double`,"border-width":3,"border-color":X(`blue-62`),color:X(`blue-47`)}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":X(`gray-44`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`gray-44`),"arrow-scale":.8,label:`data(label)`,"font-size":11,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1}},{selector:`edge.candidate`,style:{"line-style":`dashed`,"line-color":X(`gray-67`)}},{selector:`edge.stop.gap`,style:{"line-style":`dotted`,"line-color":X(`red-54`),"target-arrow-shape":`none`}},{selector:`edge.stop.exit`,style:{"line-color":X(`blue-62`),"target-arrow-color":X(`blue-62`)}},{selector:`.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`),width:3}}]}function gw(e,t,n){let r=new Map,i=e=>{let t=r.get(e.id);return t||r.set(e.id,t={kind:`function`,end:e,out:[],into:[]}),t};for(let n of t)n.from.file===e&&i(n.from).out.push(n);for(let t of n)t.to.file===e&&i(t.to).into.push(t);let a=e=>e.end.title!==void 0&&e.end.suite!==void 0&&e.into.length===0&&e.out.length>0?`${e.end.suite}\u0000${[...new Set(e.out.map(e=>e.to.id))].sort().join(`\0`)}`:null,o=new Map;for(let e of r.values()){let t=a(e);t!==null&&o.set(t,[...o.get(t)??[],e])}let s=[],c=new Set;for(let e of r.values()){let t=a(e),n=t===null?void 0:o.get(t);if(!n||n.length<2){s.push(e);continue}if(c.has(t))continue;c.add(t);let r=new Map(n.flatMap(e=>e.out.map(e=>[e.to.id,e.to])));s.push({kind:`suite`,suite:e.end.suite,callees:[...r.values()],tests:n})}return s}var _w={focus:3,site:2,call:1},vw=e=>e.end.column<=1&&e.end.line>e.start.line?e.end.line-1:e.end.line;function yw(e,t){if(e.kind!==`call`||vw(e)===e.start.line)return e;let n=Array.from(t(e.start.line)??``),r=n.indexOf(`(`,e.start.column-1),i=r>=0?r+2:n.length+1;return{...e,end:{line:e.start.line,column:i}}}function bw(e,t){let n=t=>e.lines[t-e.startLine],r=t.map(e=>yw(e,n)),i=r.map(e=>(e.end.line-e.start.line)*1e4+(e.end.column-e.start.column)),a=new Map;r.forEach((t,n)=>{let r=Math.max(t.start.line,e.startLine),i=Math.min(vw(t),e.startLine+e.lines.length-1);for(let e=r;e<=i;e++){let t=a.get(e);t?t.push(n):a.set(e,[n])}});let o=new Set;return e.lines.map((t,n)=>{let s=e.startLine+n,c=Array.from(t),l=c.map(()=>null);for(let e of a.get(s)??[]){let t=r[e],n=s===t.start.line?t.start.column-1:0,a=s===t.end.line?t.end.column-1:c.length;for(let o=Math.max(0,n);o<Math.min(c.length,a);o++){let n=l[o];(n==null||_w[t.kind]>_w[r[n].kind]||_w[t.kind]===_w[r[n].kind]&&i[e]<i[n])&&(l[o]=e)}}let u=[];return c.forEach((e,t)=>{let n=u[u.length-1],r=l[t]??null;if(n&&n.mark===r)n.text+=e;else{let t=r!==null&&!o.has(r);r!==null&&o.add(r),u.push({text:e,mark:r,first:t})}}),{n:s,runs:u,focus:r.some(e=>e.kind===`focus`&&s>=e.start.line&&s<=vw(e))}})}function xw({snippet:e,marks:t,focusLine:n,testId:r,className:i}){let a=(0,y.useRef)(null),o=(0,y.useMemo)(()=>bw(e,t),[e,t]);(0,y.useEffect)(()=>{let e=a.current,t=e?.querySelector(`[data-line="${n}"]`);e&&t&&(e.scrollTop=Math.max(0,t.offsetTop-e.clientHeight/3))},[e,n]);let s=e=>{let n=e?.closest(`[data-mark]`);if(!n)return!1;let r=t[Number(n.dataset.mark)];return r?.onClick?(r.onClick(),!0):!1};return(0,Y.jsx)(`pre`,{className:`code ${i??``}`,"data-testid":r,ref:a,onClick:e=>s(e.target),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&s(e.target)&&e.preventDefault()},children:o.map(({n:e,runs:n,focus:r})=>(0,Y.jsxs)(`div`,{"data-line":e,className:r?`focus-line`:``,children:[(0,Y.jsx)(`span`,{className:`ln`,"aria-hidden":`true`,children:e}),` `,n.map((e,n)=>{if(e.mark===null)return e.text;let r=t[e.mark],i=r.kind===`focus`?`hit`:r.kind===`site`?`site-mark`:`call-mark`,a=!!r.onClick;return(0,Y.jsx)(`span`,{className:`mark ${i}${a?` clickable`:``}`,"data-mark":e.mark,title:r.title,...a&&e.first?{role:`button`,tabIndex:0}:{},children:e.text},n)})]},e))})}function Sw({title:e,location:t,snippet:n,marks:r,focusLine:i,onClose:a}){let o=(0,y.useRef)(null),s=(0,y.useRef)(null);return(0,y.useEffect)(()=>{o.current?.focus();let e=e=>{if(e.key===`Escape`)e.stopPropagation(),a();else if(e.key===`Tab`&&s.current){let t=s.current.querySelectorAll(`button, [tabindex="0"]`),n=t[0],r=t[t.length-1];s.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[a]),(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&a(),children:(0,Y.jsxs)(`div`,{className:`modal code-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e,"data-testid":`code-modal`,ref:s,tabIndex:-1,children:[(0,Y.jsxs)(`div`,{className:`evidence-head`,children:[(0,Y.jsx)(`h3`,{children:e}),(0,Y.jsx)(`code`,{className:`muted small`,children:t}),(0,Y.jsx)(`button`,{ref:o,className:`icon close`,"aria-label":`Close (Esc)`,title:`Close (Esc)`,onClick:a,children:`×`})]}),n?(0,Y.jsx)(xw,{snippet:n,marks:r,focusLine:i,testId:`modal-code`,className:`large`}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`}),(0,Y.jsx)(`p`,{className:`muted small`,children:`Use your browser's find (⌘F / Ctrl+F) to search the code.`})]})})}var Cw=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`;function ww({project:e,run:t,from:n,to:r,onOpenFile:i}){let[a,o]=(0,y.useState)([]),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),d=JSON.stringify([e,t,n,r]),f=(0,y.useRef)(d);if(f.current=d,(0,y.useEffect)(()=>{let t=!1;return o([]),c(null),J.callsBetween(e,n,r).then(e=>!t&&o([e]),e=>!t&&c(e.message)),()=>{t=!0}},[d]),s)return(0,Y.jsx)(`p`,{className:`hint error`,children:s});let p=a[0];if(!p)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let m=a.flatMap(e=>e.calls),h=p.pair.summary,g=new Map;for(let e of m)g.set(e.from.path,[...g.get(e.from.path)??[],e]);let _=()=>{if(l)return;let t=d;u(!0),J.callsBetween(e,n,r,m.length).then(e=>{f.current===t&&o(t=>[...t,e])},e=>c(e.message)).finally(()=>u(!1))};return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`pair-details`,children:[(0,Y.jsxs)(`h3`,{children:[p.pair.from.name,` → `,p.pair.to.name]}),(0,Y.jsxs)(`p`,{"data-testid":`pair-summary`,children:[p.pair.from.name,` calls into `,p.pair.to.name,`: `,Cw(h.calls,`call`),` from`,` `,Cw(h.callers,`function`),` to `,Cw(h.callees,`function`),h.references?`, ${Cw(h.references,`reference`)}`:``,` (`,Cw(h.imports,`import`),`)`]}),h.calls===0&&(0,Y.jsx)(`p`,{className:`small muted`,children:h.references?`No calls: functions are handed on between them (references).`:`No calls: only imports link them.`}),[...g].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`pair-file`,children:[(0,Y.jsx)(`h4`,{className:`small`,children:(0,Y.jsx)(`button`,{className:`link`,onClick:()=>i(t[0].from.file),children:e})}),(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`pair-calls`,children:t.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{className:`link`,onClick:()=>i(e.from.file),children:Se(e.from)}),` `,(0,Y.jsxs)(`span`,{className:`small muted`,children:[`:`,e.evidence.span.start.line]}),` →`,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>i(e.to.file),children:Se(e.to)}),` `,(0,Y.jsxs)(`span`,{className:`small muted`,children:[`(`,e.to.path,`)`]})]},e.id))})]},e)),m.length<p.total&&(0,Y.jsx)(`button`,{className:`link small`,"data-testid":`pair-more`,disabled:l,onClick:_,children:l?`Loading…`:`${p.total-m.length} more calls…`}),p.pair.references.length>0&&(0,Y.jsxs)(`details`,{children:[(0,Y.jsxs)(`summary`,{className:`small`,children:[`References (`,h.references,`)`]}),(0,Y.jsx)(`ul`,{className:`plain small`,children:p.pair.references.map(e=>(0,Y.jsxs)(`li`,{children:[Se(e.from),` hands on `,Se(e.to),` (`,e.to.path,`) · `,e.context,` · line`,` `,e.evidence.span.start.line]},e.id))})]}),p.pair.imports.length>0&&(0,Y.jsxs)(`details`,{children:[(0,Y.jsxs)(`summary`,{className:`small`,children:[`Imports (`,h.imports,`)`]}),(0,Y.jsx)(`ul`,{className:`plain small`,"data-testid":`pair-imports`,children:p.pair.imports.map(e=>(0,Y.jsxs)(`li`,{children:[e.path,`:`,e.evidence.span.start.line,` · `,(0,Y.jsx)(`code`,{children:e.specifier})]},e.id))})]})]})}var Tw={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`};function Ew(e){let{project:t,run:n,pick:r,file:i,fileLevel:a}=e;return a&&i&&r?.startsWith(`CALLS_CROSS_FILE|`)?(0,Y.jsx)(Lw,{project:t,run:n,file:i,call:r}):a&&i&&(r?.startsWith(`IMPORTS|`)||r?.startsWith(`unresolved-import|`))?(0,Y.jsx)(Bw,{project:t,run:n,file:i,edge:r}):a&&i?(0,Y.jsx)(jw,{project:t,run:n,file:i,onOpenFile:e.onOpenFile}):r&&(r.startsWith(`DEPENDS_ON|`)||r.startsWith(`arrow|`))?(0,Y.jsx)(Dw,{...e,arrow:r}):r&&r.startsWith(`calls|`)?(0,Y.jsx)(Ow,{...e,link:r}):r&&r.startsWith(`folder|`)?(0,Y.jsx)(Pw,{...e,folder:r}):r&&!r.startsWith(`group|`)?(0,Y.jsx)(jw,{project:t,run:n,file:r,onOpenFile:e.onOpenFile,canOpen:!0}):(0,Y.jsx)(kw,{project:t,run:n,group:e.group,pick:r,onOpenGroup:e.onOpenGroup,onPick:e.onPick})}function Dw({project:e,run:t,arrow:n,onOpenFile:r}){let{groups:i}=_S(e,t);if(!i)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let a=null;if(n.startsWith(`DEPENDS_ON|`)){let e=i.dependsOn.find(e=>e.id===n);e&&(a=[[e.from],[e.to]])}else{let[e,t]=n.slice(6).split(`|`).map(decodeURIComponent);e&&t&&(a=[[e],[t]])}return!a||a[0].length===0||a[1].length===0?(0,Y.jsx)(`p`,{className:`hint`,children:`That arrow isn't on the map any more.`}):(0,Y.jsx)(ww,{project:e,run:t,from:a[0],to:a[1],onOpenFile:r})}function Ow({project:e,run:t,group:n,link:r,expand:i,showPending:a,onOpenFile:o}){let{group:s}=vS(e,t,n,i,a);if(!s)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let c=[...s.calls,...s.callStubEdges].find(e=>e.id===r);return c?(0,Y.jsx)(ww,{project:e,run:t,from:[c.from],to:[(e=>e.startsWith(`stub|`)?e.slice(5):e)(c.to)],onOpenFile:o}):(0,Y.jsx)(`p`,{className:`hint`,children:`That link isn't drawn any more.`})}function kw({project:e,run:t,group:n,pick:r,onOpenGroup:i,onPick:a}){let{groups:o}=_S(e,t),s=n??(o?.total===1?o.groups[0].id:r),c=s&&o?o.groups.find(e=>e.id===s):void 0;if(!o)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!o.stage2)return(0,Y.jsx)(`p`,{className:`hint`,children:`Stage 2 hasn't run on this project, so there are no groups yet.`});if(!c)return(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a group on the map to see what it holds and what it depends on; double-click or press Enter to open it.`});let u=e=>o.groups.find(t=>t.id===e)?.name??e,d=o.dependsOn.filter(e=>e.from===c.id&&l(e)),f=o.dependsOn.filter(e=>e.to===c.id&&l(e)),p=o.dependsOn.filter(e=>(e.from===c.id||e.to===c.id)&&!l(e)),m=c.findings,h=(e,t,r)=>e.length===0?(0,Y.jsx)(`p`,{className:`small muted`,"data-testid":r,children:`None`}):(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":r,children:e.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{className:`link`,onClick:()=>n?i(e[t]):a(e[t]),children:u(e[t])}),` `,(0,Y.jsx)(`span`,{className:`small muted`,children:l(e)?zC(e):`${e.imports} import${e.imports===1?``:`s`}, no call`})]},e.id))});return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`group-details`,children:[(0,Y.jsx)(`h3`,{children:c.name}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[c.source,` · `,Tw[c.kind]??c.kind,c.root?` · ${c.root}`:``]}),(0,Y.jsxs)(`p`,{children:[c.files.toLocaleString(),` files · `,c.functions.toLocaleString(),` functions · `,c.externalPackages,` `,`external package`,c.externalPackages===1?``:`s`]}),m.broken+m.notAnalyzed+m.openCalls+m.pending>0&&(0,Y.jsx)(`p`,{className:`small`,"data-testid":`group-findings`,children:[m.broken?`${m.broken} broken import${m.broken===1?``:`s`}`:``,m.notAnalyzed?`${m.notAnalyzed} import${m.notAnalyzed===1?``:`s`} of files not analyzed`:``,m.openCalls?`${m.openCalls} open question${m.openCalls===1?``:`s`}`:``,m.pending?`${m.pending} pending`:``].filter(Boolean).join(` · `)}),(0,Y.jsx)(`h4`,{className:`small role-into`,children:`▶ Calls into`}),h(d,`to`,`calls-into`),(0,Y.jsx)(`h4`,{className:`small role-from`,children:`◀ Called from`}),h(f,`from`,`called-from`),p.some(e=>e.from===c.id)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h4`,{className:`muted small`,title:`Type-only, value-only or unused imports: no path, so no arrow`,children:`Imports from, no calls`}),h(p.filter(e=>e.from===c.id),`to`,`imports-only`)]}),p.some(e=>e.to===c.id)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h4`,{className:`muted small`,title:`Type-only, value-only or unused imports: no path, so no arrow`,children:`Imported by, no calls`}),h(p.filter(e=>e.to===c.id),`from`,`imported-only`)]}),!n&&o.total>1&&(0,Y.jsxs)(`button`,{"data-command":`open-group`,"data-testid":`open-picked`,onClick:()=>i(c.id),children:[`Open `,c.name]})]})}var Aw=e=>e.slice(e.indexOf(`:`)+1);function jw({project:e,run:t,file:n,onOpenFile:r,canOpen:i=!1}){let{imports:a,error:o}=yS(e,t,n),{groups:s}=_S(e,t),{calls:c,error:l}=xS(e,t,i?null:n);if(o)return(0,Y.jsx)(`p`,{className:`hint error`,children:o});if(!a)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let u=a.file.group?s?.groups.find(e=>e.id===a.file.group):void 0,d=u&&u.kind!==`cluster`?u.root:``;return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`file-details`,children:[(0,Y.jsx)(`h3`,{className:`mono`,children:iS(a.file.path,d)}),(0,Y.jsx)(`p`,{className:`muted small`,children:u?`${u.name} · ${u.source}`:Aw(n)}),l&&(0,Y.jsxs)(`p`,{className:`small error`,children:[`Calls across files: `,l]}),c&&(0,Y.jsx)(Nw,{file:n,calls:c,onOpenFile:r}),(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Imports (`,a.total,`)`]}),a.imports.length===0?(0,Y.jsx)(`p`,{className:`small muted`,children:`None`}):(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`file-imports`,children:a.imports.map(e=>(0,Y.jsxs)(`li`,{className:e.outcome===`broken`?`broken`:void 0,"data-outcome":e.outcome,children:[(0,Y.jsx)(`span`,{className:`mono small`,children:e.specifier}),` `,e.outcome===`file`&&e.file?(0,Y.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path}):e.outcome===`package`&&e.package?(0,Y.jsxs)(`span`,{className:`small muted`,children:[`package `,e.package.name,e.package.version?` ${e.package.version}`:``]}):(0,Y.jsxs)(`span`,{className:`small outcome`,children:[`(`,e.outcome===`not-analyzed`?`not analyzed`:e.outcome,`:`,` `,$x[e.reason??``]??e.reason,`)`]})]},e.id))}),a.truncated&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`Showing `,a.imports.length,` of `,a.total,`.`]}),(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Imported by (`,a.importedBy.total,`)`]}),a.importedBy.files.length===0?(0,Y.jsx)(`p`,{className:`small muted`,children:`None`}):(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`file-importers`,children:a.importedBy.files.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path})},e.id))}),i&&(0,Y.jsx)(`button`,{"data-command":`open-imports-file`,"data-testid":`open-picked-file`,onClick:()=>r(n),children:`Open file`})]})}function Mw({end:e}){let{name:t,parent:n,test:r}=xe(e);return(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.jsx)(`small`,{className:`tag`,children:`test`}),` `,(0,Y.jsx)(`strong`,{title:e.name,children:t}),n&&(0,Y.jsxs)(`span`,{className:`small muted`,children:[` in `,n]})]})}function Nw({file:e,calls:t,onOpenFile:n}){let r=gw(e,t.out.calls,t.in.calls);if(r.length===0)return(0,Y.jsx)(`p`,{className:`small muted`,children:`No calls to or from other files.`});let i=r.reduce((e,t)=>e+(t.kind===`suite`?t.tests.length:1),0),a=t.out.truncated||t.in.truncated,o=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,title:e.to.name,onClick:()=>n(e.to.file),children:Se(e.to)}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`(`,e.to.path,`)`]})]});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Functions calling across files (`,i,`)`]}),(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`file-function-calls`,children:r.map(e=>e.kind===`suite`?(0,Y.jsx)(`li`,{"data-testid":`suite-calls`,children:(0,Y.jsxs)(`details`,{children:[(0,Y.jsxs)(`summary`,{children:[(0,Y.jsx)(`small`,{className:`tag`,children:`test`}),` `,(0,Y.jsxs)(`strong`,{children:[`“`,e.suite,`”`]}),(0,Y.jsxs)(`span`,{className:`small`,children:[` `,`· `,e.tests.length,` tests call`,` `,e.callees.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,(0,Y.jsx)(`button`,{className:`link`,title:e.name,onClick:()=>n(e.file),children:Se(e)}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`(`,e.path,`)`]})]},e.id))]})]}),(0,Y.jsx)(`ul`,{className:`plain small suite-tests`,children:e.tests.map(e=>(0,Y.jsxs)(`li`,{"data-function":e.end.id,children:[(0,Y.jsx)(`span`,{title:e.end.name,children:xe(e.end).name}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`· line `,e.out.map(e=>e.evidence.span.start.line).join(`, `)]})]},e.end.id))})]})},`suite|${e.tests[0].end.id}`):(0,Y.jsxs)(`li`,{"data-function":e.end.id,children:[(0,Y.jsx)(Mw,{end:e.end}),e.out.length>0&&(0,Y.jsxs)(`div`,{className:`small`,children:[`calls`,` `,e.out.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,o(e),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`at line `,e.evidence.span.start.line]})]},e.id))]}),e.into.length>0&&(0,Y.jsxs)(`div`,{className:`small`,children:[`called by`,` `,e.into.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,(0,Y.jsx)(`button`,{className:`link`,title:e.from.name,onClick:()=>n(e.from.file),children:Se(e.from)}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`(`,e.from.path,`)`]})]},e.id))]})]},e.end.id))}),a&&(0,Y.jsx)(`p`,{className:`small muted`,children:`The first 500 calls each way are listed.`})]})}function Pw({project:e,run:t,group:n,folder:r,expand:i,showPending:a,onToggleFolder:o}){let{groups:s}=_S(e,t),{group:c}=vS(e,t,n??(s?.total===1?s.groups[0].id:null),i,a),l=c?.nodes.find(e=>e.id===r);return!l||l.kind!==`folder`?(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a file or a folder in the group.`}):(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`folder-details`,children:[(0,Y.jsxs)(`h3`,{className:`mono`,children:[l.path,`/`]}),(0,Y.jsxs)(`p`,{children:[l.files.toLocaleString(),` files`]}),l.findings.broken>0&&(0,Y.jsxs)(`p`,{className:`small`,children:[l.findings.broken,` broken import`,l.findings.broken===1?``:`s`]}),(0,Y.jsx)(`button`,{"data-command":`toggle-folder`,onClick:()=>o(l.path),children:`Open the folder`})]})}function Fw({project:e,run:t,file:n,span:r}){let[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(!1),c=(0,y.useCallback)(()=>s(!1),[]),l=`${t}|${n}|${r.start.offset}|${r.end.offset}`;if((0,y.useEffect)(()=>{let t=!1;return a(null),J.snippet(e,n,r).then(e=>!t&&a(e),()=>!t&&a(`error`)),()=>{t=!0}},[e,l]),!i)return null;if(i===`error`)return(0,Y.jsx)(`p`,{className:`small muted`,children:`The code couldn't be loaded.`});let u=[{start:r.start,end:r.end,kind:`focus`}];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xw,{snippet:i,marks:u,focusLine:r.start.line,testId:`snippet`}),(0,Y.jsx)(`button`,{className:`button-link small`,"data-testid":`expand-code`,onClick:()=>s(!0),children:`Expand`}),o&&(0,Y.jsx)(Sw,{title:Aw(n),location:`${Aw(n)}:${r.start.line}`,snippet:i,marks:u,focusLine:r.start.line,onClose:c})]})}function Iw({file:e,span:t}){return(0,Y.jsx)(`p`,{className:`location small`,"data-testid":`evidence-location`,children:(0,Y.jsxs)(`code`,{children:[Aw(e),`:`,t.start.line,`:`,t.start.column]})})}function Lw({project:e,run:t,file:n,call:r}){let{calls:i}=xS(e,t,n),a=i?[...i.out.calls,...i.in.calls].find(e=>e.id===r):void 0;if(!i)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!a)return(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let o=a.via===`import`?`found by import analysis${a.hops?.length?`, through ${a.hops.length} re-export${a.hops.length===1?``:`s`}`:``}`:a.via===`component`?`found by component linking`:`found by the template link`,s=a.steps?.find(e=>e.kind===`import`);return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`call-details`,children:[(0,Y.jsxs)(`h3`,{"data-testid":`evidence-title`,children:[Se(a.from),` calls `,Se(a.to)]}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[`across files · `,o]}),s&&(0,Y.jsx)(`p`,{className:`small`,"data-testid":`call-import`,children:s.detail}),a.hops&&a.hops.length>0&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`through `,a.hops.join(` › `)]}),a.provenance&&(0,Y.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,Ce(a.provenance.stage),` · run `,a.provenance.run]}),(0,Y.jsx)(Iw,{file:a.evidence.file,span:a.evidence.span}),(0,Y.jsx)(Fw,{project:e,run:t,file:a.evidence.file,span:a.evidence.span}),(0,Y.jsx)(Re,{project:e,id:a.id},a.id)]})}function Rw(e){if(e.uses===null)return`its use isn't known`;if(e.unused)return`never used`;let t=[],n=e.uses;return n.calls&&t.push(`called ${n.calls}×`),n.jsx&&t.push(`rendered ${n.jsx}×`),n.values&&t.push(`used ${n.values}×`),n.types&&t.push(`as a type ${n.types}×`),n.extends&&t.push(`extended`),n.reexports&&t.push(`exported again`),t.join(`, `)}function zw({names:e}){return(0,Y.jsxs)(`div`,{className:`imported-names`,"data-testid":`import-names`,children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Names (`,e.length,`)`]}),(0,Y.jsx)(`ul`,{children:e.map(e=>(0,Y.jsxs)(`li`,{"data-testid":`import-name`,"data-unused":e.unused||void 0,children:[(0,Y.jsx)(`span`,{className:`mono small`,children:e.local}),` `,(0,Y.jsxs)(`span`,{className:`small`,children:[e.target?e.target.kind===`package`?`from ${e.target.label}`:`${e.target.kind===`symbol`?`${e.target.symbolKind} `:e.target.kind===`module`?`module `:``}${e.target.kind===`module`?``:e.target.label}${e.target.path?` in ${e.target.path}`:``}`:e.outcome===`not-exported`?`not exported there`:`doesn't resolve (${e.outcome})`,` · `,(0,Y.jsx)(`span`,{className:e.unused?`unused`:`muted`,children:Rw(e)})]})]},e.id))})]})}function Bw({project:e,run:t,file:n,edge:r}){let{imports:i}=yS(e,t,n);if(!i)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let a=i.imports.find(e=>e.id===r),o=i.importedBy.files.find(e=>e.id===r);if(!a&&!o)return(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let s=a?.evidence??o.evidence;return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`import-details`,children:[(0,Y.jsx)(`h3`,{"data-testid":`evidence-title`,children:a?`imports ${a.specifier}`:`${o.file.path} imports this file`}),a?.file&&(0,Y.jsxs)(`p`,{className:`small`,children:[`resolves to `,a.file.path]}),a&&!a.file&&!a.package&&(0,Y.jsxs)(`p`,{className:`small`,"data-testid":`import-outcome`,children:[a.outcome===`not-analyzed`?`not analyzed`:a.outcome,`:`,` `,$x[a.reason??``]??a.reason]}),a?.steps.map((e,t)=>(0,Y.jsx)(`p`,{className:`small muted`,children:e.detail},t)),a?.names&&a.names.length>0&&(0,Y.jsx)(zw,{names:a.names}),(a?.provenance??o?.provenance)&&(0,Y.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,Ce((a?.provenance??o.provenance).stage),` · run`,` `,(a?.provenance??o.provenance).run]}),(0,Y.jsx)(Iw,{file:s.file,span:s.span}),(0,Y.jsx)(Fw,{project:e,run:t,file:s.file,span:s.span}),(0,Y.jsx)(Re,{project:e,id:r},r)]})}var Vw=o(),Hw=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,Uw=8,Ww=50,Gw={installed:`installed by a package manager`,packages:`copied packages with their own manifests`,banners:`a library banner or versioned name`};function Kw(e){return`${[e.name==="default"||e.name===null?``:e.name,e.member??``].filter(Boolean).join(e.member?.startsWith(`(`)?``:`.`)||`default`}${e.instance?` (on an instance)`:``}`}function qw({project:e,source:t,pkg:n,onOpen:r}){let[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(!i||o)return;let r=!0;return J.library(e,n.name,n.ecosystem,t).then(e=>r&&s(e)).catch(e=>r&&l(e.message)),()=>{r=!1}},[i,o,e,n.name,n.ecosystem,t]);let f=n.files>0&&n.ownFiles===0,p=o?u?o.members:o.members.slice(0,Uw):[];return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{className:`library-row`,"data-testid":`library-package`,"data-name":n.name,"aria-expanded":i,title:`${n.name}${n.versions.length?` ${n.versions.join(`, `)}`:``}: imported by ${Hw(n.files,`file`)} (${n.ownFiles.toLocaleString(`en-US`)} own code) in ${Hw(n.groups,`group`)} · ${Hw(n.calls,`call`)}${n.references?`, ${Hw(n.references,`reference`)}`:``}`,onClick:()=>a(e=>!e),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:i?`▾`:`▸`}),(0,Y.jsx)(`span`,{className:`name`,children:n.name}),n.versions.length>0&&(0,Y.jsx)(`small`,{className:`muted`,children:n.versions.join(`, `)}),n.typeOnly&&(0,Y.jsx)(`small`,{className:`tag`,title:"Every import of it is `import type`: nothing of it runs",children:`types`}),f&&(0,Y.jsx)(`small`,{className:`tag`,title:`Imported only by tests, libraries or generated files`,children:`not own code`}),(0,Y.jsx)(`small`,{className:`count`,children:n.files})]}),i&&(0,Y.jsxs)(`div`,{className:`library-detail`,"data-testid":`library-detail`,children:[c&&(0,Y.jsx)(`p`,{className:`hint error`,children:c}),!o&&!c&&(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`}),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`small muted`,children:o.members.length===0?n.typeOnly?`Only its types are imported.`:`Nothing of it is called where the analysis can tell.`:`Used: ${Hw(n.calls,`call`)}${n.references?`, ${Hw(n.references,`reference`)}`:``}`}),p.length>0&&(0,Y.jsx)(`ul`,{className:`library-members`,children:p.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:Kw(e)}),(0,Y.jsx)(`small`,{className:`count`,children:e.calls+e.references})]},`${e.name}|${e.member}|${e.instance}`))}),o.members.length>Uw&&(0,Y.jsx)(`button`,{className:`link small`,onClick:()=>d(e=>!e),children:u?`fewer`:`${o.members.length-Uw} more`}),(0,Y.jsx)(`p`,{className:`small muted`,children:`Imported by`}),(0,Y.jsx)(`ul`,{className:`library-files`,children:o.importers.slice(0,Ww).map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{className:`link`,"data-command":`library-file`,"data-file":e.path,title:`${e.path}${e.group?` (${e.group.name})`:``}${e.own?``:`: not own code`}${e.forms.includes(`type-only`)?` · types`:``}`,onClick:()=>r(e.file),children:e.path})},e.file))}),o.importers.length>Ww&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`and `,Hw(o.importers.length-Ww,`more file`)]})]})]})]})}function Jw({project:e,run:t,source:n,filter:r,onOpen:i}){let[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``);if((0,y.useEffect)(()=>{let t=!0;return c(``),J.libraries(e,n).then(e=>t&&o(e)).catch(e=>t&&c(e.message)),()=>{t=!1}},[e,n,t]),s)return(0,Y.jsx)(`p`,{className:`hint error`,children:s});if(!a)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading libraries…`});let l=r.trim().toLowerCase(),u=a.packages.filter(e=>!l||e.name.toLowerCase().includes(l)),d=a.copied.filter(e=>!l||e.path.toLowerCase().includes(l)),f=a.leftOut.filter(e=>!l||e.path.toLowerCase().includes(l)),p=new Set([...a.copied,...a.leftOut].map(e=>e.source)).size>1,m=e=>p?`${e.source}/${e.path}`:e.path;return(0,Y.jsxs)(`div`,{className:`libraries`,"data-testid":`libraries`,children:[(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`outline-source`,children:[`Installed packages `,(0,Y.jsx)(`small`,{className:`muted`,children:a.total})]}),a.stage2?u.length===0?(0,Y.jsx)(`p`,{className:`hint`,children:l?`No packages match.`:`No file imports an installed package.`}):(0,Y.jsx)(`ul`,{children:u.map(r=>(0,Y.jsx)(qw,{project:e,source:n,pkg:r,onOpen:i},`${n??``}|${t??``}|${r.ecosystem}:${r.name}`))}):(0,Y.jsx)(`p`,{className:`hint`,children:`Packages come from import analysis (Stage 2), which hasn't run for this project.`}),a.truncated&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`The first `,Hw(a.packages.length,`package`),`.`]})]}),d.length>0&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`outline-source`,title:`Third-party code copied into the project (plan D66)`,children:[`Copied into the project `,(0,Y.jsx)(`small`,{className:`muted`,children:d.length})]}),(0,Y.jsx)(`ul`,{children:d.map(e=>(0,Y.jsxs)(`li`,{className:`library-row`,"data-testid":`library-copied`,title:`${m(e)}: ${Gw[e.why]}${e.names.length?` (${e.names.join(`, `)})`:``}. ${e.state===`kept`?`Kept: analyzed as the project's own code.`:`Not decided: counted apart from own code until you keep it or leave it out.`}`,children:[(0,Y.jsxs)(`span`,{className:`name`,children:[m(e),e.kind===`dir`?`/`:``]}),(0,Y.jsx)(`small`,{className:`tag${e.state===`pending`?` warn`:``}`,children:e.state===`kept`?`kept`:`not decided`}),(0,Y.jsx)(`small`,{className:`count`,children:e.files})]},`${e.source}|${e.path}`))})]}),f.length>0&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`outline-source`,title:`Library folders left out by default (plan D36, D57); Choose files… analyzes them`,children:[`Left out by default `,(0,Y.jsx)(`small`,{className:`muted`,children:f.length})]}),(0,Y.jsx)(`ul`,{children:f.map(e=>(0,Y.jsxs)(`li`,{className:`library-row`,"data-testid":`library-left-out`,title:`${m(e)}/: ${e.files===null?`not read`:Hw(e.files,`file`)}, not analyzed`,children:[(0,Y.jsxs)(`span`,{className:`name`,children:[m(e),`/`]}),(0,Y.jsx)(`small`,{className:`count`,children:e.files??`–`})]},`${e.source}|${e.path}`))})]})]})}var Yw=24,Xw=12,Zw=300,Qw=new Set([`apps`,`packages`,`services`,`libs`,`modules`,`crates`,`projects`]),$w=/(^|\/)([\w-]+\.config\.[cm]?[jt]sx?|\.?[\w-]*rc\.[cm]?[jt]s|(vite|vitest|jest|webpack|rollup|babel|eslint|prettier|tailwind|postcss|playwright|next|nuxt|svelte|astro|tsup|knip|commitlint|stylelint)\.[\w.-]*[cm]?[jt]s)$/i;function eT(e){return h(e)?`tests`:$w.test(e)?`config`:`source`}var tT=e=>e.status!==`analyzed`,nT={"parse-failure":`could not be parsed`,"declaration-file":`type declarations`,"language-not-analyzed":`language not analyzed yet`,"too-large":`too large`,binary:`not text`,minified:`minified`,"invalid-utf8":`not UTF-8 text`,unreadable:`could not be read`,entitlement:`beyond the license`,frozen:`kept from an earlier analysis (beyond the license)`},rT={degraded:`partly analyzed`,not_analyzed:`not analyzed`,parse_error:`could not be parsed`},iT=(e,t)=>e<t?-1:+(e>t);function aT(e,t,n){let r={key:``,name:``,dirs:new Map,files:[],total:0,functions:0};for(let i of e){let e=(n?`${i.source}/${i.path}`:i.path).split(`/`);e.pop();let a=r,o=t[i.id]?.functions??0;a.total++,a.functions+=o;let s=``;for(let t of e){s=s?`${s}/${t}`:t;let e=a.dirs.get(t);e||(e={key:s,name:t,dirs:new Map,files:[],total:0,functions:0},a.dirs.set(t,e)),a=e,a.total++,a.functions+=o}a.files.push(i)}return r}function oT(e,t=!1,n=0){for(let[r,i]of e.dirs)e.dirs.set(r,oT(i,t,n+1));if(e.key!==``&&!(t&&n===1)&&e.files.length===0&&e.dirs.size===1){let t=[...e.dirs.values()][0];return{...t,name:`${e.name}/${t.name}`}}return e}function sT(e,t,n){let r=[],i=(e,a)=>{let o=[...e.dirs.values()].sort((e,t)=>{if(a===0){let n=+!Qw.has(e.name.split(`/`)[0]),r=+!Qw.has(t.name.split(`/`)[0]);if(n!==r)return n-r}return iT(e.name,t.name)});for(let e of o){let n=t.has(e.key);r.push({type:`dir`,key:e.key,name:e.name,depth:a,open:n,total:e.total,functions:e.functions}),n&&i(e,a+1)}for(let t of[...e.files].sort((e,t)=>iT(e.path,t.path))){let e=n[t.id];r.push({type:`file`,file:t,depth:a,label:t.path.slice(t.path.lastIndexOf(`/`)+1),...e?{hint:`${e.functions}ƒ`}:{}})}};return i(e,0),r}var cT=60;function lT(e,t){let n=new Set,r=e=>{for(let t of e.dirs.values())n.add(t.key),r(t)};if(t<=cT)return r(e),n;for(let t of e.dirs.values())if(n.add(t.key),Qw.has(t.name.split(`/`).pop())||Qw.has(t.name.split(`/`)[0]))for(let e of t.dirs.values())n.add(e.key);return n}var uT=e=>`veoflow.tree.${e}`;function dT(e){try{let t=localStorage.getItem(uT(e)),n=t?JSON.parse(t):[];return n.length>0?new Set(n):null}catch{return null}}function fT(e,t){try{localStorage.setItem(uT(e),JSON.stringify([...t]))}catch{}}function pT({project:e,files:t,counts:n,current:r,onOpen:i,run:a=null,onAnalyze:o,sources:s=[],scope:c=null,onScope:l,onCollapse:u,onImports:d,onMenu:f,hidden:p=!1,onReveal:m}){let[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)({source:!0,tests:!1,config:!0}),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),E=(0,y.useRef)(null);a?.status===`committed`&&(E.current=a.runId);let[D,O]=(0,y.useState)(new Set),[k,A]=(0,y.useState)(0),[j,M]=(0,y.useState)(600),[N,P]=(0,y.useState)(0),F=(0,y.useRef)(null),I=(0,y.useRef)(null),L=t;t=(0,y.useMemo)(()=>c?L.filter(e=>e.source===c):L,[L,c]);let R=(0,y.useMemo)(()=>s.length>1||new Set(L.map(e=>e.source)).size>1,[L,s.length]),z=(0,y.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),B=e=>{let t=z.get(e)?.analysis;return t?t.kind===`git`?`${t.branch??`detached`} · ${t.revision.slice(0,7)} · ${we(t.analyzedAt)}`:`plain folder · latest only`:``},V=(0,y.useMemo)(()=>{let e={source:0,tests:0,config:0,attention:0};for(let n of t)e[eT(n.path)]++,tT(n)&&e.attention++;return e},[t]),H=(0,y.useMemo)(()=>t.filter(e=>S?tT(e):e.id===r||b[eT(e.path)]||tT(e)),[t,b,S,r]),U=(0,y.useMemo)(()=>{let e=oT(aT(H,n,R),R);return c&&R?e.dirs.get(c)??{...e,dirs:new Map,files:[]}:e},[H,n,R,c]),W=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!W.current&&e&&t.length!==0&&(W.current=!0,O(dT(e)??lT(U,t.length)))},[e,t,U]);let ee=t.find(e=>e.id===r);(0,y.useEffect)(()=>{if(!ee)return;let e=(R?`${ee.source}/${ee.path}`:ee.path).split(`/`);e.pop(),O(t=>{let n=new Set(t),r=``,i=!1;for(let t of e)r=r?`${r}/${t}`:t,n.has(r)||(n.add(r),i=!0);return i?n:t})},[ee?.id]);let G=(0,y.useMemo)(()=>{let e=_.trim().toLowerCase();return e?t.map(t=>{let n=t.path.toLowerCase(),r=n.slice(n.lastIndexOf(`/`)+1);return{f:t,rank:r.replace(/\.[^.]+$/,``)===e||r===e?0:r.startsWith(e)?1:r.includes(e)?2:n.includes(e)?3:-1,kind:eT(t.path)===`source`?0:1}}).filter(e=>e.rank>=0).sort((e,t)=>e.rank-t.rank||e.kind-t.kind||e.f.path.length-t.f.path.length||iT(e.f.path,t.f.path)).slice(0,Zw).map(({f:e})=>{let t=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``,n=R?z.get(e.source)?.name??e.source:``;return{type:`file`,file:e,depth:0,label:e.path.slice(e.path.lastIndexOf(`/`)+1),hint:[n,t].filter(Boolean).join(` · `)}}):sT(U,D,n)},[_,U,D,n,t,R,z]);(0,y.useEffect)(()=>{W.current&&e&&fT(e,D)},[D,e]),(0,y.useEffect)(()=>{N>=G.length&&P(Math.max(0,G.length-1))},[G.length,N]),(0,y.useEffect)(()=>{let e=F.current;if(!e)return;let t=new ResizeObserver(()=>M(e.clientHeight));return t.observe(e),()=>t.disconnect()},[]);let te=(0,y.useRef)(null),K=_.trim()!==``;(0,y.useEffect)(()=>{if(p)return;let e=r?`${r}\0${K}`:null;if(!r||te.current===e)return;let t=G.findIndex(e=>e.type===`file`&&e.file.id===r);if(t<0||!F.current)return;te.current=e;let n=t*Yw,i=F.current;(n<i.scrollTop||n+Yw>i.scrollTop+i.clientHeight)&&(i.scrollTop=Math.max(0,n-i.clientHeight/3),A(i.scrollTop)),P(t)},[r,G,K,p]),(0,y.useLayoutEffect)(()=>{!p&&F.current&&A(F.current.scrollTop)},[p]);let q=(0,y.useRef)(p);q.current=p;let ne=(0,y.useRef)(m);ne.current=m,(0,y.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`p`){if(document.querySelector(`[role="dialog"], [role="menu"]`))return;e.preventDefault(),q.current&&ne.current?.(),setTimeout(()=>{I.current?.focus(),I.current?.select()},0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let J=e=>O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),re=e=>{let t=Math.max(0,Math.min(G.length-1,e)),n=F.current;if(n){let e=t*Yw,r=n.scrollTop;e<r?r=e:e+Yw>r+n.clientHeight&&(r=e+Yw-n.clientHeight),n.scrollTop=r,(0,Vw.flushSync)(()=>{A(r),P(t)})}else P(t);F.current?.querySelector(`[data-row="${t}"]`)?.focus({preventScroll:!0})},ie=e=>{let t=G[e]?.depth??0;for(let n=e-1;n>=0;n--)if(G[n].type===`dir`&&G[n].depth<t)return n;return-1},ae=e=>{let t=G[N];if(e.key===`ArrowDown`)re(N+1);else if(e.key===`ArrowUp`)re(N-1);else if(e.key===`Home`)re(0);else if(e.key===`End`)re(G.length-1);else if(e.key===`ArrowRight`&&t?.type===`dir`)t.open?re(N+1):J(t.key);else if(e.key===`ArrowLeft`){if(t?.type===`dir`&&t.open)J(t.key);else{let e=ie(N);e>=0&&re(e)}}else return;e.preventDefault()},oe=Math.max(0,Math.floor(k/Yw)-Xw),se=Math.min(G.length,Math.ceil((k+j)/Yw)+Xw),ce=(e,t)=>V[e]===0?null:(0,Y.jsxs)(`button`,{className:`chip`,"aria-pressed":!S&&!w&&b[e],"data-testid":`chip-${e}`,disabled:V[e]===0,onClick:()=>{C(!1),w?(T(!1),x(t=>({...t,[e]:!0}))):x(t=>({...t,[e]:!t[e]}))},children:[t,` `,(0,Y.jsx)(`small`,{children:V[e]})]}),le=(0,y.useMemo)(()=>{let e=0,t=0;for(let n of a?.sources??[])e+=n.defaultExcluded?.length??0,t+=(n.ruleExcluded?.length??0)+(n.ruleExcludedMore??0);return{folders:e,paths:t}},[a]);return h&&e?(0,Y.jsx)(`nav`,{className:`nav`,"aria-label":`Files`,hidden:p,children:(0,Y.jsx)(eC,{project:e,files:t,run:a,onAnalyze:()=>{o?.(),g(!1)},onClose:()=>g(!1)})}):(0,Y.jsxs)(`nav`,{className:`nav`,"aria-label":`Files`,hidden:p,children:[(0,Y.jsxs)(`div`,{className:`nav-head`,children:[(s.length>1||c)&&(0,Y.jsxs)(`label`,{className:`nav-scope`,children:[(0,Y.jsx)(`span`,{className:`small muted`,children:`Scope`}),(0,Y.jsxs)(`select`,{"data-command":`scope-source`,value:c??``,onChange:e=>l?.(e.target.value||null),children:[(0,Y.jsx)(`option`,{value:``,children:`All repositories`}),s.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`outline-head`,children:[(0,Y.jsx)(`input`,{ref:I,className:`nav-filter`,"data-testid":`file-filter`,type:`search`,placeholder:w?`Filter libraries…`:`Filter ${t.length} files… ⌘P`,"aria-label":w?`Filter libraries`:`Filter files`,value:_,onChange:e=>{v(e.target.value),F.current&&(F.current.scrollTop=0),P(0)},onKeyDown:e=>{if(e.key===`Enter`&&_.trim()&&!w){let e=G.find(e=>e.type===`file`);e?.type===`file`&&i(e.file.id)}else e.key===`ArrowDown`?(e.preventDefault(),w?F.current?.parentElement?.querySelector(`.libraries button, [data-testid="library-package"]`)?.focus():re(0)):e.key===`Escape`&&v(``)}}),u&&(0,Y.jsx)(`button`,{className:`icon`,title:`Hide this pane ( [ )`,"aria-label":`Hide the files pane`,onClick:u,children:`⟨`})]}),(0,Y.jsxs)(`div`,{className:`nav-chips`,role:`group`,"aria-label":`Show`,children:[ce(`source`,`Source`),ce(`tests`,`Tests`),ce(`config`,`Config`),V.attention>0&&(0,Y.jsxs)(`button`,{className:`chip attention`,"aria-pressed":S&&!w,"data-testid":`chip-attention`,title:`Files that were not fully analyzed`,onClick:()=>{C(e=>w||!e),T(!1)},children:[`⚠ `,(0,Y.jsx)(`small`,{children:V.attention})]}),e&&(t.length>0||w)&&(0,Y.jsx)(`button`,{className:`chip`,"aria-pressed":w,"data-testid":`chip-libraries`,title:`The libraries the project uses: installed packages, copied libraries, and folders left out`,onClick:()=>{C(!1),T(e=>!e)},children:`Libraries`})]})]}),w&&e&&(0,Y.jsx)(`div`,{className:`nav-list`,children:(0,Y.jsx)(Jw,{project:e,run:E.current,source:c,filter:_,onOpen:i})}),(0,Y.jsxs)(`div`,{className:`nav-list`,hidden:w&&!!e,ref:F,role:`tree`,"aria-label":`Files`,onScroll:e=>A(e.currentTarget.scrollTop),onKeyDown:ae,children:[G.length===0&&t.length>0&&(0,Y.jsx)(`p`,{className:`hint`,children:`No files match.`}),(0,Y.jsx)(`div`,{style:{height:G.length*Yw,position:`relative`},children:G.slice(oe,se).map((e,t)=>{let n=oe+t,a={top:n*Yw,paddingLeft:8+e.depth*14};if(e.type===`dir`&&R&&!c&&e.depth===0&&z.has(e.key))return(0,Y.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":1,"aria-setsize":G.length,"aria-posinset":n+1,tabIndex:n===N?0:-1,className:`row dir repo`,"data-testid":`repo-row`,"data-source":e.key,style:a,title:z.get(e.key)?.root??e.key,onClick:()=>{P(n),J(e.key)},children:[(0,Y.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,Y.jsx)(`strong`,{className:`name`,children:z.get(e.key)?.name??e.key}),(0,Y.jsx)(`small`,{className:`muted repo-hint`,children:B(e.key)}),(0,Y.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`r:${e.key}`);if(e.type===`dir`)return(0,Y.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":e.depth+1,"aria-setsize":G.length,"aria-posinset":n+1,tabIndex:n===N?0:-1,className:`row dir`,style:a,title:e.key,onClick:()=>{P(n),J(e.key)},children:[(0,Y.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,Y.jsx)(`span`,{className:`name`,children:e.name}),(0,Y.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`d:${e.key}`);let o=e.file;return[(0,Y.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-level":e.depth+1,"aria-setsize":G.length,"aria-posinset":n+1,"aria-selected":o.id===r,tabIndex:n===N?0:-1,"data-command":`open-file`,"data-file":o.path,className:`row file ${o.id===r?`current`:``} ${o.status}`,style:a,title:o.status===`analyzed`?o.path:`${o.path}: ${rT[o.status]??o.status}${o.reason?` (${nT[o.reason]??o.reason})`:``}`,onClick:()=>{P(n),i(o.id)},onContextMenu:f&&(e=>{e.preventDefault(),f({kind:`file`,id:o.id,data:{},x:e.clientX,y:e.clientY})}),children:[(0,Y.jsx)(`span`,{className:`caret`}),(0,Y.jsxs)(`span`,{className:`name`,children:[e.label,_.trim()&&e.hint?(0,Y.jsxs)(`small`,{className:`muted`,children:[` `,e.hint]}):null]}),o.origin&&(0,Y.jsx)(`small`,{className:`origin ${o.origin}`,title:o.origin===`library`?`Installed library code, not the project's own`:o.origin===`tool`?`A tool's or coding agent's workspace, not the project's own code`:`Generated output, not the project's own code`,children:o.origin}),tT(o)?(0,Y.jsxs)(`small`,{className:`warn`,"aria-label":`${rT[o.status]??o.status}${o.reason?`: ${nT[o.reason]??o.reason}`:``}`,children:[`⚠ `,nT[o.reason??``]??o.reason??o.status]}):!_.trim()&&e.hint&&(0,Y.jsx)(`small`,{className:`count`,children:e.hint})]},`f:${o.id}`),d&&o.status!==`not_analyzed`&&(0,Y.jsx)(`button`,{className:`row-action`,"aria-hidden":`true`,"data-command":`file-imports`,"data-file":o.path,style:{top:n*Yw},tabIndex:-1,title:`Imports of ${e.label}: what it imports and what depends on it (Imports tab)`,onClick:()=>d(o.id),children:`⇄`},`i:${o.id}`)]})})]}),e&&o&&(0,Y.jsxs)(`div`,{className:`nav-foot`,children:[(0,Y.jsx)(`small`,{className:`muted`,"data-testid":`left-out`,children:le.folders+le.paths===0?``:`Left out: ${[le.folders?`${le.folders} by default (libraries, generated, tools)`:``,le.paths?`${le.paths} by your choice`:``].filter(Boolean).join(`, `)}`}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{"data-testid":`choose-files`,onClick:()=>g(!0),title:`Choose which files are analyzed`,children:`Choose files…`})]})]})}q_.use(qx);function mT(e){try{return hT(e)}catch{return gT(e)}}function hT(e){let t=q_({headless:!0,styleEnabled:!0,elements:[...e.nodes.map(e=>({data:{id:e.id,w:e.w,h:e.h}})),...e.edges.map(e=>({data:{id:e.id,source:e.source,target:e.target}}))],style:[{selector:`node`,style:{width:`data(w)`,height:`data(h)`}}]}),n=e=>t.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1,animate:!1}).run();try{n(`LR`);let r=t.elements().boundingBox(),{w:i,h:a}=e.canvas;r.w*e.fitZoom>i-2*e.pad&&r.w/Math.max(1,r.h)>i/a&&n(`TB`)}catch(e){throw t.destroy(),e}let r={};for(let e of t.nodes().toArray())r[e.id()]={...e.position()};return t.destroy(),r}function gT(e){let t=Math.max(1,Math.ceil(Math.sqrt(e.nodes.length))),n=Math.max(40,...e.nodes.map(e=>e.w))+24,r={};return e.nodes.forEach((e,i)=>{r[e.id]={x:i%t*n,y:Math.floor(i/t)*40}}),r}var _T=null,vT=typeof Worker>`u`,yT=0,bT=new Map,xT=e=>new Promise(t=>setTimeout(()=>t(mT(e)),0));function ST(){try{let e=new Worker(new URL(`/assets/callLayout.worker-BugXMtxI.js`,``+import.meta.url),{type:`module`});return e.addEventListener(`message`,e=>{let t=bT.get(e.data.id);t&&(bT.delete(e.data.id),e.data.error===void 0?t.resolve(e.data.positions):(console.error(`veoflow: laying out this graph failed; placed in a grid`,e.data.error),t.resolve(gT(t.input))))}),e.addEventListener(`error`,t=>{console.error(`veoflow: the layout worker failed; laying out on the page instead`,t),vT=!0,e.terminate(),_T=null;for(let[e,t]of bT)bT.delete(e),xT(t.input).then(t.resolve)}),e}catch{return vT=!0,null}}function CT(e){if(bT.size>0&&_T&&(_T.terminate(),_T=null,bT.clear()),!vT&&!_T&&(_T=ST()),!_T)return xT(e);let t=++yT;return new Promise(n=>{bT.set(t,{input:e,resolve:n}),_T.postMessage({id:t,input:e})})}var wT=2,TT=40,ET=25,DT=7;function OT(e){let t=AT.get(e);if(t)return t;let n=kT(e),r=new Set(e.calls.map(e=>`${e.from}\u0000${e.to}`)),i=[];for(let t of e.functions){let e=n.get(t.id);e&&e!==t.id&&!r.has(`${e}\u0000${t.id}`)&&i.push({id:`inside:${t.id}`,parent:e,child:t.id})}return AT.set(e,i),i}function kT(e){let t=new Map(e.functions.map(e=>[e.qualifiedName,e.id])),n=new Set(t.keys()),r=new Map;for(let i of e.functions){let e=ve(i.qualifiedName,n),a=e===null?void 0:t.get(e);a&&r.set(i.id,a)}return r}var AT=new WeakMap;function jT(e,t,n=null){let r=new Map,i=(e,t)=>{e!==t&&(r.has(e)||r.set(e,new Set),r.get(e).add(t))};for(let t of e.calls)i(t.from,t.to),i(t.to,t.from);for(let{parent:t,child:n}of OT(e))i(t,n),i(n,t);let a=e=>r.get(e)?.size??0,o=(e,t)=>[...e].sort((e,t)=>a(t)-a(e)||(e<t?-1:1)).slice(0,t),s=new Set(e.functions.map(e=>e.id));if(n&&s.has(n[0])&&s.has(n[1])){let e=new Set(n);for(let t of n)for(let n of o(r.get(t)??[],DT))e.add(n);return e}if(t&&s.has(t)){let e=new Set([t]),n=o(r.get(t)??[],ET);for(let t of n)e.add(t);for(let t=1;t<wT&&e.size<TT;t++)for(let t of n)for(let n of o(r.get(t)??[],5))e.size<TT&&e.add(n);return e}return new Set(o(s,TT))}var MT=e=>`site:${e}`,NT=(e,t)=>`pair:${e}->${t}`;q_.use(qx);var PT=.85,FT=1.25,IT=45,LT=.68,RT=4,zT=36,BT=e=>Math.max(36,String(e.data(`label`)).length*7+18);function VT(e){let t=e.nodes(`[kind = "function"], [kind = "port"], [kind = "ghost"]`).not(`.hidden`),n=`[kind = "call"], [kind = "ghost-call"], [kind = "inside"]`,r=e.edges(n).not(`.hidden`),i=t.filter(e=>e.connectedEdges(n).not(`.hidden`).empty());return{fns:t,isolated:i,connected:t.difference(i).union(r)}}var HT=300;function UT(e){let{connected:t}=VT(e);return{nodes:t.nodes().toArray().map(e=>({id:e.id(),w:e.outerWidth(),h:e.outerHeight()})),edges:t.edges().map(e=>({id:e.id(),source:e.source().id(),target:e.target().id()})),canvas:{w:Math.max(1,e.width()),h:Math.max(1,e.height())},fitZoom:LT,pad:zT}}function WT(e,t){let{fns:n,isolated:r,connected:i}=VT(e),a=e=>i.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1}).run(),o={w:Math.max(1,e.width()),h:Math.max(1,e.height())};if(t)e.batch(()=>{for(let e of i.nodes().toArray()){let n=t[e.id()];n&&e.position(n)}});else if(i.nonempty()){a(`LR`);let e=i.boundingBox();e.w*LT>o.w-72&&e.w/Math.max(1,e.h)>o.w/o.h&&a(`TB`)}let s=r.toArray(),c=i.nonempty()?i.boundingBox():{x1:0,y1:0,x2:0,y2:0,w:0,h:0},l=i.nonempty()?c.y2+48:0,u=Math.max(0,...s.map(e=>BT(e)))+24,d=Math.max(RT,Math.floor(Math.max(c.w,o.w/PT-72)/u));s.forEach((e,t)=>{e.position({x:c.x1+t%d*u+u/2,y:l+Math.floor(t/d)*34})});for(let e of n.toArray()){let t=e.outgoers(`node[kind = "site"]`).not(`.hidden`).toArray();if(t.length===0)continue;let n=e.position(),r=n.x+BT(e)/2+48;t.forEach((e,i)=>e.position({x:r+BT(e)/2,y:n.y+(i-(t.length-1)/2)*26}))}}function GT(e,t){if(t.empty())return;e.fit(t,zT);let n=e.zoom(),r=t.nodes().length<=IT?LT:PT;if(n>FT)e.zoom(FT),e.center(t);else if(n<r){let n=t.boundingBox();e.zoom(r),e.pan({x:zT-n.x1*r,y:zT-n.y1*r})}}function KT(e,t){if(t.edges().nonempty()||t.nodes(`[kind = "site"]`).nonempty()){GT(e,t.union(t.edges().connectedNodes()).union(t.nodes().incomers(`node`)));return}let n=t,r=n.renderedBoundingBox(),i=e.width(),a=e.height();r.x1>=0&&r.y1>=0&&r.x2<=i&&r.y2<=a||e.animate({center:{eles:n}},{duration:250})}function qT({graph:e,showUnresolved:t,selection:n,onSelect:r,onClear:i,focus:a,sitesFor:o,answered:s,marks:c,only:l=null,onContext:u,extraSite:d=null}){let f=(0,y.useRef)(null),m=(0,y.useRef)(null),h=Je();(0,y.useEffect)(()=>{m.current?.style(JT())},[h]);let g=(0,y.useRef)(l);g.current=l;let _=(0,y.useRef)(u);_.current=u,(0,y.useEffect)(()=>{m.current&&Ke(m.current,l)},[l]);let v=(0,y.useRef)(0),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(0);(0,y.useEffect)(()=>{let n=new Set(e.functions.map(e=>e.id)),a=new Map;for(let t of e.calls){if(!t.crossFile)continue;let e=n.has(t.from)?t.to:t.from;if(n.has(e)||a.has(e))continue;let r=t.function.path.split(`/`).pop()??t.function.path;a.set(e,`${r} › ${oe(t.function.qualifiedName,void 0,t.function.title).name}`)}for(let e of a.keys())n.add(e);let o=new Set(e.calls.filter(e=>e.from===e.to).map(e=>e.from)),s=new Map;for(let t of e.calls){if(t.from===t.to||!n.has(t.from)||!n.has(t.to))continue;let e=NT(t.from,t.to),r=s.get(e);r?r.calls.push(t.id):s.set(e,{from:t.from,to:t.to,calls:[t.id]})}let c=e.functions.map(e=>{let t=be(e);return t.unnamed?`λ ${t.name}`:t.name}),l=new Map(e.functions.map(e=>[e.id,e.qualifiedName])),u=new Map(e.functions.map(e=>[e.id,e])),h=OT(e),v=kT(e),y=e=>{let t=v.get(e);return t===void 0?null:l.get(t)??null},b=new Set(c.filter((e,t)=>c.indexOf(e)!==t)),x=[...e.functions.map((e,t)=>{let n=c[t],r=b.has(n)&&!n.includes(`· line`)?`${n} · line ${e.evidence.span.start.line}`:n,i=ye(e.qualifiedName,e.code,e.evidence.span.start.line,y(e.id));return{data:{id:e.id,label:o.has(e.id)?`${r} ↻`:r,kind:`function`,...i?{hover:i}:{}},classes:e.qualifiedName===`<module>`?`module`:be(e).unnamed?`unnamed`:``}}),...[...a].map(([e,t])=>({data:{id:e,label:t,kind:`port`},classes:`port`})),...h.map(e=>{let t=l.get(e.parent)??``,n=u.get(e.child),r=n?_e(n.qualifiedName,n.code,n.title)??se(n.qualifiedName):``;return{data:{id:e.id,source:e.parent,target:e.child,kind:`inside`,label:``,hover:`${r} is written inside ${t===`<module>`?`the file's top level`:se(t)}. A dotted line shows where a function is written, not a call.`},classes:`inside`}}),...[...s].map(([e,t])=>({data:{id:e,source:t.from,target:t.to,kind:`call`,calls:t.calls,label:t.calls.length>1?`×${t.calls.length}`:``}}))];if(t||d){let r=new Map;for(let i of e.unresolved){if(!n.has(i.enclosingFn)||!(t&&p(i))&&i.id!==d)continue;let e=`${i.enclosingFn}\u0000${i.expression}\u0000${i.status}`,a=r.get(e);a?a.ids.push(i.id):r.set(e,{fn:i.enclosingFn,expression:i.expression,ids:[i.id],status:i.status})}for(let e of r.values()){let t=MT(e.ids[0]),n=e.expression.length>40?`${e.expression.slice(0,39)}…`:e.expression;x.push({data:{id:t,label:e.ids.length>1?`${n} ×${e.ids.length}`:n,kind:`site`,ids:e.ids},classes:`site ${e.status}`},{data:{id:`edge:${t}`,source:e.fn,target:t,kind:`site-edge`,label:``},classes:`site-edge`})}}let S=q_({container:f.current,elements:x,autounselectify:!0,layout:{name:`preset`},minZoom:.15,maxZoom:3,style:JT()});return S.on(`tap`,`node, edge`,e=>{let t=e.target.data(`kind`),n=e.target.id();t===`function`?r({kind:`function`,id:n}):t===`inside`?r({kind:`function`,id:e.target.target().id()}):t===`call`?r({kind:`call`,id:e.target.data(`calls`)[0]}):t===`site`&&r({kind:`site`,id:e.target.data(`ids`)[0]})}),S.on(`tap`,e=>{e.target===S&&i()}),S.on(`mouseover`,`node, edge`,e=>{let t=e.target.data(`hover`),n=e.renderedPosition??e.target.renderedMidpoint?.()??{x:0,y:0};C(t?{text:t,x:n.x,y:n.y}:null)}),S.on(`mouseout`,`node, edge`,()=>C(null)),S.on(`pan zoom drag remove`,()=>C(null)),m.current=S,Ke(S,g.current),S.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`call`?`edge`:null;if(!n||!f.current)return;let r=f.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};_.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),f.current&&(f.current.veoCy=S),()=>{m.current=null,C(null),S.destroy()}},[e,t,r,i,d]);let E=(c?.removed??[]).filter(t=>t.file===e.file.id&&(t.type===`Function`||t.type===`CALLS`)).map(e=>e.id).join(`
338
+ `)},position:T.current,classes:`packages`});for(let t of e.groups)t.externalPackages>0&&n.push({data:{id:`packages|${t.id}`,kind:`uses`,source:t.id,target:`packages`,width:1,label:``,bend:0},classes:`uses`});t.add(n),x.current||h(GC(t)<WC)},[e,t,r]),(0,y.useEffect)(()=>{let e=f.current;e&&e.batch(()=>{e.elements().removeClass(`picked faded role-into role-from`),e.edges(`[kind = "depends"]`).forEach(e=>{e.data(`label`,e.data(`count`))});let t=(n?.startsWith(`DEPENDS_ON|`)||n?.startsWith(`arrow|`)?e.edges().filter(e=>XC(e.data(`source`),e.data(`target`))===n):null)??(n?e.getElementById(n):null);if(t&&t.nonempty()&&t.isEdge()){let n=t.union(t.connectedNodes());n.addClass(`picked`),e.elements().not(n).addClass(`faded`)}else if(t&&t.nonempty()){let n=t.connectedEdges(`[kind = "depends"]`);t.addClass(`picked`),n.forEach(e=>{let n=e.data(`source`)===t.id();e.addClass(n?`role-into`:`role-from`);let r=e.data(`count`);e.data(`label`,n?`▶${r?` ${r}`:``}`:`◀${r?` ${r}`:``}`)});let r=t.union(n);e.elements().not(r).not(r.connectedNodes()).addClass(`faded`)}})},[n,e,t,r]),(0,Y.jsxs)(`div`,{className:`graph-wrap`,children:[(0,Y.jsx)(`div`,{ref:d,className:`graph map`,"data-testid":`project-map`,tabIndex:0,role:`application`,"aria-label":`Project map: arrow keys move between groups, Enter opens one`,onKeyDown:t=>{let r=e.groups.map(e=>e.id);if(r.length===0)return;let s=n?r.indexOf(n):-1;if(t.key===`ArrowRight`||t.key===`ArrowDown`)i(r[(s+1)%r.length]);else if(t.key===`ArrowLeft`||t.key===`ArrowUp`)i(r[(s-1+r.length)%r.length]);else if(t.key===`Enter`&&n)a(n);else if(t.key===`Escape`)o();else return;t.preventDefault()}}),(0,Y.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Groups`,children:e.groups.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{"data-command":`pick-node`,"data-id":e.id,tabIndex:-1,onClick:()=>i(e.id),children:e.name}),(0,Y.jsxs)(`button`,{"data-command":`open-group`,"data-id":e.id,tabIndex:-1,onClick:()=>a(e.id),children:[`Open `,e.name]})]},e.id))}),(0,Y.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Arrows`,children:e.dependsOn.filter(e=>l(e)).map(t=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{"data-command":`pick-node`,"data-arrow":!0,"data-id":XC(t.from,t.to),tabIndex:-1,onClick:()=>i(XC(t.from,t.to)),children:VC(t,t=>e.groups.find(e=>e.id===t)?.name??t)})},t.id))}),v&&!g&&(0,Y.jsx)(`div`,{className:`map-hover`,"data-testid":`arrow-hover`,role:`status`,style:{left:v.x+12,top:v.y+12},children:v.text}),!g&&(0,Y.jsx)(`p`,{className:`overlay map-key small muted`,"data-testid":`map-key`,children:`A ──▶ B: A calls into B · callers left, what they call right`}),g&&(0,Y.jsx)(`ul`,{className:`map-list`,"data-testid":`map-list`,"aria-label":`Groups`,children:e.groups.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link-row${e.id===n?` picked`:``}`,"data-command":`list-group`,"data-id":e.id,onClick:()=>i(e.id),onDoubleClick:()=>a(e.id),title:`${e.name}: ${e.source} · ${HC[e.kind]??e.kind} (double-click or Enter opens it)`,onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),a(e.id))},children:[(0,Y.jsx)(`span`,{className:`name`,children:e.name}),(0,Y.jsxs)(`small`,{children:[e.source,` · `,HC[e.kind]??e.kind,` · `,UC(e.files,`file`),e.findings.broken>0?` · ${UC(e.findings.broken,`broken import`)}`:``]})]})},e.id))}),!g&&m&&(0,Y.jsxs)(`p`,{className:`overlay bottom small muted map-note`,"data-testid":`map-too-small`,children:[`All `,e.groups.length,` groups are shown, zoomed out: scroll to zoom in, or`,` `,(0,Y.jsx)(`button`,{className:`button-link`,onClick:()=>_(!0),children:`see them as a list`}),`.`]}),(0,Y.jsxs)(`div`,{className:`map-controls`,children:[(0,Y.jsx)(`button`,{"data-command":`map-as-list`,"aria-pressed":g,onClick:()=>_(!g),title:`The groups as a list`,children:g?`Map`:`List`}),!g&&(0,Y.jsx)(`button`,{className:`fit`,"data-command":`fit-map`,onClick:()=>{f.current&&(x.current=!1,h(GC(f.current)<WC))},children:`Fit`})]})]})}function QC(){return[{selector:`node`,style:{shape:`round-rectangle`,width:210,height:84,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`190px`,"text-valign":`center`,"text-halign":`center`,"font-size":13,"line-height":1.45,color:X(`gray-26`),"background-color":X(`gray-98-3`),"border-width":1,"border-color":X(`gray-86`)}},{selector:`node.broken`,style:{"border-color":X(`amber-74`)}},{selector:`node.packages`,style:{"background-color":X(`gray-100`),"border-style":`dashed`,"border-color":X(`gray-81`),color:X(`gray-44`)}},{selector:`edge`,style:{width:`data(width)`,"curve-style":`unbundled-bezier`,"control-point-distances":`data(bend)`,"control-point-weights":.5,"line-color":X(`gray-72`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`gray-72`),"arrow-scale":.8,label:`data(label)`,"font-size":11,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.unlinked`,style:{"line-style":`dashed`}},{selector:`edge.uses`,style:{"line-style":`dashed`,"line-color":X(`gray-86`),"target-arrow-shape":`none`}},...Ze(),Ge,{selector:`node.picked`,style:{"border-width":2,"border-color":X(`blue-56`),"background-color":X(`gray-97`)}},{selector:`edge.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`)}},{selector:`edge.role-into`,style:{"line-color":X(`blue-52-2`),"target-arrow-color":X(`blue-52-2`),color:X(`blue-52-2`)}},{selector:`edge.role-from`,style:{"line-color":X(`orange-59`),"target-arrow-color":X(`orange-59`),color:X(`orange-59`)}},{selector:`.faded`,style:{opacity:.25}}]}var $C=e=>e.toLocaleString(`en-US`),ew=(e,t)=>`${$C(e)} ${t}${e===1?``:`s`}`;function tw(e,t=!0){return[t&&e.withinFile?`${ew(e.withinFile,`call`)} within it`:``,e.intoOtherFiles?`${$C(e.intoOtherFiles)} into other files`:``,e.leaveProject?`${$C(e.leaveProject)} leave the project`:``,e.candidates?`${$C(e.candidates)} narrowed to candidates`:``].filter(Boolean)}var nw=e=>e.map((e,t)=>(0,Y.jsxs)(y.Fragment,{children:[t>0&&` · `,e]},t));function rw({project:e,file:t,version:n,onImports:r,onFindings:i}){let[a,o]=(0,y.useState)(null),s=a?.file===t&&a.project===e?a:null;if((0,y.useEffect)(()=>{let n=!0;return J.fileSummary(e,t).then(e=>n&&o(e)).catch(()=>n&&o(null)),()=>{n=!1}},[e,t,n]),!s)return null;let{alone:c,acrossFiles:l}=s;if(c.sites===0&&(!l||l.imports.files+l.imports.packages+l.imports.unresolved===0))return null;let u=[...tw(c),c.open?`${$C(c.open)} open`:`none open`],d=[];if(l){let e=l.open?`${$C(l.open)} stop short`:`none stop short`,t=l.imports.files+l.imports.packages,n=t+l.imports.unresolved>0?`${ew(t,`import`)}${l.imports.unresolved?`, ${$C(l.imports.unresolved)} unresolved`:``}`:null;d=[...tw(l,!1),l.open&&i?(0,Y.jsx)(`button`,{className:`link`,"data-testid":`file-summary-open`,title:`Findings for this file: its open calls (with those narrowed to candidates) and its imports that didn't resolve`,onClick:i,children:e}):e,...n?[r?(0,Y.jsx)(`button`,{className:`link`,"data-testid":`file-summary-imports`,onClick:r,children:n}):n]:[]]}return(0,Y.jsxs)(`p`,{className:`file-summary small muted`,"data-testid":`file-summary`,title:`Of its ${ew(c.sites,`call`)}: what reading this file on its own found, and what linking it to the rest of the project added`,children:[(0,Y.jsxs)(`span`,{"data-testid":`file-summary-alone`,children:[(0,Y.jsx)(`strong`,{children:`Reading this file alone:`}),` `,u.join(` · `)]}),(0,Y.jsx)(`span`,{"data-testid":`file-summary-across`,children:l?(0,Y.jsxs)(Y.Fragment,{children:[` → `,(0,Y.jsx)(`strong`,{children:`across files:`}),` `,nw(d)]}):` · cross-file analysis didn't run`})]})}function iw({project:e,projectName:t,run:n,group:r,source:i=null,pick:a,file:o,fileLevel:s,expand:c,showPending:l,tabs:u,onPick:d,onOpenGroup:f,onOpenFile:p,onToggleFolder:m,onTogglePending:h,onClear:g,onFileFindings:_,marks:v=null,only:b=null,onContext:x,area:S=null,onOpenArea:C=()=>{}}){let[w,T]=(0,y.useState)(0),{groups:E,error:D}=_S(e,n,w,i),[O,k]=(0,y.useState)(!1),[A,j]=dS(),M=s&&o!==null,{imports:N}=yS(e,n,M?o:null),{calls:P,error:F}=xS(e,n,M?o:null),[I,L]=(0,y.useState)({calls:!0,imports:!0}),R=M?N?N.file.group:null:r??(E&&E.total===1?E.groups[0].id:null),z=R?E?.groups.find(e=>e.id===R):void 0,[B,V]=(0,y.useState)(0),{group:H,error:U}=vS(e,n,M?null:R,c,l,B),[W,ee]=(0,y.useState)(new Set),G=(0,y.useMemo)(()=>E&&!R&&!M?CC(E,S,W):null,[E,R,M,S,W]),te=(0,y.useMemo)(()=>new Set(E?.groups.map(e=>e.source)).size>1,[E]),K=G?.area??S,q=K?wC(K,te):[],ne=q.map(e=>[(0,Y.jsx)(`span`,{className:`muted`,children:`›`},`s:${e.area}`),(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-area`,onClick:()=>C(e.area),children:e.label},e.area)]),J=e=>{e.startsWith(`area|`)?C(e.slice(mC.length)):e.startsWith(`singles|`)?ee(t=>new Set([...t,e.slice(hC.length)])):f(e)},re=e=>e.startsWith(`area|`)||e.startsWith(`singles|`),ie=(0,Y.jsxs)(`div`,{className:`toolbar`,children:[u,(0,Y.jsx)(`nav`,{className:`breadcrumb`,"aria-label":`Zoom`,"data-testid":`breadcrumb`,children:R?(0,Y.jsxs)(Y.Fragment,{children:[E?.total===1?(0,Y.jsx)(`span`,{children:t}):(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(),children:t}),!M&&ne,(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),M?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(R),children:z?.name??R}),(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),(0,Y.jsx)(`strong`,{className:`mono`,title:ow(o),children:Te(iS(ow(o),sw(z)),48)})]}):(0,Y.jsx)(`strong`,{children:z?.name??R})]}):M?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(),children:t}),(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),(0,Y.jsx)(`strong`,{className:`mono`,title:ow(o),children:Te(ow(o),48)})]}):q.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>f(),children:t}),ne.slice(0,-1),(0,Y.jsx)(`span`,{className:`muted`,children:`›`}),(0,Y.jsx)(`strong`,{children:q[q.length-1].label})]}):(0,Y.jsx)(`strong`,{children:t})}),(R||M||q.length>0)&&E&&E.total>1&&(0,Y.jsx)(`button`,{className:`small`,"data-command":`go-project-map`,title:`Back to the project map: every group, nothing picked`,onClick:()=>f(),children:`⌂ Project map`}),E&&!R&&E.stage2&&(0,Y.jsx)(`span`,{className:`small muted toolbar-note`,children:G?.area?(()=>{let e=G.map.groups.reduce((e,t)=>e+(t.members??1),0);return`folder · ${e.toLocaleString()} group${e===1?``:`s`} of ${E.total.toLocaleString()}`})():`project map · ${E.total} group${E.total===1?``:`s`}`}),H&&!M&&(0,Y.jsxs)(`span`,{className:`small muted toolbar-note`,children:[`group · `,H.group.files,` file`,H.group.files===1?``:`s`,` · `,H.group.source]}),R&&!M&&c.length>0&&(0,Y.jsx)(`span`,{className:`open-folders small`,children:c.map(e=>(0,Y.jsxs)(`span`,{className:`chip`,children:[iS(e,sw(z)),`/`,(0,Y.jsx)(`button`,{className:`icon`,"data-command":`toggle-folder`,"data-testid":`close-folder`,"data-path":e,"aria-label":`Close the folder ${e}`,onClick:()=>m(e),children:`×`})]},e))}),M&&(0,Y.jsx)(`span`,{className:`small muted toolbar-note`,children:`its imports and cross-file calls`}),(0,Y.jsx)(`span`,{className:`spacer`}),M&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`label`,{className:`toggle`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-calls`,checked:I.calls,onChange:e=>L({...I,calls:e.target.checked})}),`Cross-file calls`]}),(0,Y.jsxs)(`label`,{className:`toggle`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-imports`,checked:I.imports,onChange:e=>L({...I,imports:e.target.checked})}),`Imports`]})]}),R&&!M&&(0,Y.jsxs)(`label`,{className:`toggle`,title:`Imports waiting for another source to be added`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:l,onChange:h}),`Pending imports`]}),E&&!R&&E.externalPackages.total>0&&(0,Y.jsxs)(`label`,{className:`toggle`,title:`External packages are hidden by default: nearly every group imports the same few`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-packages`,checked:O,onChange:e=>k(e.target.checked)}),`External packages`]})]});if(D)return(0,Y.jsxs)(Y.Fragment,{children:[ie,(0,Y.jsxs)(`p`,{className:`hint error`,children:[D,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>T(e=>e+1),children:`Try again`})]})]});if(!E)return(0,Y.jsxs)(Y.Fragment,{children:[ie,(0,Y.jsx)(`p`,{className:`hint`,children:`Loading the imports…`})]});if(!E.stage2)return(0,Y.jsxs)(Y.Fragment,{children:[ie,(0,Y.jsx)(`p`,{className:`hint`,"data-testid":`imports-no-stage2`,children:`Imports haven't been analyzed in this project yet: Stage 2, which follows imports across files, hasn't run. Analyze the project again to see them.`})]});let ae=E.stats.own,oe=ae.files!==E.stats.files,se=S&&G?.area?SC(E,G.area):null,ce=se?new Set(se.map(e=>e.id)):null,le=se?{files:se.reduce((e,t)=>e+t.files,0),functions:se.reduce((e,t)=>e+t.functions,0),crossFileCalls:E.dependsOn.filter(e=>ce.has(e.from)&&ce.has(e.to)).reduce((e,t)=>e+t.calls,0),brokenImports:se.reduce((e,t)=>e+t.findings.broken,0),openCalls:se.reduce((e,t)=>e+t.findings.openCalls,0)}:A||!oe?E.stats:{files:ae.files,functions:ae.functions,crossFileCalls:ae.crossFileCalls,brokenImports:ae.brokenImports??E.stats.brokenImports,openCalls:ae.openCalls??E.stats.openCalls};return(0,Y.jsxs)(Y.Fragment,{children:[ie,M&&o&&(0,Y.jsx)(rw,{project:e,file:o,version:`${n}:${P?.out.committedRun??``}`,onFindings:_}),M?F?(0,Y.jsx)(`p`,{className:`hint error`,children:F}):P?(0,Y.jsx)(`div`,{className:`group-level`,"data-testid":`file-level`,children:(0,Y.jsx)(IC,{marks:v,onContext:x,file:o,calls:P,imports:N,show:I,pick:a,onPick:d,onOpenFile:e=>p(e),onClear:g})}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading the file…`}):R?U?(0,Y.jsxs)(`p`,{className:`hint error`,children:[U,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>V(e=>e+1),children:`Try again`})]}):H?(0,Y.jsxs)(`div`,{className:`group-level`,"data-testid":`group-level`,children:[H.truncated&&(0,Y.jsxs)(`p`,{className:`hint small`,children:[`Showing `,H.nodes.length,` of `,H.total,` files and folders.`]}),(0,Y.jsx)(aS,{marks:v,onContext:x,only:b,reply:H,pick:a,onPick:d,onOpenFile:e=>p(e,R),onToggleFolder:m,onClear:g})]}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading the group…`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`dl`,{className:`map-stats`,"data-testid":`map-stats`,children:[(0,Y.jsx)(aw,{n:le.files,label:`files`}),(0,Y.jsx)(aw,{n:le.functions,label:`functions`}),(0,Y.jsx)(aw,{n:le.crossFileCalls,label:se?`calls between its groups`:`cross-file calls`}),(0,Y.jsx)(aw,{n:le.brokenImports,label:`broken imports`,tone:le.brokenImports>0?`warn`:void 0}),(0,Y.jsx)(aw,{n:le.openCalls,label:`open calls`}),!se&&(0,Y.jsx)(aw,{n:E.externalPackages.total,label:O?`external packages`:`external packages (hidden)`}),oe&&!se&&(0,Y.jsxs)(`label`,{className:`toggle stats-scope`,title:`Own code: ${ae.files.toLocaleString()} of ${E.stats.files.toLocaleString()} files. The rest are tests, installed libraries, generated output or tools' files.`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`stats-all-code`,checked:A,onChange:e=>j(e.target.checked)}),`Libraries and tests too`]})]}),E.total===0?(0,Y.jsx)(`p`,{className:`hint`,children:`No groups: nothing was analyzed.`}):(0,Y.jsx)(ZC,{marks:v,onContext:x&&(e=>re(e.id)?void 0:x(e)),only:b,map:G?.map??E,layoutKey:`${e}|${E.committedRun}|${i??``}|${G?.area??``}|${[...W].join(`,`)}`,pick:a,showPackages:O,onPick:e=>re(e)?J(e):d(e),onOpen:J,onClear:g}),E.truncated&&(0,Y.jsxs)(`p`,{className:`hint small`,children:[`Showing `,E.groups.length,` of `,E.total,` groups.`]})]})]})}function aw({n:e,label:t,tone:n}){return(0,Y.jsxs)(`div`,{className:n,children:[(0,Y.jsx)(`dd`,{children:e.toLocaleString()}),(0,Y.jsx)(`dt`,{children:t})]})}var ow=e=>e.slice(e.indexOf(`:`)+1);function sw(e){return!e||e.kind===`cluster`?``:e.root}var cw=(e,t=34)=>e.length>t?`${e.slice(0,t-1)}…`:e,lw=e=>e.slice(e.lastIndexOf(`/`)+1);function uw(e){let t=[e.name,e.member].filter(Boolean).join(`.`)||`?`;return`${e.packageName??`runtime`}: ${t}`}function dw(e){let t=e.direction===`forward`?1:-1,n=[],r=new Map,i=[],a=e=>{let t=r.get(e)??0;r.set(e,t+1);let n={position:{x:0,y:0},depth:e,row:t};return i.push(n),n.position},o=new Map(e.functions.map(e=>[e.id,e.depth])),s=new Set(e.starts.map(e=>e.function));for(let t of e.functions)n.push({group:`nodes`,data:{id:t.id,kind:`function`,label:`${cw(t.name,26)}${s.has(t.id)?` ▸ start`:``}\n${cw(lw(t.path),28)}`,path:t.path,line:t.line,depth:t.depth},position:a(t.depth),classes:[`function`,...t.depth===0?[`root`]:[],...s.has(t.id)?[`start`]:[]].join(` `)});e.edges.forEach((e,t)=>{o.has(e.from)&&o.has(e.to)&&n.push({group:`edges`,data:{id:`hop|${t}`,source:e.from,target:e.to,kind:e.kind,label:e.kind===`call`||e.kind===`cross-file`?``:e.kind,path:e.evidence.file.slice(e.evidence.file.indexOf(`:`)+1),line:e.evidence.span.start.line,file:e.evidence.file},classes:e.trust===`candidate`?`hop candidate`:`hop`})});let c=new Map;for(let t of e.gaps){let e=`gap|${t.in}|${t.expression}|${t.reason}`,n=c.get(e);n?n.count++:c.set(e,{id:e,in:t.in,label:`? ${cw(t.expression,26)}\n${t.reason}`,kind:`gap`,count:1,file:t.evidence.file,line:t.evidence.span.start.line})}for(let t of e.exits){let e=uw(t.exit),n=`exit|${t.in}|${e}`,r=c.get(n);r?r.count++:c.set(n,{id:n,in:t.in,label:cw(e,30),kind:`exit`,count:1,file:t.evidence.file,line:t.evidence.span.start.line})}for(let e of[...c.values()].sort((e,t)=>e.id<t.id?-1:1)){let t=o.get(e.in);t!==void 0&&(n.push({group:`nodes`,data:{id:e.id,kind:e.kind,label:e.count>1?`${e.label} ×${e.count}`:e.label,file:e.file,line:e.line},position:a(t+1),classes:`port ${e.kind}`}),n.push({group:`edges`,data:{id:`to|${e.id}`,source:e.in,target:e.id,kind:e.kind,label:``,file:e.file,line:e.line},classes:`stop ${e.kind}`}))}let l=Math.max(0,...r.keys()),u=[],d=0;for(let e=0;e<=l;e++)u[e]=d,d+=Math.ceil((r.get(e)??1)/24)*270;for(let e of i)e.position.x=t*(u[e.depth]+Math.floor(e.row/24)*270),e.position.y=e.row%24*62;return n}var fw=e=>e.slice(e.indexOf(`:`)+1),pw=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function mw({project:e,run:t,root:n,direction:r,onDirection:i,onReach:a,onOpenFile:o,onContext:s}){let{reach:c,error:l}=bS(e,t,n,r),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=Je();(0,y.useEffect)(()=>{p.current?.style(hw())},[m]);let h=(0,y.useRef)({onReach:a,onContext:s});h.current={onReach:a,onContext:s};let g=(0,y.useMemo)(()=>c?dw(c):[],[c]);(0,y.useEffect)(()=>d(null),[n,r]),(0,y.useEffect)(()=>{if(!f.current||g.length===0)return;let e=q_({container:f.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.1,maxZoom:2.5,style:hw()});return e.on(`tap`,`edge`,t=>{e.elements().removeClass(`picked`),t.target.addClass(`picked`),d(t.target.data())}),e.on(`tap`,`node`,e=>{let t=e.target.data();t.kind===`function`?h.current.onReach(t.id):d(t)}),e.on(`cxttap`,`node`,e=>{let t=e.target.data();if(t.kind!==`function`||!f.current)return;let n=f.current.getBoundingClientRect(),r=e.renderedPosition??{x:0,y:0};h.current.onContext?.({kind:`function`,id:t.id,data:t,x:n.left+r.x,y:n.top+r.y})}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),p.current=e,()=>{p.current=null,e.destroy()}},[g]);let _=new Map((c?.functions??[]).map(e=>[e.id,e.name])),v=e=>_.get(e)??e,b=c?.counts,x=b?`in ${pw(b.files,`file`)} across ${pw(b.groups,`group`)}`:``,S=c?.functions.find(e=>e.id===n)?.name??fw(n);return(0,Y.jsxs)(`div`,{className:`reach`,"data-testid":`reach`,children:[(0,Y.jsxs)(`div`,{className:`toolbar`,children:[(0,Y.jsx)(`span`,{className:`file-title`,title:n,children:S}),(0,Y.jsx)(`div`,{className:`segmented`,role:`group`,"aria-label":`Direction`,children:[`forward`,`backward`].map(e=>(0,Y.jsx)(`button`,{"aria-pressed":r===e,"data-command":`open-reach`,"data-direction":e,title:e===`forward`?`What paths from it reach`:`What reaches it`,onClick:()=>i(e),children:e===`forward`?`Reaches →`:`← Reached by`},e))}),b&&(0,Y.jsx)(`span`,{className:`reach-counts`,"data-testid":`reach-counts`,children:r===`forward`?`${b.functions?`reaches ${pw(b.functions,`function`)} ${x}`:`reaches no other function`} · ${pw(b.gaps,`gap`)} · ${pw(b.exits,`exit`)}`:`${b.functions?`reached by ${pw(b.functions,`function`)} ${x}`:`nothing reaches it`}${c.starts.length?` · ${pw(c.starts.length,`start candidate`)}`:``}`}),c?.truncated&&(0,Y.jsxs)(`span`,{className:`badge degraded`,"data-testid":`reach-truncated`,children:[`stopped at the `,c.truncated.reason,` budget, `,pw(c.truncated.depth,`step`),` out`]})]}),l&&(0,Y.jsx)(`div`,{className:`error`,children:l}),(0,Y.jsx)(`div`,{className:`graph-wrap`,children:(0,Y.jsx)(`div`,{className:`graph map`,ref:f,"data-testid":`reach-canvas`})}),u&&(0,Y.jsxs)(`div`,{className:`reach-hop`,"data-testid":`reach-hop`,children:[(0,Y.jsxs)(`span`,{children:[String(u.kind),` · `,String(u.file??``).slice(String(u.file??``).indexOf(`:`)+1),`:`,String(u.line??``)]}),typeof u.file==`string`&&(0,Y.jsx)(`button`,{"data-command":`open-file`,onClick:()=>o(u.file,u.line),children:`Open`})]}),c&&(0,Y.jsxs)(`details`,{className:`reach-list`,"data-testid":`reach-list`,children:[(0,Y.jsx)(`summary`,{children:`As a list`}),(0,Y.jsx)(`ol`,{children:c.functions.map(e=>(0,Y.jsxs)(`li`,{"data-depth":e.depth,children:[` `.repeat(e.depth),(0,Y.jsx)(`button`,{className:`link`,"data-command":`open-reach`,title:`Reach from this function instead`,onClick:()=>a(e.id),children:e.name}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[e.path,`:`,e.line]})]},e.id))}),(0,Y.jsx)(`ul`,{"data-testid":`reach-hops`,children:c.edges.map((e,t)=>(0,Y.jsxs)(`li`,{"data-kind":e.kind,"data-trust":e.trust,children:[(0,Y.jsxs)(`button`,{"data-command":`reach-hop`,onClick:()=>d({kind:e.kind,file:e.evidence.file,line:e.evidence.span.start.line}),children:[v(e.from),` → `,v(e.to)]}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[e.kind,e.trust===`candidate`?` (candidate)`:``]})]},t))}),c.gaps.length>0&&(0,Y.jsx)(`ul`,{"data-testid":`reach-gaps`,children:c.gaps.map(e=>(0,Y.jsxs)(`li`,{children:[`? `,e.expression,` `,(0,Y.jsx)(`span`,{className:`muted`,children:e.reason}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[fw(e.evidence.file),`:`,e.evidence.span.start.line]})]},e.site))}),c.exits.length>0&&(0,Y.jsx)(`ul`,{"data-testid":`reach-exits`,children:c.exits.map(e=>(0,Y.jsxs)(`li`,{children:[e.expression,` `,(0,Y.jsx)(`span`,{className:`muted`,children:e.exit.packageName??`runtime`}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[fw(e.evidence.file),`:`,e.evidence.span.start.line]})]},e.id))})]})]})}function hw(){return[{selector:`node`,style:{shape:`round-rectangle`,width:210,height:48,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":14,color:X(`gray-26`),"background-color":X(`gray-100`),"border-width":1,"border-color":X(`gray-86`)}},{selector:`node.root`,style:{"border-color":X(`blue-56`),"border-width":2,"font-weight":`bold`}},{selector:`node.start`,style:{"border-color":X(`green-57`),"border-width":2}},{selector:`node.port.gap`,style:{"border-style":`dotted`,"border-color":X(`red-54`),color:X(`red-44`),"background-color":X(`gray-98-9`)}},{selector:`node.port.exit`,style:{"border-style":`double`,"border-width":3,"border-color":X(`blue-62`),color:X(`blue-47`)}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":X(`gray-44`),"target-arrow-shape":`triangle`,"target-arrow-color":X(`gray-44`),"arrow-scale":.8,label:`data(label)`,"font-size":11,color:X(`gray-51-2`),"text-background-color":X(`gray-100`),"text-background-opacity":1}},{selector:`edge.candidate`,style:{"line-style":`dashed`,"line-color":X(`gray-67`)}},{selector:`edge.stop.gap`,style:{"line-style":`dotted`,"line-color":X(`red-54`),"target-arrow-shape":`none`}},{selector:`edge.stop.exit`,style:{"line-color":X(`blue-62`),"target-arrow-color":X(`blue-62`)}},{selector:`.picked`,style:{"line-color":X(`blue-56`),"target-arrow-color":X(`blue-56`),width:3}}]}function gw(e,t,n){let r=new Map,i=e=>{let t=r.get(e.id);return t||r.set(e.id,t={kind:`function`,end:e,out:[],into:[]}),t};for(let n of t)n.from.file===e&&i(n.from).out.push(n);for(let t of n)t.to.file===e&&i(t.to).into.push(t);let a=e=>e.end.title!==void 0&&e.end.suite!==void 0&&e.into.length===0&&e.out.length>0?`${e.end.suite}\u0000${[...new Set(e.out.map(e=>e.to.id))].sort().join(`\0`)}`:null,o=new Map;for(let e of r.values()){let t=a(e);t!==null&&o.set(t,[...o.get(t)??[],e])}let s=[],c=new Set;for(let e of r.values()){let t=a(e),n=t===null?void 0:o.get(t);if(!n||n.length<2){s.push(e);continue}if(c.has(t))continue;c.add(t);let r=new Map(n.flatMap(e=>e.out.map(e=>[e.to.id,e.to])));s.push({kind:`suite`,suite:e.end.suite,callees:[...r.values()],tests:n})}return s}var _w={focus:3,site:2,call:1},vw=e=>e.end.column<=1&&e.end.line>e.start.line?e.end.line-1:e.end.line;function yw(e,t){if(e.kind!==`call`||vw(e)===e.start.line)return e;let n=Array.from(t(e.start.line)??``),r=n.indexOf(`(`,e.start.column-1),i=r>=0?r+2:n.length+1;return{...e,end:{line:e.start.line,column:i}}}function bw(e,t){let n=t=>e.lines[t-e.startLine],r=t.map(e=>yw(e,n)),i=r.map(e=>(e.end.line-e.start.line)*1e4+(e.end.column-e.start.column)),a=new Map;r.forEach((t,n)=>{let r=Math.max(t.start.line,e.startLine),i=Math.min(vw(t),e.startLine+e.lines.length-1);for(let e=r;e<=i;e++){let t=a.get(e);t?t.push(n):a.set(e,[n])}});let o=new Set;return e.lines.map((t,n)=>{let s=e.startLine+n,c=Array.from(t),l=c.map(()=>null);for(let e of a.get(s)??[]){let t=r[e],n=s===t.start.line?t.start.column-1:0,a=s===t.end.line?t.end.column-1:c.length;for(let o=Math.max(0,n);o<Math.min(c.length,a);o++){let n=l[o];(n==null||_w[t.kind]>_w[r[n].kind]||_w[t.kind]===_w[r[n].kind]&&i[e]<i[n])&&(l[o]=e)}}let u=[];return c.forEach((e,t)=>{let n=u[u.length-1],r=l[t]??null;if(n&&n.mark===r)n.text+=e;else{let t=r!==null&&!o.has(r);r!==null&&o.add(r),u.push({text:e,mark:r,first:t})}}),{n:s,runs:u,focus:r.some(e=>e.kind===`focus`&&s>=e.start.line&&s<=vw(e))}})}function xw({snippet:e,marks:t,focusLine:n,testId:r,className:i}){let a=(0,y.useRef)(null),o=(0,y.useMemo)(()=>bw(e,t),[e,t]);(0,y.useEffect)(()=>{let e=a.current,t=e?.querySelector(`[data-line="${n}"]`);e&&t&&(e.scrollTop=Math.max(0,t.offsetTop-e.clientHeight/3))},[e,n]);let s=e=>{let n=e?.closest(`[data-mark]`);if(!n)return!1;let r=t[Number(n.dataset.mark)];return r?.onClick?(r.onClick(),!0):!1};return(0,Y.jsx)(`pre`,{className:`code ${i??``}`,"data-testid":r,ref:a,onClick:e=>s(e.target),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&s(e.target)&&e.preventDefault()},children:o.map(({n:e,runs:n,focus:r})=>(0,Y.jsxs)(`div`,{"data-line":e,className:r?`focus-line`:``,children:[(0,Y.jsx)(`span`,{className:`ln`,"aria-hidden":`true`,children:e}),` `,n.map((e,n)=>{if(e.mark===null)return e.text;let r=t[e.mark],i=r.kind===`focus`?`hit`:r.kind===`site`?`site-mark`:`call-mark`,a=!!r.onClick;return(0,Y.jsx)(`span`,{className:`mark ${i}${a?` clickable`:``}`,"data-mark":e.mark,title:r.title,...a&&e.first?{role:`button`,tabIndex:0}:{},children:e.text},n)})]},e))})}function Sw({title:e,location:t,snippet:n,marks:r,focusLine:i,onClose:a}){let o=(0,y.useRef)(null),s=(0,y.useRef)(null);return(0,y.useEffect)(()=>{o.current?.focus();let e=e=>{if(e.key===`Escape`)e.stopPropagation(),a();else if(e.key===`Tab`&&s.current){let t=s.current.querySelectorAll(`button, [tabindex="0"]`),n=t[0],r=t[t.length-1];s.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[a]),(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&a(),children:(0,Y.jsxs)(`div`,{className:`modal code-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e,"data-testid":`code-modal`,ref:s,tabIndex:-1,children:[(0,Y.jsxs)(`div`,{className:`evidence-head`,children:[(0,Y.jsx)(`h3`,{children:e}),(0,Y.jsx)(`code`,{className:`muted small`,children:t}),(0,Y.jsx)(`button`,{ref:o,className:`icon close`,"aria-label":`Close (Esc)`,title:`Close (Esc)`,onClick:a,children:`×`})]}),n?(0,Y.jsx)(xw,{snippet:n,marks:r,focusLine:i,testId:`modal-code`,className:`large`}):(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`}),(0,Y.jsx)(`p`,{className:`muted small`,children:`Use your browser's find (⌘F / Ctrl+F) to search the code.`})]})})}var Cw=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`;function ww({project:e,run:t,from:n,to:r,onOpenFile:i}){let[a,o]=(0,y.useState)([]),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),d=JSON.stringify([e,t,n,r]),f=(0,y.useRef)(d);if(f.current=d,(0,y.useEffect)(()=>{let t=!1;return o([]),c(null),J.callsBetween(e,n,r).then(e=>!t&&o([e]),e=>!t&&c(e.message)),()=>{t=!0}},[d]),s)return(0,Y.jsx)(`p`,{className:`hint error`,children:s});let p=a[0];if(!p)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let m=a.flatMap(e=>e.calls),h=p.pair.summary,g=new Map;for(let e of m)g.set(e.from.path,[...g.get(e.from.path)??[],e]);let _=()=>{if(l)return;let t=d;u(!0),J.callsBetween(e,n,r,m.length).then(e=>{f.current===t&&o(t=>[...t,e])},e=>c(e.message)).finally(()=>u(!1))};return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`pair-details`,children:[(0,Y.jsxs)(`h3`,{children:[p.pair.from.name,` → `,p.pair.to.name]}),(0,Y.jsxs)(`p`,{"data-testid":`pair-summary`,children:[p.pair.from.name,` calls into `,p.pair.to.name,`: `,Cw(h.calls,`call`),` from`,` `,Cw(h.callers,`function`),` to `,Cw(h.callees,`function`),h.references?`, ${Cw(h.references,`reference`)}`:``,` (`,Cw(h.imports,`import`),`)`]}),h.calls===0&&(0,Y.jsx)(`p`,{className:`small muted`,children:h.references?`No calls: functions are handed on between them (references).`:`No calls: only imports link them.`}),[...g].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`pair-file`,children:[(0,Y.jsx)(`h4`,{className:`small`,children:(0,Y.jsx)(`button`,{className:`link`,onClick:()=>i(t[0].from.file),children:e})}),(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`pair-calls`,children:t.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{className:`link`,onClick:()=>i(e.from.file),children:Se(e.from)}),` `,(0,Y.jsxs)(`span`,{className:`small muted`,children:[`:`,e.evidence.span.start.line]}),` →`,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>i(e.to.file),children:Se(e.to)}),` `,(0,Y.jsxs)(`span`,{className:`small muted`,children:[`(`,e.to.path,`)`]})]},e.id))})]},e)),m.length<p.total&&(0,Y.jsx)(`button`,{className:`link small`,"data-testid":`pair-more`,disabled:l,onClick:_,children:l?`Loading…`:`${p.total-m.length} more calls…`}),p.pair.references.length>0&&(0,Y.jsxs)(`details`,{children:[(0,Y.jsxs)(`summary`,{className:`small`,children:[`References (`,h.references,`)`]}),(0,Y.jsx)(`ul`,{className:`plain small`,children:p.pair.references.map(e=>(0,Y.jsxs)(`li`,{children:[Se(e.from),` hands on `,Se(e.to),` (`,e.to.path,`) · `,e.context,` · line`,` `,e.evidence.span.start.line]},e.id))})]}),p.pair.imports.length>0&&(0,Y.jsxs)(`details`,{children:[(0,Y.jsxs)(`summary`,{className:`small`,children:[`Imports (`,h.imports,`)`]}),(0,Y.jsx)(`ul`,{className:`plain small`,"data-testid":`pair-imports`,children:p.pair.imports.map(e=>(0,Y.jsxs)(`li`,{children:[e.path,`:`,e.evidence.span.start.line,` · `,(0,Y.jsx)(`code`,{children:e.specifier})]},e.id))})]})]})}var Tw={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`};function Ew(e){let{project:t,run:n,pick:r,file:i,fileLevel:a}=e;return a&&i&&r?.startsWith(`CALLS_CROSS_FILE|`)?(0,Y.jsx)(Lw,{project:t,run:n,file:i,call:r}):a&&i&&(r?.startsWith(`IMPORTS|`)||r?.startsWith(`unresolved-import|`))?(0,Y.jsx)(Bw,{project:t,run:n,file:i,edge:r}):a&&i?(0,Y.jsx)(jw,{project:t,run:n,file:i,onOpenFile:e.onOpenFile}):r&&(r.startsWith(`DEPENDS_ON|`)||r.startsWith(`arrow|`))?(0,Y.jsx)(Dw,{...e,arrow:r}):r&&r.startsWith(`calls|`)?(0,Y.jsx)(Ow,{...e,link:r}):r&&r.startsWith(`folder|`)?(0,Y.jsx)(Pw,{...e,folder:r}):r&&!r.startsWith(`group|`)?(0,Y.jsx)(jw,{project:t,run:n,file:r,onOpenFile:e.onOpenFile,canOpen:!0}):(0,Y.jsx)(kw,{project:t,run:n,group:e.group,pick:r,onOpenGroup:e.onOpenGroup,onPick:e.onPick})}function Dw({project:e,run:t,arrow:n,onOpenFile:r}){let{groups:i}=_S(e,t);if(!i)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let a=null;if(n.startsWith(`DEPENDS_ON|`)){let e=i.dependsOn.find(e=>e.id===n);e&&(a=[[e.from],[e.to]])}else{let[e,t]=n.slice(6).split(`|`).map(decodeURIComponent);e&&t&&(a=[[e],[t]])}return!a||a[0].length===0||a[1].length===0?(0,Y.jsx)(`p`,{className:`hint`,children:`That arrow isn't on the map any more.`}):(0,Y.jsx)(ww,{project:e,run:t,from:a[0],to:a[1],onOpenFile:r})}function Ow({project:e,run:t,group:n,link:r,expand:i,showPending:a,onOpenFile:o}){let{group:s}=vS(e,t,n,i,a);if(!s)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let c=[...s.calls,...s.callStubEdges].find(e=>e.id===r);return c?(0,Y.jsx)(ww,{project:e,run:t,from:[c.from],to:[(e=>e.startsWith(`stub|`)?e.slice(5):e)(c.to)],onOpenFile:o}):(0,Y.jsx)(`p`,{className:`hint`,children:`That link isn't drawn any more.`})}function kw({project:e,run:t,group:n,pick:r,onOpenGroup:i,onPick:a}){let{groups:o}=_S(e,t),s=n??(o?.total===1?o.groups[0].id:r),c=s&&o?o.groups.find(e=>e.id===s):void 0;if(!o)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!o.stage2)return(0,Y.jsx)(`p`,{className:`hint`,children:`Stage 2 hasn't run on this project, so there are no groups yet.`});if(!c)return(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a group on the map to see what it holds and what it depends on; double-click or press Enter to open it.`});let u=e=>o.groups.find(t=>t.id===e)?.name??e,d=o.dependsOn.filter(e=>e.from===c.id&&l(e)),f=o.dependsOn.filter(e=>e.to===c.id&&l(e)),p=o.dependsOn.filter(e=>(e.from===c.id||e.to===c.id)&&!l(e)),m=c.findings,h=(e,t,r)=>e.length===0?(0,Y.jsx)(`p`,{className:`small muted`,"data-testid":r,children:`None`}):(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":r,children:e.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`button`,{className:`link`,onClick:()=>n?i(e[t]):a(e[t]),children:u(e[t])}),` `,(0,Y.jsx)(`span`,{className:`small muted`,children:l(e)?zC(e):`${e.imports} import${e.imports===1?``:`s`}, no call`})]},e.id))});return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`group-details`,children:[(0,Y.jsx)(`h3`,{children:c.name}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[c.source,` · `,Tw[c.kind]??c.kind,c.root?` · ${c.root}`:``]}),(0,Y.jsxs)(`p`,{children:[c.files.toLocaleString(),` files · `,c.functions.toLocaleString(),` functions · `,c.externalPackages,` `,`external package`,c.externalPackages===1?``:`s`]}),m.broken+m.notAnalyzed+m.openCalls+m.pending>0&&(0,Y.jsx)(`p`,{className:`small`,"data-testid":`group-findings`,children:[m.broken?`${m.broken} broken import${m.broken===1?``:`s`}`:``,m.notAnalyzed?`${m.notAnalyzed} import${m.notAnalyzed===1?``:`s`} of files not analyzed`:``,m.openCalls?`${m.openCalls} open question${m.openCalls===1?``:`s`}`:``,m.pending?`${m.pending} pending`:``].filter(Boolean).join(` · `)}),(0,Y.jsx)(`h4`,{className:`small role-into`,children:`▶ Calls into`}),h(d,`to`,`calls-into`),(0,Y.jsx)(`h4`,{className:`small role-from`,children:`◀ Called from`}),h(f,`from`,`called-from`),p.some(e=>e.from===c.id)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h4`,{className:`muted small`,title:`Type-only, value-only or unused imports: no path, so no arrow`,children:`Imports from, no calls`}),h(p.filter(e=>e.from===c.id),`to`,`imports-only`)]}),p.some(e=>e.to===c.id)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h4`,{className:`muted small`,title:`Type-only, value-only or unused imports: no path, so no arrow`,children:`Imported by, no calls`}),h(p.filter(e=>e.to===c.id),`from`,`imported-only`)]}),!n&&o.total>1&&(0,Y.jsxs)(`button`,{"data-command":`open-group`,"data-testid":`open-picked`,onClick:()=>i(c.id),children:[`Open `,c.name]})]})}var Aw=e=>e.slice(e.indexOf(`:`)+1);function jw({project:e,run:t,file:n,onOpenFile:r,canOpen:i=!1}){let{imports:a,error:o}=yS(e,t,n),{groups:s}=_S(e,t),{calls:c,error:l}=xS(e,t,i?null:n);if(o)return(0,Y.jsx)(`p`,{className:`hint error`,children:o});if(!a)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let u=a.file.group?s?.groups.find(e=>e.id===a.file.group):void 0,d=u&&u.kind!==`cluster`?u.root:``;return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`file-details`,children:[(0,Y.jsx)(`h3`,{className:`mono`,children:iS(a.file.path,d)}),(0,Y.jsx)(`p`,{className:`muted small`,children:u?`${u.name} · ${u.source}`:Aw(n)}),l&&(0,Y.jsxs)(`p`,{className:`small error`,children:[`Calls across files: `,l]}),c&&(0,Y.jsx)(Nw,{file:n,calls:c,onOpenFile:r}),(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Imports (`,a.total,`)`]}),a.imports.length===0?(0,Y.jsx)(`p`,{className:`small muted`,children:`None`}):(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`file-imports`,children:a.imports.map(e=>(0,Y.jsxs)(`li`,{className:e.outcome===`broken`?`broken`:void 0,"data-outcome":e.outcome,children:[(0,Y.jsx)(`span`,{className:`mono small`,children:e.specifier}),` `,e.outcome===`file`&&e.file?(0,Y.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path}):e.outcome===`package`&&e.package?(0,Y.jsxs)(`span`,{className:`small muted`,children:[`package `,e.package.name,e.package.version?` ${e.package.version}`:``]}):(0,Y.jsxs)(`span`,{className:`small outcome`,children:[`(`,e.outcome===`not-analyzed`?`not analyzed`:e.outcome,`:`,` `,$x[e.reason??``]??e.reason,`)`]})]},e.id))}),a.truncated&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`Showing `,a.imports.length,` of `,a.total,`.`]}),(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Imported by (`,a.importedBy.total,`)`]}),a.importedBy.files.length===0?(0,Y.jsx)(`p`,{className:`small muted`,children:`None`}):(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`file-importers`,children:a.importedBy.files.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path})},e.id))}),i&&(0,Y.jsx)(`button`,{"data-command":`open-imports-file`,"data-testid":`open-picked-file`,onClick:()=>r(n),children:`Open file`})]})}function Mw({end:e}){let{name:t,parent:n,test:r}=xe(e);return(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.jsx)(`small`,{className:`tag`,children:`test`}),` `,(0,Y.jsx)(`strong`,{title:e.name,children:t}),n&&(0,Y.jsxs)(`span`,{className:`small muted`,children:[` in `,n]})]})}function Nw({file:e,calls:t,onOpenFile:n}){let r=gw(e,t.out.calls,t.in.calls);if(r.length===0)return(0,Y.jsx)(`p`,{className:`small muted`,children:`No calls to or from other files.`});let i=r.reduce((e,t)=>e+(t.kind===`suite`?t.tests.length:1),0),a=t.out.truncated||t.in.truncated,o=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{className:`link`,title:e.to.name,onClick:()=>n(e.to.file),children:Se(e.to)}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`(`,e.to.path,`)`]})]});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Functions calling across files (`,i,`)`]}),(0,Y.jsx)(`ul`,{className:`plain`,"data-testid":`file-function-calls`,children:r.map(e=>e.kind===`suite`?(0,Y.jsx)(`li`,{"data-testid":`suite-calls`,children:(0,Y.jsxs)(`details`,{children:[(0,Y.jsxs)(`summary`,{children:[(0,Y.jsx)(`small`,{className:`tag`,children:`test`}),` `,(0,Y.jsxs)(`strong`,{children:[`“`,e.suite,`”`]}),(0,Y.jsxs)(`span`,{className:`small`,children:[` `,`· `,e.tests.length,` tests call`,` `,e.callees.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,(0,Y.jsx)(`button`,{className:`link`,title:e.name,onClick:()=>n(e.file),children:Se(e)}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`(`,e.path,`)`]})]},e.id))]})]}),(0,Y.jsx)(`ul`,{className:`plain small suite-tests`,children:e.tests.map(e=>(0,Y.jsxs)(`li`,{"data-function":e.end.id,children:[(0,Y.jsx)(`span`,{title:e.end.name,children:xe(e.end).name}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`· line `,e.out.map(e=>e.evidence.span.start.line).join(`, `)]})]},e.end.id))})]})},`suite|${e.tests[0].end.id}`):(0,Y.jsxs)(`li`,{"data-function":e.end.id,children:[(0,Y.jsx)(Mw,{end:e.end}),e.out.length>0&&(0,Y.jsxs)(`div`,{className:`small`,children:[`calls`,` `,e.out.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,o(e),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`at line `,e.evidence.span.start.line]})]},e.id))]}),e.into.length>0&&(0,Y.jsxs)(`div`,{className:`small`,children:[`called by`,` `,e.into.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,(0,Y.jsx)(`button`,{className:`link`,title:e.from.name,onClick:()=>n(e.from.file),children:Se(e.from)}),` `,(0,Y.jsxs)(`span`,{className:`muted`,children:[`(`,e.from.path,`)`]})]},e.id))]})]},e.end.id))}),a&&(0,Y.jsx)(`p`,{className:`small muted`,children:`The first 500 calls each way are listed.`})]})}function Pw({project:e,run:t,group:n,folder:r,expand:i,showPending:a,onToggleFolder:o}){let{groups:s}=_S(e,t),{group:c}=vS(e,t,n??(s?.total===1?s.groups[0].id:null),i,a),l=c?.nodes.find(e=>e.id===r);return!l||l.kind!==`folder`?(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a file or a folder in the group.`}):(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`folder-details`,children:[(0,Y.jsxs)(`h3`,{className:`mono`,children:[l.path,`/`]}),(0,Y.jsxs)(`p`,{children:[l.files.toLocaleString(),` files`]}),l.findings.broken>0&&(0,Y.jsxs)(`p`,{className:`small`,children:[l.findings.broken,` broken import`,l.findings.broken===1?``:`s`]}),(0,Y.jsx)(`button`,{"data-command":`toggle-folder`,onClick:()=>o(l.path),children:`Open the folder`})]})}function Fw({project:e,run:t,file:n,span:r}){let[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(!1),c=(0,y.useCallback)(()=>s(!1),[]),l=`${t}|${n}|${r.start.offset}|${r.end.offset}`;if((0,y.useEffect)(()=>{let t=!1;return a(null),J.snippet(e,n,r).then(e=>!t&&a(e),()=>!t&&a(`error`)),()=>{t=!0}},[e,l]),!i)return null;if(i===`error`)return(0,Y.jsx)(`p`,{className:`small muted`,children:`The code couldn't be loaded.`});let u=[{start:r.start,end:r.end,kind:`focus`}];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xw,{snippet:i,marks:u,focusLine:r.start.line,testId:`snippet`}),(0,Y.jsx)(`button`,{className:`button-link small`,"data-testid":`expand-code`,onClick:()=>s(!0),children:`Expand`}),o&&(0,Y.jsx)(Sw,{title:Aw(n),location:`${Aw(n)}:${r.start.line}`,snippet:i,marks:u,focusLine:r.start.line,onClose:c})]})}function Iw({file:e,span:t}){return(0,Y.jsx)(`p`,{className:`location small`,"data-testid":`evidence-location`,children:(0,Y.jsxs)(`code`,{children:[Aw(e),`:`,t.start.line,`:`,t.start.column]})})}function Lw({project:e,run:t,file:n,call:r}){let{calls:i}=xS(e,t,n),a=i?[...i.out.calls,...i.in.calls].find(e=>e.id===r):void 0;if(!i)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!a)return(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let o=a.via===`import`?`found by import analysis${a.hops?.length?`, through ${a.hops.length} re-export${a.hops.length===1?``:`s`}`:``}`:a.via===`component`?`found by component linking`:a.via===`injection`?`found by dependency injection: the class the framework provides`:a.via===`returned`?`found by following what a function returns`:a.via===`flow`?`found by following where the value comes from: fields, instances and methods`:a.via===`closed-world`?`found assuming the analyzed code is the whole program (closed world, a project setting)`:`found by the template link`,s=a.steps?.find(e=>e.kind===`import`);return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`call-details`,children:[(0,Y.jsxs)(`h3`,{"data-testid":`evidence-title`,children:[Se(a.from),` calls `,Se(a.to)]}),(0,Y.jsxs)(`p`,{className:`muted small`,children:[`across files · `,o]}),s&&(0,Y.jsx)(`p`,{className:`small`,"data-testid":`call-import`,children:s.detail}),a.hops&&a.hops.length>0&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`through `,a.hops.join(` › `)]}),a.provenance&&(0,Y.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,Ce(a.provenance.stage),` · run `,a.provenance.run]}),(0,Y.jsx)(Iw,{file:a.evidence.file,span:a.evidence.span}),(0,Y.jsx)(Fw,{project:e,run:t,file:a.evidence.file,span:a.evidence.span}),(0,Y.jsx)(Re,{project:e,id:a.id},a.id)]})}function Rw(e){if(e.uses===null)return`its use isn't known`;if(e.unused)return`never used`;let t=[],n=e.uses;return n.calls&&t.push(`called ${n.calls}×`),n.jsx&&t.push(`rendered ${n.jsx}×`),n.values&&t.push(`used ${n.values}×`),n.types&&t.push(`as a type ${n.types}×`),n.extends&&t.push(`extended`),n.reexports&&t.push(`exported again`),t.join(`, `)}function zw({names:e}){return(0,Y.jsxs)(`div`,{className:`imported-names`,"data-testid":`import-names`,children:[(0,Y.jsxs)(`h4`,{className:`muted small`,children:[`Names (`,e.length,`)`]}),(0,Y.jsx)(`ul`,{children:e.map(e=>(0,Y.jsxs)(`li`,{"data-testid":`import-name`,"data-unused":e.unused||void 0,children:[(0,Y.jsx)(`span`,{className:`mono small`,children:e.local}),` `,(0,Y.jsxs)(`span`,{className:`small`,children:[e.target?e.target.kind===`package`?`from ${e.target.label}`:`${e.target.kind===`symbol`?`${e.target.symbolKind} `:e.target.kind===`module`?`module `:``}${e.target.kind===`module`?``:e.target.label}${e.target.path?` in ${e.target.path}`:``}`:e.outcome===`not-exported`?`not exported there`:`doesn't resolve (${e.outcome})`,` · `,(0,Y.jsx)(`span`,{className:e.unused?`unused`:`muted`,children:Rw(e)})]})]},e.id))})]})}function Bw({project:e,run:t,file:n,edge:r}){let{imports:i}=yS(e,t,n);if(!i)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`});let a=i.imports.find(e=>e.id===r),o=i.importedBy.files.find(e=>e.id===r);if(!a&&!o)return(0,Y.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let s=a?.evidence??o.evidence;return(0,Y.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`import-details`,children:[(0,Y.jsx)(`h3`,{"data-testid":`evidence-title`,children:a?`imports ${a.specifier}`:`${o.file.path} imports this file`}),a?.file&&(0,Y.jsxs)(`p`,{className:`small`,children:[`resolves to `,a.file.path]}),a&&!a.file&&!a.package&&(0,Y.jsxs)(`p`,{className:`small`,"data-testid":`import-outcome`,children:[a.outcome===`not-analyzed`?`not analyzed`:a.outcome,`:`,` `,$x[a.reason??``]??a.reason]}),a?.steps.map((e,t)=>(0,Y.jsx)(`p`,{className:`small muted`,children:e.detail},t)),a?.names&&a.names.length>0&&(0,Y.jsx)(zw,{names:a.names}),(a?.provenance??o?.provenance)&&(0,Y.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,Ce((a?.provenance??o.provenance).stage),` · run`,` `,(a?.provenance??o.provenance).run]}),(0,Y.jsx)(Iw,{file:s.file,span:s.span}),(0,Y.jsx)(Fw,{project:e,run:t,file:s.file,span:s.span}),(0,Y.jsx)(Re,{project:e,id:r},r)]})}var Vw=o(),Hw=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,Uw=8,Ww=50,Gw={installed:`installed by a package manager`,packages:`copied packages with their own manifests`,banners:`a library banner or versioned name`};function Kw(e){return`${[e.name==="default"||e.name===null?``:e.name,e.member??``].filter(Boolean).join(e.member?.startsWith(`(`)?``:`.`)||`default`}${e.instance?` (on an instance)`:``}`}function qw({project:e,source:t,pkg:n,onOpen:r}){let[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(!i||o)return;let r=!0;return J.library(e,n.name,n.ecosystem,t).then(e=>r&&s(e)).catch(e=>r&&l(e.message)),()=>{r=!1}},[i,o,e,n.name,n.ecosystem,t]);let f=n.files>0&&n.ownFiles===0,p=o?u?o.members:o.members.slice(0,Uw):[];return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{className:`library-row`,"data-testid":`library-package`,"data-name":n.name,"aria-expanded":i,title:`${n.name}${n.versions.length?` ${n.versions.join(`, `)}`:``}: imported by ${Hw(n.files,`file`)} (${n.ownFiles.toLocaleString(`en-US`)} own code) in ${Hw(n.groups,`group`)} · ${Hw(n.calls,`call`)}${n.references?`, ${Hw(n.references,`reference`)}`:``}`,onClick:()=>a(e=>!e),children:[(0,Y.jsx)(`span`,{className:`caret`,"aria-hidden":`true`,children:i?`▾`:`▸`}),(0,Y.jsx)(`span`,{className:`name`,children:n.name}),n.versions.length>0&&(0,Y.jsx)(`small`,{className:`muted`,children:n.versions.join(`, `)}),n.typeOnly&&(0,Y.jsx)(`small`,{className:`tag`,title:"Every import of it is `import type`: nothing of it runs",children:`types`}),f&&(0,Y.jsx)(`small`,{className:`tag`,title:`Imported only by tests, libraries or generated files`,children:`not own code`}),(0,Y.jsx)(`small`,{className:`count`,children:n.files})]}),i&&(0,Y.jsxs)(`div`,{className:`library-detail`,"data-testid":`library-detail`,children:[c&&(0,Y.jsx)(`p`,{className:`hint error`,children:c}),!o&&!c&&(0,Y.jsx)(`p`,{className:`hint`,children:`Loading…`}),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`small muted`,children:o.members.length===0?n.typeOnly?`Only its types are imported.`:`Nothing of it is called where the analysis can tell.`:`Used: ${Hw(n.calls,`call`)}${n.references?`, ${Hw(n.references,`reference`)}`:``}`}),p.length>0&&(0,Y.jsx)(`ul`,{className:`library-members`,children:p.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:Kw(e)}),(0,Y.jsx)(`small`,{className:`count`,children:e.calls+e.references})]},`${e.name}|${e.member}|${e.instance}`))}),o.members.length>Uw&&(0,Y.jsx)(`button`,{className:`link small`,onClick:()=>d(e=>!e),children:u?`fewer`:`${o.members.length-Uw} more`}),(0,Y.jsx)(`p`,{className:`small muted`,children:`Imported by`}),(0,Y.jsx)(`ul`,{className:`library-files`,children:o.importers.slice(0,Ww).map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{className:`link`,"data-command":`library-file`,"data-file":e.path,title:`${e.path}${e.group?` (${e.group.name})`:``}${e.own?``:`: not own code`}${e.forms.includes(`type-only`)?` · types`:``}`,onClick:()=>r(e.file),children:e.path})},e.file))}),o.importers.length>Ww&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`and `,Hw(o.importers.length-Ww,`more file`)]})]})]})]})}function Jw({project:e,run:t,source:n,filter:r,onOpen:i}){let[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``);if((0,y.useEffect)(()=>{let t=!0;return c(``),J.libraries(e,n).then(e=>t&&o(e)).catch(e=>t&&c(e.message)),()=>{t=!1}},[e,n,t]),s)return(0,Y.jsx)(`p`,{className:`hint error`,children:s});if(!a)return(0,Y.jsx)(`p`,{className:`hint`,children:`Loading libraries…`});let l=r.trim().toLowerCase(),u=a.packages.filter(e=>!l||e.name.toLowerCase().includes(l)),d=a.copied.filter(e=>!l||e.path.toLowerCase().includes(l)),f=a.leftOut.filter(e=>!l||e.path.toLowerCase().includes(l)),p=new Set([...a.copied,...a.leftOut].map(e=>e.source)).size>1,m=e=>p?`${e.source}/${e.path}`:e.path;return(0,Y.jsxs)(`div`,{className:`libraries`,"data-testid":`libraries`,children:[(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`outline-source`,children:[`Installed packages `,(0,Y.jsx)(`small`,{className:`muted`,children:a.total})]}),a.stage2?u.length===0?(0,Y.jsx)(`p`,{className:`hint`,children:l?`No packages match.`:`No file imports an installed package.`}):(0,Y.jsx)(`ul`,{children:u.map(r=>(0,Y.jsx)(qw,{project:e,source:n,pkg:r,onOpen:i},`${n??``}|${t??``}|${r.ecosystem}:${r.name}`))}):(0,Y.jsx)(`p`,{className:`hint`,children:`Packages come from import analysis (Stage 2), which hasn't run for this project.`}),a.truncated&&(0,Y.jsxs)(`p`,{className:`small muted`,children:[`The first `,Hw(a.packages.length,`package`),`.`]})]}),d.length>0&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`outline-source`,title:`Third-party code copied into the project (plan D66)`,children:[`Copied into the project `,(0,Y.jsx)(`small`,{className:`muted`,children:d.length})]}),(0,Y.jsx)(`ul`,{children:d.map(e=>(0,Y.jsxs)(`li`,{className:`library-row`,"data-testid":`library-copied`,title:`${m(e)}: ${Gw[e.why]}${e.names.length?` (${e.names.join(`, `)})`:``}. ${e.state===`kept`?`Kept: analyzed as the project's own code.`:`Not decided: counted apart from own code until you keep it or leave it out.`}`,children:[(0,Y.jsxs)(`span`,{className:`name`,children:[m(e),e.kind===`dir`?`/`:``]}),(0,Y.jsx)(`small`,{className:`tag${e.state===`pending`?` warn`:``}`,children:e.state===`kept`?`kept`:`not decided`}),(0,Y.jsx)(`small`,{className:`count`,children:e.files})]},`${e.source}|${e.path}`))})]}),f.length>0&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`outline-source`,title:`Library folders left out by default (plan D36, D57); Choose files… analyzes them`,children:[`Left out by default `,(0,Y.jsx)(`small`,{className:`muted`,children:f.length})]}),(0,Y.jsx)(`ul`,{children:f.map(e=>(0,Y.jsxs)(`li`,{className:`library-row`,"data-testid":`library-left-out`,title:`${m(e)}/: ${e.files===null?`not read`:Hw(e.files,`file`)}, not analyzed`,children:[(0,Y.jsxs)(`span`,{className:`name`,children:[m(e),`/`]}),(0,Y.jsx)(`small`,{className:`count`,children:e.files??`–`})]},`${e.source}|${e.path}`))})]})]})}var Yw=24,Xw=12,Zw=300,Qw=new Set([`apps`,`packages`,`services`,`libs`,`modules`,`crates`,`projects`]),$w=/(^|\/)([\w-]+\.config\.[cm]?[jt]sx?|\.?[\w-]*rc\.[cm]?[jt]s|(vite|vitest|jest|webpack|rollup|babel|eslint|prettier|tailwind|postcss|playwright|next|nuxt|svelte|astro|tsup|knip|commitlint|stylelint)\.[\w.-]*[cm]?[jt]s)$/i;function eT(e){return h(e)?`tests`:$w.test(e)?`config`:`source`}var tT=e=>e.status!==`analyzed`,nT={"parse-failure":`could not be parsed`,"declaration-file":`type declarations`,"language-not-analyzed":`language not analyzed yet`,"too-large":`too large`,binary:`not text`,minified:`minified`,"invalid-utf8":`not UTF-8 text`,unreadable:`could not be read`,entitlement:`beyond the license`,frozen:`kept from an earlier analysis (beyond the license)`},rT={degraded:`partly analyzed`,not_analyzed:`not analyzed`,parse_error:`could not be parsed`},iT=(e,t)=>e<t?-1:+(e>t);function aT(e,t,n){let r={key:``,name:``,dirs:new Map,files:[],total:0,functions:0};for(let i of e){let e=(n?`${i.source}/${i.path}`:i.path).split(`/`);e.pop();let a=r,o=t[i.id]?.functions??0;a.total++,a.functions+=o;let s=``;for(let t of e){s=s?`${s}/${t}`:t;let e=a.dirs.get(t);e||(e={key:s,name:t,dirs:new Map,files:[],total:0,functions:0},a.dirs.set(t,e)),a=e,a.total++,a.functions+=o}a.files.push(i)}return r}function oT(e,t=!1,n=0){for(let[r,i]of e.dirs)e.dirs.set(r,oT(i,t,n+1));if(e.key!==``&&!(t&&n===1)&&e.files.length===0&&e.dirs.size===1){let t=[...e.dirs.values()][0];return{...t,name:`${e.name}/${t.name}`}}return e}function sT(e,t,n){let r=[],i=(e,a)=>{let o=[...e.dirs.values()].sort((e,t)=>{if(a===0){let n=+!Qw.has(e.name.split(`/`)[0]),r=+!Qw.has(t.name.split(`/`)[0]);if(n!==r)return n-r}return iT(e.name,t.name)});for(let e of o){let n=t.has(e.key);r.push({type:`dir`,key:e.key,name:e.name,depth:a,open:n,total:e.total,functions:e.functions}),n&&i(e,a+1)}for(let t of[...e.files].sort((e,t)=>iT(e.path,t.path))){let e=n[t.id];r.push({type:`file`,file:t,depth:a,label:t.path.slice(t.path.lastIndexOf(`/`)+1),...e?{hint:`${e.functions}ƒ`}:{}})}};return i(e,0),r}var cT=60;function lT(e,t){let n=new Set,r=e=>{for(let t of e.dirs.values())n.add(t.key),r(t)};if(t<=cT)return r(e),n;for(let t of e.dirs.values())if(n.add(t.key),Qw.has(t.name.split(`/`).pop())||Qw.has(t.name.split(`/`)[0]))for(let e of t.dirs.values())n.add(e.key);return n}var uT=e=>`veoflow.tree.${e}`;function dT(e){try{let t=localStorage.getItem(uT(e)),n=t?JSON.parse(t):[];return n.length>0?new Set(n):null}catch{return null}}function fT(e,t){try{localStorage.setItem(uT(e),JSON.stringify([...t]))}catch{}}function pT({project:e,files:t,counts:n,current:r,onOpen:i,run:a=null,onAnalyze:o,sources:s=[],scope:c=null,onScope:l,onCollapse:u,onImports:d,onMenu:f,hidden:p=!1,onReveal:m}){let[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)({source:!0,tests:!1,config:!0}),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),E=(0,y.useRef)(null);a?.status===`committed`&&(E.current=a.runId);let[D,O]=(0,y.useState)(new Set),[k,A]=(0,y.useState)(0),[j,M]=(0,y.useState)(600),[N,P]=(0,y.useState)(0),F=(0,y.useRef)(null),I=(0,y.useRef)(null),L=t;t=(0,y.useMemo)(()=>c?L.filter(e=>e.source===c):L,[L,c]);let R=(0,y.useMemo)(()=>s.length>1||new Set(L.map(e=>e.source)).size>1,[L,s.length]),z=(0,y.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),B=e=>{let t=z.get(e)?.analysis;return t?t.kind===`git`?`${t.branch??`detached`} · ${t.revision.slice(0,7)} · ${we(t.analyzedAt)}`:`plain folder · latest only`:``},V=(0,y.useMemo)(()=>{let e={source:0,tests:0,config:0,attention:0};for(let n of t)e[eT(n.path)]++,tT(n)&&e.attention++;return e},[t]),H=(0,y.useMemo)(()=>t.filter(e=>S?tT(e):e.id===r||b[eT(e.path)]||tT(e)),[t,b,S,r]),U=(0,y.useMemo)(()=>{let e=oT(aT(H,n,R),R);return c&&R?e.dirs.get(c)??{...e,dirs:new Map,files:[]}:e},[H,n,R,c]),W=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!W.current&&e&&t.length!==0&&(W.current=!0,O(dT(e)??lT(U,t.length)))},[e,t,U]);let ee=t.find(e=>e.id===r);(0,y.useEffect)(()=>{if(!ee)return;let e=(R?`${ee.source}/${ee.path}`:ee.path).split(`/`);e.pop(),O(t=>{let n=new Set(t),r=``,i=!1;for(let t of e)r=r?`${r}/${t}`:t,n.has(r)||(n.add(r),i=!0);return i?n:t})},[ee?.id]);let G=(0,y.useMemo)(()=>{let e=_.trim().toLowerCase();return e?t.map(t=>{let n=t.path.toLowerCase(),r=n.slice(n.lastIndexOf(`/`)+1);return{f:t,rank:r.replace(/\.[^.]+$/,``)===e||r===e?0:r.startsWith(e)?1:r.includes(e)?2:n.includes(e)?3:-1,kind:eT(t.path)===`source`?0:1}}).filter(e=>e.rank>=0).sort((e,t)=>e.rank-t.rank||e.kind-t.kind||e.f.path.length-t.f.path.length||iT(e.f.path,t.f.path)).slice(0,Zw).map(({f:e})=>{let t=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``,n=R?z.get(e.source)?.name??e.source:``;return{type:`file`,file:e,depth:0,label:e.path.slice(e.path.lastIndexOf(`/`)+1),hint:[n,t].filter(Boolean).join(` · `)}}):sT(U,D,n)},[_,U,D,n,t,R,z]);(0,y.useEffect)(()=>{W.current&&e&&fT(e,D)},[D,e]),(0,y.useEffect)(()=>{N>=G.length&&P(Math.max(0,G.length-1))},[G.length,N]),(0,y.useEffect)(()=>{let e=F.current;if(!e)return;let t=new ResizeObserver(()=>M(e.clientHeight));return t.observe(e),()=>t.disconnect()},[]);let te=(0,y.useRef)(null),K=_.trim()!==``;(0,y.useEffect)(()=>{if(p)return;let e=r?`${r}\0${K}`:null;if(!r||te.current===e)return;let t=G.findIndex(e=>e.type===`file`&&e.file.id===r);if(t<0||!F.current)return;te.current=e;let n=t*Yw,i=F.current;(n<i.scrollTop||n+Yw>i.scrollTop+i.clientHeight)&&(i.scrollTop=Math.max(0,n-i.clientHeight/3),A(i.scrollTop)),P(t)},[r,G,K,p]),(0,y.useLayoutEffect)(()=>{!p&&F.current&&A(F.current.scrollTop)},[p]);let q=(0,y.useRef)(p);q.current=p;let ne=(0,y.useRef)(m);ne.current=m,(0,y.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`p`){if(document.querySelector(`[role="dialog"], [role="menu"]`))return;e.preventDefault(),q.current&&ne.current?.(),setTimeout(()=>{I.current?.focus(),I.current?.select()},0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let J=e=>O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),re=e=>{let t=Math.max(0,Math.min(G.length-1,e)),n=F.current;if(n){let e=t*Yw,r=n.scrollTop;e<r?r=e:e+Yw>r+n.clientHeight&&(r=e+Yw-n.clientHeight),n.scrollTop=r,(0,Vw.flushSync)(()=>{A(r),P(t)})}else P(t);F.current?.querySelector(`[data-row="${t}"]`)?.focus({preventScroll:!0})},ie=e=>{let t=G[e]?.depth??0;for(let n=e-1;n>=0;n--)if(G[n].type===`dir`&&G[n].depth<t)return n;return-1},ae=e=>{let t=G[N];if(e.key===`ArrowDown`)re(N+1);else if(e.key===`ArrowUp`)re(N-1);else if(e.key===`Home`)re(0);else if(e.key===`End`)re(G.length-1);else if(e.key===`ArrowRight`&&t?.type===`dir`)t.open?re(N+1):J(t.key);else if(e.key===`ArrowLeft`){if(t?.type===`dir`&&t.open)J(t.key);else{let e=ie(N);e>=0&&re(e)}}else return;e.preventDefault()},oe=Math.max(0,Math.floor(k/Yw)-Xw),se=Math.min(G.length,Math.ceil((k+j)/Yw)+Xw),ce=(e,t)=>V[e]===0?null:(0,Y.jsxs)(`button`,{className:`chip`,"aria-pressed":!S&&!w&&b[e],"data-testid":`chip-${e}`,disabled:V[e]===0,onClick:()=>{C(!1),w?(T(!1),x(t=>({...t,[e]:!0}))):x(t=>({...t,[e]:!t[e]}))},children:[t,` `,(0,Y.jsx)(`small`,{children:V[e]})]}),le=(0,y.useMemo)(()=>{let e=0,t=0;for(let n of a?.sources??[])e+=n.defaultExcluded?.length??0,t+=(n.ruleExcluded?.length??0)+(n.ruleExcludedMore??0);return{folders:e,paths:t}},[a]);return h&&e?(0,Y.jsx)(`nav`,{className:`nav`,"aria-label":`Files`,hidden:p,children:(0,Y.jsx)(eC,{project:e,files:t,run:a,onAnalyze:()=>{o?.(),g(!1)},onClose:()=>g(!1)})}):(0,Y.jsxs)(`nav`,{className:`nav`,"aria-label":`Files`,hidden:p,children:[(0,Y.jsxs)(`div`,{className:`nav-head`,children:[(s.length>1||c)&&(0,Y.jsxs)(`label`,{className:`nav-scope`,children:[(0,Y.jsx)(`span`,{className:`small muted`,children:`Scope`}),(0,Y.jsxs)(`select`,{"data-command":`scope-source`,value:c??``,onChange:e=>l?.(e.target.value||null),children:[(0,Y.jsx)(`option`,{value:``,children:`All repositories`}),s.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`outline-head`,children:[(0,Y.jsx)(`input`,{ref:I,className:`nav-filter`,"data-testid":`file-filter`,type:`search`,placeholder:w?`Filter libraries…`:`Filter ${t.length} files… ⌘P`,"aria-label":w?`Filter libraries`:`Filter files`,value:_,onChange:e=>{v(e.target.value),F.current&&(F.current.scrollTop=0),P(0)},onKeyDown:e=>{if(e.key===`Enter`&&_.trim()&&!w){let e=G.find(e=>e.type===`file`);e?.type===`file`&&i(e.file.id)}else e.key===`ArrowDown`?(e.preventDefault(),w?F.current?.parentElement?.querySelector(`.libraries button, [data-testid="library-package"]`)?.focus():re(0)):e.key===`Escape`&&v(``)}}),u&&(0,Y.jsx)(`button`,{className:`icon`,title:`Hide this pane ( [ )`,"aria-label":`Hide the files pane`,onClick:u,children:`⟨`})]}),(0,Y.jsxs)(`div`,{className:`nav-chips`,role:`group`,"aria-label":`Show`,children:[ce(`source`,`Source`),ce(`tests`,`Tests`),ce(`config`,`Config`),V.attention>0&&(0,Y.jsxs)(`button`,{className:`chip attention`,"aria-pressed":S&&!w,"data-testid":`chip-attention`,title:`Files that were not fully analyzed`,onClick:()=>{C(e=>w||!e),T(!1)},children:[`⚠ `,(0,Y.jsx)(`small`,{children:V.attention})]}),e&&(t.length>0||w)&&(0,Y.jsx)(`button`,{className:`chip`,"aria-pressed":w,"data-testid":`chip-libraries`,title:`The libraries the project uses: installed packages, copied libraries, and folders left out`,onClick:()=>{C(!1),T(e=>!e)},children:`Libraries`})]})]}),w&&e&&(0,Y.jsx)(`div`,{className:`nav-list`,children:(0,Y.jsx)(Jw,{project:e,run:E.current,source:c,filter:_,onOpen:i})}),(0,Y.jsxs)(`div`,{className:`nav-list`,hidden:w&&!!e,ref:F,role:`tree`,"aria-label":`Files`,onScroll:e=>A(e.currentTarget.scrollTop),onKeyDown:ae,children:[G.length===0&&t.length>0&&(0,Y.jsx)(`p`,{className:`hint`,children:`No files match.`}),(0,Y.jsx)(`div`,{style:{height:G.length*Yw,position:`relative`},children:G.slice(oe,se).map((e,t)=>{let n=oe+t,a={top:n*Yw,paddingLeft:8+e.depth*14};if(e.type===`dir`&&R&&!c&&e.depth===0&&z.has(e.key))return(0,Y.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":1,"aria-setsize":G.length,"aria-posinset":n+1,tabIndex:n===N?0:-1,className:`row dir repo`,"data-testid":`repo-row`,"data-source":e.key,style:a,title:z.get(e.key)?.root??e.key,onClick:()=>{P(n),J(e.key)},children:[(0,Y.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,Y.jsx)(`strong`,{className:`name`,children:z.get(e.key)?.name??e.key}),(0,Y.jsx)(`small`,{className:`muted repo-hint`,children:B(e.key)}),(0,Y.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`r:${e.key}`);if(e.type===`dir`)return(0,Y.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":e.depth+1,"aria-setsize":G.length,"aria-posinset":n+1,tabIndex:n===N?0:-1,className:`row dir`,style:a,title:e.key,onClick:()=>{P(n),J(e.key)},children:[(0,Y.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,Y.jsx)(`span`,{className:`name`,children:e.name}),(0,Y.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`d:${e.key}`);let o=e.file;return[(0,Y.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-level":e.depth+1,"aria-setsize":G.length,"aria-posinset":n+1,"aria-selected":o.id===r,tabIndex:n===N?0:-1,"data-command":`open-file`,"data-file":o.path,className:`row file ${o.id===r?`current`:``} ${o.status}`,style:a,title:o.status===`analyzed`?o.path:`${o.path}: ${rT[o.status]??o.status}${o.reason?` (${nT[o.reason]??o.reason})`:``}`,onClick:()=>{P(n),i(o.id)},onContextMenu:f&&(e=>{e.preventDefault(),f({kind:`file`,id:o.id,data:{},x:e.clientX,y:e.clientY})}),children:[(0,Y.jsx)(`span`,{className:`caret`}),(0,Y.jsxs)(`span`,{className:`name`,children:[e.label,_.trim()&&e.hint?(0,Y.jsxs)(`small`,{className:`muted`,children:[` `,e.hint]}):null]}),o.origin&&(0,Y.jsx)(`small`,{className:`origin ${o.origin}`,title:o.origin===`library`?`Installed library code, not the project's own`:o.origin===`tool`?`A tool's or coding agent's workspace, not the project's own code`:`Generated output, not the project's own code`,children:o.origin}),tT(o)?(0,Y.jsxs)(`small`,{className:`warn`,"aria-label":`${rT[o.status]??o.status}${o.reason?`: ${nT[o.reason]??o.reason}`:``}`,children:[`⚠ `,nT[o.reason??``]??o.reason??o.status]}):!_.trim()&&e.hint&&(0,Y.jsx)(`small`,{className:`count`,children:e.hint})]},`f:${o.id}`),d&&o.status!==`not_analyzed`&&(0,Y.jsx)(`button`,{className:`row-action`,"aria-hidden":`true`,"data-command":`file-imports`,"data-file":o.path,style:{top:n*Yw},tabIndex:-1,title:`Imports of ${e.label}: what it imports and what depends on it (Imports tab)`,onClick:()=>d(o.id),children:`⇄`},`i:${o.id}`)]})})]}),e&&o&&(0,Y.jsxs)(`div`,{className:`nav-foot`,children:[(0,Y.jsx)(`small`,{className:`muted`,"data-testid":`left-out`,children:le.folders+le.paths===0?``:`Left out: ${[le.folders?`${le.folders} by default (libraries, generated, tools)`:``,le.paths?`${le.paths} by your choice`:``].filter(Boolean).join(`, `)}`}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{"data-testid":`choose-files`,onClick:()=>g(!0),title:`Choose which files are analyzed`,children:`Choose files…`})]})]})}q_.use(qx);function mT(e){try{return hT(e)}catch{return gT(e)}}function hT(e){let t=q_({headless:!0,styleEnabled:!0,elements:[...e.nodes.map(e=>({data:{id:e.id,w:e.w,h:e.h}})),...e.edges.map(e=>({data:{id:e.id,source:e.source,target:e.target}}))],style:[{selector:`node`,style:{width:`data(w)`,height:`data(h)`}}]}),n=e=>t.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1,animate:!1}).run();try{n(`LR`);let r=t.elements().boundingBox(),{w:i,h:a}=e.canvas;r.w*e.fitZoom>i-2*e.pad&&r.w/Math.max(1,r.h)>i/a&&n(`TB`)}catch(e){throw t.destroy(),e}let r={};for(let e of t.nodes().toArray())r[e.id()]={...e.position()};return t.destroy(),r}function gT(e){let t=Math.max(1,Math.ceil(Math.sqrt(e.nodes.length))),n=Math.max(40,...e.nodes.map(e=>e.w))+24,r={};return e.nodes.forEach((e,i)=>{r[e.id]={x:i%t*n,y:Math.floor(i/t)*40}}),r}var _T=null,vT=typeof Worker>`u`,yT=0,bT=new Map,xT=e=>new Promise(t=>setTimeout(()=>t(mT(e)),0));function ST(){try{let e=new Worker(new URL(`/assets/callLayout.worker-BugXMtxI.js`,``+import.meta.url),{type:`module`});return e.addEventListener(`message`,e=>{let t=bT.get(e.data.id);t&&(bT.delete(e.data.id),e.data.error===void 0?t.resolve(e.data.positions):(console.error(`veoflow: laying out this graph failed; placed in a grid`,e.data.error),t.resolve(gT(t.input))))}),e.addEventListener(`error`,t=>{console.error(`veoflow: the layout worker failed; laying out on the page instead`,t),vT=!0,e.terminate(),_T=null;for(let[e,t]of bT)bT.delete(e),xT(t.input).then(t.resolve)}),e}catch{return vT=!0,null}}function CT(e){if(bT.size>0&&_T&&(_T.terminate(),_T=null,bT.clear()),!vT&&!_T&&(_T=ST()),!_T)return xT(e);let t=++yT;return new Promise(n=>{bT.set(t,{input:e,resolve:n}),_T.postMessage({id:t,input:e})})}var wT=2,TT=40,ET=25,DT=7;function OT(e){let t=AT.get(e);if(t)return t;let n=kT(e),r=new Set(e.calls.map(e=>`${e.from}\u0000${e.to}`)),i=[];for(let t of e.functions){let e=n.get(t.id);e&&e!==t.id&&!r.has(`${e}\u0000${t.id}`)&&i.push({id:`inside:${t.id}`,parent:e,child:t.id})}return AT.set(e,i),i}function kT(e){let t=new Map(e.functions.map(e=>[e.qualifiedName,e.id])),n=new Set(t.keys()),r=new Map;for(let i of e.functions){let e=ve(i.qualifiedName,n),a=e===null?void 0:t.get(e);a&&r.set(i.id,a)}return r}var AT=new WeakMap;function jT(e,t,n=null){let r=new Map,i=(e,t)=>{e!==t&&(r.has(e)||r.set(e,new Set),r.get(e).add(t))};for(let t of e.calls)i(t.from,t.to),i(t.to,t.from);for(let{parent:t,child:n}of OT(e))i(t,n),i(n,t);let a=e=>r.get(e)?.size??0,o=(e,t)=>[...e].sort((e,t)=>a(t)-a(e)||(e<t?-1:1)).slice(0,t),s=new Set(e.functions.map(e=>e.id));if(n&&s.has(n[0])&&s.has(n[1])){let e=new Set(n);for(let t of n)for(let n of o(r.get(t)??[],DT))e.add(n);return e}if(t&&s.has(t)){let e=new Set([t]),n=o(r.get(t)??[],ET);for(let t of n)e.add(t);for(let t=1;t<wT&&e.size<TT;t++)for(let t of n)for(let n of o(r.get(t)??[],5))e.size<TT&&e.add(n);return e}return new Set(o(s,TT))}var MT=e=>`site:${e}`,NT=(e,t)=>`pair:${e}->${t}`;q_.use(qx);var PT=.85,FT=1.25,IT=45,LT=.68,RT=4,zT=36,BT=e=>Math.max(36,String(e.data(`label`)).length*7+18);function VT(e){let t=e.nodes(`[kind = "function"], [kind = "port"], [kind = "ghost"]`).not(`.hidden`),n=`[kind = "call"], [kind = "ghost-call"], [kind = "inside"]`,r=e.edges(n).not(`.hidden`),i=t.filter(e=>e.connectedEdges(n).not(`.hidden`).empty());return{fns:t,isolated:i,connected:t.difference(i).union(r)}}var HT=300;function UT(e){let{connected:t}=VT(e);return{nodes:t.nodes().toArray().map(e=>({id:e.id(),w:e.outerWidth(),h:e.outerHeight()})),edges:t.edges().map(e=>({id:e.id(),source:e.source().id(),target:e.target().id()})),canvas:{w:Math.max(1,e.width()),h:Math.max(1,e.height())},fitZoom:LT,pad:zT}}function WT(e,t){let{fns:n,isolated:r,connected:i}=VT(e),a=e=>i.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1}).run(),o={w:Math.max(1,e.width()),h:Math.max(1,e.height())};if(t)e.batch(()=>{for(let e of i.nodes().toArray()){let n=t[e.id()];n&&e.position(n)}});else if(i.nonempty()){a(`LR`);let e=i.boundingBox();e.w*LT>o.w-72&&e.w/Math.max(1,e.h)>o.w/o.h&&a(`TB`)}let s=r.toArray(),c=i.nonempty()?i.boundingBox():{x1:0,y1:0,x2:0,y2:0,w:0,h:0},l=i.nonempty()?c.y2+48:0,u=Math.max(0,...s.map(e=>BT(e)))+24,d=Math.max(RT,Math.floor(Math.max(c.w,o.w/PT-72)/u));s.forEach((e,t)=>{e.position({x:c.x1+t%d*u+u/2,y:l+Math.floor(t/d)*34})});for(let e of n.toArray()){let t=e.outgoers(`node[kind = "site"]`).not(`.hidden`).toArray();if(t.length===0)continue;let n=e.position(),r=n.x+BT(e)/2+48;t.forEach((e,i)=>e.position({x:r+BT(e)/2,y:n.y+(i-(t.length-1)/2)*26}))}}function GT(e,t){if(t.empty())return;e.fit(t,zT);let n=e.zoom(),r=t.nodes().length<=IT?LT:PT;if(n>FT)e.zoom(FT),e.center(t);else if(n<r){let n=t.boundingBox();e.zoom(r),e.pan({x:zT-n.x1*r,y:zT-n.y1*r})}}function KT(e,t){if(t.edges().nonempty()||t.nodes(`[kind = "site"]`).nonempty()){GT(e,t.union(t.edges().connectedNodes()).union(t.nodes().incomers(`node`)));return}let n=t,r=n.renderedBoundingBox(),i=e.width(),a=e.height();r.x1>=0&&r.y1>=0&&r.x2<=i&&r.y2<=a||e.animate({center:{eles:n}},{duration:250})}function qT({graph:e,showUnresolved:t,selection:n,onSelect:r,onClear:i,focus:a,sitesFor:o,answered:s,marks:c,only:l=null,onContext:u,extraSite:d=null}){let f=(0,y.useRef)(null),m=(0,y.useRef)(null),h=Je();(0,y.useEffect)(()=>{m.current?.style(JT())},[h]);let g=(0,y.useRef)(l);g.current=l;let _=(0,y.useRef)(u);_.current=u,(0,y.useEffect)(()=>{m.current&&Ke(m.current,l)},[l]);let v=(0,y.useRef)(0),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(0);(0,y.useEffect)(()=>{let n=new Set(e.functions.map(e=>e.id)),a=new Map;for(let t of e.calls){if(!t.crossFile)continue;let e=n.has(t.from)?t.to:t.from;if(n.has(e)||a.has(e))continue;let r=t.function.path.split(`/`).pop()??t.function.path;a.set(e,`${r} › ${oe(t.function.qualifiedName,void 0,t.function.title).name}`)}for(let e of a.keys())n.add(e);let o=new Set(e.calls.filter(e=>e.from===e.to).map(e=>e.from)),s=new Map;for(let t of e.calls){if(t.from===t.to||!n.has(t.from)||!n.has(t.to))continue;let e=NT(t.from,t.to),r=s.get(e);r?r.calls.push(t.id):s.set(e,{from:t.from,to:t.to,calls:[t.id]})}let c=e.functions.map(e=>{let t=be(e);return t.unnamed?`λ ${t.name}`:t.name}),l=new Map(e.functions.map(e=>[e.id,e.qualifiedName])),u=new Map(e.functions.map(e=>[e.id,e])),h=OT(e),v=kT(e),y=e=>{let t=v.get(e);return t===void 0?null:l.get(t)??null},b=new Set(c.filter((e,t)=>c.indexOf(e)!==t)),x=[...e.functions.map((e,t)=>{let n=c[t],r=b.has(n)&&!n.includes(`· line`)?`${n} · line ${e.evidence.span.start.line}`:n,i=ye(e.qualifiedName,e.code,e.evidence.span.start.line,y(e.id));return{data:{id:e.id,label:o.has(e.id)?`${r} ↻`:r,kind:`function`,...i?{hover:i}:{}},classes:e.qualifiedName===`<module>`?`module`:be(e).unnamed?`unnamed`:``}}),...[...a].map(([e,t])=>({data:{id:e,label:t,kind:`port`},classes:`port`})),...h.map(e=>{let t=l.get(e.parent)??``,n=u.get(e.child),r=n?_e(n.qualifiedName,n.code,n.title)??se(n.qualifiedName):``;return{data:{id:e.id,source:e.parent,target:e.child,kind:`inside`,label:``,hover:`${r} is written inside ${t===`<module>`?`the file's top level`:se(t)}. A dotted line shows where a function is written, not a call.`},classes:`inside`}}),...[...s].map(([e,t])=>({data:{id:e,source:t.from,target:t.to,kind:`call`,calls:t.calls,label:t.calls.length>1?`×${t.calls.length}`:``}}))];if(t||d){let r=new Map;for(let i of e.unresolved){if(!n.has(i.enclosingFn)||!(t&&p(i))&&i.id!==d)continue;let e=`${i.enclosingFn}\u0000${i.expression}\u0000${i.status}`,a=r.get(e);a?a.ids.push(i.id):r.set(e,{fn:i.enclosingFn,expression:i.expression,ids:[i.id],status:i.status})}for(let e of r.values()){let t=MT(e.ids[0]),n=e.expression.length>40?`${e.expression.slice(0,39)}…`:e.expression;x.push({data:{id:t,label:e.ids.length>1?`${n} ×${e.ids.length}`:n,kind:`site`,ids:e.ids},classes:`site ${e.status}`},{data:{id:`edge:${t}`,source:e.fn,target:t,kind:`site-edge`,label:``},classes:`site-edge`})}}let S=q_({container:f.current,elements:x,autounselectify:!0,layout:{name:`preset`},minZoom:.15,maxZoom:3,style:JT()});return S.on(`tap`,`node, edge`,e=>{let t=e.target.data(`kind`),n=e.target.id();t===`function`?r({kind:`function`,id:n}):t===`inside`?r({kind:`function`,id:e.target.target().id()}):t===`call`?r({kind:`call`,id:e.target.data(`calls`)[0]}):t===`site`&&r({kind:`site`,id:e.target.data(`ids`)[0]})}),S.on(`tap`,e=>{e.target===S&&i()}),S.on(`mouseover`,`node, edge`,e=>{let t=e.target.data(`hover`),n=e.renderedPosition??e.target.renderedMidpoint?.()??{x:0,y:0};C(t?{text:t,x:n.x,y:n.y}:null)}),S.on(`mouseout`,`node, edge`,()=>C(null)),S.on(`pan zoom drag remove`,()=>C(null)),m.current=S,Ke(S,g.current),S.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`call`?`edge`:null;if(!n||!f.current)return;let r=f.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};_.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),f.current&&(f.current.veoCy=S),()=>{m.current=null,C(null),S.destroy()}},[e,t,r,i,d]);let E=(c?.removed??[]).filter(t=>t.file===e.file.id&&(t.type===`Function`||t.type===`CALLS`)).map(e=>e.id).join(`
339
339
  `);(0,y.useEffect)(()=>{let t=m.current;t&&t.batch(()=>{if(t.elements(`.ghost`).remove(),t.elements().removeClass(`diff-added diff-removed diff-changed`),!c)return;t.nodes(`[kind = "function"]`).forEach(e=>{let t=c.byId.get(e.id());t&&e.addClass(Xe(t))}),t.edges(`[kind = "call"]`).forEach(e=>{let t=e.data(`calls`).map(e=>c.byId.get(e)).find(Boolean);t&&e.addClass(Xe(t))});let n=new Set(t.nodes().map(e=>e.id())),r=new Set,i=[];for(let t of c.removed){if(t.type!==`Function`||t.file!==e.file.id||n.has(t.id))continue;let a=t.fact;r.add(t.id),i.push({data:{id:t.id,label:`${a.qualifiedName??a.name??t.id} (removed)`,kind:`ghost`},classes:`diff-removed ghost`})}for(let e of c.removed){if(e.type!==`CALLS`)continue;let t=e.fact,a=e=>!!e&&(n.has(e)||r.has(e));a(t.from)&&a(t.to)&&t.from!==t.to&&i.push({data:{id:`gone:${e.id}`,source:t.from,target:t.to,kind:`ghost-call`,label:``},classes:`diff-removed ghost`})}i.length&&t.add(i)})},[c,e,t,d]);let D=a?o:null;return(0,y.useEffect)(()=>{let e=m.current;if(!e)return;e.batch(()=>{if(e.elements().removeClass(`hidden`),a){let t=e.nodes().filter(e=>e.data(`kind`)===`function`?!a.has(e.id()):e.incomers(`node`).first().id()!==D);t.addClass(`hidden`),t.connectedEdges().addClass(`hidden`)}});let t=++v.current;if(VT(e).connected.nodes().length<=HT){WT(e),GT(e,e.elements().not(`.hidden`)),g.current&&Ke(e,g.current),x(!1);return}x(!0),CT(UT(e)).then(n=>{t===v.current&&m.current===e&&(WT(e,n),GT(e,e.elements().not(`.hidden`)),g.current&&Ke(e,g.current),x(!1),T(e=>e+1))})},[a,e,t,D,E,d]),(0,y.useEffect)(()=>{let t=m.current;if(!t||(t.batch(()=>{t.elements().removeClass(`picked faded`)}),f.current?.setAttribute(`data-picked`,``),!n))return;let r=n.kind===`site`?t.nodes(`[kind = "site"]`).filter(e=>e.data(`ids`).includes(n.id)):t.getElementById(n.id);if(r.empty()&&n.kind===`call`&&(r=t.edges().filter(e=>(e.data(`calls`)??[]).includes(n.id)),r.empty())){let i=e.calls.find(e=>e.id===n.id);i&&(r=t.getElementById(i.from))}if(r.empty())return;f.current?.setAttribute(`data-picked`,`${n.kind}:${n.id}`);let i=r.union(r.nodes().closedNeighborhood()).union(r.edges().connectedNodes());t.batch(()=>{r.addClass(`picked`),a||t.elements().not(i).addClass(`faded`)}),KT(t,r)},[n,e,t,a,w,d]),(0,y.useEffect)(()=>{let e=m.current;e&&e.batch(()=>{e.nodes().removeClass(`answered`),s&&e.nodes().filter(e=>s.has(e.id())).addClass(`answered`)})},[s,e,t,a,d]),(0,Y.jsxs)(`div`,{className:`graph-wrap`,children:[(0,Y.jsx)(`div`,{className:`graph`,ref:f,"data-testid":`graph`,"data-laying-out":b||void 0}),b&&(0,Y.jsx)(`div`,{className:`laying-out`,children:`Laying out…`}),S&&(0,Y.jsx)(`div`,{className:`graph-hover`,role:`tooltip`,"data-testid":`graph-hover`,style:{left:S.x+12,top:S.y+12},children:S.text}),(0,Y.jsxs)(`details`,{className:`graph-key`,"data-testid":`graph-key`,children:[(0,Y.jsx)(`summary`,{children:`Key`}),(0,Y.jsxs)(`ul`,{children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node`}),(0,Y.jsx)(`span`,{children:`a function`})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node unnamed`,children:`λ`}),(0,Y.jsxs)(`span`,{children:[`a function with no name in the code, shown as its code: `,(0,Y.jsx)(`code`,{children:`.map(l => …)`}),` is the arrow function handed to `,(0,Y.jsx)(`code`,{children:`.map()`})]})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-node module`}),(0,Y.jsx)(`span`,{children:`the file's top level: what runs when the file is loaded`})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line call`}),(0,Y.jsx)(`span`,{children:`calls (×2: two call sites)`})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line inside`}),(0,Y.jsx)(`span`,{children:`written inside: where a function is written, not a call`})]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`key-line site`}),(0,Y.jsx)(`span`,{children:`a call the analysis couldn't tie to a function here`})]})]})]}),(0,Y.jsx)(`button`,{className:`fit`,title:`Fit the graph to the view`,"aria-label":`Fit the graph to the view`,onClick:()=>{let e=m.current;e&&GT(e,e.elements().not(`.hidden`))},children:`Fit`})]})}function JT(){return[{selector:`node`,style:{label:`data(label)`,"font-size":12,"text-valign":`center`,"text-halign":`center`,shape:`round-rectangle`,width:BT,height:22,"background-color":X(`gray-95`),"border-width":1,"border-color":X(`blue-62`),color:X(`gray-26`)}},{selector:`node.module`,style:{"background-color":X(`gray-95-2`),"border-color":X(`gray-66`),"font-weight":`bold`}},{selector:`node.unnamed`,style:{"font-style":`italic`,"background-color":X(`gray-96-7`),"border-color":X(`purple-66`),"border-style":`dashed`}},{selector:`node.port`,style:{"background-color":X(`gray-100`),"border-style":`dashed`,"border-color":X(`blue-63`),color:X(`gray-45`)}},{selector:`node.site`,style:{"background-color":X(`gray-100`),"border-style":`dashed`,"border-color":X(`orange-64`),color:X(`amber-51`)}},{selector:`node.site.awaiting-link, node.site.external`,style:{"border-color":X(`gray-68`),color:X(`gray-57`)}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"target-arrow-shape":`triangle`,"line-color":X(`blue-72`),"target-arrow-color":X(`blue-72`),label:`data(label)`,"font-size":10,color:X(`gray-51`),"text-background-color":X(`gray-99`),"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.inside`,style:{"line-style":`dotted`,width:1.5,"line-color":X(`purple-70`),"target-arrow-shape":`none`}},{selector:`edge.site-edge`,style:{"line-style":`dashed`,"line-color":X(`amber-74`),"target-arrow-color":X(`amber-74`)}},...Ze(),Ge,{selector:`.hidden`,style:{display:`none`}},{selector:`node.answered`,style:{"border-width":2,"border-color":X(`amber-73`),"background-color":X(`amber-97`)}},{selector:`.faded`,style:{opacity:.22}},{selector:`node.picked`,style:{"border-width":2,"border-color":X(`blue-51`),"background-color":X(`gray-91`)}},{selector:`edge.picked`,style:{"line-color":X(`blue-51`),"target-arrow-color":X(`blue-51`),width:3}}]}var YT=(e,t,n)=>(e.find(e=>e.id===t)?.kept??[]).some(e=>n===e||n.startsWith(`${e}/`)),XT={installed:`installed packages`,packages:`copied packages with their own manifests`,banners:`library banners or versioned names`},ZT=3,QT=(e,t)=>`veoflow.librariesLater.${e}.${t}`,$T=(e,t)=>`veoflow.librariesSeen.${e}.${t}`,eE=e=>{try{return localStorage.getItem(e)===`1`}catch{return!1}};function tE({project:e,run:t,sources:n,onAnalyze:r,onKept:i,onChooseFiles:a}){let[o,s]=(0,y.useState)({}),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(()=>t?eE(QT(e,t.runId)):!1),[f,p]=(0,y.useState)(()=>!t||!eE($T(e,t.runId)));(0,y.useEffect)(()=>{if(t)try{localStorage.setItem($T(e,t.runId),`1`)}catch{}},[e,t?.runId]);let m=(t?.sources??[]).flatMap(e=>(e.libraries??[]).filter(t=>!YT(n,e.sourceId,t.path)).map(t=>({...t,source:e.sourceId}))),h=m.filter(e=>!o[`${e.source}:${e.path}`]),g=Object.values(o).filter(e=>e===`out`).length;if(!t||u||m.length===0||h.length===0&&g===0)return null;let _=async(t,n)=>{l(``);try{await J.select(e,t.source,[t.path],!n,!n),s(e=>({...e,[`${t.source}:${t.path}`]:n?`out`:`kept`})),n||i()}catch(e){l(e.message??String(e))}},v=e=>`${e.toLocaleString(`en-US`)} file${e===1?``:`s`}`,b=()=>{try{localStorage.setItem(QT(e,t.runId),`1`)}catch{}d(!0)};return!f&&h.length>0&&g===0?(0,Y.jsxs)(`section`,{className:`library-offer folded`,"data-testid":`library-offer`,"data-folded":!0,"aria-label":`Third-party libraries`,children:[(0,Y.jsx)(`span`,{children:h.length===1?h[0].kind===`dir`?`${h[0].path}/ looks like ${v(h[0].files)} of third-party libraries`:`${h[0].path} looks like a third-party library`:`${h.length} folders or files look like third-party libraries`}),(0,Y.jsx)(`button`,{className:`link`,"data-testid":`library-review`,onClick:()=>p(!0),children:`Review`}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{className:`link small`,title:`Hide this until the next analysis`,onClick:b,children:`Later`})]}):(0,Y.jsxs)(`section`,{className:`library-offer`,"data-testid":`library-offer`,"aria-label":`Third-party libraries`,children:[h.length>0&&(0,Y.jsx)(`ul`,{children:h.slice(0,ZT).map(e=>(0,Y.jsxs)(`li`,{"data-path":e.path,children:[(0,Y.jsxs)(`span`,{className:`what`,children:[(0,Y.jsxs)(`strong`,{className:`mono`,children:[e.path,e.kind===`dir`?`/`:``]}),` `,`looks like`,` `,e.kind===`dir`?`${v(e.files)} of third-party libraries`:`a third-party library`,` `,(0,Y.jsxs)(`small`,{className:`muted`,children:[`(`,XT[e.why],`: `,e.names.join(`, `),`)`]})]}),(0,Y.jsx)(`button`,{"data-testid":`library-leave-out`,onClick:()=>void _(e,!0),children:`Leave out`}),(0,Y.jsx)(`button`,{className:`quiet`,"data-testid":`library-keep`,title:`Keep analyzing it, and don't offer it again`,onClick:()=>void _(e,!1),children:`Keep analyzing`})]},`${e.source}:${e.path}`))}),(0,Y.jsxs)(`div`,{className:`offer-foot`,children:[h.length>ZT&&(0,Y.jsxs)(`button`,{className:`link`,onClick:()=>a(h[ZT].source),children:[h.length-ZT,` more…`]}),g>0&&(0,Y.jsxs)(`span`,{children:[g,` left out at the next analysis.`,` `,(0,Y.jsx)(`button`,{className:`link`,"data-testid":`library-analyze`,onClick:r,children:`Analyze now`})]}),c&&(0,Y.jsx)(`span`,{className:`error small`,children:c}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{className:`link small`,title:`Hide this until the next analysis`,onClick:b,children:`Later`})]})]})}var nE=e=>/ looks like .*third-party librar/.test(e);function rE({run:e,quiet:t=!1}){let n=e?.sources??[],r=n.flatMap(e=>(e.notices??[]).filter(e=>!nE(e)).map(t=>n.length>1?`${e.sourceId}: ${t}`:t));return r.length?(0,Y.jsx)(`ul`,{className:`run-notices${t?` quiet`:``}`,"data-testid":`run-notices`,"aria-label":`Notes from the analysis`,children:r.map(e=>(0,Y.jsx)(`li`,{children:e},e))}):null}function iE({analysis:e}){let t=e.outdated.every(e=>e.was===null);return(0,Y.jsxs)(`p`,{className:`outdated-note`,"data-testid":`graph-outdated`,children:[t?`This graph was made before veoflow recorded which analysis made it, so it may be older than this version's.`:`This graph was made by ${e.veoflow?`veoflow ${e.veoflow}`:`another veoflow`}; ${e.outdated.map(e=>e.stage).join(`, `)} ${e.outdated.length===1?`has`:`have`} changed since.`,` `,`Analyze again to see what this version finds.`]})}function aE({project:e,files:t,run:n,counts:r,source:i,sources:a,onOpen:o,onQuestions:s}){let[c,l]=(0,y.useState)(null),[u,d]=dS();(0,y.useEffect)(()=>{let t=!1;return J.totals(e,30,i??void 0,!u).then(e=>!t&&l(e),()=>!t&&l(`error`)),()=>{t=!0}},[e,t,i,u,a]);let f=c&&c!==`error`?c:null,p=(0,y.useMemo)(()=>(f?.mostCalled??[]).filter(e=>eT(e.path)===`source`).slice(0,5).map(e=>({key:e.id,name:e.name,count:e.calls})),[f]),m=f?.pendingLibraries,h=(0,y.useMemo)(()=>v(new Map(Object.entries(m??{}))),[m]),g=(0,y.useMemo)(()=>t.filter(e=>(!i||e.id.startsWith(`${i}:`))&&(u||h(e))),[t,i,u,h]),_=(0,y.useMemo)(()=>t.some(e=>!h(e)),[t,h]),b=(0,y.useMemo)(()=>g.reduce((e,t)=>e+(r[t.id]?.functions??0),0),[g,r]),x=(0,y.useMemo)(()=>g.filter(e=>eT(e.path)===`source`&&!e.origin).map(e=>({f:e,n:r[e.id]?.functions??0})).filter(e=>e.n>0).sort((e,t)=>t.n-e.n||(e.f.path<t.f.path?-1:1)).slice(0,5),[g,r]),S=(0,y.useMemo)(()=>new Map(t.map(e=>[e.id,e.path])),[t]),C=(0,y.useMemo)(()=>new Set(g.map(e=>e.id.slice(0,e.id.indexOf(`:`)))).size>1,[g]),w=e=>e.toLocaleString(`en-US`);return(0,Y.jsxs)(`div`,{className:`overview`,"data-testid":`overview`,children:[(0,Y.jsx)(rE,{run:n,quiet:!0}),f?.analysis?.outdated.length?(0,Y.jsx)(iE,{analysis:f.analysis}):null,f?.stage2&&f.completeness.sites>0&&(0,Y.jsxs)(`section`,{className:`paths`,"data-testid":`overview-paths`,children:[(0,Y.jsx)(`strong`,{children:rC(f.completeness)}),(0,Y.jsxs)(`small`,{children:[iC(f.completeness).filter(e=>e.count>0).map(e=>`${w(e.count)} ${e.label}`).join(` · `),f.completeness.openByReason.length>0&&` — they stop: ${f.completeness.openByReason.slice(0,3).map(e=>`${w(e.sites)} ${e.reason}`).join(`, `)}`]})]}),(0,Y.jsxs)(`dl`,{className:`stats`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`files`}),(0,Y.jsx)(`dd`,{children:w(g.length)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`functions`}),(0,Y.jsx)(`dd`,{children:w(b)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`dt`,{children:[`calls`,f?.stage2&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`br`,{}),(0,Y.jsxs)(`small`,{children:[w(f.calls.acrossFiles),` across files`]})]})]}),(0,Y.jsx)(`dd`,{"data-testid":`overview-calls`,children:f?w(f.calls.withinFiles+f.calls.acrossFiles):c===`error`?`?`:`…`})]}),(0,Y.jsxs)(`div`,{className:`muted-stat`,children:[(0,Y.jsxs)(`dt`,{children:[`open calls`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`small`,{children:`calls the analysis couldn't follow`})]}),(0,Y.jsx)(`dd`,{children:(0,Y.jsx)(`button`,{className:`stat-link`,"data-testid":`overview-open-calls`,onClick:s,title:`Show them in Findings (the same count as there)`,children:f?w(f.openCalls):c===`error`?`?`:`…`})})]}),_&&(0,Y.jsxs)(`label`,{className:`toggle stats-scope`,title:`Own code first: tests, installed libraries, generated output and tools' files are counted when this is on`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`overview-all-code`,checked:u,onChange:e=>d(e.target.checked)}),`Libraries and tests too`]})]}),(0,Y.jsxs)(`div`,{className:`columns`,children:[(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{children:`Largest files`}),(0,Y.jsx)(`ul`,{children:x.map(({f:e,n:t})=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link-row`,onClick:()=>o(e.id),title:e.path,children:[(0,Y.jsx)(`span`,{className:`name`,children:C?`${e.id.slice(0,e.id.indexOf(`:`))} › ${e.path}`:e.path}),(0,Y.jsxs)(`small`,{children:[t,` function`,t===1?``:`s`]})]})},e.id))})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{children:`Most called`}),(0,Y.jsx)(`ul`,{children:p.map(e=>{let t=e.key.slice(0,e.key.lastIndexOf(`:`));return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{className:`link-row`,onClick:()=>o(t),title:`${e.name??e.key} in ${S.get(t)??t}`,children:[(0,Y.jsxs)(`span`,{className:`name`,children:[oe(e.name??e.key).name,p.filter(t=>t.name===e.name).length>1&&(0,Y.jsxs)(`small`,{className:`muted`,children:[` `,(S.get(t)??t).split(`/`).pop()]})]}),(0,Y.jsxs)(`small`,{children:[e.count,` call`,e.count===1?``:`s`]})]})},e.key)})})]})]}),(0,Y.jsx)(`p`,{className:`muted small`,children:`Open a file on the left, or ask a question above (⌘K).`})]})}function oE({onClose:e,onSaved:t}){let[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),m=(0,y.useRef)(null);(0,y.useEffect)(()=>{J.settings().then(({model:e})=>{r(e),a(e.baseUrl),s(e.model),setTimeout(()=>m.current?.focus(),0)},e=>d({ok:!1,text:`Could not load the settings: ${e.message??String(e)}`}))},[]),(0,y.useEffect)(()=>{let t=t=>t.key===`Escape`&&e();return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let h=async(e={})=>{p(!0),d(null);try{let{model:n}=await J.saveSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{},...e});return r(n),l(``),t(n),n}catch(e){return d({ok:!1,text:e.message??String(e)}),null}finally{p(!1)}},[g,_]=(0,y.useState)(!1),v=async(t=!1)=>{if(!t&&(c.trim()||n?.apiKeySet)){p(!0),d(null);let e=!1;try{let t=await J.testSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{}});e=t.ok,t.ok||d({ok:!1,text:t.message})}catch(e){d({ok:!1,text:e.message??String(e)})}finally{p(!1)}if(!e){_(!0);return}}await h()&&e()},b=async()=>{p(!0),d(null);try{let e=await J.testSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{}});d({ok:e.ok&&e.toolCalls,text:e.message})}catch(e){d({ok:!1,text:e.message??String(e)})}finally{p(!1)}};return(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:t=>t.target===t.currentTarget&&e(),children:(0,Y.jsxs)(`form`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-testid":`settings-dialog`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,Y.jsx)(`h2`,{id:`settings-title`,children:`Settings`}),(0,Y.jsxs)(`p`,{className:`muted`,children:[`Built-in questions work without a model. To ask anything, connect a model through`,` `,(0,Y.jsx)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noreferrer`,children:`OpenRouter`}),` `,`(or any OpenAI-compatible endpoint) with your own key.`]}),(0,Y.jsxs)(`fieldset`,{disabled:!n,className:`plain`,children:[(0,Y.jsxs)(`label`,{children:[`Model`,(0,Y.jsx)(`input`,{ref:m,"data-testid":`settings-model`,value:o,onChange:e=>s(e.target.value),placeholder:`anthropic/claude-sonnet-5.5`,spellCheck:!1}),(0,Y.jsx)(`small`,{className:`muted`,children:`An OpenRouter model id that supports tool calls.`})]}),(0,Y.jsxs)(`label`,{children:[`API key`,(0,Y.jsx)(`input`,{"data-testid":`settings-key`,type:`password`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),placeholder:n?.apiKeySet?`Saved (…${n.apiKeyHint})${n.keySource===`env`?` from OPENROUTER_API_KEY`:``}`:`sk-or-…`,spellCheck:!1}),(0,Y.jsx)(`small`,{className:`muted`,children:`Stored only on this computer, in the veoflow folder (readable by you only). It is never shown again.`})]}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:`Advanced`}),(0,Y.jsxs)(`label`,{children:[`Base URL`,(0,Y.jsx)(`input`,{"data-testid":`settings-base-url`,value:i,onChange:e=>a(e.target.value),placeholder:`https://openrouter.ai/api/v1`,spellCheck:!1})]})]})]}),(0,Y.jsx)(`p`,{className:`muted small`,children:`When a model answers, your question and the graph data it looks up (names, file paths, line numbers) are sent to the provider. Nothing is sent for built-in questions.`}),u&&(0,Y.jsx)(`p`,{className:u.ok?`ok`:`error`,role:`status`,"data-testid":`settings-status`,children:u.text}),(0,Y.jsxs)(`div`,{className:`buttons`,children:[n?.apiKeySet&&n.keySource===`config`&&(0,Y.jsx)(`button`,{type:`button`,className:`danger`,disabled:f,onClick:()=>void h({apiKey:null}),"data-testid":`settings-remove-key`,children:`Remove key`}),(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{type:`button`,disabled:f||!n,onClick:()=>void b(),"data-testid":`settings-test`,children:`Test connection`}),(0,Y.jsx)(`button`,{type:`button`,onClick:e,children:`Cancel`}),g&&(0,Y.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>void v(!0),"data-testid":`settings-save-anyway`,children:`Save anyway`}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:f||!n,"data-testid":`settings-save`,children:`Save`})]})]})})}function sE(e,t){if(t.type===`undo`)return I(e);if(t.type===`redo`)return L(e);if(t.type===`load`)return R(t.view)===R(e.present)?e:{past:[...e.past,e.present],present:t.view,future:[]};let n={name:t.name,...t.args?{args:t.args}:{}};try{return t.type===`reset`?{...e,present:F(P(e.present),n).present}:F(e,n)}catch(t){return console.warn(t),e}}var cE=[{id:`stage1`,name:`Functions & calls`,release:`R1`},{id:`stage2`,name:`Cross-file links`,release:`R2`},{id:`stage3`,name:`APIs & data`,release:`R4`},{id:`stage4`,name:`Runtime`,release:`R11`},{id:`stage5`,name:`Deployment`,release:`R10`}];function lE(){let[e,t]=(0,y.useReducer)(sE,void 0,()=>P(V(location.hash.slice(1)))),n=e.present,r=(0,y.useCallback)((e,n)=>t({type:`command`,name:e,...n?{args:n}:{}}),[]),[i,a]=(0,y.useState)([]),o=(0,y.useRef)(!0),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)({}),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(`file`),[v,b]=(0,y.useState)(``),x=(0,y.useRef)(n.tab);x.current=n.tab;let[C,w]=(0,y.useState)(()=>{try{return localStorage.getItem(`veoflow.navCollapsed`)===`1`}catch{return!1}}),T=(0,y.useCallback)(e=>{w(t=>{let n=typeof e==`function`?e(t):e;try{localStorage.setItem(`veoflow.navCollapsed`,n?`1`:`0`)}catch{}return n})},[]),E=(0,y.useRef)(0),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,z]=(0,y.useState)(null),[B,ee]=(0,y.useState)(null),[K,q]=(0,y.useState)([]),[ne,ie]=(0,y.useState)([]),ae=(0,y.useMemo)(()=>new Set(ne.flatMap(e=>[...e.changed,...e.removed].map(t=>`${e.sourceId}:${t}`))),[ne]),[se,ce]=(0,y.useState)(`pending`),le=(0,y.useRef)(!1);le.current=se===`running`;let[ue,de]=(0,y.useState)(``),[fe,pe]=(0,y.useState)(new Map),[me,he]=(0,y.useState)(``),[ge,_e]=(0,y.useState)(``),[ve,ye]=(0,y.useState)(!1),[be,xe]=(0,y.useState)(null),[Se,Ce]=(0,y.useState)(null),[we,Ee]=(0,y.useState)(null),[De,ke]=(0,y.useReducer)(e=>e+1,0);te(n.run);let Ae=(0,y.useRef)(!0);(0,y.useEffect)(()=>{if(Ae.current){Ae.current=!1;return}ke()},[n.run]);let je=(0,y.useRef)(n);je.current=n,(0,y.useEffect)(()=>{let e=e=>{let{run:n,reason:r}=e.detail??{};je.current.run&&n===je.current.run&&(t({type:`reset`,name:`openRun`,args:{}}),_e(r===`history`?`That run is older than the 30 days of history this license shows, so the latest analysis is shown.`:`That run is no longer available (a newer draft or analysis replaced it), so the latest analysis is shown.`))};return window.addEventListener(`veo-run-gone`,e),()=>window.removeEventListener(`veo-run-gone`,e)},[]);let Me=n.run??F,Ne=PS(n.project,n.compare,De),Pe=(0,y.useMemo)(()=>Ye(Ne.data),[Ne.data]),{groups:Fe}=_S(n.project,Me,0,n.source),Le=(0,y.useCallback)((e,t)=>r(`select`,{kind:`function`,id:e,file:t}),[r]),Re=(0,y.useCallback)(e=>{let t=e.file,i=e=>n.tab!==e&&r(`showTab`,{tab:e});if(e.change===`removed`){t&&e.type!==`File`&&Pe?.fileFacts.get(t)!==`removed`&&(i(`file`),r(`openFile`,{file:t}));return}switch(e.type){case`Function`:if(t)return r(`select`,{kind:`function`,id:e.id,file:t});break;case`CALLS`:case`CALLS_CROSS_FILE`:if(t)return r(`select`,{kind:`call`,id:e.id,file:t});break;case`UnresolvedCallSite`:if(t)return r(`select`,{kind:`site`,id:e.id,file:t});break;case`IMPORTS`:case`UnresolvedImport`:if(t)return r(`openImportsFile`,{file:t,pick:e.id});break;case`Group`:return i(`imports`),r(`openGroup`,{group:e.id});case`DEPENDS_ON`:return i(`imports`),r(`openGroup`,{group:String(e.fact.from)})}t&&(i(`file`),r(`openFile`,{file:t}))},[r,n.tab,Pe]),[ze,Be]=(0,y.useState)(null),[Ve,He]=(0,y.useState)(null),Ue=(0,y.useRef)(n.project);Ue.current=n.project;let We=(0,y.useRef)(n.file);We.current=n.file;let Ge=(0,y.useRef)(n.source);Ge.current=n.source;let[Ke,qe]=(0,y.useState)(!1),[X,Je]=(0,y.useState)([]),[Xe,Ze]=(0,y.useState)([]),[Qe,$e]=(0,y.useState)(null),[et,tt]=(0,y.useState)(!1),[nt,rt]=(0,y.useState)(!1),[it,at]=(0,y.useState)(0),ot=(0,y.useRef)(null),st=(0,y.useRef)(null),[ct,lt]=(0,y.useState)(!1),[ut,dt]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(at(0),!Ke)return;let e=Date.now(),t=setInterval(()=>at(Math.round((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[Ke,Ve]),(0,y.useEffect)(()=>{J.settings().then(e=>$e(e.model),()=>void 0)},[]);let ft=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=`#${R(n)}`,t=JSON.stringify([n.project,n.file,n.selection,n.tab,n.group,n.fileLevel]);if(location.hash!==e){let r=R(V(location.hash.slice(1)))===R(n);ft.current!==null&&ft.current!==t&&!r?window.history.pushState(null,``,e):window.history.replaceState(null,``,e)}ft.current=t},[n]),(0,y.useEffect)(()=>{let e=()=>t({type:`load`,view:V(location.hash.slice(1))});return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,y.useEffect)(()=>{if(n.project||!i.some(e=>e.findingsPending))return;let e=setTimeout(()=>{J.projects(!0).then(({projects:e})=>a(e),()=>void 0)},2e3);return()=>clearTimeout(e)},[i,n.project]),(0,y.useEffect)(()=>{let e=!1;return J.projects(!n.project).then(({projects:r})=>{if(e)return;a(r),c(!0);let i=r.some(e=>e.id===n.project);n.project&&!i&&he(`Project ${n.project} was not found.`),(o.current&&!n.project||n.project&&!i)&&t(r.length===1?{type:`reset`,name:`selectProject`,args:{project:r[0].id}}:{type:`reset`,name:`goHome`,args:{}}),o.current=!1},t=>!e&&he(t.message)),()=>{e=!0}},[De,n.project===null]),(0,y.useEffect)(()=>{if(!n.project)return Ze([]);let e=!1;return J.suggestions(n.project).then(t=>!e&&Ze(t.suggestions),()=>!e&&Ze([])),()=>{e=!0}},[n.project,De]),(0,y.useEffect)(()=>{u([]),f({}),Be(null),qe(!1),He(null),wt.current++,de(``),O(null),A(!1),N(!1),I(null),ce(`pending`),z(null),ee(null),q([]),ie([])},[n.project]),(0,y.useEffect)(()=>{if(!n.project){u([]);return}let e=!1,t=n.project;return J.files(t).then(t=>{e||(u(t.files),N(!0))},()=>{e||(u([]),N(!0))}),J.fileCounts(t).then(t=>!e&&f(t.counts),()=>!e&&f({})),J.status(t).then(n=>{e||(O(n.latest),z(n.draft??null),ee(n.debug??null),I(n.committedRun),A(!0),n.progress&&pe(e=>e.has(t)?e:new Map(e).set(t,n.progress)),ce(n.runInProgress?`running`:n.latest?.status===`failed`?`failed`:n.latest?`done`:`pending`))},()=>void 0),()=>{e=!0}},[n.project,De]),(0,y.useEffect)(()=>{if(ie([]),!n.project||F===null)return;let e=n.project,t=!1,r=()=>!le.current&&void J.stale(e).then(e=>!t&&ie(e.committedRun===F?e.sources:[]),()=>void 0);return r(),window.addEventListener(`focus`,r),()=>{t=!0,window.removeEventListener(`focus`,r)}},[n.project,F]);let[pt,mt]=(0,y.useState)([]),ht=(0,y.useMemo)(()=>n.file&&(n.tab===`file`||n.fileLevel)?{kind:`file`,file:n.file}:n.tab===`imports`&&n.group?{kind:`group`,group:n.group}:n.source?{kind:`source`,source:n.source,name:pt.find(e=>e.id===n.source)?.name}:null,[n.file,n.tab,n.fileLevel,n.group,n.source,pt]);(0,y.useEffect)(()=>{if(!n.project)return mt([]);let e=!1;return J.sources(n.project).then(t=>!e&&mt(t.sources.map(e=>({...e,optIn:e.optIn??[]}))),()=>void 0),()=>{e=!0}},[n.project,De]),(0,y.useEffect)(()=>{n.source&&pt.length>0&&!pt.some(e=>e.id===n.source)&&t({type:`reset`,name:`scopeSource`,args:{}})},[n.source,pt]);let{data:gt}=ES(n.project,Me,g===`project`?null:ht,[],De),_t=gt?gt.counts.broken+gt.counts.notAnalyzed+gt.counts.openCalls:null,[vt,yt]=(0,y.useState)(null),bt=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!n.project||!n.file){h(null);return}n.file!==bt.current&&_e(``),bt.current=n.file,h(e=>e&&e.file.id===n.file?e:null),lt(!1);let e=!1,r=n.file;return J.fileGraph(n.project,r).then(t=>!e&&h(t),r=>{e||G(r)||(h(null),_e(n.run===null?`That file wasn't in the latest analysis, so the project overview is shown instead.`:`That file isn't in run ${n.run}, so the project overview is shown instead.`),t({type:`reset`,name:`selectProject`,args:{project:n.project}}))}),()=>{e=!0}},[n.project,n.file,De]),(0,y.useEffect)(()=>re(ke,e=>{if(typeof e.projectId==`string`&&pe(t=>{let n=t.get(e.projectId)??null,r=S(n,e);if(r===n)return t;let i=new Map(t);return r?i.set(e.projectId,r):i.delete(e.projectId),i}),!n.project){(e.type===`run.started`||e.type===`run.committed`||e.type===`run.failed`)&&ke();return}e.projectId===n.project&&(e.type===`run.started`?(ce(`running`),de(`Analyzing…`)):e.type===`stage.completed`?de(`Analyzing…`):e.type===`run.committed`?(ie([]),ce(`done`),de(`Analyzed just now`),ke()):e.type===`run.failed`&&(ce(`failed`),de(`Analysis failed: ${String(e.error)}`),ke()))}),[n.project]),(0,y.useEffect)(()=>{let e=e=>{let n=e.target;if(document.querySelector(`[role="dialog"], [role="menu"]`)||n.closest(`input:not([type="checkbox"]):not([type="radio"]), textarea, select, [contenteditable], [role=dialog]`))return;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`z`){e.preventDefault(),t({type:e.shiftKey?`redo`:`undo`});return}if(e.metaKey||e.ctrlKey||e.altKey)return;let i=E.current&&Date.now()-E.current<1200;if(E.current=0,i&&e.key===`m`){r(`openGroup`,{});return}e.key===`Escape`?r(`clearSelection`):e.key===`u`?r(`toggleUnresolved`):e.key===`1`?r(`showTab`,{tab:`file`}):e.key===`2`?x.current!==`imports`&&r(`showTab`,{tab:`imports`}):e.key===`3`?r(`showTab`,{tab:`reach`}):e.key===`[`?T(e=>!e):e.key===`g`&&(E.current=Date.now())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let xt=(0,y.useCallback)(e=>r(`select`,e),[r]),St=(0,y.useCallback)(()=>r(`clearSelection`),[r]),Ct=(0,y.useCallback)(()=>{_(`file`),r(`showPanel`,{panel:`questions`})},[r]),Z=async(e,t)=>{if(b(``),!CE(e)){b(`Enter an absolute path (for example /Users/you/app), not "${e}"`);return}let i=t?be??n.project:null;try{U(`addFolder`,{root:e}),i||(i=(await J.createProject(e.split(/[\\/]/).filter(Boolean).pop()??`project`,e)).project.id,r(`selectProject`,{project:i})),await J.addSource(i,e)}catch(e){b(e.message??String(e));return}ye(!1),xe(null),b(``),ce(`running`);try{await J.analyze(i)}catch(e){he(e.message??String(e))}ke()},wt=(0,y.useRef)(0),Tt=(0,y.useRef)(null),Et=async(e,i)=>{if(!n.project)return;U(`ask`,{question:e});let a=++wt.current,o=n.project;Tt.current?.abort();let s=new AbortController;Tt.current=s,t({type:`reset`,name:`showPanel`,args:{panel:`answer`}}),qe(!0),He(e),Je(t=>[e,...t.filter(t=>t!==e)].slice(0,5));let c;try{c=await J.ask(o,e,i,We.current,s.signal,Ge.current)}catch(t){let n=t;c={question:e,via:`help`,...i?{mode:i}:{},summary:`Could not answer: ${n.message??String(t)}`,results:[],toolCalls:[],error:{code:n.code??`error`,message:n.message??String(t)}}}if(a!==wt.current||Ue.current!==o)return;let l=c.results[0];l?.kind===`function`&&l.file===We.current&&(c.intent===`callers`||c.intent===`callees`||c.intent===`definition`)&&(r(`select`,{kind:`function`,id:l.id,file:l.file}),t({type:`reset`,name:`showPanel`,args:{panel:`answer`}})),Be(c),qe(!1),He(null)},Dt=e=>{for(let t of W(e))r(t.name,t.args);t({type:`reset`,name:`showPanel`,args:{panel:`answer`}})},Q=()=>{Tt.current?.abort(),wt.current++,qe(!1),He(null)},Ot=()=>{n.project&&(U(`analyzeDraft`),he(``),de(`Analyzing your uncommitted edits as a draft…`),J.analyzeDraft(n.project).catch(e=>{he(e.message),ke()}))},kt=e=>{n.project&&(U(`analyzeFrom`,{from:e}),he(``),de(`Analyzing again from ${e}…`),J.analyzeFrom(n.project,e).catch(e=>{he(e.message),ke()}))},At=e=>{n.project&&(U(`analyzeDebug`,{until:e}),he(``),de(`Debug run: analyzing up to ${e}…`),J.analyzeDebug(n.project,e).catch(e=>{he(e.message),ke()}))};(0,y.useEffect)(()=>{if(!n.project)return;let e=!1;return J.stages(n.project).then(t=>!e&&q(t.pipeline),()=>!e&&q([])),()=>{e=!0}},[n.project]);let[jt,Mt]=(0,y.useState)(null),Nt=(0,y.useCallback)(()=>Mt(null),[]),Pt=e=>{let t=e=>e.slice(0,e.indexOf(`:`)),i=e=>decodeURIComponent(e.slice(e.indexOf(`:`)+1)),a=e=>e.slice(0,e.indexOf(`:`,e.indexOf(`:`)+1)),o=(e,t)=>({label:`Leave it out of analysis…`,command:`chooseFiles`,run:()=>Ee({source:e,...t?{path:t}:{}})}),s=e=>({label:`Re-analyze its repository`,command:`analyzeSource`,run:()=>void Ft(e)}),c=e=>({label:`Broken imports in it`,command:`showPanel`,run:()=>{e(),yt(`broken`),r(`showPanel`,{panel:`questions`})}});if(e.kind===`group`){let[,t=``,i=``]=e.id.split(`|`);return{title:String(e.data.label??e.id).split(`
340
340
  `)[0],entries:[{label:`Open`,command:`openGroup`,run:()=>r(`openGroup`,{group:e.id})},{label:`Show only its links`,command:`showOnlyLinks`,run:()=>{(n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}},{label:`What depends on it`,command:`pickNode`,run:()=>r(`pickNode`,{id:e.id})},c(()=>r(`openGroup`,{group:e.id})),s(t),...i.startsWith(`cluster:`)?[]:[o(t,i||void 0)]]}}if(e.kind===`file`){let a=t(e.id);return{title:i(e.id),entries:[{label:`Open`,command:n.tab===`imports`?`openImportsFile`:`openFile`,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:e.id}):r(`openFile`,{file:e.id})},...n.tab===`imports`&&!n.fileLevel?[{label:`Show only its links`,command:`showOnlyLinks`,run:()=>r(`showOnlyLinks`,{id:e.id})}]:[],{label:n.tab===`imports`?`What depends on it`:`⇄ Imports of this file`,command:`openImportsFile`,run:()=>r(`openImportsFile`,{file:e.id})},c(()=>r(`openImportsFile`,{file:e.id})),{label:`Reach from this file`,command:`openReach`,run:()=>r(`openReach`,{root:e.id,direction:`forward`})},s(a),o(a,i(e.id))]}}if(e.kind===`folder`){let t=e.id.split(`|`)[2]??``,n=String(e.data.path??``);return{title:`${n}/`,entries:[{label:`Open or close`,command:`toggleFolder`,run:()=>r(`toggleFolder`,{path:n})},s(t),o(t,n)]}}if(e.kind===`function`){let c=a(e.id),l=e.id.slice(c.length+1);return{title:l,entries:[{label:`Open`,command:`select`,run:()=>r(`select`,{kind:`function`,id:e.id,file:c})},...n.tab===`file`&&Zt===`graph`?[{label:`Show only its links`,command:`showOnlyLinks`,run:()=>r(`showOnlyLinks`,{id:e.id})}]:[],{label:`Who calls it`,command:`ask`,run:()=>void Et(`who calls ${l}`)},{label:`Reach from here`,command:`openReach`,run:()=>r(`openReach`,{root:e.id,direction:`forward`})},{label:`What reaches it`,command:`openReach`,run:()=>r(`openReach`,{root:e.id,direction:`backward`})},s(t(c)),{...o(t(c),i(c)),label:`Leave its file out of analysis…`}]}}let l=e.data,u=e=>[{label:`Go to its start`,command:`openGroup`,run:()=>l.source&&e(l.source)},{label:`Go to its end`,command:`openGroup`,run:()=>l.target&&e(l.target)}];if(l.kind===`call`&&l.calls?.length&&n.tab===`file`)return{title:`Call`,entries:[{label:`Open`,command:`select`,run:()=>r(`select`,{kind:`call`,id:l.calls[0]})}]};if(l.kind===`depends`)return{title:`Dependency`,entries:[{label:`Show its calls`,command:`pickNode`,run:()=>l.source&&l.target&&r(`pickNode`,{id:XC(l.source,l.target)})},...u(e=>r(`openGroup`,{group:e}))]};if(l.kind===`calls`)return{title:`Calls`,entries:[{label:`Show its calls`,command:`pickNode`,run:()=>r(`pickNode`,{id:e.id})},...u(e=>e.startsWith(`stub|`)?r(`openGroup`,{group:e.slice(5)}):e.startsWith(`folder|`)?r(`toggleFolder`,{path:e.split(`|`).slice(4).join(`|`)}):r(`openImportsFile`,{file:e}))]};if(l.kind===`imports`)return{title:`Imports`,entries:u(e=>e.startsWith(`folder|`)?r(`toggleFolder`,{path:e.split(`|`).slice(4).join(`|`)}):r(`openImportsFile`,{file:e})).map(e=>({...e,command:`openImportsFile`}))};let d=e.data.edge??e.id;return{title:`Link`,entries:[{label:`Open`,command:`pickNode`,run:()=>r(`pickNode`,{id:d})}]}};(0,y.useEffect)(()=>{let e=e=>{if(!(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)||e.target.closest?.(`input, textarea, select, [role=dialog], [role=menu]`))return;let r=document.querySelector(`.graph-wrap .graph`)?.getBoundingClientRect(),i={x:r?r.left+r.width/2:200,y:r?r.top+r.height/3:200},a=null;if(n.tab===`file`&&n.selection?.kind===`function`?a={kind:`function`,id:n.selection.id,data:{},...i}:n.tab===`imports`&&n.pick&&(n.pick.startsWith(`group|`)||/^[^|]+:/.test(n.pick))&&(a={kind:n.pick.startsWith(`group|`)?`group`:`file`,id:n.pick,data:{},...i}),!a)return;e.preventDefault();let o=Fe?.groups.find(e=>e.id===a.id);o&&(a.data={label:o.name}),t=!0,Mt(a)},t=!1,r=e=>{t&&e.preventDefault(),t=!1};return window.addEventListener(`keydown`,e),window.addEventListener(`contextmenu`,r),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`contextmenu`,r)}},[n.tab,n.selection,n.pick,Fe]);let Ft=async e=>{if(n.project){try{await J.analyzeSource(n.project,e)}catch(e){he(e.message??String(e))}ke()}},It=()=>{n.project&&(U(`analyze`),he(``),ce(`running`),J.analyze(n.project).catch(e=>{he(e.message),ke()}))},Lt=(0,y.useCallback)(e=>uC(e,{view:n,projects:i.map(e=>({id:e.id,name:e.name})),sources:pt.map(e=>({id:e.id,...e.name?{name:e.name}:{}})),files:l.map(e=>({id:e.id,path:e.path})),groups:(Fe?.groups??[]).map(e=>({id:e.id,name:e.name})),canDraft:pt.some(e=>e.analysis?.kind===`git`),stages:F===null?[]:K,command:(e,t)=>r(e,t??{}),action:(e,t)=>{e!==`addFolder`&&U(e,t??{}),e===`analyze`?It():e===`analyzeSource`?Ft(String(t?.source)):e===`chooseFiles`?Ee({source:String(t?.source),...t?.path?{path:String(t.path)}:{}}):e===`analyzeDraft`?Ot():e===`analyzeDebug`?At(String(t?.until)):e===`analyzeFrom`?kt(String(t?.from)):e===`addFolder`?ye(!0):e===`openSettings`?tt(!0):e===`openProjectSettings`&&Ce(t?.tab??`repositories`)}}),[n,i,pt,l,Fe,r]),Rt=m!==null&&m.functions.length>80&&!ct,zt=n.selection?.kind===`function`?n.selection.id:n.selection?.kind===`call`?m?.calls.find(e=>e.id===n.selection.id)?.from??null:n.selection?.kind===`site`?m?.unresolved.find(e=>e.id===n.selection.id)?.enclosingFn??null:null,Bt=zt&&m?.functions.some(e=>e.id===zt)?zt:null,Vt=n.selection?.kind===`call`?m?.calls.find(e=>e.id===n.selection.id):void 0,Ht=Vt?[Vt.from,Vt.to]:null,Ut=Ht?.join(`|`)??``,Wt=(0,y.useMemo)(()=>Rt&&m?jT(m,Bt,Ut?Ut.split(`|`):null):null,[Rt,m,Bt,Ut]),Gt=m?m.unresolved.filter(p).length:0,Kt=n.selection?.kind===`site`?m?.unresolved.find(e=>e.id===n.selection.id):void 0,qt=Kt&&!(n.showUnresolved&&p(Kt))?Kt.id:null,Jt=(0,y.useMemo)(()=>{if(!ze||!m)return null;let e=new Set(ze.results.filter(e=>e.kind===`function`&&e.file===m.file.id).map(e=>e.id));return e.size?e:null},[ze,m]),Yt=Bt?(()=>{let e=m?.functions.find(e=>e.id===Bt);return oe(e?.qualifiedName??``,void 0,e?.title).name})():``,Xt=Bt?new Set((m?.calls??[]).flatMap(e=>e.from===Bt&&e.to!==Bt?[e.to]:e.to===Bt&&e.from!==Bt?[e.from]:[])).size:0,Zt=ut??(m&&m.calls.length===0?`list`:`graph`),Qt=n.tab===`file`&&!n.file&&n.panel===`answer`&&(ze!==null||Ke),$t=n.tab===`imports`&&F!==null&&l.length>0,en=(0,Y.jsx)(Ie,{answer:ze,busy:Ke,pending:Ve,elapsed:it,modelConfigured:Qe?.configured??!1,selectedId:n.selection?.id??null,wide:nt,onWide:rt,onOpen:Dt,onAsk:(e,t)=>void Et(e,t),onCancel:Q,onTemplate:e=>st.current?.prefill(e),onSettings:()=>tt(!0),onShowQuestions:e=>{r(`openFile`,{file:e}),_(`file`),t({type:`reset`,name:`showPanel`,args:{panel:`questions`}})}});return(0,Y.jsxs)(`div`,{className:`app`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsx)(`button`,{className:`logo`,"aria-label":`veoflow: all projects (home)`,"data-command":`go-home`,title:j.goHome.description,onClick:()=>r(`goHome`,{}),children:`veoflow`}),(0,Y.jsxs)(`select`,{"data-command":`select-project`,"aria-label":`Project`,className:`project`,value:i.some(e=>e.id===n.project)?n.project??``:``,onChange:e=>r(`selectProject`,{project:e.target.value}),children:[(0,Y.jsx)(`option`,{value:``,disabled:!0,children:i.length===0?`No project yet`:`Choose a project`}),i.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),n.project&&(0,Y.jsx)(yE,{tab:n.tab,reach:n.reach!==null,onTab:e=>r(`showTab`,{tab:e})}),(0,Y.jsxs)(`button`,{"data-testid":`add-folder`,className:`quiet`,title:H.addFolder.description,"aria-label":`Add a folder`,onClick:()=>ye(!0),children:[`+`,(0,Y.jsx)(`span`,{className:`wide-only`,children:` Add folder`})]}),(0,Y.jsx)(Oe,{project:n.project,modelName:Qe?.configured?Qe.model:null,disabled:!n.project||l.length===0,loading:!!n.project&&l.length===0&&!k,suggestions:Xe,recent:X,busy:Ke,onAsk:e=>void Et(e),handle:st,palette:Lt,onOpenFunction:Le}),n.project&&(0,Y.jsx)(uE,{stage1:se,message:ue,progress:se===`running`?fe.get(n.project)??null:null,...se!==`running`&&D?.errorCode===`stage-inputs-changed`?{onFullRun:It}:{},latest:D,loading:!!n.project&&!k,...n.project&&se===`running`?{onCancel:()=>{let e=n.project;ue!==`Cancelling…`&&(de(`Cancelling…`),J.cancelRun(e).then(()=>{de(``),ke()},e=>de(`Couldn't cancel: ${e.message}`)))}}:{}}),n.project&&pt.some(e=>e.analysis?.kind===`git`)&&(0,Y.jsx)(`button`,{"data-testid":`analyze-draft`,className:`icon`,title:H.analyzeDraft.description,"aria-label":`Analyze uncommitted edits`,onClick:Ot,children:`✎`}),n.project&&(0,Y.jsx)(`button`,{"data-testid":`reanalyze`,className:`icon`,title:`${H.analyze.description}`,"aria-label":`Analyze again`,onClick:It,children:`↻`}),n.project&&(0,Y.jsx)(`button`,{"data-command":`toggle-history`,className:`quiet${n.history?` active`:``}`,"aria-pressed":n.history,title:j.toggleHistory.description,onClick:()=>r(`toggleHistory`,{}),children:`History`}),(0,Y.jsx)(`button`,{"data-testid":`undo`,disabled:e.past.length===0,onClick:()=>t({type:`undo`}),title:`Undo (⌘Z)`,"aria-label":`Undo`,className:`icon`,children:(0,Y.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:`M6 3 2 7l4 4M2.5 7H10a4 4 0 0 1 0 8H7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`})})}),(0,Y.jsx)(`button`,{"data-testid":`redo`,disabled:e.future.length===0,onClick:()=>t({type:`redo`}),title:`Redo (⇧⌘Z)`,"aria-label":`Redo`,className:`icon`,children:(0,Y.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:`M10 3l4 4-4 4M13.5 7H6a4 4 0 0 0 0 8h3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`})})}),n.project&&(0,Y.jsx)(`button`,{"data-testid":`project-settings`,className:`quiet`,title:H.openProjectSettings.description,onClick:()=>{U(`openProjectSettings`),Ce(`repositories`)},children:`Repositories`}),(0,Y.jsx)(`button`,{"data-testid":`settings`,className:`icon`,title:H.openSettings.description,"aria-label":`Settings`,ref:ot,onClick:()=>{U(`openSettings`),tt(!0)},children:(0,Y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,"aria-hidden":`true`,children:[(0,Y.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinejoin:`round`,d:`M10.3 3h3.4l.5 2.4 1.7.7 2-1.4 2.4 2.4-1.4 2 .7 1.7 2.4.5v3.4l-2.4.5-.7 1.7 1.4 2-2.4 2.4-2-1.4-1.7.7-.5 2.4h-3.4l-.5-2.4-1.7-.7-2 1.4-2.4-2.4 1.4-2-.7-1.7L3 13.7v-3.4l2.4-.5.7-1.7-1.4-2 2.4-2.4 2 1.4 1.7-.7z`}),(0,Y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`})]})})]}),ge&&(0,Y.jsxs)(`div`,{className:`notice`,role:`status`,"data-testid":`notice`,children:[(0,Y.jsx)(`span`,{children:ge}),(0,Y.jsx)(`button`,{className:`icon`,"aria-label":`Dismiss`,onClick:()=>_e(``),children:`×`})]}),n.only&&(0,Y.jsxs)(`div`,{className:`notice`,role:`status`,"data-testid":`only-banner`,children:[(0,Y.jsxs)(`span`,{children:[`Showing only`,` `,n.only.startsWith(`group|`)?n.only.split(`|`).slice(2).join(`|`).replace(/^cluster:/,``)||n.only.split(`|`)[1]:n.only.slice(n.only.indexOf(`:`)+1),` `,`and what it links to.`]}),(0,Y.jsx)(`button`,{"data-command":`show-only-links`,onClick:()=>r(`showOnlyLinks`,{}),children:`Show everything`})]}),n.project?n.run!==null&&(n.compare!==null||n.run!==F)?(0,Y.jsxs)(`div`,{className:`notice draft`,role:`status`,"data-testid":`draft-banner`,children:[(0,Y.jsx)(`span`,{children:n.compare?`Comparing run ${n.compare.a} with run ${n.compare.b}: the canvas shows run ${n.compare.b}, its changes marked.`:n.run===L?.runId?`You're viewing a draft of your uncommitted edits (run ${n.run}). The latest analysis is unchanged.`:n.run===B?.runId?`You're viewing a debug run that stopped after ${B.stages.at(-1)?.stage??`?`} (run ${n.run}): it shows only what those stages produced, and is never committed. The latest analysis is unchanged.`:`You're viewing run ${n.run}, not the latest analysis.`}),n.run===B?.runId&&F!==null&&!n.compare&&(0,Y.jsx)(`button`,{"data-command":`compare-runs`,"data-testid":`debug-compare`,onClick:()=>r(`compareRuns`,{a:F,b:B.runId}),children:`Compare with latest`}),(0,Y.jsx)(`button`,{"data-command":`open-run`,onClick:()=>r(`openRun`,{}),children:`Back to latest`})]}):(0,Y.jsxs)(Y.Fragment,{children:[L&&(0,Y.jsxs)(`div`,{className:`notice`,role:`status`,"data-testid":`draft-ready`,children:[(0,Y.jsxs)(`span`,{children:[`A draft of your uncommitted edits is ready (run `,L.runId,`).`]}),(0,Y.jsx)(`button`,{"data-command":`open-run`,onClick:()=>r(`openRun`,{run:L.runId}),children:`Open it`})]}),B&&(0,Y.jsxs)(`div`,{className:`notice`,role:`status`,"data-testid":`debug-ready`,children:[(0,Y.jsxs)(`span`,{children:[`A debug run that stopped after `,B.stages.at(-1)?.stage??`?`,` is ready (run`,` `,B.runId,`).`]}),(0,Y.jsx)(`button`,{"data-command":`open-run`,onClick:()=>r(`openRun`,{run:B.runId}),children:`Open it`})]})]}):null,n.project&&ne.length>0&&se!==`running`&&(0,Y.jsxs)(`div`,{className:`notice`,role:`status`,"data-testid":`stale-evidence`,children:[(0,Y.jsx)(`span`,{children:TE(ne)}),(0,Y.jsx)(`button`,{onClick:It,"data-testid":`stale-reanalyze`,children:`Re-analyze`})]}),me&&(0,Y.jsxs)(`div`,{className:`error`,role:`alert`,"data-testid":`error`,children:[(0,Y.jsx)(`span`,{children:me}),(0,Y.jsx)(`button`,{className:`icon`,"aria-label":`Dismiss`,onClick:()=>he(``),children:`×`})]}),ve&&(0,Y.jsx)(dE,{current:i.find(e=>e.id===(be??n.project))?.name??(be?`the new project`:null),intoByDefault:be!==null||i.find(e=>e.id===n.project)?.sources===0,onAdd:(e,t)=>void Z(e,t),onCancel:()=>{ye(!1),xe(null),b(``)},error:v}),Se&&n.project&&(0,Y.jsx)(YS,{initialTab:Se,project:n.project,projectName:i.find(e=>e.id===n.project)?.name??n.project,refresh:De,onClose:()=>Ce(null),onAdd:()=>{Ce(null),ye(!0)},onChooseFiles:e=>Ee({source:e}),onAnalyzeAll:It,onChanged:ke,covered:we!==null},Se),jt&&(()=>{let e=Pt(jt);return(0,Y.jsx)(sC,{title:e.title,entries:e.entries,x:jt.x,y:jt.y,onClose:Nt})})(),we!==null&&n.project&&(0,Y.jsx)(eC,{project:n.project,only:we.source,...we.path?{at:we.path}:{},files:l,run:D,onAnalyze:()=>{It(),Ee(null)},onClose:()=>Ee(null)}),et&&(0,Y.jsx)(oE,{onClose:()=>{tt(!1),ot.current?.focus()},onSaved:e=>$e(e)}),!n.project&&(0,Y.jsx)(aC,{projects:i,progress:fe,loading:!s,onOpen:e=>r(`selectProject`,{project:e}),onCreated:e=>{ke(),r(`selectProject`,{project:e}),xe(e),ye(!0)},onAddFolder:()=>ye(!0),onDeleted:()=>ke()}),n.project&&(0,Y.jsxs)(`main`,{className:[nt&&n.panel===`answer`&&!Qt?`wide-aside`:``,C?`nav-hidden`:``].filter(Boolean).join(` `),children:[C?(0,Y.jsx)(`div`,{className:`nav-collapsed-bar`,children:(0,Y.jsx)(`button`,{className:`icon`,"data-command":`show-nav`,title:`Show the ${$t?`groups`:`files`} pane ( [ )`,"aria-label":`Show the ${$t?`groups`:`files`} pane`,onClick:()=>T(!1),children:`⟩`})}):$t?(0,Y.jsx)(EC,{project:n.project,run:Me,source:n.source,group:n.group,file:n.file,fileLevel:n.fileLevel,expand:n.expand,showPending:n.showPending,onOpenGroup:(e,t)=>r(`openGroup`,e?{group:e,...t?{folder:t}:{}}:{}),onCloseGroup:()=>r(n.area?`openArea`:`openGroup`,n.area?{area:n.area}:{}),onOpenFile:(e,t)=>r(`openImportsFile`,t?{file:e,group:t}:{file:e}),onToggleFolder:e=>r(`toggleFolder`,{path:e}),onCollapse:()=>T(!0),onMenu:Mt,sources:pt,onScope:e=>r(`scopeSource`,e?{source:e}:{}),area:n.area??null}):null,(0,Y.jsx)(pT,{hidden:C||$t,onReveal:()=>{T(!1),n.tab!==`file`&&r(`showTab`,{tab:`file`})},onCollapse:()=>T(!0),project:n.project,files:l,counts:d,current:n.file,onOpen:e=>r(`openFile`,{file:e}),onImports:e=>r(`openImportsFile`,{file:e}),onMenu:Mt,run:D,onAnalyze:()=>{n.project&&(ce(`running`),J.analyze(n.project).catch(e=>he(e.message)))},sources:pt,scope:n.source,onScope:e=>r(`scopeSource`,e?{source:e}:{})},n.project??``),(0,Y.jsxs)(`section`,{className:`center`,children:[(0,Y.jsx)(tE,{project:n.project,run:D?.runId===F?D:null,sources:pt,onAnalyze:It,onKept:()=>{mS(),ke()},onChooseFiles:e=>Ee({source:e})},`${n.project}:${F}`),n.project&&n.tab===`reach`&&n.reach&&F!==null?(0,Y.jsx)(mw,{project:n.project,run:Me,root:n.reach.root,direction:n.reach.direction,onDirection:e=>r(`openReach`,{root:n.reach.root,direction:e}),onReach:e=>r(`openReach`,{root:e}),onOpenFile:e=>{r(`openFile`,{file:e}),r(`showTab`,{tab:`file`})},onContext:Mt}):n.project&&n.tab===`reach`&&F===null?(0,Y.jsx)(`div`,{className:`empty`,"data-testid":`reach-empty`,children:`Reach needs an analysis: run one, and open Reach from a function or file.`}):n.project&&$t?(0,Y.jsx)(iw,{marks:Pe,only:n.only,onContext:Mt,project:n.project,projectName:i.find(e=>e.id===n.project)?.name??n.project,run:Me,group:n.group,area:n.area,onOpenArea:e=>r(`openArea`,e?{area:e}:{}),source:n.source,pick:n.pick,file:n.file,fileLevel:n.fileLevel,expand:n.expand,showPending:n.showPending,onPick:e=>r(`pickNode`,{id:e}),onOpenGroup:e=>r(`openGroup`,e?{group:e}:{}),onOpenFile:(e,t)=>r(`openImportsFile`,t?{file:e,group:t}:{file:e}),onToggleFolder:e=>r(`toggleFolder`,{path:e}),onTogglePending:()=>r(`togglePending`),onClear:St,onFileFindings:Ct}):m?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`toolbar`,children:[(0,Y.jsx)(`span`,{className:`file-title`,"data-testid":`file-title`,title:m.file.path,children:Te(m.file.path)}),m.file.status===`degraded`&&(0,Y.jsx)(`span`,{className:`badge degraded`,"data-testid":`degraded`,title:m.file.reason??``,children:`partly analyzed`}),(0,Y.jsx)(`span`,{className:`spacer`}),m.file.status!==`not_analyzed`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{"data-command":`file-to-imports`,title:`This file on the Imports tab: what it imports, what depends on it, its calls across files (2)`,onClick:()=>r(`openImportsFile`,{file:m.file.id}),children:[`⇄ Imports`,(0,Y.jsx)(`span`,{className:`wide-only`,children:` of this file`})]}),(0,Y.jsxs)(`div`,{className:`segmented`,role:`group`,"aria-label":`Show as`,children:[(0,Y.jsx)(`button`,{"aria-pressed":Zt===`graph`,"data-testid":`show-graph`,onClick:()=>dt(`graph`),children:`Graph`}),(0,Y.jsx)(`button`,{"aria-pressed":Zt===`list`,"data-testid":`show-list`,onClick:()=>dt(`list`),children:`List`})]}),(0,Y.jsxs)(`label`,{className:`toggle`,title:`Calls within this file the analysis could not resolve, drawn in the graph (press u): ${Gt} of the ${m.unresolved.length} unresolved calls here; the rest are imports or built-ins.${gt&&n.file&&g===`file`&&ht?.kind===`file`&&gt.counts.openCalls!==Gt?` Findings lists ${gt.counts.openCalls} open calls for this file: it adds calls through imports that couldn't be linked.`:``}`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-unresolved`,checked:n.showUnresolved&&Gt>0,disabled:Gt===0,onChange:()=>r(`toggleUnresolved`)}),`Open questions (`,wE(Gt),`)`]}),m.functions.length>80&&Zt===`graph`&&(0,Y.jsxs)(`label`,{className:`toggle`,title:`Large files show the selection and its neighbours`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`whole-file`,checked:ct,onChange:e=>lt(e.target.checked)}),`Whole file`]})]})]}),m.file.status!==`not_analyzed`&&n.project&&(0,Y.jsx)(rw,{project:n.project,file:m.file.id,version:Me,onImports:()=>r(`openImportsFile`,{file:m.file.id}),onFindings:Ct}),Wt&&Zt===`graph`&&(0,Y.jsxs)(`p`,{className:`focus-note`,"data-testid":`focus-note`,children:[Bt?Xt===0?`${Yt} calls nothing else in this file, and nothing here calls it. `:`${Yt} and ${Math.min(Xt,Wt.size-1)} of its ${Xt} direct neighbours${Wt.size-1>Xt?`, with some of theirs`:``}. `:Ht?`This call, its two functions and a few of their neighbours. `:`The ${Wt.size} most connected of ${m.functions.length} functions. Select one to focus on it${n.showUnresolved?` and see its open questions`:``}. `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>dt(`list`),children:`See all in the list`})]}),m.findings.length>0&&(0,Y.jsx)(`ul`,{className:`findings`,"data-testid":`findings`,children:m.findings.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:e.kind}),`: `,e.message]},e.id))}),m.file.status===`not_analyzed`?(0,Y.jsx)(`p`,{className:`hint`,"data-testid":`not-analyzed`,children:pE(m.file.reason)}):Zt===`graph`?(0,Y.jsx)(qT,{marks:Pe,only:n.only,onContext:Mt,graph:m,showUnresolved:n.showUnresolved,selection:n.selection,onSelect:xt,onClear:St,focus:Wt,sitesFor:Bt,answered:Jt,extraSite:qt}):(0,Y.jsx)(fE,{graph:m,showUnresolved:n.showUnresolved,selection:n.selection,onSelect:xt,extraSite:qt,onContext:Mt})]}):n.file?(0,Y.jsxs)(`p`,{className:`hint`,"data-testid":`loading-file`,children:[`Loading `,l.find(e=>e.id===n.file)?.path??`the file`,`…`]}):Qt?(0,Y.jsx)(`div`,{className:`centre-answer`,children:en}):n.project&&l.length>0?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(aE,{project:n.project,files:l,run:D?.runId===F?D:null,counts:d,source:n.source??null,sources:pt,onOpen:e=>r(`openFile`,{file:e}),onQuestions:()=>{yt(`open-call`),r(`showPanel`,{panel:`questions`})}})}):n.project&&k&&M&&F!==null?(0,Y.jsxs)(`div`,{className:`overview`,"data-testid":`overview-empty`,children:[(0,Y.jsx)(`p`,{className:`hint`,children:`No files were analyzed in this project.`}),(0,Y.jsx)(rE,{run:D?.runId===F?D:null})]}):(0,Y.jsx)(`p`,{className:`hint`,children:n.project&&(!k||!M)?`Loading ${i.find(e=>e.id===n.project)?.name??`the project`}…`:(0,Y.jsxs)(Y.Fragment,{children:[`Add a folder to analyze it.`,` `,(0,Y.jsx)(`button`,{className:`primary`,"data-testid":`empty-add-folder`,onClick:()=>ye(!0),children:`Add folder`})]})})]}),(0,Y.jsx)(`aside`,{children:n.history&&n.project?(0,Y.jsx)(US,{project:n.project,refresh:De,run:n.run,compare:n.compare,diff:Ne.data,diffError:Ne.error,onView:e=>r(`openRun`,e===null?{}:{run:e}),onCompare:e=>r(`compareRuns`,e??{}),onClose:()=>r(`toggleHistory`,{}),onLocate:Re,stages:K,onDebug:At,onFrom:kt}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tabs`,role:`tablist`,children:[(ze||Ke||n.panel===`answer`)&&!Qt&&(0,Y.jsx)(`button`,{role:`tab`,"data-command":`show-panel`,"data-testid":`answer-tab`,"aria-selected":n.panel===`answer`,onClick:()=>r(`showPanel`,{panel:`answer`}),children:`Answer`}),(0,Y.jsx)(`button`,{role:`tab`,"data-command":`show-panel`,"aria-selected":n.panel===`evidence`,title:$t?`What is picked on the canvas, in detail`:`The code that proves what is selected`,onClick:()=>r(`showPanel`,{panel:`evidence`}),children:`Selected`}),(0,Y.jsxs)(`button`,{role:`tab`,"data-command":`show-panel`,"data-testid":`questions-tab`,"aria-selected":n.panel===`questions`,title:ht&&g===`file`?`What the analysis couldn't settle in this ${ht.kind}`:`What the analysis couldn't settle in the project`,onClick:()=>r(`showPanel`,{panel:`questions`}),children:[ht&&g===`file`?`Findings here`:`Findings`,` (`,_t===null?`…`:wE(_t),`)`]})]}),n.panel===`answer`&&!Qt?en:n.panel===`evidence`||n.panel===`answer`?(0,Y.jsxs)(Y.Fragment,{children:[ze&&!Qt&&(0,Y.jsx)(`button`,{className:`link back`,onClick:()=>t({type:`reset`,name:`showPanel`,args:{panel:`answer`}}),children:`← Back to the answer`}),$t&&n.project?(0,Y.jsx)(Ew,{project:n.project,run:Me,group:n.group,pick:n.pick,file:n.file,fileLevel:n.fileLevel,expand:n.expand,showPending:n.showPending,onPick:e=>r(`pickNode`,{id:e}),onOpenGroup:e=>r(`openGroup`,{group:e}),onOpenFile:e=>r(`openImportsFile`,{file:e}),onToggleFolder:e=>r(`toggleFolder`,{path:e})}):(0,Y.jsx)(mE,{project:n.project,graph:m,changedOnDisk:ae,selection:n.selection,onClear:St,onSelect:xt,onOpenFunction:e=>r(`select`,{kind:`function`,...e}),onShowImports:()=>r(`showTab`,{tab:`imports`}),sources:pt})]}):n.project&&(0,Y.jsx)(DS,{project:n.project,run:Me,scope:ht,wholeProject:g===`project`,canScope:ht!==null,showPending:n.showPending,refresh:De,onWholeProject:e=>_(e?`project`:`file`),onTogglePending:()=>r(`togglePending`),filter:vt,onFilter:yt,onSelectSite:(e,t)=>r(`select`,{kind:`site`,id:e,file:t}),onOpenImport:(e,t,n)=>r(`openImportsFile`,n?{file:e,pick:t,group:n}:{file:e,pick:t}),onManageLicense:()=>{U(`openProjectSettings`,{tab:`license`}),Ce(`license`)}})]})})]})]})}function uE({stage1:e,message:t,progress:n=null,onFullRun:r,latest:i,loading:a,onCancel:o}){let[,s]=(0,y.useState)(0);(0,y.useEffect)(()=>{if(!n)return;let e=setInterval(()=>s(e=>e+1),1e3);return()=>clearInterval(e)},[n===null]);let c=n&&t!==`Cancelling…`?T(n):null,l=n?.startedAt?Date.parse(n.startedAt):null,u=c&&l?Math.max(0,Math.round((Date.now()-l)/1e3)):null,d=(c?`${c.text}${u===null?``:` · ${u<60?`${u} s`:`${Math.floor(u/60)} min ${u%60} s`}`}`:``)||t||(i?i.status===`failed`?i.errorCode===`cancelled`?`Analysis cancelled; the graph is as it was`:`Analysis failed${i.error?`: ${i.error}`:``}`:i.status===`running`?`Analyzing…`:`Analyzed${i.finishedAt?` ${we(i.finishedAt)}`:``}`:a?`Loading…`:``);return(0,Y.jsxs)(`ol`,{className:`timeline`,"data-testid":`timeline`,children:[n&&n.stages.length>0?n.stages.map((e,t)=>{let r=n.finished.find(t=>t.stage===e),i=r?`done`:e===n.stage?`running`:`pending`;return(0,Y.jsx)(`li`,{className:i,"data-stage":e,"data-state":i,title:`${C[e]??e}${r?`: done in ${(r.durationMs/1e3).toFixed(1)} s`:i===`running`?`: running`:`: next`}`,children:(0,Y.jsx)(`span`,{className:`dot`})},e)}):null,!(n&&n.stages.length>0)&&cE.filter(e=>e.release===`R1`).map(t=>{let n=t.id===`stage1`?e:`future`;return(0,Y.jsx)(`li`,{className:n,"data-stage":t.id,"data-state":n,title:t.name,children:(0,Y.jsx)(`span`,{className:`dot`})},t.id)}),(0,Y.jsxs)(`li`,{className:`message`,"data-testid":`run-message`,title:i?`${d} · run ${i.runId}`:d||void 0,children:[(0,Y.jsx)(`span`,{className:`status-text`,"data-testid":`run-status-text`,children:d}),c&&(0,Y.jsx)(`span`,{className:`run-bar`,"data-testid":`run-bar`,role:`progressbar`,"aria-label":`Analysis progress`,...c.fraction===null?{}:{"aria-valuenow":Math.round(c.fraction*100)},children:(0,Y.jsx)(`span`,{style:{width:`${Math.round((c.fraction??0)*100)}%`}})}),r&&(0,Y.jsx)(`button`,{className:`link`,"data-testid":`full-run`,onClick:r,children:`Analyze the whole project`}),o&&(0,Y.jsx)(`button`,{className:`link`,"data-testid":`cancel-run`,disabled:t===`Cancelling…`,onClick:o,title:`Stop this analysis; the graph stays as it was`,children:`Cancel`})]})]})}function dE({current:e,onAdd:t,onCancel:n,error:r,intoByDefault:i=!1}){let[a,o]=(0,y.useState)(i),[s,c]=(0,y.useState)(``),l=(0,y.useRef)(null);return(0,y.useEffect)(()=>l.current?.focus(),[]),(0,y.useEffect)(()=>{let e=e=>e.key===`Escape`&&n();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,Y.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,Y.jsxs)(`form`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`add-title`,onSubmit:e=>{e.preventDefault(),s.trim()&&t(s.trim(),a)},children:[(0,Y.jsx)(`h2`,{id:`add-title`,children:`Add a folder`}),(0,Y.jsxs)(`label`,{children:[`Folder to analyze`,(0,Y.jsx)(`input`,{ref:l,"data-testid":`folder-path`,value:s,onChange:e=>c(e.target.value),placeholder:`/Users/you/projects/app`,spellCheck:!1}),r?(0,Y.jsx)(`small`,{className:`field-error`,role:`alert`,children:r}):(0,Y.jsx)(`small`,{className:`muted`,children:`The absolute path of a git repository or any folder. It is read, never changed.`})]}),e&&(0,Y.jsxs)(`label`,{className:`inline`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,"data-testid":`add-into-current`,checked:a,onChange:e=>o(e.target.checked)}),`Add it to `,e,` instead of a new project (to analyze several repositories together)`]}),(0,Y.jsxs)(`div`,{className:`buttons`,children:[(0,Y.jsx)(`span`,{className:`spacer`}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`add-folder-submit`,children:`Add and analyze`})]})]})})}function fE({graph:e,showUnresolved:t,selection:n,onSelect:r,extraSite:i=null,onContext:a}){let o=new Map(e.functions.map(e=>[e.id,be(e).name])),s=[...e.functions].sort((e,t)=>e.evidence.span.start.line-t.evidence.span.start.line),c=e.unresolved.filter(e=>t&&p(e)&&e.id!==i).sort((e,t)=>e.evidence.span.start.line-t.evidence.span.start.line),l=i?e.unresolved.find(e=>e.id===i):void 0,u=(e,t,i)=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"data-command":`select`,"data-kind":e.kind,"data-id":e.id,className:n?.kind===e.kind&&n.id===e.id?`selected`:``,onClick:()=>r(e),onContextMenu:t=>{let n=e.kind===`function`?`function`:e.kind===`call`?`edge`:null;n&&a&&(t.preventDefault(),a({kind:n,id:e.id,data:n===`edge`?{kind:`call`,calls:[e.id]}:{},x:t.clientX,y:t.clientY}))},children:[t,i&&(0,Y.jsxs)(`small`,{className:`muted`,children:[` `,i]})]})},`${e.kind}:${e.id}`);return(0,Y.jsxs)(`div`,{className:`elements`,"data-testid":`elements`,children:[(0,Y.jsxs)(`h4`,{children:[`Functions (`,e.functions.length,`)`]}),(0,Y.jsx)(`ul`,{children:s.map(e=>{let t=be(e);return u({kind:`function`,id:e.id},`${t.unnamed?`λ`:`ƒ`} ${t.name}`,t.parent?`in ${t.parent}`:void 0)})}),e.calls.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{children:[`Calls (`,e.calls.length,`)`]}),(0,Y.jsx)(`ul`,{children:e.calls.map(e=>u({kind:`call`,id:e.id},`${o.get(e.from)??SE(e)} → ${o.get(e.to)??SE(e)} (line ${e.evidence.span.start.line})`))})]}),l&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h4`,{children:`Selected call site`}),(0,Y.jsx)(`ul`,{children:u({kind:`site`,id:l.id},`? ${l.expression}`,`line ${l.evidence.span.start.line} · ${l.status===`awaiting-link`?`not linked across files`:l.status}`)})]}),c.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`h4`,{children:[`Open questions (`,c.length,`)`]}),(0,Y.jsx)(`ul`,{children:c.map(e=>u({kind:`site`,id:e.id},`? ${e.expression}`,`${d(e.reason)}, line ${e.evidence.span.start.line}`))})]})]})}function pE(e){switch(e){case`declaration-file`:return`Type declarations only (.d.ts): there are no functions to show.`;case`language-not-analyzed`:return`This language is not analyzed yet; Python, Go and Rust arrive in a later release.`;case`too-large`:return`This file is too large to analyze.`;case`binary`:return`This is not a text file.`;case`minified`:return`Minified code (built output, not source); choose it in Choose files to analyze it anyway.`;default:return`This file was not analyzed${e?` (${e})`:``}.`}}function mE({project:e,graph:t,changedOnDisk:n,selection:r,onClear:i,onSelect:a,onOpenFunction:o,onShowImports:s,sources:c}){let[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),h=(0,y.useRef)(null),g=(0,y.useMemo)(()=>new Map(c.map(e=>[e.id,e.root])),[c]),_=(0,y.useMemo)(()=>{if(!t||!r)return null;if(r.kind===`function`){let e=t.functions.find(e=>e.id===r.id),n=e&&oe(e.qualifiedName,void 0,e.title);return e&&n&&{title:`function ${n.name}`,parent:n.parent,detail:[e.kind===`module`?gE.module:e.kind===`function`?``:gE[e.kind]??e.kind,e.exported?`exported`:``,e.isAsync?`async`:``].filter(Boolean).join(`, `),evidence:e.evidence,provenance:e.provenance,frame:e.id,whole:e.qualifiedName===`<module>`}}if(r.kind===`call`){let e=t.calls.find(e=>e.id===r.id),n=e=>{let n=t.functions.find(t=>t.id===e);return n?oe(n.qualifiedName,void 0,n.title).name:e};return e&&{title:`${n(e.from)} calls ${n(e.to)}`,parent:``,detail:`${_E[e.form]??`${e.form} call`} on line ${e.evidence.span.start.line}${e.resolution===`static-exact`?``:`, ${vE[e.resolution]??e.resolution}`}`,evidence:e.evidence,provenance:e.provenance,frame:e.from,whole:!1}}let e=t.unresolved.find(e=>e.id===r.id);return e&&{title:`Open question: ${e.expression}`,parent:``,detail:bE(e),evidence:e.evidence,provenance:e.provenance,frame:e.enclosingFn,whole:!1}},[t,r]),v=(0,y.useMemo)(()=>{if(!t||!_)return null;let e=t.functions.find(e=>e.id===_.frame)?.evidence.span??_.evidence.span,n=_.evidence.span,i=e=>{let n=t.functions.find(t=>t.id===e);return n?oe(n.qualifiedName,void 0,n.title).name:e},o=t.calls.filter(e=>e.from===_.frame&&e.id!==r?.id).map(e=>({start:e.evidence.span.start,end:e.evidence.span.end,kind:`call`,title:`Calls ${i(e.to)} (select)`,onClick:()=>a({kind:`call`,id:e.id})}));r?.kind!==`function`&&o.push({start:n.start,end:n.end,kind:`focus`});let s=e.end.line-e.start.line+1,c=Math.max(e.start.line,Math.min(n.start.line-30,e.end.line-hE+1));return{frame:e,panel:s<=hE?e:{start:{...e.start,line:c},end:{...e.end,line:Math.min(e.end.line,c+hE-1)}},marks:o,focusLine:n.start.line,clipped:s>hE}},[t,_,r,a]),b=_?.evidence.file??null,x=v?`${b}|${v.panel.start.line}|${v.panel.end.line}`:``,S=v?.clipped?`${b}|${v.frame.start.line}|${v.frame.end.line}`:``;(0,y.useEffect)(()=>{if(!e||!b||!v){u(null);return}let t=!1;return J.snippet(e,b,v.panel).then(e=>!t&&u(e),()=>!t&&u(null)),()=>{t=!0}},[e,x]),(0,y.useEffect)(()=>{if(!d||!e||!b||!v||!S)return;let t=!1;return J.snippet(e,b,v.frame).then(e=>!t&&m(e),()=>!t&&m(null)),()=>{t=!0}},[d,e,S]);let C=v?.clipped?p:l;if((0,y.useEffect)(()=>{_||f(!1)},[_]),!_)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`hint`,children:`Select a function or a call, in the graph or the list, to see the code that proves it.`}),e&&t&&(0,Y.jsx)(pC,{project:e,file:t.file.id,run:t.committedRun,onOpen:o,onShowImports:s})]});let{span:w}=_.evidence,T=_.evidence.file.slice(0,_.evidence.file.indexOf(`:`)),E=t?.file.path??``,D=g.get(T)?xE(`${g.get(T)}/${E}`):null;return(0,Y.jsxs)(`div`,{className:`evidence`,"data-testid":`evidence`,children:[(0,Y.jsxs)(`div`,{className:`evidence-head`,children:[(0,Y.jsx)(`h3`,{"data-testid":`evidence-title`,children:_.title}),(0,Y.jsx)(`button`,{className:`icon close`,"data-command":`clear-selection`,"aria-label":`Clear the selection (Esc)`,title:`Clear the selection (Esc)`,onClick:i,children:`×`})]}),_.parent&&(0,Y.jsxs)(`p`,{className:`muted small`,children:[`in `,_.parent]}),_.detail&&(0,Y.jsx)(`p`,{children:_.detail}),e&&t&&r?.kind===`function`&&(0,Y.jsx)(MC,{project:e,graph:t,fn:r.id,onOpen:o,onShowImports:s}),e&&t&&r?.kind===`function`&&(0,Y.jsx)(OC,{project:e,fn:r.id,run:t.committedRun,onOpen:o}),e&&r&&r.kind!==`function`&&(0,Y.jsx)(Re,{project:e,id:r.id},r.id),_.provenance&&(0,Y.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,Ce(_.provenance.stage),` · run `,_.provenance.run]}),n.has(_.evidence.file)&&(0,Y.jsx)(`p`,{className:`muted small`,"data-testid":`evidence-changed`,children:`This file changed on disk since it was analyzed. The code shown is what was analyzed; the editor may open it at a different line. Re-analyze to update.`}),(0,Y.jsxs)(`p`,{className:`location`,"data-testid":`evidence-location`,children:[(0,Y.jsxs)(`code`,{children:[E,`:`,w.start.line,`:`,w.start.column]}),D&&(0,Y.jsx)(`a`,{className:`button-link`,"data-testid":`open-in-editor`,href:`vscode://file${D}:${w.start.line}:${w.start.column}`,children:`Open in editor`}),l&&(0,Y.jsx)(`button`,{className:`button-link`,ref:h,onClick:()=>f(!0),"data-testid":`expand-code`,children:`Expand`})]}),l&&v&&(0,Y.jsx)(xw,{snippet:l,marks:v.marks,focusLine:v.focusLine,testId:`snippet`}),l&&v&&v.marks.some(e=>e.kind===`call`)&&(0,Y.jsxs)(`p`,{className:`muted small legend`,children:[r?.kind!==`function`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mark hit`,children:`The selection`}),`;`,` `]}),(0,Y.jsx)(`span`,{className:`mark call-mark`,children:`highlighted`}),` calls in this function; click one to see it.`]}),l&&v?.clipped&&(0,Y.jsxs)(`p`,{className:`muted small`,children:[`Showing lines `,l.startLine,`–`,l.startLine+l.lines.length-1,`.`,` `,(0,Y.jsx)(`button`,{className:`link`,onClick:()=>f(!0),children:`Expand to see all of it`})]}),(0,Y.jsxs)(`p`,{className:`commit muted small`,title:_.evidence.commit,children:[`at commit `,(0,Y.jsx)(`code`,{children:_.evidence.commit.slice(0,12)}),` `,(0,Y.jsx)(`button`,{className:`link`,"data-testid":`copy-commit`,"aria-label":`Copy the full commit`,onClick:()=>void navigator.clipboard?.writeText(_.evidence.commit),children:`copy`})]}),d&&v&&(0,Y.jsx)(Sw,{title:_.title,location:`${E}:${w.start.line}`,snippet:C,marks:v.marks,focusLine:v.focusLine,onClose:()=>{f(!1),h.current?.focus()}})]})}var hE=400,gE={function:`Function`,method:`Method`,arrow:`Arrow function`,constructor:`Constructor`,getter:`Getter`,setter:`Setter`,module:`The file's top-level code`},_E={plain:`Called`,member:`Called as a method`,optional:`Called with ?.`,new:`Constructed with new`,super:`Called through super`,"call-apply":`Called with call/apply`,bind:`Bound with bind`,"tagged-template":`Called as a tagged template`,decorator:`Applied as a decorator`,jsx:`Rendered as a JSX element`,iife:`Called immediately`},vE={"static-exact":`resolved exactly`,"static-inferred":`resolved by inference`,"dynamic-only":`seen only at run time`,"runtime-confirmed":`confirmed at run time`};function yE({tab:e,reach:t,onTab:n}){return(0,Y.jsx)(`div`,{className:`segmented view-tabs`,role:`tablist`,"aria-label":`View`,children:(t?[`file`,`imports`,`reach`]:[`file`,`imports`]).map(t=>(0,Y.jsx)(`button`,{role:`tab`,"aria-selected":e===t,"data-command":`show-tab`,"data-tab":t,title:t===`file`?`Files: inside one file, its functions and calls (1)`:t===`imports`?`Imports: how files and groups depend on each other (2)`:`Reach: where paths from or to one function or file go (3)`,onClick:()=>n(t),children:t===`file`?`Files`:t===`imports`?`Imports`:`Reach`},t))})}function bE(e){switch(e.reason){case`dynamic-dispatch`:return`Type unknown: the call is on a value whose type the analysis doesn't know (dynamic dispatch), so it can't tell which function runs.`;case`reflection`:return`Reflection: called through eval, Reflect or Function, so the target is unknown.`;case`template-binding`:return`Awaiting its component: a call in a template file, resolved once a component declaring the template is analyzed.`;case`template-reference`:return`Registered elsewhere: a component or directive registered outside this file (a global or a module), so its definition isn't linked.`;case`imported-symbol`:return`Imported${e.importSpecifier?` from '${e.importSpecifier}'`:``}: calls across files are not linked yet.`;case`runtime-global`:return`Built-in: part of the language or runtime, outside the code analyzed.`;case`builtin-value`:return`On a built-in value: the value it is called on is a string, number, DOM element or other runtime value, so it runs the runtime's code.`;default:return`${e.reason} (${e.status})`}}function xE(e){let t=e.replace(/\\/g,`/`);return encodeURI(t.startsWith(`/`)?t:`/${t}`).replace(/#/g,`%23`).replace(/\?/g,`%3F`)}function SE(e){return`${oe(e.function.qualifiedName,void 0,e.function.title).name} (${e.function.path})`}function CE(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function wE(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:`${Math.round(e/100)/10}k`.replace(/\.0k$/,`k`)}function TE(e){let t=e=>e.root.split(/[\\/]/).filter(Boolean).at(-1)??e.sourceId,n=e=>e.changed.length+e.removed.length;if(e.length===1){let r=e[0],i=n(r),a=i===1?r.changed[0]??r.removed[0]:`${i} files`;return`${t(r)} changed on disk since it was analyzed (${a}), so some evidence may point at old lines.`}return`${e.map(t).join(`, `)} changed on disk since they were analyzed, so some evidence may point at old lines.`}(0,b.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(y.StrictMode,{children:(0,Y.jsx)(lE,{})}));