@johnz4021/illuminate 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,5 +67,5 @@ Error generating stack: `+i.message+`
67
67
  `).forEach((l,a)=>{a>0&&n.push(f.jsx("br",{},`${t}-br${o++}`)),l&&n.push(l)})};for(const s of e.matchAll(mC)){i(e.slice(r,s.index));const l=`${t}-${o++}`;if(s[2]!==void 0)n.push(f.jsx("code",{children:s[2]},l));else if(s[3]!==void 0||s[4]!==void 0)n.push(f.jsx("strong",{children:Rn(s[3]??s[4],l)},l));else if(s[5]!==void 0||s[6]!==void 0)n.push(f.jsx("em",{children:Rn(s[5]??s[6],l)},l));else if(s[7]!==void 0){const a=s[8];n.push(/^https?:\/\//i.test(a)?f.jsx("a",{href:a,target:"_blank",rel:"noreferrer",children:Rn(s[7],l)},l):f.jsx("span",{children:Rn(s[7],l)},l))}r=s.index+s[0].length}return i(e.slice(r)),n}function ni({text:e,className:t}){const n=pC(e);return n.length?f.jsx("div",{className:t?`md ${t}`:"md",children:n.map((r,o)=>{const i=`b${o}`;if(r.kind==="p")return f.jsx("p",{children:Rn(r.text,i)},i);if(r.kind==="h")return f.jsx("p",{className:"md-h",children:Rn(r.text,i)},i);if(r.kind==="code")return f.jsx("pre",{children:f.jsx("code",{children:r.text})},i);const s=r.items.map((l,a)=>f.jsx("li",{children:Rn(l,`${i}-${a}`)},`${i}-${a}`));return r.kind==="ul"?f.jsx("ul",{children:s},i):f.jsx("ol",{start:r.start,children:s},i)})}):null}const gC=/^About the walkthrough step “([^”]*)”: /,yC=(e,t)=>`About the walkthrough step “${e}”: ${t}`;function vC(e){const t=gC.exec(e);return t?{question:e.slice(t[0].length),step:t[1]}:{question:e,step:null}}const ar=()=>({nodes:[],edges:[],absences:[]}),mo=e=>e.nodes.length+e.edges.length+e.absences.length,xC=e=>({mapId:e,phase:"loading",meta:null,map:null,report:null,job:null,error:null,answers:[],shown:null,selection:ar(),tour:null,peek:!1,views:[],viewIndex:-1,fixes:{},fresh:[],hidden:[],connected:!1,agent:z0}),wC=e=>e.views[e.viewIndex]??null;function yi(e){if(!e.map)return[];const t=new Set([...e.map.areas,...e.map.nodes,...e.map.edges,...e.map.absences].map(n=>n.id));return e.answers.flatMap(n=>{const r=n.added.filter(o=>t.has(o));return r.length?[{answerId:n.id,question:n.question,ids:r,visible:!e.hidden.includes(n.id)}]:[]})}const kC=e=>yi(e).flatMap(t=>t.ids);function F0(e){if(!e.map)return null;const t=new Set(yi(e).filter(o=>!o.visible).flatMap(o=>o.ids));if(!t.size)return e.map;const n=e.map.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e.map,areas:e.map.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.map.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.map.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}function SC(e,t){if(!t)return e;const n=(r,o)=>r.filter(i=>o.some(s=>s.id===i));return{nodes:n(e.nodes,t.nodes),edges:n(e.edges,t.edges),absences:n(e.absences,t.absences)}}function NC(e,t){var s,l,a;const n=e.tour[t];if(!n)return null;const r=e.nodes.filter(u=>{var c;return(c=n.focus.areas)==null?void 0:c.includes(u.area)}).map(u=>u.id),o=[...n.focus.nodes??[],...n.focus.edges??[],...n.focus.absences??[],...r],i=(n.focus.edges??[]).length||(n.focus.absences??[]).length?[]:H0(e,new Set(o));return{focus:((s=n.focus.nodes)==null?void 0:s[0])??((l=n.focus.edges)==null?void 0:l[0])??((a=n.focus.absences)==null?void 0:a[0])??null,highlight:[...new Set([...o,...i])]}}function H0(e,t){return e.edges.filter(n=>t.has(n.from)&&t.has(n.to)).map(n=>n.id)}function hh(e,t){const n=[...t.moves.highlight,...t.added],r=e?[...new Set([...n,...H0(e,new Set(n))])]:n;return r.length||t.moves.focus?{focus:t.moves.focus??r[0]??null,highlight:r}:null}function sr(e,t){if(!t)return e;const n=[...e.views.slice(0,e.viewIndex+1),t].slice(-50);return{...e,views:n,viewIndex:n.length-1}}function ph(e,t,n){const r={...t};for(const o of e){if(!o.fix||r[o.fix.id]&&!n)continue;const i=n?n[o.fix.id]:{status:"proposed"};r[o.fix.id]={proposal:o.fix,answerId:o.id,status:(i==null?void 0:i.status)??"rejected",problems:[],edgeId:(i==null?void 0:i.edgeId)??null,closed:(i==null?void 0:i.closed)??[],undoable:(i==null?void 0:i.undoable)??!0}}return r}function EC(e,t){var n;switch(t.type){case"loaded":{const r=t.payload,o=r.map?"ready":r.job?"making":r.failure?"failed":"missing";return{...e,phase:o,meta:r.meta,map:r.map,report:r.report,job:r.job,error:((n=r.failure)==null?void 0:n.error)??null,answers:r.answers,shown:null,fixes:ph(r.answers,e.fixes,r.fixes??{}),agent:r.agent??e.agent}}case"missing":return{...e,phase:"missing"};case"connected":return{...e,connected:t.value};case"event":{const r=t.event;if(r.mapId!==e.mapId)return e;if(r.type==="job")return r.status==="started"?{...e,job:{kind:r.job,question:r.question,progress:[]},error:null,phase:r.job==="make"?"making":e.phase}:r.status==="failed"?{...e,job:null,error:r.error??"Something went wrong.",phase:r.job==="make"&&!e.map?"failed":e.phase}:{...e,job:null};if(r.type==="progress")return e.job?{...e,job:{...e.job,progress:[...e.job.progress,r.text].slice(-200)}}:e;if(r.type==="map"){const o=s=>s.filter(l=>r.map.nodes.some(a=>a.id===l)||r.map.edges.some(a=>a.id===l)||r.map.absences.some(a=>a.id===l)),i={nodes:o(e.selection.nodes),edges:o(e.selection.edges),absences:o(e.selection.absences)};return{...e,phase:"ready",meta:r.meta,map:r.map,report:r.report,selection:i}}if(r.type==="answer"){const o=[...e.answers,r.answer],i={...e,answers:o,shown:r.answer.id,tour:null,peek:!1,fresh:r.answer.added,fixes:ph([r.answer],e.fixes,void 0)};return sr(i,hh(e.map,r.answer))}if(r.type==="answerUpdate")return{...e,answers:e.answers.map(o=>o.id===r.answer.id?r.answer:o)};if(r.type==="fix"){const o=e.fixes[r.fixId];if(!o)return e;const i=r.status,s={...e.fixes,[r.fixId]:{...o,status:i,problems:r.problems??[],edgeId:r.edgeId??o.edgeId,closed:r.closed??o.closed,undoable:r.status==="applied"?!0:o.undoable}},l={...e,fixes:s};if(r.status==="applied"&&r.edgeId){const a=o.proposal.connects;return sr(l,{focus:r.edgeId,highlight:[r.edgeId,...a?[a.from,a.to]:[]]})}return l}return e}case"select":{const r=e.selection[t.kind],o=r.includes(t.id),i=t.additive?{...e.selection,[t.kind]:o?r.filter(s=>s!==t.id):[...r,t.id]}:{...ar(),[t.kind]:o&&mo(e.selection)===1?[]:[t.id]};return{...e,selection:i}}case"selectMany":return{...e,selection:t.selection};case"clearSelection":return{...e,selection:ar()};case"tour":{if(t.stop===null||!e.map)return{...e,tour:null,peek:!1};const r=Math.max(0,Math.min(t.stop,e.map.tour.length-1));return sr({...e,tour:r,selection:ar()},NC(e.map,r))}case"peek":{if(!t.open)return{...e,peek:!1};const r=e.answers[e.answers.length-1];return r?{...e,peek:!0,shown:e.shown??r.id}:e}case"focus":{if(!e.map)return e;const r=e.map.nodes.some(o=>o.id===t.id)?"nodes":e.map.edges.some(o=>o.id===t.id)?"edges":e.map.absences.some(o=>o.id===t.id)?"absences":null;return r?sr({...e,tour:null,peek:!1,selection:{...ar(),[r]:[t.id]}},{focus:t.id,highlight:[t.id]}):e}case"back":return e.viewIndex>0?{...e,viewIndex:e.viewIndex-1}:e.viewIndex===0?{...e,viewIndex:-1}:e;case"forward":return e.viewIndex<e.views.length-1?{...e,viewIndex:e.viewIndex+1}:e;case"show":{const r=e.answers.find(o=>o.id===t.answerId);return sr({...e,shown:t.answerId,tour:null,peek:!1},r?hh(e.map,r):null)}case"overview":return sr({...e,shown:null,tour:null,peek:!1,selection:ar(),fresh:[]},{focus:null,highlight:[]});case"layer":case"allLayers":{const r=t.type==="layer"?[t.answerId]:yi(e).map(s=>s.answerId),o=t.visible?e.hidden.filter(s=>!r.includes(s)):[...new Set([...e.hidden,...r])],i={...e,hidden:o};return{...i,selection:SC(e.selection,F0(i))}}case"fixStatus":{const r=e.fixes[t.fixId];return r?{...e,fixes:{...e.fixes,[t.fixId]:{...r,status:t.status,problems:t.problems??r.problems}}}:e}case"error":return{...e,error:t.message}}}const Xr=(...e)=>e.filter(Boolean).join(" ");function et(e,t){const n=e.nodes.find(s=>s.id===t);if(n)return n.name;const r=e.edges.find(s=>s.id===t);if(r)return`${et(e,r.from)} → ${et(e,r.to)}`;const o=e.absences.find(s=>s.id===t);if(o)return o.claim;const i=e.areas.find(s=>s.id===t);return(i==null?void 0:i.label)??t}const _C={add:{pending:"Proposed: this isn’t in the code yet.",done:"This was proposed, and the code now has it."},change:{pending:"Proposed: this code would change.",done:"This was proposed to change, and the code here has changed since."},remove:{pending:"Proposed: this code would be removed.",done:"This was proposed for removal, and it’s no longer in the code."}},CC={added:"New since",changed:"Changed since",removed:"Removed since"};function Su(e,t){return e?e.nodes[t]??e.edges[t]??(e.absences[t]?{status:e.absences[t].status,reasons:e.absences[t].reasons}:null):null}function Ke({eyebrow:e,title:t,children:n,tone:r,className:o}){return f.jsxs("section",{className:Xr("card",r&&`card-${r}`,o),children:[e&&f.jsx("div",{className:"eyebrow",children:e}),t&&f.jsx("h2",{className:"card-title",children:t}),n]})}function jC({map:e,ids:t,onPick:n}){return t.length?f.jsx("div",{className:"chips",children:t.map(({id:r,status:o})=>f.jsxs("button",{className:Xr("chip",o==="proposed"?"chip-proposed":o!=="confirmed"&&"chip-unconfirmed"),onClick:()=>n(r),title:o==="confirmed"?"Confirmed against the code":o==="proposed"?"Part of a proposal, not in the code":"Couldn't confirm against the code",children:[f.jsx("span",{className:o==="confirmed"?"tick":o==="proposed"?"pmark":"qmark",children:o==="confirmed"?"✓":o==="proposed"?"+":"?"}),et(e,r)]},r))}):null}function mh({lines:e,working:t}){const n=e.slice(-8);return f.jsxs("ul",{className:"progress",children:[n.map((r,o)=>f.jsxs("li",{className:Xr(t&&o===n.length-1&&"running"),children:[f.jsx("span",{className:"ic",children:t&&o===n.length-1?"…":"✓"}),r]},`${o}-${r}`)),!n.length&&t&&f.jsxs("li",{className:"running",children:[f.jsx("span",{className:"ic",children:"…"}),"Starting"]})]})}function MC({fix:e,onApprove:t,onReject:n,onUndo:r,map:o}){const i=e.proposal,s=i.files.filter(l=>l.uncommitted);return e.status==="applied"?f.jsxs(Ke,{eyebrow:"Fix applied · re-checked",tone:"ok",children:[f.jsxs("ul",{className:"progress",children:[f.jsxs("li",{children:[f.jsx("span",{className:"ic",children:"✓"}),"Changed ",i.files.length," ",i.files.length===1?"file":"files",": ",i.files.map(l=>l.file).join(", ")]}),e.edgeId&&f.jsxs("li",{children:[f.jsx("span",{className:"ic",children:"✓"}),"New confirmed connection: ",et(o,e.edgeId)]}),e.closed.length>0&&f.jsxs("li",{children:[f.jsx("span",{className:"ic",children:"✓"}),"Closed: ",e.closed.length===1?"the missing connection":`${e.closed.length} missing connections`]})]}),e.undoable?f.jsx("div",{className:"btns",children:f.jsx("button",{className:"btn",onClick:r,children:"Undo this fix"})}):f.jsx("p",{className:"muted small",children:"Undo ended when illuminate stopped. Use git to reverse it."})]}):e.status==="rejected"||e.status==="undone"?f.jsxs(Ke,{eyebrow:e.status==="undone"?"Fix undone":"Fix rejected",children:[f.jsx(ni,{text:i.summary,className:"muted"}),e.status==="undone"&&f.jsx("div",{className:"btns",children:f.jsx("button",{className:"btn",onClick:t,children:"Apply it again"})})]}):f.jsxs(Ke,{eyebrow:`Proposed fix · ${i.files.length} ${i.files.length===1?"file":"files"} · nothing changed yet`,tone:"ai",children:[f.jsx(ni,{text:i.summary}),i.connects&&f.jsx("p",{className:"muted small",children:"The green dashed arrow is the connection it adds."}),f.jsx("pre",{className:"diff",children:i.diff.split(`
68
68
  `).map((l,a)=>f.jsxs("span",{className:l.startsWith("+ ")?"add":l.startsWith("- ")?"del":l.includes(" · ")?"file":"",children:[l,`
69
69
  `]},a))}),s.length>0?f.jsxs("p",{className:"warn small",children:["⚠ ",s.map(l=>l.file).join(", ")," ",s.length===1?"has":"have"," uncommitted changes. They'll be kept; the fix applies on top."]}):null,e.problems.length>0&&f.jsx("ul",{className:"problems",children:e.problems.map(l=>f.jsx("li",{children:l},l))}),f.jsxs("div",{className:"btns",children:[f.jsx("button",{className:"btn primary",disabled:e.status==="applying",onClick:t,children:e.status==="applying"?"Applying…":"Approve"}),f.jsx("button",{className:"btn",onClick:n,children:"Reject"})]}),f.jsx("p",{className:"muted small",children:"Won't apply if these files change first."})]})}function $C({state:e,dispatch:t,onFix:n,onFocus:r,onOffer:o,composer:i}){const s=e.map,l=e.job,a=$.useRef(null);if($.useEffect(()=>{const d=a.current;d&&(d.scrollTop=d.scrollHeight)},[e.answers.length,l==null?void 0:l.progress.length,!!l]),e.phase==="loading")return f.jsx("aside",{className:"panel",children:f.jsx("div",{className:"panel-scroll",children:f.jsx(Ke,{children:f.jsx("p",{className:"muted",children:"Loading…"})})})});if(e.phase==="missing")return f.jsx("aside",{className:"panel",children:f.jsx("div",{className:"panel-scroll",children:f.jsx(Ke,{title:"No map here",children:f.jsx("p",{className:"muted",children:"This map isn't in this repo."})})})});if(!s)return f.jsx("aside",{className:"panel",children:f.jsxs("div",{className:"panel-scroll",children:[l&&f.jsx(Ke,{eyebrow:"Making your map",title:l.question,tone:"ai",children:f.jsx(mh,{lines:l.progress,working:!0})}),e.phase==="failed"&&f.jsx(Ke,{title:"The map couldn't be made",tone:"dead",children:f.jsx("p",{children:e.error})})]})});[...e.selection.nodes,...e.selection.edges,...e.selection.absences];const u=yi(e),c=u.length>0&&u.every(d=>!d.visible);return f.jsxs("aside",{className:"panel","aria-label":"Conversation about this map",children:[f.jsxs("header",{className:"panel-head",children:[f.jsx("h2",{className:"panel-title",children:"Conversation"}),u.length>0&&f.jsx("button",{className:"link-btn small",onClick:()=>t({type:"allLayers",visible:c}),children:c?"Show everything":"Show the original map"}),f.jsx("button",{className:"card-close","aria-label":"Close the conversation",title:"Close (Esc). It stays here to reopen.",onClick:()=>t(e.tour!==null?{type:"peek",open:!1}:{type:"overview"}),children:"×"})]}),f.jsxs("div",{className:"panel-scroll",ref:a,children:[e.error&&f.jsxs("div",{className:"banner banner-dead",role:"alert",children:[e.error,f.jsx("button",{className:"link-btn",onClick:()=>t({type:"error",message:null}),children:"Dismiss"})]}),e.answers.map(d=>f.jsx(bC,{answer:d,state:e,dispatch:t,onFix:n,onFocus:r,onOffer:o},d.id)),(l==null?void 0:l.kind)==="ask"&&f.jsxs("article",{className:"turn",children:[f.jsx(B0,{question:l.question}),f.jsx(Ke,{eyebrow:`${e.agent.name} is working`,tone:"ai",children:f.jsx(mh,{lines:l.progress,working:!0})})]}),!e.answers.length&&!l&&f.jsx("p",{className:"muted small thread-empty",children:"Ask anything about this map. Click a box or arrow first to ask about it."})]}),f.jsx("footer",{className:"panel-foot",children:i})]})}function B0({question:e,about:t}){const{question:n,step:r}=vC(e),o=[r&&`the step “${r}”`,t].filter(Boolean);return f.jsxs("div",{className:"you",children:[f.jsx("p",{className:"you-q",children:n}),o.length>0&&f.jsxs("span",{className:"you-about",children:["About ",o.join(", ")]})]})}function bC({answer:e,state:t,dispatch:n,onFix:r,onFocus:o,onOffer:i}){const s=t.map,l=e.fix?t.fixes[e.fix.id]??null:null,a=e.id===t.shown&&t.tour===null,u=[...e.selection.nodes??[],...e.selection.edges??[],...e.selection.absences??[]].map(x=>et(s,x)).join(", "),c=yi(t).find(x=>x.answerId===e.id),d=e.problems.filter(x=>x.startsWith("The proposed fix")),h=e.problems.filter(x=>!x.startsWith("The proposed fix")),p=e.refs.filter(x=>{var k;return x.status!=="unknown"&&((k=Su(t.report,x.id))==null?void 0:k.status)==="unconfirmed"}).map(x=>x.id),y=e.moves.highlight.length>0||!!e.moves.focus||e.added.length>0||(e.screens??[]).length>0;return f.jsxs("article",{className:"turn",children:[f.jsx(B0,{question:e.question,about:u||void 0}),e.offer?f.jsx(PC,{answer:e,busy:!!t.job,agentName:t.agent.name,onOffer:i}):f.jsxs("section",{className:Xr("card","reply",a&&"card-focus"),children:[f.jsxs("div",{className:"reply-meta",children:[f.jsx("span",{children:e.source==="map"?"From the map":"Looked in the code"}),y&&(a?f.jsx("span",{className:"reply-lit",children:"Lit on the map"}):f.jsx("button",{className:"link-btn small",onClick:()=>n({type:"show",answerId:e.id}),children:"Show on the map"}))]}),f.jsx(ni,{text:e.concept,className:"depth-text"}),(e.notes??[]).length>0&&f.jsx(sC,{mapId:t.mapId,answerId:e.id,stamp:t.report}),(e.screens??[]).map(x=>{const k=ku(t.report,x);return k?f.jsx(O0,{show:k,name:et(s,x)},x):null}),p.length>0&&f.jsxs("p",{className:"warn small reply-warn",children:["Relies on ",p.length===1?"1 thing":`${p.length} things`," the checker couldn't confirm:"," ",p.map((x,k)=>f.jsxs("span",{children:[k>0&&", ",f.jsx("button",{className:"link-btn small",title:"Show it on the map",onClick:()=>o(x),children:et(s,x)})]},x))]}),c&&f.jsxs("div",{className:"reply-added",children:[f.jsxs("span",{children:["Added ",c.ids.length," to the map"]}),f.jsx("button",{className:"link-btn small",onClick:()=>n({type:"layer",answerId:e.id,visible:!c.visible}),children:c.visible?"Hide":"Show"})]}),h.length>0&&f.jsxs("details",{className:"problems-box",children:[f.jsxs("summary",{children:[h.length," thing",h.length===1?"":"s"," Claude found but couldn't confirm or show"]}),f.jsx("ul",{className:"problems",children:h.map(x=>f.jsx("li",{children:x},x))})]})]}),l&&f.jsx(MC,{fix:l,map:s,onApprove:()=>r(l.proposal.id,"approve"),onReject:()=>r(l.proposal.id,"reject"),onUndo:()=>r(l.proposal.id,"undo")}),d.length>0&&f.jsxs(Ke,{eyebrow:"The proposed fix can't be applied",tone:"dead",children:[f.jsx("ul",{className:"problems",children:d.map(x=>f.jsx("li",{children:x.replace("The proposed fix can't be applied: ","")},x))}),f.jsx("p",{className:"muted small",children:"Ask again, or ask for a smaller change."})]})]})}function PC({answer:e,busy:t,agentName:n,onOffer:r}){const o=e.offer;return o.status==="mapped"?f.jsxs(Ke,{eyebrow:"A different part of the app",children:[f.jsx("p",{className:"muted",children:"You made a new map for this."}),o.mapId&&f.jsx("div",{className:"btns",children:f.jsx("a",{className:"btn primary",href:Dt(o.mapId),children:"Open it"})})]}):o.status==="answered"?f.jsx(Ke,{eyebrow:"A different part of the app",children:f.jsx("p",{className:"muted",children:"Answered in words, below."})}):f.jsxs(Ke,{eyebrow:"A different part of the app",tone:"ai",children:[f.jsx("p",{children:"This is about a different part of the app than this map shows."}),o.existing&&f.jsxs("p",{children:["There's already a map for it: “",o.existing.question,"”."]}),f.jsxs("div",{className:"btns",children:[o.existing&&f.jsx("a",{className:"btn primary",href:Dt(o.existing.id),children:"Open that map"}),f.jsx("button",{className:o.existing?"btn":"btn primary",onClick:()=>r(e.id,"map"),children:"Make a new map for this"}),f.jsx("button",{className:"btn",disabled:t,onClick:()=>r(e.id,"words"),title:t?`${n} is still working on this map`:void 0,children:"Just answer in words"})]})]})}function IC({mapId:e,map:t,report:n,ids:r,onClose:o}){var I,O,F,U,B;const[i,s]=lC(),[l,a]=aC(),[u,c]=$.useState(null),d=f.jsx("button",{className:"card-close","aria-label":"Close",title:"Close (Esc)",onClick:o,children:"×"});if(r.length>1)return f.jsxs(Ke,{eyebrow:`Asking about ${r.length} things`,className:"card-selected",children:[d,f.jsx(jC,{map:t,ids:r.map(N=>{var T;return{id:N,status:((T=Su(n,N))==null?void 0:T.status)??"unknown"}}),onPick:()=>{}})]});const h=r[0],p=t.nodes.find(N=>N.id===h),y=t.edges.find(N=>N.id===h),x=t.absences.find(N=>N.id===h),k=Su(n,h),g=(p==null?void 0:p.evidence)??(y==null?void 0:y.evidence)??[],v=k&&"evidence"in k&&k.evidence?k.evidence:[],m=p?"Step":y?"Connection":"Missing connection",w=(k==null?void 0:k.proposal)??null,C=(O=(I=p??y)==null?void 0:I.proposed)==null?void 0:O.note,S=k&&"change"in k?k.change??null:null,_=((U=(F=n==null?void 0:n.since)==null?void 0:F.commit)==null?void 0:U.slice(0,7))??"the commit this map is compared with",j=x?(n==null?void 0:n.absences[x.id])??null:null;return f.jsxs(Ke,{eyebrow:m,title:et(t,h),tone:x?"dead":void 0,className:"card-selected",children:[d,((B=p==null?void 0:p.explain)==null?void 0:B.concept)&&f.jsx(ni,{text:p.explain.concept,className:"depth-text"}),p&&ku(n,p.id)&&f.jsx(O0,{show:ku(n,p.id),name:p.name}),w&&f.jsxs("div",{className:Xr("proposal-note",`proposal-note-${w.state}`),children:[f.jsx("strong",{children:_C[w.kind][w.state]}),C&&f.jsxs(f.Fragment,{children:[" ",C]})]}),S&&f.jsxs("div",{className:Xr("change-note",`change-note-${S.kind}`),children:[f.jsxs("div",{className:"change-head",children:[f.jsxs("span",{children:[f.jsxs("strong",{children:[CC[S.kind]," ",_,"."]}),S.kind==="changed"&&!S.diff&&" A line it cites wasn’t there then.",S.kind==="removed"&&" It was in the code then and is gone now.",S.diff&&f.jsx(TC,{diff:S.diff})]}),S.diff&&f.jsx("button",{className:"link-btn small",onClick:()=>a(!l),children:l?"Hide what changed":"Show what changed"})]}),S.diff&&l&&f.jsx("pre",{className:"diff",children:S.diff.map((N,T)=>f.jsxs("span",{className:N.startsWith("+ ")?"add":N.startsWith("- ")?"del":"",children:[N,`
70
- `]},T))})]}),x&&j&&f.jsxs("p",{children:[j.found>x.matches?"This may no longer be missing: the search below now finds something.":"Nothing in the code connects these, going by this search."," ","Searched ",j.searched??"?"," ",j.searched===1?"file":"files",x.search.paths?f.jsxs(f.Fragment,{children:[" in ",f.jsx("code",{children:x.search.paths.join(", ")})]}):" (the whole repo)"," for ",f.jsx("code",{children:x.search.pattern}),": ",j.found," ",j.found===1?"match":"matches","."]}),k&&k.status==="unconfirmed"&&f.jsxs("div",{className:"warn small",children:["Couldn't confirm against the code: ",k.reasons.join("; ")]}),g.length>0&&f.jsxs("div",{className:"basis",children:[f.jsxs("div",{className:"code-toggle",children:[f.jsx("div",{className:"eyebrow",children:(S==null?void 0:S.kind)==="removed"?`In the code as it was at ${_}`:"In the code"}),f.jsx("button",{className:"link-btn small",onClick:()=>s(!i),children:i?"Hide the code":"Show the code"})]}),f.jsx("div",{className:"chips",children:g.map((N,T)=>{var b,M;const z=((b=v[T])==null?void 0:b.ok)??!1,D=((M=v[T])==null?void 0:M.foundAt)??N.line;return z?f.jsxs("button",{className:"chip cite",title:"Show this line in the code",onClick:()=>{s(!0),c(L=>({at:`${N.file}:${D}`,n:((L==null?void 0:L.n)??0)+1}))},children:[f.jsx("span",{className:"tick",children:"✓"}),N.file,":",D]},T):f.jsxs("span",{className:"chip static chip-unconfirmed",children:[f.jsx("span",{className:"qmark",children:"?"}),N.file,":",D]},T)})}),i&&(p||y)&&f.jsx(iC,{mapId:e,itemId:h,change:(S==null?void 0:S.kind)??null,since:_,stamp:n,jump:u})]})]})}function TC({diff:e}){const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return f.jsxs("span",{className:"diff-size",children:[t>0&&f.jsxs("span",{className:"add",children:[" +",t]}),n>0&&f.jsxs("span",{className:"del",children:[" −",n]})]})}function zC({map:e,selection:t,draft:n,busy:r,agentName:o="Claude",autoFocus:i,onDraft:s,onRemove:l,step:a,onRemoveStep:u,onSend:c}){const d=$.useRef(null),h=["nodes","edges","absences"].flatMap(p=>t[p].map(y=>({kind:p,id:y})));return $.useEffect(()=>{const p=d.current;p&&(p.style.height="auto",p.style.height=`${Math.min(p.scrollHeight,140)}px`)},[n]),$.useEffect(()=>{var p;n&&((p=d.current)==null||p.focus())},[n===""]),$.useEffect(()=>{var p;i&&((p=d.current)==null||p.focus({preventScroll:!0}))},[]),f.jsxs("form",{className:"composer",onSubmit:p=>{p.preventDefault(),!r&&n.trim()&&c()},children:[a&&f.jsxs("span",{className:"sel-chip sel-step",children:[f.jsxs("span",{className:"sel-text",title:`Walkthrough step: ${a}`,children:["▸ ",a]}),f.jsx("button",{type:"button","aria-label":`Don't ask about the step “${a}”`,onClick:u,children:"×"})]}),h.map(p=>f.jsxs("span",{className:`sel-chip sel-${p.kind}`,children:[f.jsxs("span",{className:"sel-text",title:et(e,p.id),children:[p.kind==="absences"?"✕ ":"◉ ",et(e,p.id)]}),f.jsx("button",{type:"button","aria-label":`Remove ${et(e,p.id)}`,onClick:()=>l(p.kind,p.id),children:"×"})]},`${p.kind}:${p.id}`)),f.jsx("textarea",{ref:d,id:"ask",rows:1,value:n,placeholder:r?`${o} is working…`:h.length?"Ask about what you selected…":a?"Ask about this step…":"Ask about this map…",onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),!r&&n.trim()&&c())},"aria-label":"Ask a question about the map"}),f.jsx("button",{type:"submit",className:"send",disabled:r||!n.trim(),"aria-label":"Send",children:"↑"})]})}function LC({map:e,agent:t,selection:n,step:r,onRemove:o}){const i=["nodes","edges","absences"].flatMap(l=>n[l].map(a=>({kind:l,id:a}))),s=q2(t,i.length,r);return f.jsxs("div",{className:"composer composer-chat",role:"note","aria-label":"Where to ask",children:[i.map(l=>f.jsxs("span",{className:`sel-chip sel-${l.kind}`,children:[f.jsxs("span",{className:"sel-text",title:et(e,l.id),children:[l.kind==="absences"?"✕ ":"◉ ",et(e,l.id)]}),f.jsx("button",{type:"button","aria-label":`Remove ${et(e,l.id)}`,onClick:()=>o(l.kind,l.id),children:"×"})]},`${l.kind}:${l.id}`)),f.jsxs("p",{className:"chat-hint",children:[f.jsx("strong",{children:s.title})," ",f.jsx("span",{className:"muted",children:s.detail})]})]})}const ha="illuminate-toured",AC=100;function gh(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function RC(e,t,n=AC){return[...e.filter(r=>r!==t),t].slice(-n)}function DC(e,t){const[n,r]=$.useState(()=>gh(ti(ha)).includes(e));return $.useEffect(()=>{!t||n||!e||(Nl(ha,JSON.stringify(RC(gh(ti(ha)),e))),r(!0))},[e,t,n]),n}function OC({map:e,mapId:t,tour:n,onTour:r,selected:o,children:i}){const s=DC(t,n!==null),l=e.tour.length,a=l>0&&n===null;return!a&&!i?null:f.jsxs("div",{className:"dock",children:[a&&f.jsxs("section",{className:"dock-part dock-walk","aria-label":"Walkthrough",children:[f.jsx("h2",{className:"dock-title",children:"Walkthrough"}),f.jsxs("button",{className:s?"dock-start":"dock-start glow",onClick:()=>r(0),children:["Take the walkthrough ",f.jsxs("span",{className:"muted",children:[l," ",l===1?"stop":"stops"]})]})]}),i&&f.jsxs("section",{className:"dock-part dock-ask","aria-label":"Ask about the map",children:[f.jsxs("div",{className:"dock-head",children:[f.jsx("h2",{className:"dock-title",children:"Ask about the map"}),f.jsx("span",{className:"dock-hint",children:o?"Shift-click to add more":"Click a box or arrow to ask about it"})]}),i]})]})}function FC({state:e,dispatch:t}){const n=e.answers[e.answers.length-1];return n?f.jsx("div",{className:"history-corner",children:f.jsxs("button",{className:"pill-btn history-btn",onClick:()=>t(e.tour!==null?{type:"peek",open:!0}:{type:"show",answerId:n.id}),title:"Open the conversation about this map",children:[f.jsx("span",{className:"history-arrow",children:"‹"})," Conversation ",f.jsx("span",{className:"muted",children:e.answers.length})]})}):null}const lr=14,Ie=12;function HC(e,t){const n=l=>l[l.length-1],r=n(t.nodes),o=n(t.edges),i=n(t.absences),s=r!==void 0?`.react-flow__node[data-id="${CSS.escape(r)}"]`:o!==void 0?`.link-label[data-id="${CSS.escape(`e:${o}`)}"]`:i!==void 0?`.link-label[data-id="${CSS.escape(`a:${i}`)}"]`:null;return s?e.querySelector(s):null}const Nu="illuminate-bubble-size",V0=300,W0=180;function BC(){try{const e=JSON.parse(ti(Nu)??"null");if(e&&typeof e=="object"&&"w"in e&&"h"in e&&typeof e.w=="number"&&typeof e.h=="number")return{w:Math.max(V0,e.w),h:Math.max(W0,e.h)}}catch{}return null}function VC({mapId:e,map:t,report:n,selection:r,onClose:o}){const i=[...r.nodes,...r.edges,...r.absences],s=i.join(" "),l=$.useRef(null),[a,u]=$.useState(null),c=$.useRef(null),d=mi(),h=le(m=>m.transform.join(",")),[p,y]=$.useState(""),[x,k]=$.useState(BC),g=m=>{const w=l.current,C=w==null?void 0:w.querySelector(".card-selected"),S=w==null?void 0:w.parentElement;if(!w||!C||!S||!a)return;m.preventDefault();const _=m.clientX,j=m.clientY,I=w.offsetWidth,O=C.offsetHeight,F=S.clientWidth-2*Ie,U=a.side==="right"?1:-1;let B={w:I,h:O};const N=z=>{B={w:Math.round(Math.max(V0,Math.min(F,I+U*(z.clientX-_)))),h:Math.round(Math.max(W0,O+z.clientY-j))},k(B)},T=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",T),document.body.classList.remove("resizing-bubble"),Nl(Nu,JSON.stringify(B))};window.addEventListener("pointermove",N),window.addEventListener("pointerup",T),document.body.classList.add("resizing-bubble")},v=()=>{try{localStorage.removeItem(Nu)}catch{}k(null)};return $.useLayoutEffect(()=>{const m=l.current;if(!m)return;const w=new ResizeObserver(()=>y(`${m.offsetWidth}x${m.offsetHeight}`));return w.observe(m),()=>w.disconnect()},[s]),$.useLayoutEffect(()=>{const m=l.current,w=m==null?void 0:m.parentElement;if(!m||!w)return;const C=HC(w,r);if(!C){u(null);return}const S=w.getBoundingClientRect(),_=C.getBoundingClientRect(),j={left:_.left-S.left,right:_.right-S.left,top:_.top-S.top,bottom:_.bottom-S.top},I=w.querySelector(".dock"),O=I?I.getBoundingClientRect().top-S.top-Ie:S.height-Ie,F=Math.max(160,O-Ie),U=m.offsetWidth,B=Math.min(m.offsetHeight,F),N=S.width-Ie-j.right-lr,T=j.left-lr-Ie,z=N>=U||N>=T?"right":"left",D=z==="right"?j.right+lr:j.left-lr-U,b=Math.max(Ie,Math.min(D,S.width-Ie-U)),M=Math.max(Ie,Math.min(j.top,O-B)),L=Math.max(16,Math.min((j.top+j.bottom)/2-M,B-16));if(u({left:b,top:M,side:z,pointer:L,maxHeight:F}),c.current===s)return;c.current=s;const P=z==="right"?j.left:j.left-lr-U,H=z==="right"?j.right+lr+U:j.right,ee=H-P<=S.width-2*Ie,K=ee?P:j.left,Y=ee?H:j.right,V=K<Ie?Ie-K:Y>S.width-Ie?S.width-Ie-Y:0,X=j.top<Ie?Ie-j.top:j.bottom>O?Math.max(O-j.bottom,Ie-j.top):0;if(V||X){const E=d.getViewport();d.setViewport({...E,x:E.x+V,y:E.y+X},{duration:300})}},[s,h,p]),i.length?f.jsxs("div",{ref:l,className:`box-bubble box-bubble-${(a==null?void 0:a.side)??"right"}`,style:{...a?{left:a.left,top:a.top,"--bubble-max":`${a.maxHeight}px`}:{visibility:"hidden",left:0,top:0},...x?{width:x.w,"--bubble-cap":`${x.h}px`}:{}},role:"dialog","aria-label":"What you selected",children:[a&&f.jsx("i",{className:"box-bubble-pointer",style:{top:a.pointer},"aria-hidden":"true"}),f.jsx(IC,{mapId:e,map:t,report:n,ids:i,onClose:o},s),f.jsx("span",{className:"box-bubble-grip",onPointerDown:g,onDoubleClick:v,title:"Drag to resize. Double-click for the usual size.","aria-hidden":"true"})]}):null}const WC="modulepreload",UC=function(e){return"/"+e},yh={},YC=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),l=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));o=Promise.allSettled(n.map(a=>{if(a=UC(a),a in yh)return;yh[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":WC,u||(d.as="script"),d.crossOrigin="",d.href=a,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((h,p)=>{d.addEventListener("load",h),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${a}`)))})}))}function i(s){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=s,window.dispatchEvent(l),!l.defaultPrevented)throw s}return o.then(s=>{for(const l of s||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Vn=232,Dn=96,U0=e=>e.view==="journey"&&[...e.nodes,...e.edges].some(t=>!!t.branch);function Xs(e,t){var i;const n=((i=e.nodes[t])==null?void 0:i.y)??0,r=e.rowTops??[];let o=0;for(const[s,l]of r.entries())n>=l-1&&(o=s);return o}const XC=132;function Eu(e,t=!1){return e==="choice"?{w:196,h:132}:e==="action"?{w:196,h:60}:t?{w:232,h:64+XC}:{w:196,h:72}}let KC=null;const Hc=()=>KC??(KC=YC(()=>import("./elk.bundled-CUh_UDad.js").then(e=>e.e),[]).then(e=>new e.default)),Bc={"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};function El(e,t){const n=new Set(e.nodes.map(r=>r.id));return[...e.edges.map(r=>({id:`e:${r.id}`,from:r.from,to:r.to})),...e.absences.flatMap(r=>r.between?[{id:`a:${r.id}`,from:r.between.from,to:r.between.to}]:[]),...t.map(r=>({id:`x:${r.id}`,from:r.from,to:r.to}))].filter(r=>n.has(r.from)&&n.has(r.to)&&r.from!==r.to)}const St={top:52,side:26,bottom:26},ur=64,cs=44,GC=56,QC=140;async function Y0(e,t,n,r){const o=await e.layout({id:t,layoutOptions:{...Bc,"elk.direction":"DOWN","elk.padding":`[top=${St.top},left=${St.side},bottom=${St.bottom},right=${St.side}]`,"elk.layered.spacing.nodeNodeBetweenLayers":String(ur),"elk.spacing.nodeNode":String(cs)},children:n.map(s=>({id:s.id,width:Vn,height:Dn})),edges:r.map(s=>({id:s.id,sources:[s.from],targets:[s.to]}))}),i={};for(const s of o.children??[])i[s.id]={x:s.x??0,y:s.y??0,w:Vn,h:Dn};return{nodes:i,size:{w:o.width??Vn+2*St.side,h:o.height??Dn+St.top+St.bottom}}}function qC(e,t){const n=e.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e,areas:e.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}async function ZC(e,t=[],n=new Set,r=new Set){var C;if(e.view==="journey")return U0(e)?tj(e,t,r):X0(e,t,r);const o=e.nodes.filter(S=>n.has(S.id));if(!o.length)return kh(e,t);const i=qC(e,n),s=new Set(i.nodes.map(S=>S.id)),l=await kh(i,t.filter(S=>s.has(S.from)&&s.has(S.to))),a=await Hc(),u=Object.fromEntries(Object.entries(l.areas).map(([S,_])=>[S,{..._}])),c={...l.nodes},d={},h={};for(const S of o)(h[C=S.area]??(h[C]=[])).push(S);for(const[S,_]of Object.entries(h)){const j=u[S];if(!j)continue;const I=Math.max(1,Math.floor((j.w-2*St.side+cs)/(Vn+cs))),O=Math.max(St.top-ur,...i.nodes.filter(U=>U.area===S).map(U=>{var B;return(((B=c[U.id])==null?void 0:B.y)??0)+Dn}))+ur;_.forEach((U,B)=>{c[U.id]={x:St.side+B%I*(Vn+cs),y:O+Math.floor(B/I)*(Dn+ur),w:Vn,h:Dn}});const F=Math.max(j.h,O+Math.ceil(_.length/I)*(Dn+ur)-ur+St.bottom);d[S]=F-j.h,j.h=F}const p=Object.fromEntries(Object.entries(l.areas).map(([S,_])=>[S,_])),y=Object.keys(p).sort((S,_)=>p[S].y-p[_].y),x={};for(const S of y){const _=p[S];x[S]=Math.max(0,...y.filter(j=>j!==S&&x[j]!==void 0).filter(j=>{const I=p[j];return I.y+I.h<=_.y+1&&I.x<_.x+_.w&&_.x<I.x+I.w}).map(j=>x[j]+(d[j]??0))),u[S].y+=x[S]}const k=El(e,t),g=new Map(e.nodes.map(S=>[S.id,S.area])),v=Math.max(0,...Object.values(u).map(S=>S.x+S.w))+QC;let m=0;for(const S of e.areas){if(u[S.id])continue;const _=e.nodes.filter(O=>O.area===S.id);if(!_.length)continue;const j=k.filter(O=>g.get(O.from)===S.id&&g.get(O.to)===S.id),I=await Y0(a,S.id,_,j);Object.assign(c,I.nodes),u[S.id]={x:v,y:m,w:I.size.w,h:I.size.h},m+=I.size.h+GC}const w=Object.values(u);return{areas:u,nodes:c,width:Math.max(0,...w.map(S=>S.x+S.w)),height:Math.max(0,...w.map(S=>S.y+S.h))}}const vh=1900,_u=130;async function X0(e,t,n){const o=await(await Hc()).layout({id:"root",layoutOptions:{...Bc,"elk.direction":"RIGHT","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.spacing.nodeNodeBetweenLayers":"176","elk.spacing.nodeNode":"56","elk.spacing.componentComponent":"72"},children:e.nodes.map(p=>({id:p.id,width:Eu(p.kind,n.has(p.id)).w,height:Eu(p.kind,n.has(p.id)).h})),edges:El(e,t).map(p=>({id:p.id,sources:[p.from],targets:[p.to]}))}),i={};for(const p of o.children??[])i[p.id]={x:p.x??0,y:p.y??0,w:p.width??0,h:p.height??0};const s=o.width??0;if(s<=vh)return{areas:{},nodes:i,width:s,height:o.height??0,flat:!0};const l=[];for(const[p,y]of Object.entries(i).sort((x,k)=>x[1].x+x[1].w/2-(k[1].x+k[1].w/2))){const x=l[l.length-1];x&&y.x+y.w/2<x.right?(x.ids.push(p),x.left=Math.min(x.left,y.x),x.right=Math.max(x.right,y.x+y.w)):l.push({left:y.x,right:y.x+y.w,ids:[p]})}const a=Math.ceil(s/vh),u=Math.ceil(l.length/a);let c=0,d=0;const h=[];for(let p=0;p*u<l.length;p++){const y=l.slice(p*u,(p+1)*u),x=y.flatMap(v=>v.ids),k=y[0].left,g=Math.min(...x.map(v=>i[v].y));h.push(c);for(const v of x)i[v]={...i[v],x:i[v].x-k,y:i[v].y-g+c};c=Math.max(...x.map(v=>i[v].y+i[v].h))+_u,d=Math.max(d,y[y.length-1].right-k)}return{areas:{},nodes:i,width:d,height:c-_u,flat:!0,rowTops:h}}const Ui=176,xh=120,wh=34,JC=14;function ej(e,t){const n=new Map(e.map(i=>[i,0]));for(const i of t)n.set(i.to,(n.get(i.to)??0)+1);const r=new Set(e),o=[];for(;r.size;){const i=e.find(s=>r.has(s)&&!n.get(s))??e.find(s=>r.has(s));r.delete(i),o.push(i);for(const s of t)s.from===i&&r.has(s.to)&&n.set(s.to,n.get(s.to)-1)}return o}async function tj(e,t,n){const r=El(e,t),o=new Map(e.nodes.map(E=>[E.id,Eu(E.kind,n.has(E.id))])),i=new Map(e.nodes.map(E=>[E.id,E.branch??null])),s=ej(e.nodes.map(E=>E.id),r),l=s.filter(E=>!i.get(E));if(!l.length)return X0(e,t,n);const a=E=>o.get(E).w,u=E=>o.get(E).h,c=new Map,d=new Map;let h=0;for(const E of l)c.set(E,h),d.set(E,0),h+=a(E)+Ui;const p=E=>c.get(E)+a(E)/2,y=E=>c.get(E)+a(E),x=[...new Set([...e.nodes,...e.edges].flatMap(E=>E.branch?[E.branch]:[]))],k=new Map;for(const E of s){const R=i.get(E);R&&k.set(R,[...k.get(R)??[],E])}const g=[],v=new Map,m=new Set(k.keys()),w=(E,R)=>{const q=k.get(E),Q=new Set(q),G=r.filter(ie=>Q.has(ie.to)&&!Q.has(ie.from));if(!R&&G.length&&!G.some(ie=>d.has(ie.from)))return null;const A=G.filter(ie=>d.has(ie.from)).map(ie=>ie.from).sort((ie,Ae)=>d.get(ie)-d.get(Ae)||p(ie)-p(Ae))[0]??null,W=A&&d.get(A)===0?l[l.indexOf(A)+1]:void 0,Z=q[0],te=A?W?(p(A)+p(W))/2:p(A)+(a(A)/2+Ui+a(Z)/2)/2:a(Z)/2,oe=[];let de=te-a(Z)/2;for(const ie of q)oe.push(de),de+=a(ie)+Ui;const me=r.filter(ie=>Q.has(ie.from)&&!Q.has(ie.to)&&d.has(ie.to)),ke=me.filter(ie=>p(ie.to)>=oe[0]).map(ie=>p(ie.to)),Me=me.filter(ie=>p(ie.to)<oe[0]).map(ie=>p(ie.to));return{name:E,ids:q,anchor:A,xs:oe,kind:Me.length?2:ke.length?0:1,reach:Math.max(0,...ke),span:[Math.min(A?p(A):oe[0],...Me)-30,Math.max(de-Ui,...ke)+30],verticals:[...A?[{x:p(A),from:d.get(A)}]:[],...me.map(ie=>({x:p(ie.to),from:d.get(ie.to)}))],minLane:A?d.get(A)+1:1,root:A?d.get(A)===0?l.indexOf(A):v.get(i.get(A))??l.length:l.length}};for(;m.size;){const R=[...m].flatMap(A=>w(A,!1)??[]).sort((A,W)=>(A.anchor?p(A.anchor):1/0)-(W.anchor?p(W.anchor):1/0)||A.kind-W.kind||A.reach-W.reach||x.indexOf(A.name)-x.indexOf(W.name))[0]??w(x.find(A=>m.has(A))??[...m][0],!0);m.delete(R.name);const q=A=>!g.some(W=>W.lane===A&&W.span[0]<R.span[1]&&R.span[0]<W.span[1]),Q=A=>R.verticals.every(W=>g.every(Z=>!(Z.lane>W.from&&Z.lane<A)||Z.boxes.every(te=>W.x<c.get(te)-12||W.x>y(te)+12)))&&g.every(W=>W.lane<=A||W.verticals.every(Z=>Z.from>=A||R.xs.every((te,oe)=>Z.x<te-12||Z.x>te+a(R.ids[oe])+12)));let G=R.minLane;for(;G<R.minLane+12&&!(q(G)&&Q(G));)G++;if(G>=R.minLane+12)for(G=R.minLane;!q(G);G++);R.ids.forEach((A,W)=>{c.set(A,R.xs[W]),d.set(A,G)}),g.push({name:R.name,lane:G,span:R.span,verticals:R.verticals,boxes:R.ids,root:R.root}),v.set(R.name,R.root)}const C=[...new Set([...d.values()])].sort((E,R)=>E-R),S=new Map,_=new Map;let j=0;for(const E of C){const R=Math.max(...[...d].filter(([,q])=>q===E).map(([q])=>u(q)));S.set(E,j),_.set(E,j+R),j+=R+xh}const I={};for(const E of e.nodes){const R=d.get(E.id);I[E.id]={x:c.get(E.id),y:S.get(R)+(_.get(R)-S.get(R)-u(E.id))/2,w:a(E.id),h:u(E.id)}}const O=new Map(e.nodes.map(E=>[E.id,E.kind])),F=(E,R,q)=>{const Q=I[E],G=O.get(E)==="choice"?Math.min(Q.h/2,Math.abs(R-(Q.x+Q.w/2))*Q.h/Q.w):0;return q==="top"?Q.y+G:Q.y+Q.h-G},U=E=>I[E].y+I[E].h/2,B=E=>d.get(E),N=E=>[...d].filter(([,R])=>R===E).map(([R])=>R).sort((R,q)=>c.get(R)-c.get(q)),T=new Map,z=new Map,D=(E,R,q,Q)=>z.set(`${E}:${R}`,[...z.get(`${E}:${R}`)??[],{link:q,key:Q}]);for(const E of r){const R=B(E.from),q=B(E.to);let Q;if(R===q){const G=N(R);Q=G.indexOf(E.to)===G.indexOf(E.from)+1?"straight":R===0?"arc":"under"}else q>R?Q="down":Q=p(E.to)>y(E.from)+24?"rejoin":p(E.to)<c.get(E.from)-24?"return":"up";T.set(E.id,Q),Q==="arc"&&(D(E.from,"t",E.id,[p(E.to)]),D(E.to,"t",E.id,[p(E.from)])),(Q==="rejoin"||Q==="up")&&D(E.to,"b",E.id,[0,R]),Q==="return"&&D(E.to,"b",E.id,[1,-R]),Q==="down"&&D(E.from,"b",E.id,[2,-q])}const b=new Map;for(const[E,R]of z){const q=E.slice(0,E.lastIndexOf(":"));R.sort((Q,G)=>Q.key.reduce((A,W,Z)=>A||W-(G.key[Z]??0),0)),R.forEach((Q,G)=>b.set(`${Q.link}:${E}`,p(q)+(G-(R.length-1)/2)*JC))}const M=(E,R,q)=>b.get(`${E}:${R}:${q}`)??p(R),L=r.filter(E=>T.get(E.id)==="arc").sort((E,R)=>Math.abs(p(E.to)-p(E.from))-Math.abs(p(R.to)-p(R.from))),P=new Map(L.map((E,R)=>[E.id,R])),H=new Map,ee={};for(const E of r){const R=I[E.from],q=I[E.to],Q=B(E.from),G=T.get(E.id);let A;if(G==="straight")A={points:[[R.x+R.w,U(E.from)],[q.x,U(E.to)]],label:0};else if(G==="arc"){const W=-58-18*P.get(E.id),Z=M(E.id,E.from,"t"),te=M(E.id,E.to,"t");A={points:[[Z,F(E.from,Z,"top")],[Z,W],[te,W],[te,F(E.to,te,"top")]],label:1}}else if(G==="under"||G==="return"){const W=H.get(Q)??0;H.set(Q,W+1);const Z=_.get(Q)+wh+16*W,te=p(E.from)+(G==="under"?6:0),oe=G==="return"?M(E.id,E.to,"b"):p(E.to)-6;A={points:[[te,R.y+R.h],[te,Z],[oe,Z],[oe,F(E.to,oe,"bottom")]],label:1}}else if(G==="down"){const W=M(E.id,E.from,"b"),Z=p(E.to),te=S.get(B(E.to))-wh;A=Math.abs(Z-W)<4?{points:[[W,F(E.from,W,"bottom")],[W,q.y]],label:0}:{points:[[W,F(E.from,W,"bottom")],[W,te],[Z,te],[Z,q.y]],label:1}}else if(G==="rejoin"){const W=M(E.id,E.to,"b"),Z=N(Q).some(oe=>oe!==E.from&&c.get(oe)<W&&y(oe)>R.x+R.w),te=S.get(Q)-xh/2;A=Z?{points:[[p(E.from),R.y],[p(E.from),te],[W,te],[W,F(E.to,W,"bottom")]],label:1}:{points:[[R.x+R.w,U(E.from)],[W,U(E.from)],[W,F(E.to,W,"bottom")]],label:W-(R.x+R.w)>=150?0:1}}else{const W=Math.min(Math.max(M(E.id,E.to,"b"),R.x+12),R.x+R.w-12);A={points:[[W,R.y],[W,F(E.to,W,"bottom")]],label:0}}ee[E.id]=A}const Y=x.map(E=>{var G;const R=g.find(A=>A.name===E);if(R)return{name:E,root:R.root};const q=(G=e.edges.find(A=>A.branch===E))==null?void 0:G.from,Q=q?i.get(q):null;return{name:E,root:q&&d.get(q)===0?l.indexOf(q):Q?v.get(Q)??l.length:l.length}}).sort((E,R)=>E.root-R.root||x.indexOf(E.name)-x.indexOf(R.name)).map(E=>E.name),V=Object.values(I),X=Object.values(ee).flatMap(E=>E.points);return{areas:{},nodes:I,width:Math.max(...V.map(E=>E.x+E.w),...X.map(E=>E[0])),height:Math.max(...V.map(E=>E.y+E.h),...X.map(E=>E[1])),flat:!0,routes:ee,branches:Y}}async function kh(e,t){const n=await Hc(),r=new Map(e.nodes.map(c=>[c.id,c.area])),o=El(e,t),i={},s={};for(const c of e.areas){const d=e.nodes.filter(y=>y.area===c.id);if(!d.length)continue;const h=o.filter(y=>r.get(y.from)===c.id&&r.get(y.to)===c.id),p=await Y0(n,c.id,d,h);Object.assign(i,p.nodes),s[c.id]=p.size}const l=new Map;for(const c of o){const d=r.get(c.from),h=r.get(c.to);d!==h&&s[d]&&s[h]&&l.set(`${d}>${h}`,{from:d,to:h})}const a=await n.layout({id:"root",layoutOptions:{...Bc,"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.nodeNode":"48","elk.spacing.componentComponent":"64"},children:e.areas.filter(c=>s[c.id]).map(c=>({id:c.id,width:s[c.id].w,height:s[c.id].h})),edges:[...l.values()].map((c,d)=>({id:`p${d}`,sources:[c.from],targets:[c.to]}))}),u={};for(const c of a.children??[])u[c.id]={x:c.x??0,y:c.y??0,w:c.width??0,h:c.height??0};return{areas:u,nodes:i,width:a.width??0,height:a.height??0}}function nj(e,t,n,r){if(t.flat){const c=y=>{const x=t.nodes[y];return x?{x:x.x+x.w/2,y:x.y+x.h/2}:{x:0,y:0}},d=c(r).x-c(n).x,h=c(r).y-c(n).y;if(Math.abs(d)<40)return h>=0?["b","t"]:["t","b"];const p=Xs(t,r)-Xs(t,n);return p?p>0?["b","t"]:["r","b"]:d>=0?["r","l"]:["l","r"]}const o=c=>{var d;return((d=e.nodes.find(h=>h.id===c))==null?void 0:d.area)??""},i=c=>{const d=t.areas[o(c)],h=t.nodes[c];return d&&h?{x:d.x+h.x+h.w/2,y:d.y+h.y+h.h/2}:{x:0,y:0}},s=i(n),l=i(r),a=l.x-s.x,u=l.y-s.y;return o(n)===o(r)||Math.abs(a)<Vn*.75?u>=0?["b","t"]:["t","b"]:a>=0?["r","l"]:["l","r"]}function rj(e,t=[],n=[],r=[]){return JSON.stringify([e.view==="journey"?[e.nodes.map(o=>o.kind),[...r].sort(),...U0(e)?[[...e.nodes,...e.edges].map(o=>o.branch??"")]:[]]:null,[...n].sort(),e.areas.map(o=>o.id),e.nodes.map(o=>`${o.id}@${o.area}`),e.edges.map(o=>`${o.from}>${o.to}`),e.absences.map(o=>o.between?`${o.between.from}~${o.between.to}`:""),t.map(o=>`${o.from}+${o.to}`)])}const nn=(...e)=>e.filter(Boolean).join(" "),Wn={add:{pending:"Proposed",done:"Now in the code",mark:"+",title:"Proposed: not in the code yet"},change:{pending:"Would change",done:"Changed",mark:"~",title:"Proposed: this code would change"},remove:{pending:"Would be removed",done:"Removed",mark:"−",title:"Proposed: this code would be removed"}},_l=e=>e&&`proposal proposal-${e.kind} proposal-${e.state}`,Un={added:{label:"Added",mark:"+",title:"New since the commit this map is compared with"},changed:{label:"Changed",mark:"~",title:"Different from the commit this map is compared with"},removed:{label:"Removed",mark:"−",title:"Was in the code at the commit this map is compared with, and is gone now"}},Cl=e=>e&&`change change-${e}`,Ks={later:{label:"Not there yet",title:"Added after this version of the code"},gone:{label:"Gone",title:"Removed: it was in the code before, and isn’t now"}};function oj(e){if(!(e!=null&&e.length))return null;const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return[t&&`+${t}`,n&&`−${n}`].filter(Boolean).join(" ")||null}const ij=[["before","Before","The code as it was at that commit; what was added since is a shadow"],["after","After","The code as it is now; what was removed is a shadow"],["both","Both","The code as it is now, with what was removed drawn in too"]];function sj({commit:e,when:t,onWhen:n}){return f.jsxs("div",{className:"change-key",children:[f.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the code to show",children:ij.map(([r,o,i])=>f.jsx("button",{className:nn("seg-btn",t===r&&"on"),title:i,"aria-pressed":t===r,onClick:()=>n(r),children:o},r))}),f.jsx("span",{className:"change-key-title",children:t==="before"?`The code at ${e}`:t==="after"?"The code now":`Now, compared with ${e}`}),t==="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch"}),"Same as before"]}),t==="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch key-added"}),"Added"]}),f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:nn("key-swatch key-changed",t!=="both"&&"key-quiet")}),t==="before"?"Changes later":"Changed"]}),t==="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch key-removed"}),"Removed (only in the before)"]}),t!=="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch key-ghost"}),t==="before"?"Not there yet":"Gone"]})]})}const lj=5,jl=e=>e&&`branch branch-${e.colour}`;function aj({branches:e}){return f.jsxs("div",{className:"change-key branch-key",children:[f.jsx("span",{className:"change-key-title",children:"Ways through"}),f.jsxs("span",{className:"key-item",title:"What most people do, start to finish",children:[f.jsx("i",{className:"key-swatch"}),"Main path"]}),e.map(t=>f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:nn("key-swatch",jl(t))}),t.name]},t.name))]})}const Yi={entry:["Where it starts","▸"],store:["Saved data","▤"],external:["Outside the app","↗"],job:["Background job","◷"]},Sh=[["t",re.Top],["r",re.Right],["b",re.Bottom],["l",re.Left]];function K0(){return f.jsxs(f.Fragment,{children:[Sh.map(([e,t])=>f.jsx(Ur,{id:`s${e}`,type:"source",position:t,className:"handle",isConnectable:!1},`s${e}`)),Sh.map(([e,t])=>f.jsx(Ur,{id:`t${e}`,type:"target",position:t,className:"handle",isConnectable:!1},`t${e}`))]})}function uj({data:e}){var t,n,r;return e.journey?f.jsx(cj,{data:e}):f.jsxs("div",{className:nn("step","nopan",`kind-${e.kind}`,!e.confirmed&&"unconfirmed",_l(e.proposal),Cl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),onClick:o=>{o.stopPropagation(),e.onClick(o.shiftKey||o.metaKey)},children:[f.jsx(K0,{}),(Yi[e.kind]||e.fresh||e.screen||e.proposal||e.change||e.ghost)&&f.jsxs("div",{className:"step-head",children:[e.ghost&&f.jsx("span",{className:"badge-ghost",title:Ks[e.ghost].title,children:Ks[e.ghost].label}),e.proposal&&f.jsx("span",{className:"badge-proposal",children:Wn[e.proposal.kind][e.proposal.state]}),e.change&&f.jsxs("span",{className:"badge-change",title:Un[e.change].title,children:[e.quiet==="before"?"Changes later":Un[e.change].label,e.changeSize&&!e.quiet&&f.jsxs("span",{className:"change-size",children:[" ",e.changeSize]})]}),Yi[e.kind]&&!e.proposal&&!e.change&&!e.ghost&&f.jsxs(f.Fragment,{children:[f.jsx("i",{className:"step-mark","aria-hidden":"true",children:Yi[e.kind][1]}),Yi[e.kind][0]]}),e.screen&&f.jsx("span",{className:"badge-screen",title:"Select this step to see the screen",children:"▣ Screen"}),e.fresh&&f.jsx("span",{className:"badge-new",children:"New"})]}),f.jsx("div",{className:"step-name",title:e.name,children:e.name}),f.jsxs("div",{className:"step-code",title:((t=e.proposal)==null?void 0:t.state)==="pending"?Wn[e.proposal.kind].title:e.confirmed?"Confirmed against the code":"The checker couldn't confirm this against the code",children:[((n=e.proposal)==null?void 0:n.state)==="pending"&&e.proposal.kind==="add"?f.jsx("span",{className:"pmark",children:"+"}):((r=e.proposal)==null?void 0:r.state)==="done"&&e.proposal.kind!=="add"?f.jsx("span",{className:"pmark",children:Wn[e.proposal.kind].mark}):e.change&&e.confirmed?f.jsx("span",{className:"cmark",children:Un[e.change].mark}):f.jsx("span",{className:e.confirmed?"tick":"qmark",children:e.confirmed?"✓":"?"}),f.jsx("span",{className:"step-sub",children:e.sub})]})]})}function cj({data:e}){const t=e.journey,n=e.proposal;return f.jsxs("div",{className:nn("step","jstep","nopan",`j-${t.shape}`,t.show&&"j-pictured",t.outside&&"j-outside",!e.confirmed&&"unconfirmed",_l(n),Cl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",jl(t.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),style:{width:t.w,height:t.h},onClick:r=>{r.stopPropagation(),e.onClick(r.shiftKey||r.metaKey)},children:[f.jsx(K0,{}),t.stage&&f.jsx("div",{className:"j-stage",children:t.stage}),t.shape==="choice"&&f.jsx("svg",{className:"j-diamond",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:f.jsx("polygon",{points:"50,1 99,50 50,99 1,50",vectorEffect:"non-scaling-stroke"})}),f.jsxs("div",{className:"j-tags",children:[n&&f.jsx("span",{className:"badge-proposal",children:Wn[n.kind][n.state]}),e.ghost&&f.jsx("span",{className:"badge-ghost",title:Ks[e.ghost].title,children:Ks[e.ghost].label}),e.change&&f.jsx("span",{className:"badge-change",title:Un[e.change].title,children:e.quiet==="before"?"Changes later":Un[e.change].label}),!e.confirmed&&f.jsx("span",{className:"j-q",title:"The checker couldn't confirm this against the code",children:"?"}),e.fresh&&f.jsx("span",{className:"badge-new",children:"New"})]}),t.show&&f.jsx(uC,{show:t.show,name:e.name}),f.jsx("div",{className:"j-name",title:e.name,children:e.name}),t.outside&&t.shape!=="choice"&&f.jsx("div",{className:"j-note",children:"Outside the app"})]})}function dj({data:e}){return f.jsx("div",{className:nn("area",e.dim&&"dim"),children:f.jsxs("div",{className:"area-label",children:[e.label,e.note&&f.jsxs("span",{className:"area-note",children:[" ",e.note]})]})})}function fj(e,t,n,r,o){const i=Math.hypot(n-e,r-t)||1,s=-(r-t)/i,l=(n-e)/i,a=(e+n)/2+s*o*2,u=(t+r)/2+l*o*2;return[`M ${e} ${t} Q ${a} ${u} ${n} ${r}`,(e+n)/2+s*o,(t+r)/2+l*o]}function Nh(e,t=18,n){let r=`M ${e[0][0]} ${e[0][1]}`;for(let a=1;a<e.length-1;a++){const[u,c]=e[a-1],[d,h]=e[a],[p,y]=e[a+1],x=Math.min(t,Math.hypot(d-u,h-c)/2),k=Math.min(t,Math.hypot(p-d,y-h)/2),g=Math.sign(d-u),v=Math.sign(h-c),m=Math.sign(p-d),w=Math.sign(y-h);r+=` L ${d-g*x} ${h-v*x} Q ${d} ${h} ${d+m*k} ${h+w*k}`}const o=e[e.length-1];r+=` L ${o[0]} ${o[1]}`;const[i,s]=n!==void 0?[e[n],e[n+1]]:[];if(i&&s)return[r,(i[0]+s[0])/2,(i[1]+s[1])/2];let l=[0,e[0][0],e[0][1]];for(let a=1;a<e.length;a++){const[u,c]=e[a-1],[d,h]=e[a];c===h&&Math.abs(d-u)>l[0]&&(l=[Math.abs(d-u),(u+d)/2,h])}return[r,l[1],l[2]]}function hj({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i,targetPosition:s,markerEnd:l,data:a}){const[u,c,d]=a!=null&&a.route?Nh(a.route.points,18,a.route.label):(a==null?void 0:a.wrapY)!==void 0&&i===re.Right?Nh([[t,n],[t+30,n],[t+30,a.wrapY],[r,a.wrapY],[r,o]]):(a==null?void 0:a.wrapY)!==void 0?Ws({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:s,borderRadius:18,centerY:a.wrapY}):a!=null&&a.offset?fj(t,n,r,o,a.offset):Tc({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:s});return a?f.jsxs(f.Fragment,{children:[a.selected&&f.jsx("path",{d:u,className:"edge-halo"}),f.jsx(gi,{id:e,path:u,markerEnd:l,interactionWidth:18}),f.jsx(k2,{children:f.jsxs("div",{className:nn("link-label",`link-${a.variant}`,!a.confirmed&&"unconfirmed",_l(a.proposal),Cl(a.change),a.ghost&&"ghost",jl(a.branch),a.hl&&"hl",a.dim&&"dim",a.selected&&"selected","nodrag nopan"),"data-id":e,style:{transform:`translate(-50%, -50%) translate(${c}px, ${d}px)`},onClick:h=>{var p;h.stopPropagation(),(p=a.onClick)==null||p.call(a,h.shiftKey||h.metaKey)},children:[a.variant==="absence"&&f.jsx("span",{className:"gap-q","aria-hidden":"true",children:"?"}),a.proposal&&f.jsx("span",{className:"pmark",title:a.proposal.state==="done"?Wn[a.proposal.kind].done:Wn[a.proposal.kind].title,children:a.proposal.state==="done"&&a.proposal.kind==="add"?"✓":Wn[a.proposal.kind].mark}),a.change&&f.jsx("span",{className:"cmark",title:Un[a.change].title,children:Un[a.change].mark}),f.jsx("span",{className:"link-text",children:a.label}),!a.confirmed&&a.variant==="edge"&&f.jsx("span",{className:"q",children:" ?"})]})})]}):null}const pj={step:uj,area:dj},mj={link:hj};function Eh(e,t){const n=new Set;for(const r of t){e.nodes.some(s=>s.id===r)&&n.add(r);const o=e.edges.find(s=>s.id===r);o&&n.add(o.from).add(o.to);const i=e.absences.find(s=>s.id===r);i!=null&&i.between&&n.add(i.between.from).add(i.between.to)}return[...n]}const gj="440px",yj=e=>e.length>28?`${e.slice(0,26)}…`:e;function vj(e){var F,U,B,N,T,z,D,b,M,L;const t=(F=e.ghost)!=null&&F.connects&&e.map.nodes.some(P=>P.id===e.ghost.connects.from)&&e.map.nodes.some(P=>P.id===e.ghost.connects.to)?e.ghost:null,n=$.useMemo(()=>t!=null&&t.connects?[{id:t.id,from:t.connects.from,to:t.connects.to}]:[],[t]),r=$.useMemo(()=>e.map.view==="journey"?e.map.nodes.filter(P=>{var H,ee,K;return P.kind!=="action"&&P.kind!=="choice"&&((K=(ee=(H=e.report)==null?void 0:H.screens)==null?void 0:ee[P.id])==null?void 0:K.status)==="confirmed"}).map(P=>P.id):[],[e.map,e.report]),o=rj(e.map,n,e.added,r),[i,s]=$.useState(null),l=mi(),[a,u]=$.useState("both"),d=!!((B=(U=e.report)==null?void 0:U.since)!=null&&B.commit)?a:"both",h=P=>{var H,ee,K,Y,V,X;return((K=(ee=(H=e.report)==null?void 0:H.nodes[P])==null?void 0:ee.change)==null?void 0:K.kind)??((X=(V=(Y=e.report)==null?void 0:Y.edges[P])==null?void 0:V.change)==null?void 0:X.kind)??null},p=P=>d==="before"&&h(P)==="added"?"later":d==="after"&&h(P)==="removed"?"gone":null,y=P=>d==="both"||P==="changed"?P:null;$.useEffect(()=>{let P=!0;return ZC(e.map,n,new Set(e.added),new Set(r)).then(H=>P&&s({key:o,layout:H}),H=>console.error("illuminate: the map could not be laid out",H)),()=>{P=!1}},[o]);const x=(N=e.view)!=null&&N.highlight.length?new Set(e.view.highlight):null,k=$.useMemo(()=>x?new Set(Eh(e.map,[...x])):null,[x,e.map]),g=e.selection,v=$.useMemo(()=>((i==null?void 0:i.layout.branches)??[]).map((P,H)=>({name:P,colour:H%lj+1})),[i]),m=P=>P?v.find(H=>H.name===P)??null:null,w=(P,H,ee)=>{var V;if(!v.length||!ee)return null;if(P==="node")return m((V=e.map.nodes.find(X=>X.id===H))==null?void 0:V.branch);const K=e.map.edges.find(X=>X.id===H),Y=X=>{var E;return(E=e.map.nodes.find(R=>R.id===X))==null?void 0:E.branch};return m((K==null?void 0:K.branch)??Y(K==null?void 0:K.to)??Y(K==null?void 0:K.from))},C=$.useMemo(()=>{if(!i)return[];const P=i.layout,H=V=>!k||e.map.nodes.some(X=>X.area===V&&k.has(X.id)),ee=e.map.areas.flatMap(V=>{const X=P.areas[V.id];return X?[{id:`area:${V.id}`,type:"area",position:{x:X.x,y:X.y},style:{width:X.w,height:X.h},data:{label:V.label,note:null,dim:!H(V.id)},selectable:!1,draggable:!1,zIndex:0}]:[]}),K=new Map;if(P.flat){const V=X=>P.branches&&X.branch?1:0;for(const X of e.map.areas){const E=e.map.nodes.filter(R=>R.area===X.id&&P.nodes[R.id]).sort((R,q)=>V(R)-V(q)||P.nodes[R.id].x-P.nodes[q.id].x||P.nodes[R.id].y-P.nodes[q.id].y)[0];E&&K.set(E.id,X.label)}}const Y=e.map.nodes.flatMap(V=>{var q,Q,G,A,W,Z,te,oe,de,me,ke,Me,ie,Ae,tt,Pe,He,Be,ct;const X=P.nodes[V.id];if(!X)return[];const E=V.evidence[0],R=V.symbol?V.symbol.slice(V.symbol.indexOf("#")+1):E?`${E.file.split("/").pop()}:${E.line}`:"not in the code yet";return[{id:V.id,type:"step",...P.flat?{}:{parentId:`area:${V.area}`,extent:"parent"},position:{x:X.x,y:X.y},data:{name:V.name,sub:R,kind:V.kind,confirmed:!!e.report&&((q=e.report.nodes[V.id])==null?void 0:q.status)!=="unconfirmed",proposal:((G=(Q=e.report)==null?void 0:Q.nodes[V.id])==null?void 0:G.proposal)??null,screen:((Z=(W=(A=e.report)==null?void 0:A.screens)==null?void 0:W[V.id])==null?void 0:Z.status)==="confirmed",selected:g.nodes.includes(V.id),hl:!!(k!=null&&k.has(V.id)),dim:!!k&&!k.has(V.id)&&!g.nodes.includes(V.id),fresh:e.fresh.includes(V.id),change:y(((de=(oe=(te=e.report)==null?void 0:te.nodes[V.id])==null?void 0:oe.change)==null?void 0:de.kind)??null),changeSize:oj((Me=(ke=(me=e.report)==null?void 0:me.nodes[V.id])==null?void 0:ke.change)==null?void 0:Me.diff),ghost:p(V.id),quiet:d==="both"?null:d,...P.flat&&{journey:{w:X.w,h:X.h,shape:V.kind==="choice"?"choice":V.kind==="action"?"action":"screen",outside:V.kind==="external",stage:K.get(V.id)??null,show:r.includes(V.id)?((tt=(Ae=(ie=e.report)==null?void 0:ie.screens)==null?void 0:Ae[V.id])==null?void 0:tt.show)??null:null,branch:w("node",V.id,!!e.report&&((Pe=e.report.nodes[V.id])==null?void 0:Pe.status)!=="unconfirmed"&&!((He=e.report.nodes[V.id])!=null&&He.proposal)&&!y(((ct=(Be=e.report.nodes[V.id])==null?void 0:Be.change)==null?void 0:ct.kind)??null)&&!p(V.id))}},onClick:qr=>e.onSelect("nodes",V.id,qr)},draggable:!1,zIndex:1}]});return[...ee,...Y]},[i,e.map,e.report,g,k,e.fresh,e.onSelect,r,d,v]),S=$.useMemo(()=>{var R,q,Q,G;if(!i)return[];const P=A=>({type:qo.ArrowClosed,width:16,height:16,color:A}),H=A=>!!(x!=null&&x.has(A)),ee=(A,W)=>{const[Z,te]=nj(e.map,i.layout,A,W);return{sourceHandle:`s${Z}`,targetHandle:`t${te}`}},K=new Map,Y=(A,W)=>{const Z=i.layout.rowTops,te=Xs(i.layout,A),oe=Xs(i.layout,W);if(!Z||te===oe)return;const de=Math.max(te,oe),me=K.get(de)??0;return K.set(de,me+1),Z[de]-_u/2+(me%2?1:-1)*Math.ceil(me/2)*18},V=e.map.edges.map(A=>{var Me,ie,Ae,tt,Pe,He,Be;const W=!!e.report&&((Me=e.report.edges[A.id])==null?void 0:Me.status)!=="unconfirmed",Z=((Ae=(ie=e.report)==null?void 0:ie.edges[A.id])==null?void 0:Ae.proposal)??null,te=y(((He=(Pe=(tt=e.report)==null?void 0:tt.edges[A.id])==null?void 0:Pe.change)==null?void 0:He.kind)??null),oe=p(A.id)??p(A.from)??p(A.to),de=H(A.id)||!!k&&k.has(A.from)&&k.has(A.to)&&!x,me="edge",ke=w("edge",A.id,!Z&&!te&&!oe);return{id:`e:${A.id}`,source:A.from,target:A.to,...ee(A.from,A.to),type:"link",className:nn("link",`link-${me}`,!W&&"unconfirmed",_l(Z),Cl(te),oe&&"ghost",jl(ke),H(A.id)&&"hl",!!x&&!H(A.id)&&"dim",g.edges.includes(A.id)&&"selected"),markerEnd:P(oe?"var(--line)":(Z==null?void 0:Z.state)==="pending"&&Z.kind!=="remove"?"var(--ai)":te==="added"?"var(--ok)":te==="removed"?"var(--dead)":ke?`var(--branch-${ke.colour})`:H(A.id)?"var(--path)":"var(--line-strong)"),zIndex:2,data:{label:A.label,wrapY:Y(A.from,A.to),route:(Be=i.layout.routes)==null?void 0:Be[`e:${A.id}`],branch:ke,variant:me,proposal:Z,change:te,ghost:oe,confirmed:W,hl:de,dim:!!x&&!H(A.id)&&!g.edges.includes(A.id),selected:g.edges.includes(A.id),onClick:ct=>e.onSelect("edges",A.id,ct)}}}),X=A=>{var W;return((W=t==null?void 0:t.connects)==null?void 0:W.from)===A.from&&t.connects.to===A.to};for(const A of e.map.absences){if(!A.between||X(A.between))continue;const W=((q=(R=e.report)==null?void 0:R.absences[A.id])==null?void 0:q.status)==="confirmed";V.push({id:`a:${A.id}`,hidden:d==="before",source:A.between.from,target:A.between.to,...ee(A.between.from,A.between.to),type:"link",className:nn("link","link-absence",!W&&"unconfirmed",H(A.id)&&"hl",!!x&&!H(A.id)&&"dim",g.absences.includes(A.id)&&"selected"),markerEnd:P("var(--dead)"),zIndex:2,data:{label:yj(A.claim),route:(Q=i.layout.routes)==null?void 0:Q[`a:${A.id}`],variant:"absence",confirmed:W,hl:H(A.id),dim:!!x&&!H(A.id)&&!g.absences.includes(A.id),selected:g.absences.includes(A.id),onClick:Z=>e.onSelect("absences",A.id,Z)}})}t!=null&&t.connects&&V.push({id:`g:${t.id}`,source:t.connects.from,target:t.connects.to,...ee(t.connects.from,t.connects.to),type:"link",className:"link link-ghost",markerEnd:P("var(--ok)"),zIndex:3,data:{label:`+ ${t.connects.label}`,route:(G=i.layout.routes)==null?void 0:G[`x:${t.id}`],variant:"ghost",confirmed:!0,hl:!0,dim:!1,selected:!1}});const E=new Map;for(const A of V){const W=[A.source,A.target].sort().join("|");E.set(W,[...E.get(W)??[],A])}for(const A of E.values())A.length<2||A.some(W=>{var Z;return(Z=W.data)==null?void 0:Z.route})||A.forEach((W,Z)=>{W.data&&(W.data.offset=(Z-(A.length-1)/2)*44)});return V},[i,e.map,e.report,g,x,k,t,e.onSelect,d,v]),_=le(P=>P.width),j=$.useRef(0);$.useEffect(()=>{const P=j.current;if(j.current=_,!P||!_||P===_||e.touring)return;const H=l.getViewport();l.setViewport({...H,x:H.x+(_-P)/2})},[_]);const I=JSON.stringify([i==null?void 0:i.key,(T=e.view)==null?void 0:T.focus,(z=e.view)==null?void 0:z.highlight,e.touring,e.touring?_:null]),O=$.useRef(!0);return $.useEffect(()=>{if(!i)return;const P=e.view?Eh(e.map,e.view.highlight.length?e.view.highlight:e.view.focus?[e.view.focus]:[]):[];let H=0,ee=0;const K=()=>{var A;const Y=l.getNodes();if(H<2||!Y.length||!Y.every(W=>{var Z,te;return(te=(Z=l.getInternalNode(W.id))==null?void 0:Z.measured)==null?void 0:te.width})){H++<60&&(ee=requestAnimationFrame(K));return}const V=O.current?0:650;O.current=!1;const X=Object.values(i.layout.nodes),E=Object.values(i.layout.routes??{}).flatMap(W=>W.points),R=Math.max(0,Math.min(0,...X.map(W=>W.y))-Math.min(0,...E.map(W=>W[1]))),q=Math.max(0,Math.max(0,...E.map(W=>W[1]))-Math.max(0,...X.map(W=>W.y+W.h))+(E.length?16:0)),Q=(A=i.layout.branches)!=null&&A.length?56:0,G=P.length?{top:`${60+Q}px`,left:e.touring?gj:"60px",right:"60px",bottom:"150px"}:{top:`${64+R+Q}px`,left:"32px",right:"32px",bottom:`${130+q}px`};l.fitView(P.length?{nodes:P.map(W=>({id:W})),duration:V,padding:G,maxZoom:1.15}:{duration:V,padding:G,maxZoom:1.1})};return ee=requestAnimationFrame(K),()=>cancelAnimationFrame(ee)},[I]),f.jsxs(x2,{className:i!=null&&i.layout.flat?"journey":void 0,nodes:C,edges:S,nodeTypes:pj,edgeTypes:mj,onNodeClick:()=>{},onEdgeClick:(P,H)=>{H.id.startsWith("e:")&&e.onSelect("edges",H.id.slice(2),P.shiftKey||P.metaKey),H.id.startsWith("a:")&&e.onSelect("absences",H.id.slice(2),P.shiftKey||P.metaKey)},onPaneClick:e.onClear,panOnDrag:!0,elementsSelectable:!1,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,maxZoom:2,children:[f.jsx(C2,{variant:Qt.Dots,gap:22,size:1.3}),(((b=(D=e.report)==null?void 0:D.since)==null?void 0:b.commit)||v.length>0)&&f.jsx(pi,{position:"top-left",children:f.jsxs("div",{className:"map-keys",children:[((L=(M=e.report)==null?void 0:M.since)==null?void 0:L.commit)&&f.jsx(sj,{commit:e.report.since.commit.slice(0,7),when:d,onWhen:u}),v.length>0&&f.jsx(aj,{branches:v})]})})]})}function Ml(e){e!==`${location.pathname}${location.search}`&&(history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")))}function xj(){const[e,t]=$.useState(location.pathname);return $.useEffect(()=>{const n=()=>t(location.pathname),r=o=>{var s,l;if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;const i=(l=(s=o.target)==null?void 0:s.closest)==null?void 0:l.call(s,"a[href]");!(i instanceof HTMLAnchorElement)||i.target||i.origin!==location.origin||(o.preventDefault(),Ml(`${i.pathname}${i.search}`))};return window.addEventListener("popstate",n),document.addEventListener("click",r),()=>{window.removeEventListener("popstate",n),document.removeEventListener("click",r)}},[]),e}const wj=8e3;function G0({busy:e,agentName:t="Claude",onStopped:n,onError:r}){const[o,i]=$.useState(!1);return $.useEffect(()=>{if(!o)return;const s=setTimeout(()=>i(!1),wj),l=a=>{a.key==="Escape"&&i(!1)};return window.addEventListener("keydown",l),()=>{clearTimeout(s),window.removeEventListener("keydown",l)}},[o]),o&&!e?f.jsxs("span",{className:"stop-ask",role:"group","aria-label":"Stop illuminate?",children:[f.jsx("span",{className:"stop-ask-text",children:"Stop illuminate? Maps stay saved."}),f.jsx("button",{className:"pill-btn stop-yes",autoFocus:!0,onClick:()=>{i(!1),_t.stop().then(n,s=>r(s.message))},children:"Stop"}),f.jsx("button",{className:"pill-btn",onClick:()=>i(!1),children:"Keep running"})]}):f.jsx("button",{className:"pill-btn",disabled:e,title:e?`${t} is still working`:"Maps stay saved. Undo for applied fixes ends.",onClick:()=>i(!0),children:"Stop illuminate"})}function kj(){return f.jsxs("main",{className:"home",children:[f.jsx("h1",{children:"illuminate has stopped"}),f.jsx("p",{className:"muted lede",children:"You can close this tab."}),f.jsxs("p",{className:"muted lede",children:["Maps are saved in ",f.jsx("code",{children:".illuminate/maps"}),". Run ",f.jsx("code",{children:"illume open"})," in the repo to see them again."]})]})}function Sj({onStopped:e}){const[t,n]=$.useState(""),[r,o]=$.useState(null),[i,s]=$.useState([]),[l,a]=$.useState(""),[u,c]=$.useState(null),[d,h]=$.useState(!1),[p,y]=$.useState(z0);$.useEffect(()=>T0(()=>{},()=>{},e),[e]),$.useEffect(()=>{_t.list().then(k=>{n(k.repo),o(k.maps),s(k.making),k.agent&&y(k.agent)},k=>c(k.message))},[]);const x=async()=>{if(l.trim()){h(!0);try{const{id:k}=await _t.make(l.trim());Ml(Dt(k))}catch(k){c(k.message),h(!1)}}};return f.jsxs("main",{className:"home",children:[f.jsxs("div",{className:"home-brand",children:[f.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate",t&&f.jsx("span",{className:"muted",children:t})]}),f.jsx("h1",{children:"Ask how your code works"}),f.jsx("p",{className:"muted lede",children:"Every box and arrow is checked against the code."}),Sl(p)?f.jsxs("p",{className:"home-ask chat-hint",children:[f.jsxs("strong",{children:["Ask for a new map in the ",p.name," chat beside this page"]})," ",f.jsx("span",{className:"muted",children:"for example: “Map what happens when a user signs up.”"})]}):f.jsxs("form",{className:"home-ask",onSubmit:k=>{k.preventDefault(),x()},children:[f.jsx("input",{id:"question",value:l,onChange:k=>a(k.target.value),placeholder:"What happens when a user signs up?","aria-label":"Your question",autoFocus:!0}),f.jsx("button",{className:"btn primary",disabled:d||!l.trim(),children:d?"Starting…":"Map it"})]}),u&&f.jsx("div",{className:"banner banner-dead",role:"alert",children:u}),i.length>0&&f.jsxs("section",{children:[f.jsx("h2",{className:"section-title",children:"Being made now"}),f.jsx("ul",{className:"maplist",children:i.map(k=>f.jsxs("li",{children:[f.jsx("a",{href:Dt(k.id),children:k.question}),f.jsxs("span",{className:"muted small",children:[p.name," is exploring…"]})]},k.id))})]}),f.jsxs("section",{children:[f.jsx("h2",{className:"section-title",children:"Maps in this repo"}),r===null?f.jsx("p",{className:"muted",children:"Loading…"}):r.length===0?f.jsx("p",{className:"muted",children:"None yet."}):f.jsx("ul",{className:"maplist",children:r.map(k=>f.jsxs("li",{children:[f.jsx("a",{href:Dt(k.id),children:k.question}),f.jsxs("span",{className:"muted small",children:[new Date(k.updatedAt).toLocaleString(),k.commit?` · ${k.commit.slice(0,7)}`:""]})]},k.id))})]}),f.jsx("footer",{className:"home-foot",children:f.jsx(G0,{busy:i.length>0,agentName:p.name,onStopped:e,onError:c})})]})}const _h="illuminate-panel-width",Cu=300,Q0=400,Nj=360,pa=e=>Math.round(Math.max(Cu,Math.min(e,Math.max(Cu,window.innerWidth-Nj))));function Ej(){const[e,t]=$.useState(()=>{const r=Number(localStorage.getItem(_h));return pa(r>0?r:Q0)}),n=$.useCallback(r=>{const o=pa(r);t(o),localStorage.setItem(_h,String(o))},[]);return $.useEffect(()=>{const r=()=>t(o=>pa(o));return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),[e,n]}function _j({width:e,onWidth:t}){return f.jsx("div",{className:"panel-handle",role:"separator","aria-orientation":"vertical","aria-label":"Panel width","aria-valuenow":e,"aria-valuemin":Cu,tabIndex:0,title:"Drag to resize the panel",onPointerDown:n=>{n.preventDefault();const r=n.currentTarget;r.setPointerCapture(n.pointerId),document.body.classList.add("resizing");const o=s=>t(window.innerWidth-s.clientX),i=()=>{r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",i),r.removeEventListener("pointercancel",i),document.body.classList.remove("resizing")};r.addEventListener("pointermove",o),r.addEventListener("pointerup",i),r.addEventListener("pointercancel",i)},onDoubleClick:()=>t(Q0),onKeyDown:n=>{n.key==="ArrowLeft"&&(n.preventDefault(),t(e+24)),n.key==="ArrowRight"&&(n.preventDefault(),t(e-24))}})}const Cj=(...e)=>e.filter(Boolean).join(" ");function jj({map:e,stop:t,onTour:n,onAsk:r}){var s;const o=e.tour[t];if(!o)return null;const i=t===e.tour.length-1;return f.jsxs("section",{className:"card card-focus tour-bubble","aria-label":"Walkthrough","aria-live":"polite",children:[f.jsx("button",{className:"card-close","aria-label":"Leave the walkthrough",title:"Leave the walkthrough (Esc)",onClick:()=>n(null),children:"×"}),f.jsxs("div",{className:"tour-head",children:[f.jsxs("span",{className:"eyebrow",children:["Walkthrough, stop ",t+1," of ",e.tour.length]}),f.jsx("span",{className:"dots","aria-hidden":"true",children:e.tour.map((l,a)=>f.jsx("i",{className:Cj(a===t&&"on",a<t&&"done")},l.id))})]}),f.jsx("h2",{className:"card-title",children:o.title}),f.jsx(ni,{text:o.text,className:"depth-text"}),(s=o.terms)!=null&&s.length?f.jsxs("p",{className:"muted small",children:["Terms: ",o.terms.join(", ")]}):null,f.jsxs("div",{className:"tour-nav",children:[f.jsx("button",{className:"btn",disabled:t===0,onClick:()=>n(t-1),children:"‹ Back"}),r&&f.jsx("button",{className:"btn",onClick:r,children:"Ask about this step"}),f.jsx("span",{className:"grow"}),i?f.jsx("button",{className:"btn primary",onClick:()=>n(null),children:"Done"}):f.jsx("button",{className:"btn primary",onClick:()=>n(t+1),children:"Next ›"})]}),f.jsx("div",{className:"kbd",children:"← → to step, Esc to leave"})]})}function Mj(){return Yr?f.jsx($j,{}):f.jsxs("main",{className:"home",children:[f.jsx("h1",{children:"Open illuminate from its link"}),f.jsxs("p",{className:"muted lede",children:["Use the link illuminate printed in your terminal (it ends in ",f.jsx("code",{children:"?t=…"}),")."]})]})}function $j(){const[e,t]=$.useState(!1),n=$.useCallback(()=>{window.close(),t(!0)},[]),r=xj();if(e)return f.jsx(kj,{});const o=/^\/m\/([a-z0-9-]{1,80})\/?$/.exec(r);return o?f.jsx(Tj,{mapId:o[1],onStopped:n},o[1]):f.jsx(Sj,{onStopped:n})}function bj({mapId:e,question:t,making:n}){const[r,o]=$.useState([]);$.useEffect(()=>{_t.list().then(s=>o([...s.making.map(l=>({...l,making:!0})),...s.maps.map(l=>({id:l.id,question:l.question}))]),()=>{})},[e,n]);const i=r.some(s=>s.id===e)?r:[{id:e,question:t},...r];return f.jsx("select",{className:"switcher",value:e,onChange:s=>Ml(Dt(s.target.value)),"aria-label":"Switch to another map",title:"Switch to another map in this repo",children:i.map(s=>f.jsxs("option",{value:s.id,children:[s.question||s.id,s.making?" (being made)":""]},s.id))})}function Pj({report:e}){if(!e)return null;const t=e.summary.unconfirmed,{pending:n,done:r}=e.summary.proposals??{pending:0,done:0},o=n+r,i=o?f.jsx("span",{className:"map-status proposals",title:"Parts of this map are a proposal, drawn in violet: they aren't in the code yet, or would change or go. illuminate checks the code to see which have been done.",children:r===0?`${o} proposed ${o===1?"change":"changes"}`:`${r} of ${o} proposed changes done`}):null,s=f.jsxs(f.Fragment,{children:[i,f.jsx(Ij,{report:e})]});return t?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"map-status off",title:"Every time the map is shown, illuminate re-checks it against the code. These parts no longer hold, usually because the code changed after the map was made. They're dashed and marked ? on the map; click one to see why.",children:t===1?"1 part of this map doesn’t match the code":`${t} parts of this map don’t match the code`}),s]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"map-status ok",title:"Every box and arrow on this map was just re-checked and is really in the code, and every gap's search still finds nothing. That shows each part is real; it doesn't show the map covers everything.",children:"✓ Every part is in the code"}),s]})}function Ij({report:e}){const t=e.since;if(!t)return null;if(!t.commit)return f.jsx("span",{className:"map-status off",title:`This map compares the code with "${t.ref}", but that isn't a commit in this repo, so nothing could be compared.`,children:"Can’t find the commit this map compares with"});const{added:n,changed:r,removed:o}=e.summary.changes??{added:0,changed:0,removed:0},i=t.date?new Date(t.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):null,s=[n&&`${n} added`,r&&`${r} changed`,o&&`${o} removed`].filter(Boolean).join(" · ");return f.jsxs("span",{className:"map-status changes",title:`This map shows the code as it is now, compared with commit ${t.commit.slice(0,7)}${t.subject?` ("${t.subject}")`:""}. illuminate works out from the two versions which boxes and arrows are new, different or gone. It can't tell who made a change.`,children:["Changes since ",t.commit.slice(0,7),i?` (${i})`:"",s?`: ${s}`:": nothing on this map differs"]})}function Tj({mapId:e,onStopped:t}){var D,b,M,L,P,H,ee,K;const[n,r]=$.useReducer(EC,e,xC),[o,i]=$.useState(""),[s,l]=Ej(),a=$.useRef(!1),u=$.useCallback(()=>{_t.get(e).then(Y=>r({type:"loaded",payload:Y}),Y=>r(Y instanceof I0&&/No such map/.test(Y.message)?{type:"missing"}:{type:"error",message:Y.message}))},[e]);$.useEffect(u,[u]),$.useEffect(()=>T0(Y=>r({type:"event",event:Y}),Y=>{r({type:"connected",value:Y}),Y&&a.current===!1&&n.phase!=="loading"&&u(),a.current=Y},t,e),[]);const c=n.map&&n.tour!==null?((D=n.map.tour[n.tour])==null?void 0:D.title)??null:null;$.useEffect(()=>{const Y=n.phase==="ready"?Z2(n.agent,n.selection,c):null;if(!Y)return;const V=setTimeout(()=>void _t.selection(e,Y.selection,Y.step).catch(()=>{}),250);return()=>clearTimeout(V)},[e,n.phase,n.agent,n.selection,c]);const d=Sl(n.agent),[h,p]=$.useState(null);$.useEffect(()=>p(null),[n.tour]);const y=n.map&&n.tour!==null&&h===n.tour?((b=n.map.tour[n.tour])==null?void 0:b.title)??null:null,x=$.useCallback(Y=>{const V=Y.trim();if(!V||n.job)return;const X=y?yC(y,V):V;_t.ask(e,X,n.selection).then(()=>i(""),E=>r({type:"error",message:E.message}))},[e,n.job,n.selection,y]),k=(Y,V)=>{V==="approve"&&r({type:"fixStatus",fixId:Y,status:"applying",problems:[]}),_t[V](e,Y).catch(X=>{r(V==="approve"?{type:"fixStatus",fixId:Y,status:"failed",problems:X.problems.length?X.problems:[X.message]}:{type:"error",message:[X.message,...X.problems].join(" ")})})},g=(Y,V)=>{_t.offer(e,Y,V).then(X=>{X.id&&Ml(Dt(X.id))},X=>r({type:"error",message:X.message}))};$.useEffect(()=>{const Y=V=>{const X=V.target instanceof HTMLTextAreaElement||V.target instanceof HTMLInputElement;if(V.key==="Escape"){mo(n.selection)?r({type:"clearSelection"}):n.tour!==null&&n.peek?r({type:"peek",open:!1}):n.tour!==null?r({type:"tour",stop:null}):r({type:"overview"});return}X||n.tour===null||(V.key==="ArrowRight"&&r({type:"tour",stop:n.tour+1}),V.key==="ArrowLeft"&&r({type:"tour",stop:n.tour-1}))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n.tour,n.peek,n.selection]);const v=n.answers.find(Y=>Y.id===n.shown),m=v!=null&&v.fix&&["proposed","applying","failed"].includes(((M=n.fixes[v.fix.id])==null?void 0:M.status)??"")?v.fix:null,w=$.useCallback((Y,V,X)=>r({type:"select",kind:Y,id:V,additive:X}),[]),C=$.useCallback(()=>r({type:"clearSelection"}),[]),S=F0(n),_=kC(n),j=wC(n),I=!!n.map&&n.tour!==null,O=$.useMemo(()=>({...n,answers:eC(n.agent,n.answers,n.fixes)}),[n]),F=n.shown!==null&&O.answers.some(Y=>Y.id===n.shown),U=((L=n.job)==null?void 0:L.kind)==="ask"&&!d,N=(!n.map||!!n.error||!!n.job&&(n.job.kind==="make"||U)||F)&&(!I||n.peek||!!n.error||U),T=N&&!!n.map,z=n.map&&d?f.jsx(LC,{map:n.map,agent:n.agent,selection:n.selection,step:c,onRemove:(Y,V)=>r({type:"select",kind:Y,id:V,additive:!0})}):n.map?f.jsx(zC,{map:n.map,selection:n.selection,draft:o,busy:!!n.job,agentName:n.agent.name,autoFocus:T,onDraft:i,onRemove:(Y,V)=>r({type:"select",kind:Y,id:V,additive:!0}),step:y,onRemoveStep:()=>p(null),onSend:()=>x(o)}):null;return f.jsx(M0,{children:f.jsxs("div",{className:"app",children:[f.jsxs("header",{className:"topbar",children:[f.jsxs("a",{className:"brand",href:Dt(),title:"All maps in this repo",children:[f.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate"]}),f.jsxs("div",{className:"topbar-map",children:[((P=n.meta)==null?void 0:P.parent)&&f.jsxs("a",{className:"crumb",href:Dt(n.meta.parent.mapId),title:`Back to the map this one came from: ${n.meta.parent.question}`,children:["← ",n.meta.parent.question]}),f.jsx(bj,{mapId:e,question:((H=n.map)==null?void 0:H.question)??((ee=n.job)==null?void 0:ee.question)??"",making:((K=n.job)==null?void 0:K.kind)==="make"})]}),f.jsx(Pj,{report:n.report}),f.jsx("a",{className:"pill-btn",href:Dt(),title:"Ask a new question and make a map for it",children:"New map"}),f.jsx(G0,{busy:!!n.job,agentName:n.agent.name,onStopped:t,onError:Y=>r({type:"error",message:Y})}),f.jsx("span",{className:n.connected?"live on":"live",title:n.connected?"Connected to illuminate":"Reconnecting to illuminate…"})]}),f.jsxs("div",{className:N?"body":"body full",style:{"--panel-w":`${s}px`},children:[f.jsx("div",{className:"canvas",children:n.map&&S?f.jsxs(f.Fragment,{children:[f.jsx(vj,{map:S,report:n.report,selection:n.selection,view:j,fresh:n.fresh,added:_,ghost:m??null,touring:I,onSelect:w,onClear:C}),!N&&f.jsx(FC,{state:O,dispatch:r}),mo(n.selection)>0&&f.jsx(VC,{mapId:e,map:S,report:n.report,selection:n.selection,onClose:C}),I&&mo(n.selection)===0&&f.jsx(jj,{map:n.map,stop:n.tour,onTour:Y=>r({type:"tour",stop:Y}),onAsk:d?void 0:()=>{var Y;p(n.tour),(Y=document.getElementById("ask"))==null||Y.focus()}}),f.jsx(OC,{map:n.map,mapId:e,tour:n.tour,onTour:Y=>r({type:"tour",stop:Y}),selected:mo(n.selection),children:T?null:z})]}):f.jsx("div",{className:"empty",children:n.phase==="making"?f.jsxs("div",{className:"pulse",children:[n.agent.name," is exploring the code…"]}):null})}),N&&f.jsx(_j,{width:s,onWidth:l}),N&&f.jsx($C,{state:O,dispatch:r,onFix:k,onFocus:Y=>r({type:"focus",id:Y}),onOffer:g,composer:T?z:null})]})]})})}Fm(document.getElementById("root")).render(f.jsx($.StrictMode,{children:f.jsx(Mj,{})}));export{zj as c,Ch as g};
71
- //# sourceMappingURL=index-Booj4TYt.js.map
70
+ `]},T))})]}),x&&j&&f.jsxs("p",{children:[j.found>x.matches?"This may no longer be missing: the search below now finds something.":"Nothing in the code connects these, going by this search."," ","Searched ",j.searched??"?"," ",j.searched===1?"file":"files",x.search.paths?f.jsxs(f.Fragment,{children:[" in ",f.jsx("code",{children:x.search.paths.join(", ")})]}):" (the whole repo)"," for ",f.jsx("code",{children:x.search.pattern}),": ",j.found," ",j.found===1?"match":"matches","."]}),k&&k.status==="unconfirmed"&&f.jsxs("div",{className:"warn small",children:["Couldn't confirm against the code: ",k.reasons.join("; ")]}),g.length>0&&f.jsxs("div",{className:"basis",children:[f.jsxs("div",{className:"code-toggle",children:[f.jsx("div",{className:"eyebrow",children:(S==null?void 0:S.kind)==="removed"?`In the code as it was at ${_}`:"In the code"}),f.jsx("button",{className:"link-btn small",onClick:()=>s(!i),children:i?"Hide the code":"Show the code"})]}),f.jsx("div",{className:"chips",children:g.map((N,T)=>{var b,M;const z=((b=v[T])==null?void 0:b.ok)??!1,D=((M=v[T])==null?void 0:M.foundAt)??N.line;return z?f.jsxs("button",{className:"chip cite",title:"Show this line in the code",onClick:()=>{s(!0),c(L=>({at:`${N.file}:${D}`,n:((L==null?void 0:L.n)??0)+1}))},children:[f.jsx("span",{className:"tick",children:"✓"}),N.file,":",D]},T):f.jsxs("span",{className:"chip static chip-unconfirmed",children:[f.jsx("span",{className:"qmark",children:"?"}),N.file,":",D]},T)})}),i&&(p||y)&&f.jsx(iC,{mapId:e,itemId:h,change:(S==null?void 0:S.kind)??null,since:_,stamp:n,jump:u})]})]})}function TC({diff:e}){const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return f.jsxs("span",{className:"diff-size",children:[t>0&&f.jsxs("span",{className:"add",children:[" +",t]}),n>0&&f.jsxs("span",{className:"del",children:[" −",n]})]})}function zC({map:e,selection:t,draft:n,busy:r,agentName:o="Claude",autoFocus:i,onDraft:s,onRemove:l,step:a,onRemoveStep:u,onSend:c}){const d=$.useRef(null),h=["nodes","edges","absences"].flatMap(p=>t[p].map(y=>({kind:p,id:y})));return $.useEffect(()=>{const p=d.current;p&&(p.style.height="auto",p.style.height=`${Math.min(p.scrollHeight,140)}px`)},[n]),$.useEffect(()=>{var p;n&&((p=d.current)==null||p.focus())},[n===""]),$.useEffect(()=>{var p;i&&((p=d.current)==null||p.focus({preventScroll:!0}))},[]),f.jsxs("form",{className:"composer",onSubmit:p=>{p.preventDefault(),!r&&n.trim()&&c()},children:[a&&f.jsxs("span",{className:"sel-chip sel-step",children:[f.jsxs("span",{className:"sel-text",title:`Walkthrough step: ${a}`,children:["▸ ",a]}),f.jsx("button",{type:"button","aria-label":`Don't ask about the step “${a}”`,onClick:u,children:"×"})]}),h.map(p=>f.jsxs("span",{className:`sel-chip sel-${p.kind}`,children:[f.jsxs("span",{className:"sel-text",title:et(e,p.id),children:[p.kind==="absences"?"✕ ":"◉ ",et(e,p.id)]}),f.jsx("button",{type:"button","aria-label":`Remove ${et(e,p.id)}`,onClick:()=>l(p.kind,p.id),children:"×"})]},`${p.kind}:${p.id}`)),f.jsx("textarea",{ref:d,id:"ask",rows:1,value:n,placeholder:r?`${o} is working…`:h.length?"Ask about what you selected…":a?"Ask about this step…":"Ask about this map…",onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),!r&&n.trim()&&c())},"aria-label":"Ask a question about the map"}),f.jsx("button",{type:"submit",className:"send",disabled:r||!n.trim(),"aria-label":"Send",children:"↑"})]})}function LC({map:e,agent:t,selection:n,step:r,onRemove:o}){const i=["nodes","edges","absences"].flatMap(l=>n[l].map(a=>({kind:l,id:a}))),s=q2(t,i.length,r);return f.jsxs("div",{className:"composer composer-chat",role:"note","aria-label":"Where to ask",children:[i.map(l=>f.jsxs("span",{className:`sel-chip sel-${l.kind}`,children:[f.jsxs("span",{className:"sel-text",title:et(e,l.id),children:[l.kind==="absences"?"✕ ":"◉ ",et(e,l.id)]}),f.jsx("button",{type:"button","aria-label":`Remove ${et(e,l.id)}`,onClick:()=>o(l.kind,l.id),children:"×"})]},`${l.kind}:${l.id}`)),f.jsxs("p",{className:"chat-hint",children:[f.jsx("strong",{children:s.title})," ",f.jsx("span",{className:"muted",children:s.detail})]})]})}const ha="illuminate-toured",AC=100;function gh(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function RC(e,t,n=AC){return[...e.filter(r=>r!==t),t].slice(-n)}function DC(e,t){const[n,r]=$.useState(()=>gh(ti(ha)).includes(e));return $.useEffect(()=>{!t||n||!e||(Nl(ha,JSON.stringify(RC(gh(ti(ha)),e))),r(!0))},[e,t,n]),n}function OC({map:e,mapId:t,tour:n,onTour:r,selected:o,children:i}){const s=DC(t,n!==null),l=e.tour.length,a=l>0&&n===null;return!a&&!i?null:f.jsxs("div",{className:"dock",children:[a&&f.jsxs("section",{className:"dock-part dock-walk","aria-label":"Walkthrough",children:[f.jsx("h2",{className:"dock-title",children:"Walkthrough"}),f.jsxs("button",{className:s?"dock-start":"dock-start glow",onClick:()=>r(0),children:["Take the walkthrough ",f.jsxs("span",{className:"muted",children:[l," ",l===1?"stop":"stops"]})]})]}),i&&f.jsxs("section",{className:"dock-part dock-ask","aria-label":"Ask about the map",children:[f.jsxs("div",{className:"dock-head",children:[f.jsx("h2",{className:"dock-title",children:"Ask about the map"}),f.jsx("span",{className:"dock-hint",children:o?"Shift-click to add more":"Click a box or arrow to ask about it"})]}),i]})]})}function FC({state:e,dispatch:t}){const n=e.answers[e.answers.length-1];return n?f.jsx("div",{className:"history-corner",children:f.jsxs("button",{className:"pill-btn history-btn",onClick:()=>t(e.tour!==null?{type:"peek",open:!0}:{type:"show",answerId:n.id}),title:"Open the conversation about this map",children:[f.jsx("span",{className:"history-arrow",children:"‹"})," Conversation ",f.jsx("span",{className:"muted",children:e.answers.length})]})}):null}const lr=14,Ie=12;function HC(e,t){const n=l=>l[l.length-1],r=n(t.nodes),o=n(t.edges),i=n(t.absences),s=r!==void 0?`.react-flow__node[data-id="${CSS.escape(r)}"]`:o!==void 0?`.link-label[data-id="${CSS.escape(`e:${o}`)}"]`:i!==void 0?`.link-label[data-id="${CSS.escape(`a:${i}`)}"]`:null;return s?e.querySelector(s):null}const Nu="illuminate-bubble-size",V0=300,W0=180;function BC(){try{const e=JSON.parse(ti(Nu)??"null");if(e&&typeof e=="object"&&"w"in e&&"h"in e&&typeof e.w=="number"&&typeof e.h=="number")return{w:Math.max(V0,e.w),h:Math.max(W0,e.h)}}catch{}return null}function VC({mapId:e,map:t,report:n,selection:r,onClose:o}){const i=[...r.nodes,...r.edges,...r.absences],s=i.join(" "),l=$.useRef(null),[a,u]=$.useState(null),c=$.useRef(null),d=mi(),h=le(m=>m.transform.join(",")),[p,y]=$.useState(""),[x,k]=$.useState(BC),g=m=>{const w=l.current,C=w==null?void 0:w.querySelector(".card-selected"),S=w==null?void 0:w.parentElement;if(!w||!C||!S||!a)return;m.preventDefault();const _=m.clientX,j=m.clientY,I=w.offsetWidth,O=C.offsetHeight,F=S.clientWidth-2*Ie,U=a.side==="right"?1:-1;let B={w:I,h:O};const N=z=>{B={w:Math.round(Math.max(V0,Math.min(F,I+U*(z.clientX-_)))),h:Math.round(Math.max(W0,O+z.clientY-j))},k(B)},T=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",T),document.body.classList.remove("resizing-bubble"),Nl(Nu,JSON.stringify(B))};window.addEventListener("pointermove",N),window.addEventListener("pointerup",T),document.body.classList.add("resizing-bubble")},v=()=>{try{localStorage.removeItem(Nu)}catch{}k(null)};return $.useLayoutEffect(()=>{const m=l.current;if(!m)return;const w=new ResizeObserver(()=>y(`${m.offsetWidth}x${m.offsetHeight}`));return w.observe(m),()=>w.disconnect()},[s]),$.useLayoutEffect(()=>{const m=l.current,w=m==null?void 0:m.parentElement;if(!m||!w)return;const C=HC(w,r);if(!C){u(null);return}const S=w.getBoundingClientRect(),_=C.getBoundingClientRect(),j={left:_.left-S.left,right:_.right-S.left,top:_.top-S.top,bottom:_.bottom-S.top},I=w.querySelector(".dock"),O=I?I.getBoundingClientRect().top-S.top-Ie:S.height-Ie,F=Math.max(160,O-Ie),U=m.offsetWidth,B=Math.min(m.offsetHeight,F),N=S.width-Ie-j.right-lr,T=j.left-lr-Ie,z=N>=U||N>=T?"right":"left",D=z==="right"?j.right+lr:j.left-lr-U,b=Math.max(Ie,Math.min(D,S.width-Ie-U)),M=Math.max(Ie,Math.min(j.top,O-B)),L=Math.max(16,Math.min((j.top+j.bottom)/2-M,B-16));if(u({left:b,top:M,side:z,pointer:L,maxHeight:F}),c.current===s)return;c.current=s;const P=z==="right"?j.left:j.left-lr-U,H=z==="right"?j.right+lr+U:j.right,ee=H-P<=S.width-2*Ie,K=ee?P:j.left,Y=ee?H:j.right,V=K<Ie?Ie-K:Y>S.width-Ie?S.width-Ie-Y:0,X=j.top<Ie?Ie-j.top:j.bottom>O?Math.max(O-j.bottom,Ie-j.top):0;if(V||X){const E=d.getViewport();d.setViewport({...E,x:E.x+V,y:E.y+X},{duration:300})}},[s,h,p]),i.length?f.jsxs("div",{ref:l,className:`box-bubble box-bubble-${(a==null?void 0:a.side)??"right"}`,style:{...a?{left:a.left,top:a.top,"--bubble-max":`${a.maxHeight}px`}:{visibility:"hidden",left:0,top:0},...x?{width:x.w,"--bubble-cap":`${x.h}px`}:{}},role:"dialog","aria-label":"What you selected",children:[a&&f.jsx("i",{className:"box-bubble-pointer",style:{top:a.pointer},"aria-hidden":"true"}),f.jsx(IC,{mapId:e,map:t,report:n,ids:i,onClose:o},s),f.jsx("span",{className:"box-bubble-grip",onPointerDown:g,onDoubleClick:v,title:"Drag to resize. Double-click for the usual size.","aria-hidden":"true"})]}):null}const WC="modulepreload",UC=function(e){return"/"+e},yh={},YC=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),l=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));o=Promise.allSettled(n.map(a=>{if(a=UC(a),a in yh)return;yh[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":WC,u||(d.as="script"),d.crossOrigin="",d.href=a,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((h,p)=>{d.addEventListener("load",h),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${a}`)))})}))}function i(s){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=s,window.dispatchEvent(l),!l.defaultPrevented)throw s}return o.then(s=>{for(const l of s||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Vn=232,Dn=96,U0=e=>e.view==="journey"&&[...e.nodes,...e.edges].some(t=>!!t.branch);function Xs(e,t){var i;const n=((i=e.nodes[t])==null?void 0:i.y)??0,r=e.rowTops??[];let o=0;for(const[s,l]of r.entries())n>=l-1&&(o=s);return o}const XC=132;function Eu(e,t=!1){return e==="choice"?{w:196,h:132}:e==="action"?{w:196,h:60}:t?{w:232,h:64+XC}:{w:196,h:72}}let KC=null;const Hc=()=>KC??(KC=YC(()=>import("./elk.bundled-Uq41P_C7.js").then(e=>e.e),[]).then(e=>new e.default)),Bc={"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};function El(e,t){const n=new Set(e.nodes.map(r=>r.id));return[...e.edges.map(r=>({id:`e:${r.id}`,from:r.from,to:r.to})),...e.absences.flatMap(r=>r.between?[{id:`a:${r.id}`,from:r.between.from,to:r.between.to}]:[]),...t.map(r=>({id:`x:${r.id}`,from:r.from,to:r.to}))].filter(r=>n.has(r.from)&&n.has(r.to)&&r.from!==r.to)}const St={top:52,side:26,bottom:26},ur=64,cs=44,GC=56,QC=140;async function Y0(e,t,n,r){const o=await e.layout({id:t,layoutOptions:{...Bc,"elk.direction":"DOWN","elk.padding":`[top=${St.top},left=${St.side},bottom=${St.bottom},right=${St.side}]`,"elk.layered.spacing.nodeNodeBetweenLayers":String(ur),"elk.spacing.nodeNode":String(cs)},children:n.map(s=>({id:s.id,width:Vn,height:Dn})),edges:r.map(s=>({id:s.id,sources:[s.from],targets:[s.to]}))}),i={};for(const s of o.children??[])i[s.id]={x:s.x??0,y:s.y??0,w:Vn,h:Dn};return{nodes:i,size:{w:o.width??Vn+2*St.side,h:o.height??Dn+St.top+St.bottom}}}function qC(e,t){const n=e.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e,areas:e.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}async function ZC(e,t=[],n=new Set,r=new Set){var C;if(e.view==="journey")return U0(e)?tj(e,t,r):X0(e,t,r);const o=e.nodes.filter(S=>n.has(S.id));if(!o.length)return kh(e,t);const i=qC(e,n),s=new Set(i.nodes.map(S=>S.id)),l=await kh(i,t.filter(S=>s.has(S.from)&&s.has(S.to))),a=await Hc(),u=Object.fromEntries(Object.entries(l.areas).map(([S,_])=>[S,{..._}])),c={...l.nodes},d={},h={};for(const S of o)(h[C=S.area]??(h[C]=[])).push(S);for(const[S,_]of Object.entries(h)){const j=u[S];if(!j)continue;const I=Math.max(1,Math.floor((j.w-2*St.side+cs)/(Vn+cs))),O=Math.max(St.top-ur,...i.nodes.filter(U=>U.area===S).map(U=>{var B;return(((B=c[U.id])==null?void 0:B.y)??0)+Dn}))+ur;_.forEach((U,B)=>{c[U.id]={x:St.side+B%I*(Vn+cs),y:O+Math.floor(B/I)*(Dn+ur),w:Vn,h:Dn}});const F=Math.max(j.h,O+Math.ceil(_.length/I)*(Dn+ur)-ur+St.bottom);d[S]=F-j.h,j.h=F}const p=Object.fromEntries(Object.entries(l.areas).map(([S,_])=>[S,_])),y=Object.keys(p).sort((S,_)=>p[S].y-p[_].y),x={};for(const S of y){const _=p[S];x[S]=Math.max(0,...y.filter(j=>j!==S&&x[j]!==void 0).filter(j=>{const I=p[j];return I.y+I.h<=_.y+1&&I.x<_.x+_.w&&_.x<I.x+I.w}).map(j=>x[j]+(d[j]??0))),u[S].y+=x[S]}const k=El(e,t),g=new Map(e.nodes.map(S=>[S.id,S.area])),v=Math.max(0,...Object.values(u).map(S=>S.x+S.w))+QC;let m=0;for(const S of e.areas){if(u[S.id])continue;const _=e.nodes.filter(O=>O.area===S.id);if(!_.length)continue;const j=k.filter(O=>g.get(O.from)===S.id&&g.get(O.to)===S.id),I=await Y0(a,S.id,_,j);Object.assign(c,I.nodes),u[S.id]={x:v,y:m,w:I.size.w,h:I.size.h},m+=I.size.h+GC}const w=Object.values(u);return{areas:u,nodes:c,width:Math.max(0,...w.map(S=>S.x+S.w)),height:Math.max(0,...w.map(S=>S.y+S.h))}}const vh=1900,_u=130;async function X0(e,t,n){const o=await(await Hc()).layout({id:"root",layoutOptions:{...Bc,"elk.direction":"RIGHT","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.spacing.nodeNodeBetweenLayers":"176","elk.spacing.nodeNode":"56","elk.spacing.componentComponent":"72"},children:e.nodes.map(p=>({id:p.id,width:Eu(p.kind,n.has(p.id)).w,height:Eu(p.kind,n.has(p.id)).h})),edges:El(e,t).map(p=>({id:p.id,sources:[p.from],targets:[p.to]}))}),i={};for(const p of o.children??[])i[p.id]={x:p.x??0,y:p.y??0,w:p.width??0,h:p.height??0};const s=o.width??0;if(s<=vh)return{areas:{},nodes:i,width:s,height:o.height??0,flat:!0};const l=[];for(const[p,y]of Object.entries(i).sort((x,k)=>x[1].x+x[1].w/2-(k[1].x+k[1].w/2))){const x=l[l.length-1];x&&y.x+y.w/2<x.right?(x.ids.push(p),x.left=Math.min(x.left,y.x),x.right=Math.max(x.right,y.x+y.w)):l.push({left:y.x,right:y.x+y.w,ids:[p]})}const a=Math.ceil(s/vh),u=Math.ceil(l.length/a);let c=0,d=0;const h=[];for(let p=0;p*u<l.length;p++){const y=l.slice(p*u,(p+1)*u),x=y.flatMap(v=>v.ids),k=y[0].left,g=Math.min(...x.map(v=>i[v].y));h.push(c);for(const v of x)i[v]={...i[v],x:i[v].x-k,y:i[v].y-g+c};c=Math.max(...x.map(v=>i[v].y+i[v].h))+_u,d=Math.max(d,y[y.length-1].right-k)}return{areas:{},nodes:i,width:d,height:c-_u,flat:!0,rowTops:h}}const Ui=176,xh=120,wh=34,JC=14;function ej(e,t){const n=new Map(e.map(i=>[i,0]));for(const i of t)n.set(i.to,(n.get(i.to)??0)+1);const r=new Set(e),o=[];for(;r.size;){const i=e.find(s=>r.has(s)&&!n.get(s))??e.find(s=>r.has(s));r.delete(i),o.push(i);for(const s of t)s.from===i&&r.has(s.to)&&n.set(s.to,n.get(s.to)-1)}return o}async function tj(e,t,n){const r=El(e,t),o=new Map(e.nodes.map(E=>[E.id,Eu(E.kind,n.has(E.id))])),i=new Map(e.nodes.map(E=>[E.id,E.branch??null])),s=ej(e.nodes.map(E=>E.id),r),l=s.filter(E=>!i.get(E));if(!l.length)return X0(e,t,n);const a=E=>o.get(E).w,u=E=>o.get(E).h,c=new Map,d=new Map;let h=0;for(const E of l)c.set(E,h),d.set(E,0),h+=a(E)+Ui;const p=E=>c.get(E)+a(E)/2,y=E=>c.get(E)+a(E),x=[...new Set([...e.nodes,...e.edges].flatMap(E=>E.branch?[E.branch]:[]))],k=new Map;for(const E of s){const R=i.get(E);R&&k.set(R,[...k.get(R)??[],E])}const g=[],v=new Map,m=new Set(k.keys()),w=(E,R)=>{const q=k.get(E),Q=new Set(q),G=r.filter(ie=>Q.has(ie.to)&&!Q.has(ie.from));if(!R&&G.length&&!G.some(ie=>d.has(ie.from)))return null;const A=G.filter(ie=>d.has(ie.from)).map(ie=>ie.from).sort((ie,Ae)=>d.get(ie)-d.get(Ae)||p(ie)-p(Ae))[0]??null,W=A&&d.get(A)===0?l[l.indexOf(A)+1]:void 0,Z=q[0],te=A?W?(p(A)+p(W))/2:p(A)+(a(A)/2+Ui+a(Z)/2)/2:a(Z)/2,oe=[];let de=te-a(Z)/2;for(const ie of q)oe.push(de),de+=a(ie)+Ui;const me=r.filter(ie=>Q.has(ie.from)&&!Q.has(ie.to)&&d.has(ie.to)),ke=me.filter(ie=>p(ie.to)>=oe[0]).map(ie=>p(ie.to)),Me=me.filter(ie=>p(ie.to)<oe[0]).map(ie=>p(ie.to));return{name:E,ids:q,anchor:A,xs:oe,kind:Me.length?2:ke.length?0:1,reach:Math.max(0,...ke),span:[Math.min(A?p(A):oe[0],...Me)-30,Math.max(de-Ui,...ke)+30],verticals:[...A?[{x:p(A),from:d.get(A)}]:[],...me.map(ie=>({x:p(ie.to),from:d.get(ie.to)}))],minLane:A?d.get(A)+1:1,root:A?d.get(A)===0?l.indexOf(A):v.get(i.get(A))??l.length:l.length}};for(;m.size;){const R=[...m].flatMap(A=>w(A,!1)??[]).sort((A,W)=>(A.anchor?p(A.anchor):1/0)-(W.anchor?p(W.anchor):1/0)||A.kind-W.kind||A.reach-W.reach||x.indexOf(A.name)-x.indexOf(W.name))[0]??w(x.find(A=>m.has(A))??[...m][0],!0);m.delete(R.name);const q=A=>!g.some(W=>W.lane===A&&W.span[0]<R.span[1]&&R.span[0]<W.span[1]),Q=A=>R.verticals.every(W=>g.every(Z=>!(Z.lane>W.from&&Z.lane<A)||Z.boxes.every(te=>W.x<c.get(te)-12||W.x>y(te)+12)))&&g.every(W=>W.lane<=A||W.verticals.every(Z=>Z.from>=A||R.xs.every((te,oe)=>Z.x<te-12||Z.x>te+a(R.ids[oe])+12)));let G=R.minLane;for(;G<R.minLane+12&&!(q(G)&&Q(G));)G++;if(G>=R.minLane+12)for(G=R.minLane;!q(G);G++);R.ids.forEach((A,W)=>{c.set(A,R.xs[W]),d.set(A,G)}),g.push({name:R.name,lane:G,span:R.span,verticals:R.verticals,boxes:R.ids,root:R.root}),v.set(R.name,R.root)}const C=[...new Set([...d.values()])].sort((E,R)=>E-R),S=new Map,_=new Map;let j=0;for(const E of C){const R=Math.max(...[...d].filter(([,q])=>q===E).map(([q])=>u(q)));S.set(E,j),_.set(E,j+R),j+=R+xh}const I={};for(const E of e.nodes){const R=d.get(E.id);I[E.id]={x:c.get(E.id),y:S.get(R)+(_.get(R)-S.get(R)-u(E.id))/2,w:a(E.id),h:u(E.id)}}const O=new Map(e.nodes.map(E=>[E.id,E.kind])),F=(E,R,q)=>{const Q=I[E],G=O.get(E)==="choice"?Math.min(Q.h/2,Math.abs(R-(Q.x+Q.w/2))*Q.h/Q.w):0;return q==="top"?Q.y+G:Q.y+Q.h-G},U=E=>I[E].y+I[E].h/2,B=E=>d.get(E),N=E=>[...d].filter(([,R])=>R===E).map(([R])=>R).sort((R,q)=>c.get(R)-c.get(q)),T=new Map,z=new Map,D=(E,R,q,Q)=>z.set(`${E}:${R}`,[...z.get(`${E}:${R}`)??[],{link:q,key:Q}]);for(const E of r){const R=B(E.from),q=B(E.to);let Q;if(R===q){const G=N(R);Q=G.indexOf(E.to)===G.indexOf(E.from)+1?"straight":R===0?"arc":"under"}else q>R?Q="down":Q=p(E.to)>y(E.from)+24?"rejoin":p(E.to)<c.get(E.from)-24?"return":"up";T.set(E.id,Q),Q==="arc"&&(D(E.from,"t",E.id,[p(E.to)]),D(E.to,"t",E.id,[p(E.from)])),(Q==="rejoin"||Q==="up")&&D(E.to,"b",E.id,[0,R]),Q==="return"&&D(E.to,"b",E.id,[1,-R]),Q==="down"&&D(E.from,"b",E.id,[2,-q])}const b=new Map;for(const[E,R]of z){const q=E.slice(0,E.lastIndexOf(":"));R.sort((Q,G)=>Q.key.reduce((A,W,Z)=>A||W-(G.key[Z]??0),0)),R.forEach((Q,G)=>b.set(`${Q.link}:${E}`,p(q)+(G-(R.length-1)/2)*JC))}const M=(E,R,q)=>b.get(`${E}:${R}:${q}`)??p(R),L=r.filter(E=>T.get(E.id)==="arc").sort((E,R)=>Math.abs(p(E.to)-p(E.from))-Math.abs(p(R.to)-p(R.from))),P=new Map(L.map((E,R)=>[E.id,R])),H=new Map,ee={};for(const E of r){const R=I[E.from],q=I[E.to],Q=B(E.from),G=T.get(E.id);let A;if(G==="straight")A={points:[[R.x+R.w,U(E.from)],[q.x,U(E.to)]],label:0};else if(G==="arc"){const W=-58-18*P.get(E.id),Z=M(E.id,E.from,"t"),te=M(E.id,E.to,"t");A={points:[[Z,F(E.from,Z,"top")],[Z,W],[te,W],[te,F(E.to,te,"top")]],label:1}}else if(G==="under"||G==="return"){const W=H.get(Q)??0;H.set(Q,W+1);const Z=_.get(Q)+wh+16*W,te=p(E.from)+(G==="under"?6:0),oe=G==="return"?M(E.id,E.to,"b"):p(E.to)-6;A={points:[[te,R.y+R.h],[te,Z],[oe,Z],[oe,F(E.to,oe,"bottom")]],label:1}}else if(G==="down"){const W=M(E.id,E.from,"b"),Z=p(E.to),te=S.get(B(E.to))-wh;A=Math.abs(Z-W)<4?{points:[[W,F(E.from,W,"bottom")],[W,q.y]],label:0}:{points:[[W,F(E.from,W,"bottom")],[W,te],[Z,te],[Z,q.y]],label:1}}else if(G==="rejoin"){const W=M(E.id,E.to,"b"),Z=N(Q).some(oe=>oe!==E.from&&c.get(oe)<W&&y(oe)>R.x+R.w),te=S.get(Q)-xh/2;A=Z?{points:[[p(E.from),R.y],[p(E.from),te],[W,te],[W,F(E.to,W,"bottom")]],label:1}:{points:[[R.x+R.w,U(E.from)],[W,U(E.from)],[W,F(E.to,W,"bottom")]],label:W-(R.x+R.w)>=150?0:1}}else{const W=Math.min(Math.max(M(E.id,E.to,"b"),R.x+12),R.x+R.w-12);A={points:[[W,R.y],[W,F(E.to,W,"bottom")]],label:0}}ee[E.id]=A}const Y=x.map(E=>{var G;const R=g.find(A=>A.name===E);if(R)return{name:E,root:R.root};const q=(G=e.edges.find(A=>A.branch===E))==null?void 0:G.from,Q=q?i.get(q):null;return{name:E,root:q&&d.get(q)===0?l.indexOf(q):Q?v.get(Q)??l.length:l.length}}).sort((E,R)=>E.root-R.root||x.indexOf(E.name)-x.indexOf(R.name)).map(E=>E.name),V=Object.values(I),X=Object.values(ee).flatMap(E=>E.points);return{areas:{},nodes:I,width:Math.max(...V.map(E=>E.x+E.w),...X.map(E=>E[0])),height:Math.max(...V.map(E=>E.y+E.h),...X.map(E=>E[1])),flat:!0,routes:ee,branches:Y}}async function kh(e,t){const n=await Hc(),r=new Map(e.nodes.map(c=>[c.id,c.area])),o=El(e,t),i={},s={};for(const c of e.areas){const d=e.nodes.filter(y=>y.area===c.id);if(!d.length)continue;const h=o.filter(y=>r.get(y.from)===c.id&&r.get(y.to)===c.id),p=await Y0(n,c.id,d,h);Object.assign(i,p.nodes),s[c.id]=p.size}const l=new Map;for(const c of o){const d=r.get(c.from),h=r.get(c.to);d!==h&&s[d]&&s[h]&&l.set(`${d}>${h}`,{from:d,to:h})}const a=await n.layout({id:"root",layoutOptions:{...Bc,"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.nodeNode":"48","elk.spacing.componentComponent":"64"},children:e.areas.filter(c=>s[c.id]).map(c=>({id:c.id,width:s[c.id].w,height:s[c.id].h})),edges:[...l.values()].map((c,d)=>({id:`p${d}`,sources:[c.from],targets:[c.to]}))}),u={};for(const c of a.children??[])u[c.id]={x:c.x??0,y:c.y??0,w:c.width??0,h:c.height??0};return{areas:u,nodes:i,width:a.width??0,height:a.height??0}}function nj(e,t,n,r){if(t.flat){const c=y=>{const x=t.nodes[y];return x?{x:x.x+x.w/2,y:x.y+x.h/2}:{x:0,y:0}},d=c(r).x-c(n).x,h=c(r).y-c(n).y;if(Math.abs(d)<40)return h>=0?["b","t"]:["t","b"];const p=Xs(t,r)-Xs(t,n);return p?p>0?["b","t"]:["r","b"]:d>=0?["r","l"]:["l","r"]}const o=c=>{var d;return((d=e.nodes.find(h=>h.id===c))==null?void 0:d.area)??""},i=c=>{const d=t.areas[o(c)],h=t.nodes[c];return d&&h?{x:d.x+h.x+h.w/2,y:d.y+h.y+h.h/2}:{x:0,y:0}},s=i(n),l=i(r),a=l.x-s.x,u=l.y-s.y;return o(n)===o(r)||Math.abs(a)<Vn*.75?u>=0?["b","t"]:["t","b"]:a>=0?["r","l"]:["l","r"]}function rj(e,t=[],n=[],r=[]){return JSON.stringify([e.view==="journey"?[e.nodes.map(o=>o.kind),[...r].sort(),...U0(e)?[[...e.nodes,...e.edges].map(o=>o.branch??"")]:[]]:null,[...n].sort(),e.areas.map(o=>o.id),e.nodes.map(o=>`${o.id}@${o.area}`),e.edges.map(o=>`${o.from}>${o.to}`),e.absences.map(o=>o.between?`${o.between.from}~${o.between.to}`:""),t.map(o=>`${o.from}+${o.to}`)])}const nn=(...e)=>e.filter(Boolean).join(" "),Wn={add:{pending:"Proposed",done:"Now in the code",mark:"+",title:"Proposed: not in the code yet"},change:{pending:"Would change",done:"Changed",mark:"~",title:"Proposed: this code would change"},remove:{pending:"Would be removed",done:"Removed",mark:"−",title:"Proposed: this code would be removed"}},_l=e=>e&&`proposal proposal-${e.kind} proposal-${e.state}`,Un={added:{label:"Added",mark:"+",title:"New since the commit this map is compared with"},changed:{label:"Changed",mark:"~",title:"Different from the commit this map is compared with"},removed:{label:"Removed",mark:"−",title:"Was in the code at the commit this map is compared with, and is gone now"}},Cl=e=>e&&`change change-${e}`,Ks={later:{label:"Not there yet",title:"Added after this version of the code"},gone:{label:"Gone",title:"Removed: it was in the code before, and isn’t now"}};function oj(e){if(!(e!=null&&e.length))return null;const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return[t&&`+${t}`,n&&`−${n}`].filter(Boolean).join(" ")||null}const ij=[["before","Before","The code as it was at that commit; what was added since is a shadow"],["after","After","The code as it is now; what was removed is a shadow"],["both","Both","The code as it is now, with what was removed drawn in too"]];function sj({commit:e,when:t,onWhen:n}){return f.jsxs("div",{className:"change-key",children:[f.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the code to show",children:ij.map(([r,o,i])=>f.jsx("button",{className:nn("seg-btn",t===r&&"on"),title:i,"aria-pressed":t===r,onClick:()=>n(r),children:o},r))}),f.jsx("span",{className:"change-key-title",children:t==="before"?`The code at ${e}`:t==="after"?"The code now":`Now, compared with ${e}`}),t==="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch"}),"Same as before"]}),t==="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch key-added"}),"Added"]}),f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:nn("key-swatch key-changed",t!=="both"&&"key-quiet")}),t==="before"?"Changes later":"Changed"]}),t==="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch key-removed"}),"Removed (only in the before)"]}),t!=="both"&&f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:"key-swatch key-ghost"}),t==="before"?"Not there yet":"Gone"]})]})}const lj=5,jl=e=>e&&`branch branch-${e.colour}`;function aj({branches:e}){return f.jsxs("div",{className:"change-key branch-key",children:[f.jsx("span",{className:"change-key-title",children:"Ways through"}),f.jsxs("span",{className:"key-item",title:"What most people do, start to finish",children:[f.jsx("i",{className:"key-swatch"}),"Main path"]}),e.map(t=>f.jsxs("span",{className:"key-item",children:[f.jsx("i",{className:nn("key-swatch",jl(t))}),t.name]},t.name))]})}const Yi={entry:["Where it starts","▸"],store:["Saved data","▤"],external:["Outside the app","↗"],job:["Background job","◷"]},Sh=[["t",re.Top],["r",re.Right],["b",re.Bottom],["l",re.Left]];function K0(){return f.jsxs(f.Fragment,{children:[Sh.map(([e,t])=>f.jsx(Ur,{id:`s${e}`,type:"source",position:t,className:"handle",isConnectable:!1},`s${e}`)),Sh.map(([e,t])=>f.jsx(Ur,{id:`t${e}`,type:"target",position:t,className:"handle",isConnectable:!1},`t${e}`))]})}function uj({data:e}){var t,n,r;return e.journey?f.jsx(cj,{data:e}):f.jsxs("div",{className:nn("step","nopan",`kind-${e.kind}`,!e.confirmed&&"unconfirmed",_l(e.proposal),Cl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),onClick:o=>{o.stopPropagation(),e.onClick(o.shiftKey||o.metaKey)},children:[f.jsx(K0,{}),(Yi[e.kind]||e.fresh||e.screen||e.proposal||e.change||e.ghost)&&f.jsxs("div",{className:"step-head",children:[e.ghost&&f.jsx("span",{className:"badge-ghost",title:Ks[e.ghost].title,children:Ks[e.ghost].label}),e.proposal&&f.jsx("span",{className:"badge-proposal",children:Wn[e.proposal.kind][e.proposal.state]}),e.change&&f.jsxs("span",{className:"badge-change",title:Un[e.change].title,children:[e.quiet==="before"?"Changes later":Un[e.change].label,e.changeSize&&!e.quiet&&f.jsxs("span",{className:"change-size",children:[" ",e.changeSize]})]}),Yi[e.kind]&&!e.proposal&&!e.change&&!e.ghost&&f.jsxs(f.Fragment,{children:[f.jsx("i",{className:"step-mark","aria-hidden":"true",children:Yi[e.kind][1]}),Yi[e.kind][0]]}),e.screen&&f.jsx("span",{className:"badge-screen",title:"Select this step to see the screen",children:"▣ Screen"}),e.fresh&&f.jsx("span",{className:"badge-new",children:"New"})]}),f.jsx("div",{className:"step-name",title:e.name,children:e.name}),f.jsxs("div",{className:"step-code",title:((t=e.proposal)==null?void 0:t.state)==="pending"?Wn[e.proposal.kind].title:e.confirmed?"Confirmed against the code":"The checker couldn't confirm this against the code",children:[((n=e.proposal)==null?void 0:n.state)==="pending"&&e.proposal.kind==="add"?f.jsx("span",{className:"pmark",children:"+"}):((r=e.proposal)==null?void 0:r.state)==="done"&&e.proposal.kind!=="add"?f.jsx("span",{className:"pmark",children:Wn[e.proposal.kind].mark}):e.change&&e.confirmed?f.jsx("span",{className:"cmark",children:Un[e.change].mark}):f.jsx("span",{className:e.confirmed?"tick":"qmark",children:e.confirmed?"✓":"?"}),f.jsx("span",{className:"step-sub",children:e.sub})]})]})}function cj({data:e}){const t=e.journey,n=e.proposal;return f.jsxs("div",{className:nn("step","jstep","nopan",`j-${t.shape}`,t.show&&"j-pictured",t.outside&&"j-outside",!e.confirmed&&"unconfirmed",_l(n),Cl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",jl(t.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),style:{width:t.w,height:t.h},onClick:r=>{r.stopPropagation(),e.onClick(r.shiftKey||r.metaKey)},children:[f.jsx(K0,{}),t.stage&&f.jsx("div",{className:"j-stage",children:t.stage}),t.shape==="choice"&&f.jsx("svg",{className:"j-diamond",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:f.jsx("polygon",{points:"50,1 99,50 50,99 1,50",vectorEffect:"non-scaling-stroke"})}),f.jsxs("div",{className:"j-tags",children:[n&&f.jsx("span",{className:"badge-proposal",children:Wn[n.kind][n.state]}),e.ghost&&f.jsx("span",{className:"badge-ghost",title:Ks[e.ghost].title,children:Ks[e.ghost].label}),e.change&&f.jsx("span",{className:"badge-change",title:Un[e.change].title,children:e.quiet==="before"?"Changes later":Un[e.change].label}),!e.confirmed&&f.jsx("span",{className:"j-q",title:"The checker couldn't confirm this against the code",children:"?"}),e.fresh&&f.jsx("span",{className:"badge-new",children:"New"})]}),t.show&&f.jsx(uC,{show:t.show,name:e.name}),f.jsx("div",{className:"j-name",title:e.name,children:e.name}),t.outside&&t.shape!=="choice"&&f.jsx("div",{className:"j-note",children:"Outside the app"})]})}function dj({data:e}){return f.jsx("div",{className:nn("area",e.dim&&"dim"),children:f.jsxs("div",{className:"area-label",children:[e.label,e.note&&f.jsxs("span",{className:"area-note",children:[" ",e.note]})]})})}function fj(e,t,n,r,o){const i=Math.hypot(n-e,r-t)||1,s=-(r-t)/i,l=(n-e)/i,a=(e+n)/2+s*o*2,u=(t+r)/2+l*o*2;return[`M ${e} ${t} Q ${a} ${u} ${n} ${r}`,(e+n)/2+s*o,(t+r)/2+l*o]}function Nh(e,t=18,n){let r=`M ${e[0][0]} ${e[0][1]}`;for(let a=1;a<e.length-1;a++){const[u,c]=e[a-1],[d,h]=e[a],[p,y]=e[a+1],x=Math.min(t,Math.hypot(d-u,h-c)/2),k=Math.min(t,Math.hypot(p-d,y-h)/2),g=Math.sign(d-u),v=Math.sign(h-c),m=Math.sign(p-d),w=Math.sign(y-h);r+=` L ${d-g*x} ${h-v*x} Q ${d} ${h} ${d+m*k} ${h+w*k}`}const o=e[e.length-1];r+=` L ${o[0]} ${o[1]}`;const[i,s]=n!==void 0?[e[n],e[n+1]]:[];if(i&&s)return[r,(i[0]+s[0])/2,(i[1]+s[1])/2];let l=[0,e[0][0],e[0][1]];for(let a=1;a<e.length;a++){const[u,c]=e[a-1],[d,h]=e[a];c===h&&Math.abs(d-u)>l[0]&&(l=[Math.abs(d-u),(u+d)/2,h])}return[r,l[1],l[2]]}function hj({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i,targetPosition:s,markerEnd:l,data:a}){const[u,c,d]=a!=null&&a.route?Nh(a.route.points,18,a.route.label):(a==null?void 0:a.wrapY)!==void 0&&i===re.Right?Nh([[t,n],[t+30,n],[t+30,a.wrapY],[r,a.wrapY],[r,o]]):(a==null?void 0:a.wrapY)!==void 0?Ws({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:s,borderRadius:18,centerY:a.wrapY}):a!=null&&a.offset?fj(t,n,r,o,a.offset):Tc({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:s});return a?f.jsxs(f.Fragment,{children:[a.selected&&f.jsx("path",{d:u,className:"edge-halo"}),f.jsx(gi,{id:e,path:u,markerEnd:l,interactionWidth:18}),f.jsx(k2,{children:f.jsxs("div",{className:nn("link-label",`link-${a.variant}`,!a.confirmed&&"unconfirmed",_l(a.proposal),Cl(a.change),a.ghost&&"ghost",jl(a.branch),a.hl&&"hl",a.dim&&"dim",a.selected&&"selected","nodrag nopan"),"data-id":e,style:{transform:`translate(-50%, -50%) translate(${c}px, ${d}px)`},onClick:h=>{var p;h.stopPropagation(),(p=a.onClick)==null||p.call(a,h.shiftKey||h.metaKey)},children:[a.variant==="absence"&&f.jsx("span",{className:"gap-q","aria-hidden":"true",children:"?"}),a.proposal&&f.jsx("span",{className:"pmark",title:a.proposal.state==="done"?Wn[a.proposal.kind].done:Wn[a.proposal.kind].title,children:a.proposal.state==="done"&&a.proposal.kind==="add"?"✓":Wn[a.proposal.kind].mark}),a.change&&f.jsx("span",{className:"cmark",title:Un[a.change].title,children:Un[a.change].mark}),f.jsx("span",{className:"link-text",children:a.label}),!a.confirmed&&a.variant==="edge"&&f.jsx("span",{className:"q",children:" ?"})]})})]}):null}const pj={step:uj,area:dj},mj={link:hj};function Eh(e,t){const n=new Set;for(const r of t){e.nodes.some(s=>s.id===r)&&n.add(r);const o=e.edges.find(s=>s.id===r);o&&n.add(o.from).add(o.to);const i=e.absences.find(s=>s.id===r);i!=null&&i.between&&n.add(i.between.from).add(i.between.to)}return[...n]}const gj="440px",yj=e=>e.length>28?`${e.slice(0,26)}…`:e;function vj(e){var F,U,B,N,T,z,D,b,M,L;const t=(F=e.ghost)!=null&&F.connects&&e.map.nodes.some(P=>P.id===e.ghost.connects.from)&&e.map.nodes.some(P=>P.id===e.ghost.connects.to)?e.ghost:null,n=$.useMemo(()=>t!=null&&t.connects?[{id:t.id,from:t.connects.from,to:t.connects.to}]:[],[t]),r=$.useMemo(()=>e.map.view==="journey"?e.map.nodes.filter(P=>{var H,ee,K;return P.kind!=="action"&&P.kind!=="choice"&&((K=(ee=(H=e.report)==null?void 0:H.screens)==null?void 0:ee[P.id])==null?void 0:K.status)==="confirmed"}).map(P=>P.id):[],[e.map,e.report]),o=rj(e.map,n,e.added,r),[i,s]=$.useState(null),l=mi(),[a,u]=$.useState("both"),d=!!((B=(U=e.report)==null?void 0:U.since)!=null&&B.commit)?a:"both",h=P=>{var H,ee,K,Y,V,X;return((K=(ee=(H=e.report)==null?void 0:H.nodes[P])==null?void 0:ee.change)==null?void 0:K.kind)??((X=(V=(Y=e.report)==null?void 0:Y.edges[P])==null?void 0:V.change)==null?void 0:X.kind)??null},p=P=>d==="before"&&h(P)==="added"?"later":d==="after"&&h(P)==="removed"?"gone":null,y=P=>d==="both"||P==="changed"?P:null;$.useEffect(()=>{let P=!0;return ZC(e.map,n,new Set(e.added),new Set(r)).then(H=>P&&s({key:o,layout:H}),H=>console.error("illuminate: the map could not be laid out",H)),()=>{P=!1}},[o]);const x=(N=e.view)!=null&&N.highlight.length?new Set(e.view.highlight):null,k=$.useMemo(()=>x?new Set(Eh(e.map,[...x])):null,[x,e.map]),g=e.selection,v=$.useMemo(()=>((i==null?void 0:i.layout.branches)??[]).map((P,H)=>({name:P,colour:H%lj+1})),[i]),m=P=>P?v.find(H=>H.name===P)??null:null,w=(P,H,ee)=>{var V;if(!v.length||!ee)return null;if(P==="node")return m((V=e.map.nodes.find(X=>X.id===H))==null?void 0:V.branch);const K=e.map.edges.find(X=>X.id===H),Y=X=>{var E;return(E=e.map.nodes.find(R=>R.id===X))==null?void 0:E.branch};return m((K==null?void 0:K.branch)??Y(K==null?void 0:K.to)??Y(K==null?void 0:K.from))},C=$.useMemo(()=>{if(!i)return[];const P=i.layout,H=V=>!k||e.map.nodes.some(X=>X.area===V&&k.has(X.id)),ee=e.map.areas.flatMap(V=>{const X=P.areas[V.id];return X?[{id:`area:${V.id}`,type:"area",position:{x:X.x,y:X.y},style:{width:X.w,height:X.h},data:{label:V.label,note:null,dim:!H(V.id)},selectable:!1,draggable:!1,zIndex:0}]:[]}),K=new Map;if(P.flat){const V=X=>P.branches&&X.branch?1:0;for(const X of e.map.areas){const E=e.map.nodes.filter(R=>R.area===X.id&&P.nodes[R.id]).sort((R,q)=>V(R)-V(q)||P.nodes[R.id].x-P.nodes[q.id].x||P.nodes[R.id].y-P.nodes[q.id].y)[0];E&&K.set(E.id,X.label)}}const Y=e.map.nodes.flatMap(V=>{var q,Q,G,A,W,Z,te,oe,de,me,ke,Me,ie,Ae,tt,Pe,He,Be,ct;const X=P.nodes[V.id];if(!X)return[];const E=V.evidence[0],R=V.symbol?V.symbol.slice(V.symbol.indexOf("#")+1):E?`${E.file.split("/").pop()}:${E.line}`:"not in the code yet";return[{id:V.id,type:"step",...P.flat?{}:{parentId:`area:${V.area}`,extent:"parent"},position:{x:X.x,y:X.y},data:{name:V.name,sub:R,kind:V.kind,confirmed:!!e.report&&((q=e.report.nodes[V.id])==null?void 0:q.status)!=="unconfirmed",proposal:((G=(Q=e.report)==null?void 0:Q.nodes[V.id])==null?void 0:G.proposal)??null,screen:((Z=(W=(A=e.report)==null?void 0:A.screens)==null?void 0:W[V.id])==null?void 0:Z.status)==="confirmed",selected:g.nodes.includes(V.id),hl:!!(k!=null&&k.has(V.id)),dim:!!k&&!k.has(V.id)&&!g.nodes.includes(V.id),fresh:e.fresh.includes(V.id),change:y(((de=(oe=(te=e.report)==null?void 0:te.nodes[V.id])==null?void 0:oe.change)==null?void 0:de.kind)??null),changeSize:oj((Me=(ke=(me=e.report)==null?void 0:me.nodes[V.id])==null?void 0:ke.change)==null?void 0:Me.diff),ghost:p(V.id),quiet:d==="both"?null:d,...P.flat&&{journey:{w:X.w,h:X.h,shape:V.kind==="choice"?"choice":V.kind==="action"?"action":"screen",outside:V.kind==="external",stage:K.get(V.id)??null,show:r.includes(V.id)?((tt=(Ae=(ie=e.report)==null?void 0:ie.screens)==null?void 0:Ae[V.id])==null?void 0:tt.show)??null:null,branch:w("node",V.id,!!e.report&&((Pe=e.report.nodes[V.id])==null?void 0:Pe.status)!=="unconfirmed"&&!((He=e.report.nodes[V.id])!=null&&He.proposal)&&!y(((ct=(Be=e.report.nodes[V.id])==null?void 0:Be.change)==null?void 0:ct.kind)??null)&&!p(V.id))}},onClick:qr=>e.onSelect("nodes",V.id,qr)},draggable:!1,zIndex:1}]});return[...ee,...Y]},[i,e.map,e.report,g,k,e.fresh,e.onSelect,r,d,v]),S=$.useMemo(()=>{var R,q,Q,G;if(!i)return[];const P=A=>({type:qo.ArrowClosed,width:16,height:16,color:A}),H=A=>!!(x!=null&&x.has(A)),ee=(A,W)=>{const[Z,te]=nj(e.map,i.layout,A,W);return{sourceHandle:`s${Z}`,targetHandle:`t${te}`}},K=new Map,Y=(A,W)=>{const Z=i.layout.rowTops,te=Xs(i.layout,A),oe=Xs(i.layout,W);if(!Z||te===oe)return;const de=Math.max(te,oe),me=K.get(de)??0;return K.set(de,me+1),Z[de]-_u/2+(me%2?1:-1)*Math.ceil(me/2)*18},V=e.map.edges.map(A=>{var Me,ie,Ae,tt,Pe,He,Be;const W=!!e.report&&((Me=e.report.edges[A.id])==null?void 0:Me.status)!=="unconfirmed",Z=((Ae=(ie=e.report)==null?void 0:ie.edges[A.id])==null?void 0:Ae.proposal)??null,te=y(((He=(Pe=(tt=e.report)==null?void 0:tt.edges[A.id])==null?void 0:Pe.change)==null?void 0:He.kind)??null),oe=p(A.id)??p(A.from)??p(A.to),de=H(A.id)||!!k&&k.has(A.from)&&k.has(A.to)&&!x,me="edge",ke=w("edge",A.id,!Z&&!te&&!oe);return{id:`e:${A.id}`,source:A.from,target:A.to,...ee(A.from,A.to),type:"link",className:nn("link",`link-${me}`,!W&&"unconfirmed",_l(Z),Cl(te),oe&&"ghost",jl(ke),H(A.id)&&"hl",!!x&&!H(A.id)&&"dim",g.edges.includes(A.id)&&"selected"),markerEnd:P(oe?"var(--line)":(Z==null?void 0:Z.state)==="pending"&&Z.kind!=="remove"?"var(--ai)":te==="added"?"var(--ok)":te==="removed"?"var(--dead)":ke?`var(--branch-${ke.colour})`:H(A.id)?"var(--path)":"var(--line-strong)"),zIndex:2,data:{label:A.label,wrapY:Y(A.from,A.to),route:(Be=i.layout.routes)==null?void 0:Be[`e:${A.id}`],branch:ke,variant:me,proposal:Z,change:te,ghost:oe,confirmed:W,hl:de,dim:!!x&&!H(A.id)&&!g.edges.includes(A.id),selected:g.edges.includes(A.id),onClick:ct=>e.onSelect("edges",A.id,ct)}}}),X=A=>{var W;return((W=t==null?void 0:t.connects)==null?void 0:W.from)===A.from&&t.connects.to===A.to};for(const A of e.map.absences){if(!A.between||X(A.between))continue;const W=((q=(R=e.report)==null?void 0:R.absences[A.id])==null?void 0:q.status)==="confirmed";V.push({id:`a:${A.id}`,hidden:d==="before",source:A.between.from,target:A.between.to,...ee(A.between.from,A.between.to),type:"link",className:nn("link","link-absence",!W&&"unconfirmed",H(A.id)&&"hl",!!x&&!H(A.id)&&"dim",g.absences.includes(A.id)&&"selected"),markerEnd:P("var(--dead)"),zIndex:2,data:{label:yj(A.claim),route:(Q=i.layout.routes)==null?void 0:Q[`a:${A.id}`],variant:"absence",confirmed:W,hl:H(A.id),dim:!!x&&!H(A.id)&&!g.absences.includes(A.id),selected:g.absences.includes(A.id),onClick:Z=>e.onSelect("absences",A.id,Z)}})}t!=null&&t.connects&&V.push({id:`g:${t.id}`,source:t.connects.from,target:t.connects.to,...ee(t.connects.from,t.connects.to),type:"link",className:"link link-ghost",markerEnd:P("var(--ok)"),zIndex:3,data:{label:`+ ${t.connects.label}`,route:(G=i.layout.routes)==null?void 0:G[`x:${t.id}`],variant:"ghost",confirmed:!0,hl:!0,dim:!1,selected:!1}});const E=new Map;for(const A of V){const W=[A.source,A.target].sort().join("|");E.set(W,[...E.get(W)??[],A])}for(const A of E.values())A.length<2||A.some(W=>{var Z;return(Z=W.data)==null?void 0:Z.route})||A.forEach((W,Z)=>{W.data&&(W.data.offset=(Z-(A.length-1)/2)*44)});return V},[i,e.map,e.report,g,x,k,t,e.onSelect,d,v]),_=le(P=>P.width),j=$.useRef(0);$.useEffect(()=>{const P=j.current;if(j.current=_,!P||!_||P===_||e.touring)return;const H=l.getViewport();l.setViewport({...H,x:H.x+(_-P)/2})},[_]);const I=JSON.stringify([i==null?void 0:i.key,(T=e.view)==null?void 0:T.focus,(z=e.view)==null?void 0:z.highlight,e.touring,e.touring?_:null]),O=$.useRef(!0);return $.useEffect(()=>{if(!i)return;const P=e.view?Eh(e.map,e.view.highlight.length?e.view.highlight:e.view.focus?[e.view.focus]:[]):[];let H=0,ee=0;const K=()=>{var A;const Y=l.getNodes();if(H<2||!Y.length||!Y.every(W=>{var Z,te;return(te=(Z=l.getInternalNode(W.id))==null?void 0:Z.measured)==null?void 0:te.width})){H++<60&&(ee=requestAnimationFrame(K));return}const V=O.current?0:650;O.current=!1;const X=Object.values(i.layout.nodes),E=Object.values(i.layout.routes??{}).flatMap(W=>W.points),R=Math.max(0,Math.min(0,...X.map(W=>W.y))-Math.min(0,...E.map(W=>W[1]))),q=Math.max(0,Math.max(0,...E.map(W=>W[1]))-Math.max(0,...X.map(W=>W.y+W.h))+(E.length?16:0)),Q=(A=i.layout.branches)!=null&&A.length?56:0,G=P.length?{top:`${60+Q}px`,left:e.touring?gj:"60px",right:"60px",bottom:"150px"}:{top:`${64+R+Q}px`,left:"32px",right:"32px",bottom:`${130+q}px`};l.fitView(P.length?{nodes:P.map(W=>({id:W})),duration:V,padding:G,maxZoom:1.15}:{duration:V,padding:G,maxZoom:1.1})};return ee=requestAnimationFrame(K),()=>cancelAnimationFrame(ee)},[I]),f.jsxs(x2,{className:i!=null&&i.layout.flat?"journey":void 0,nodes:C,edges:S,nodeTypes:pj,edgeTypes:mj,onNodeClick:()=>{},onEdgeClick:(P,H)=>{H.id.startsWith("e:")&&e.onSelect("edges",H.id.slice(2),P.shiftKey||P.metaKey),H.id.startsWith("a:")&&e.onSelect("absences",H.id.slice(2),P.shiftKey||P.metaKey)},onPaneClick:e.onClear,panOnDrag:!0,elementsSelectable:!1,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,maxZoom:2,children:[f.jsx(C2,{variant:Qt.Dots,gap:22,size:1.3}),(((b=(D=e.report)==null?void 0:D.since)==null?void 0:b.commit)||v.length>0)&&f.jsx(pi,{position:"top-left",children:f.jsxs("div",{className:"map-keys",children:[((L=(M=e.report)==null?void 0:M.since)==null?void 0:L.commit)&&f.jsx(sj,{commit:e.report.since.commit.slice(0,7),when:d,onWhen:u}),v.length>0&&f.jsx(aj,{branches:v})]})})]})}function Ml(e){e!==`${location.pathname}${location.search}`&&(history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")))}function xj(){const[e,t]=$.useState(location.pathname);return $.useEffect(()=>{const n=()=>t(location.pathname),r=o=>{var s,l;if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;const i=(l=(s=o.target)==null?void 0:s.closest)==null?void 0:l.call(s,"a[href]");!(i instanceof HTMLAnchorElement)||i.target||i.origin!==location.origin||(o.preventDefault(),Ml(`${i.pathname}${i.search}`))};return window.addEventListener("popstate",n),document.addEventListener("click",r),()=>{window.removeEventListener("popstate",n),document.removeEventListener("click",r)}},[]),e}const wj=8e3;function G0({busy:e,agentName:t="Claude",onStopped:n,onError:r}){const[o,i]=$.useState(!1);return $.useEffect(()=>{if(!o)return;const s=setTimeout(()=>i(!1),wj),l=a=>{a.key==="Escape"&&i(!1)};return window.addEventListener("keydown",l),()=>{clearTimeout(s),window.removeEventListener("keydown",l)}},[o]),o&&!e?f.jsxs("span",{className:"stop-ask",role:"group","aria-label":"Stop illuminate?",children:[f.jsx("span",{className:"stop-ask-text",children:"Stop illuminate? Maps stay saved."}),f.jsx("button",{className:"pill-btn stop-yes",autoFocus:!0,onClick:()=>{i(!1),_t.stop().then(n,s=>r(s.message))},children:"Stop"}),f.jsx("button",{className:"pill-btn",onClick:()=>i(!1),children:"Keep running"})]}):f.jsx("button",{className:"pill-btn",disabled:e,title:e?`${t} is still working`:"Maps stay saved. Undo for applied fixes ends.",onClick:()=>i(!0),children:"Stop illuminate"})}function kj(){return f.jsxs("main",{className:"home",children:[f.jsx("h1",{children:"illuminate has stopped"}),f.jsx("p",{className:"muted lede",children:"You can close this tab."}),f.jsxs("p",{className:"muted lede",children:["Maps are saved in ",f.jsx("code",{children:".illuminate/maps"}),". Run ",f.jsx("code",{children:"illume open"})," in the repo to see them again."]})]})}function Sj({onStopped:e}){const[t,n]=$.useState(""),[r,o]=$.useState(null),[i,s]=$.useState([]),[l,a]=$.useState(""),[u,c]=$.useState(null),[d,h]=$.useState(!1),[p,y]=$.useState(z0);$.useEffect(()=>T0(()=>{},()=>{},e),[e]),$.useEffect(()=>{_t.list().then(k=>{n(k.repo),o(k.maps),s(k.making),k.agent&&y(k.agent)},k=>c(k.message))},[]);const x=async()=>{if(l.trim()){h(!0);try{const{id:k}=await _t.make(l.trim());Ml(Dt(k))}catch(k){c(k.message),h(!1)}}};return f.jsxs("main",{className:"home",children:[f.jsxs("div",{className:"home-brand",children:[f.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate",t&&f.jsx("span",{className:"muted",children:t})]}),f.jsx("h1",{children:"Ask how your code works"}),f.jsx("p",{className:"muted lede",children:"Every box and arrow is checked against the code."}),Sl(p)?f.jsxs("p",{className:"home-ask chat-hint",children:[f.jsxs("strong",{children:["Ask for a new map in the ",p.name," chat beside this page"]})," ",f.jsx("span",{className:"muted",children:"for example: “Map what happens when a user signs up.”"})]}):f.jsxs("form",{className:"home-ask",onSubmit:k=>{k.preventDefault(),x()},children:[f.jsx("input",{id:"question",value:l,onChange:k=>a(k.target.value),placeholder:"What happens when a user signs up?","aria-label":"Your question",autoFocus:!0}),f.jsx("button",{className:"btn primary",disabled:d||!l.trim(),children:d?"Starting…":"Map it"})]}),u&&f.jsx("div",{className:"banner banner-dead",role:"alert",children:u}),i.length>0&&f.jsxs("section",{children:[f.jsx("h2",{className:"section-title",children:"Being made now"}),f.jsx("ul",{className:"maplist",children:i.map(k=>f.jsxs("li",{children:[f.jsx("a",{href:Dt(k.id),children:k.question}),f.jsxs("span",{className:"muted small",children:[p.name," is exploring…"]})]},k.id))})]}),f.jsxs("section",{children:[f.jsx("h2",{className:"section-title",children:"Maps in this repo"}),r===null?f.jsx("p",{className:"muted",children:"Loading…"}):r.length===0?f.jsx("p",{className:"muted",children:"None yet."}):f.jsx("ul",{className:"maplist",children:r.map(k=>f.jsxs("li",{children:[f.jsx("a",{href:Dt(k.id),children:k.question}),f.jsxs("span",{className:"muted small",children:[new Date(k.updatedAt).toLocaleString(),k.commit?` · ${k.commit.slice(0,7)}`:""]})]},k.id))})]}),f.jsx("footer",{className:"home-foot",children:f.jsx(G0,{busy:i.length>0,agentName:p.name,onStopped:e,onError:c})})]})}const _h="illuminate-panel-width",Cu=300,Q0=400,Nj=360,pa=e=>Math.round(Math.max(Cu,Math.min(e,Math.max(Cu,window.innerWidth-Nj))));function Ej(){const[e,t]=$.useState(()=>{const r=Number(localStorage.getItem(_h));return pa(r>0?r:Q0)}),n=$.useCallback(r=>{const o=pa(r);t(o),localStorage.setItem(_h,String(o))},[]);return $.useEffect(()=>{const r=()=>t(o=>pa(o));return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),[e,n]}function _j({width:e,onWidth:t}){return f.jsx("div",{className:"panel-handle",role:"separator","aria-orientation":"vertical","aria-label":"Panel width","aria-valuenow":e,"aria-valuemin":Cu,tabIndex:0,title:"Drag to resize the panel",onPointerDown:n=>{n.preventDefault();const r=n.currentTarget;r.setPointerCapture(n.pointerId),document.body.classList.add("resizing");const o=s=>t(window.innerWidth-s.clientX),i=()=>{r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",i),r.removeEventListener("pointercancel",i),document.body.classList.remove("resizing")};r.addEventListener("pointermove",o),r.addEventListener("pointerup",i),r.addEventListener("pointercancel",i)},onDoubleClick:()=>t(Q0),onKeyDown:n=>{n.key==="ArrowLeft"&&(n.preventDefault(),t(e+24)),n.key==="ArrowRight"&&(n.preventDefault(),t(e-24))}})}const Cj=(...e)=>e.filter(Boolean).join(" ");function jj({map:e,stop:t,onTour:n,onAsk:r}){var s;const o=e.tour[t];if(!o)return null;const i=t===e.tour.length-1;return f.jsxs("section",{className:"card card-focus tour-bubble","aria-label":"Walkthrough","aria-live":"polite",children:[f.jsx("button",{className:"card-close","aria-label":"Leave the walkthrough",title:"Leave the walkthrough (Esc)",onClick:()=>n(null),children:"×"}),f.jsxs("div",{className:"tour-head",children:[f.jsxs("span",{className:"eyebrow",children:["Walkthrough, stop ",t+1," of ",e.tour.length]}),f.jsx("span",{className:"dots","aria-hidden":"true",children:e.tour.map((l,a)=>f.jsx("i",{className:Cj(a===t&&"on",a<t&&"done")},l.id))})]}),f.jsx("h2",{className:"card-title",children:o.title}),f.jsx(ni,{text:o.text,className:"depth-text"}),(s=o.terms)!=null&&s.length?f.jsxs("p",{className:"muted small",children:["Terms: ",o.terms.join(", ")]}):null,f.jsxs("div",{className:"tour-nav",children:[f.jsx("button",{className:"btn",disabled:t===0,onClick:()=>n(t-1),children:"‹ Back"}),r&&f.jsx("button",{className:"btn",onClick:r,children:"Ask about this step"}),f.jsx("span",{className:"grow"}),i?f.jsx("button",{className:"btn primary",onClick:()=>n(null),children:"Done"}):f.jsx("button",{className:"btn primary",onClick:()=>n(t+1),children:"Next ›"})]}),f.jsx("div",{className:"kbd",children:"← → to step, Esc to leave"})]})}function Mj(){return Yr?f.jsx($j,{}):f.jsxs("main",{className:"home",children:[f.jsx("h1",{children:"Open illuminate from its link"}),f.jsxs("p",{className:"muted lede",children:["Use the link illuminate printed in your terminal (it ends in ",f.jsx("code",{children:"?t=…"}),")."]})]})}function $j(){const[e,t]=$.useState(!1),n=$.useCallback(()=>{window.close(),t(!0)},[]),r=xj();if(e)return f.jsx(kj,{});const o=/^\/m\/([a-z0-9-]{1,80})\/?$/.exec(r);return o?f.jsx(Tj,{mapId:o[1],onStopped:n},o[1]):f.jsx(Sj,{onStopped:n})}function bj({mapId:e,question:t,making:n}){const[r,o]=$.useState([]);$.useEffect(()=>{_t.list().then(s=>o([...s.making.map(l=>({...l,making:!0})),...s.maps.map(l=>({id:l.id,question:l.question}))]),()=>{})},[e,n]);const i=r.some(s=>s.id===e)?r:[{id:e,question:t},...r];return f.jsx("select",{className:"switcher",value:e,onChange:s=>Ml(Dt(s.target.value)),"aria-label":"Switch to another map",title:"Switch to another map in this repo",children:i.map(s=>f.jsxs("option",{value:s.id,children:[s.question||s.id,s.making?" (being made)":""]},s.id))})}function Pj({report:e}){if(!e)return null;const t=e.summary.unconfirmed,{pending:n,done:r}=e.summary.proposals??{pending:0,done:0},o=n+r,i=o?f.jsx("span",{className:"map-status proposals",title:"Parts of this map are a proposal, drawn in violet: they aren't in the code yet, or would change or go. illuminate checks the code to see which have been done.",children:r===0?`${o} proposed ${o===1?"change":"changes"}`:`${r} of ${o} proposed changes done`}):null,s=f.jsxs(f.Fragment,{children:[i,f.jsx(Ij,{report:e})]});return t?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"map-status off",title:"Every time the map is shown, illuminate re-checks it against the code. These parts no longer hold, usually because the code changed after the map was made. They're dashed and marked ? on the map; click one to see why.",children:t===1?"1 part of this map doesn’t match the code":`${t} parts of this map don’t match the code`}),s]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"map-status ok",title:"Every box and arrow on this map was just re-checked and is really in the code, and every gap's search still finds nothing. That shows each part is real; it doesn't show the map covers everything.",children:"✓ Every part is in the code"}),s]})}function Ij({report:e}){const t=e.since;if(!t)return null;if(!t.commit)return f.jsx("span",{className:"map-status off",title:`This map compares the code with "${t.ref}", but that isn't a commit in this repo, so nothing could be compared.`,children:"Can’t find the commit this map compares with"});const{added:n,changed:r,removed:o}=e.summary.changes??{added:0,changed:0,removed:0},i=t.date?new Date(t.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):null,s=[n&&`${n} added`,r&&`${r} changed`,o&&`${o} removed`].filter(Boolean).join(" · ");return f.jsxs("span",{className:"map-status changes",title:`This map shows the code as it is now, compared with commit ${t.commit.slice(0,7)}${t.subject?` ("${t.subject}")`:""}. illuminate works out from the two versions which boxes and arrows are new, different or gone. It can't tell who made a change.`,children:["Changes since ",t.commit.slice(0,7),i?` (${i})`:"",s?`: ${s}`:": nothing on this map differs"]})}function Tj({mapId:e,onStopped:t}){var D,b,M,L,P,H,ee,K;const[n,r]=$.useReducer(EC,e,xC),[o,i]=$.useState(""),[s,l]=Ej(),a=$.useRef(!1),u=$.useCallback(()=>{_t.get(e).then(Y=>r({type:"loaded",payload:Y}),Y=>r(Y instanceof I0&&/No such map/.test(Y.message)?{type:"missing"}:{type:"error",message:Y.message}))},[e]);$.useEffect(u,[u]),$.useEffect(()=>T0(Y=>r({type:"event",event:Y}),Y=>{r({type:"connected",value:Y}),Y&&a.current===!1&&n.phase!=="loading"&&u(),a.current=Y},t,e),[]);const c=n.map&&n.tour!==null?((D=n.map.tour[n.tour])==null?void 0:D.title)??null:null;$.useEffect(()=>{const Y=n.phase==="ready"?Z2(n.agent,n.selection,c):null;if(!Y)return;const V=setTimeout(()=>void _t.selection(e,Y.selection,Y.step).catch(()=>{}),250);return()=>clearTimeout(V)},[e,n.phase,n.agent,n.selection,c]);const d=Sl(n.agent),[h,p]=$.useState(null);$.useEffect(()=>p(null),[n.tour]);const y=n.map&&n.tour!==null&&h===n.tour?((b=n.map.tour[n.tour])==null?void 0:b.title)??null:null,x=$.useCallback(Y=>{const V=Y.trim();if(!V||n.job)return;const X=y?yC(y,V):V;_t.ask(e,X,n.selection).then(()=>i(""),E=>r({type:"error",message:E.message}))},[e,n.job,n.selection,y]),k=(Y,V)=>{V==="approve"&&r({type:"fixStatus",fixId:Y,status:"applying",problems:[]}),_t[V](e,Y).catch(X=>{r(V==="approve"?{type:"fixStatus",fixId:Y,status:"failed",problems:X.problems.length?X.problems:[X.message]}:{type:"error",message:[X.message,...X.problems].join(" ")})})},g=(Y,V)=>{_t.offer(e,Y,V).then(X=>{X.id&&Ml(Dt(X.id))},X=>r({type:"error",message:X.message}))};$.useEffect(()=>{const Y=V=>{const X=V.target instanceof HTMLTextAreaElement||V.target instanceof HTMLInputElement;if(V.key==="Escape"){mo(n.selection)?r({type:"clearSelection"}):n.tour!==null&&n.peek?r({type:"peek",open:!1}):n.tour!==null?r({type:"tour",stop:null}):r({type:"overview"});return}X||n.tour===null||(V.key==="ArrowRight"&&r({type:"tour",stop:n.tour+1}),V.key==="ArrowLeft"&&r({type:"tour",stop:n.tour-1}))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n.tour,n.peek,n.selection]);const v=n.answers.find(Y=>Y.id===n.shown),m=v!=null&&v.fix&&["proposed","applying","failed"].includes(((M=n.fixes[v.fix.id])==null?void 0:M.status)??"")?v.fix:null,w=$.useCallback((Y,V,X)=>r({type:"select",kind:Y,id:V,additive:X}),[]),C=$.useCallback(()=>r({type:"clearSelection"}),[]),S=F0(n),_=kC(n),j=wC(n),I=!!n.map&&n.tour!==null,O=$.useMemo(()=>({...n,answers:eC(n.agent,n.answers,n.fixes)}),[n]),F=n.shown!==null&&O.answers.some(Y=>Y.id===n.shown),U=((L=n.job)==null?void 0:L.kind)==="ask"&&!d,N=(!n.map||!!n.error||!!n.job&&(n.job.kind==="make"||U)||F)&&(!I||n.peek||!!n.error||U),T=N&&!!n.map,z=n.map&&d?f.jsx(LC,{map:n.map,agent:n.agent,selection:n.selection,step:c,onRemove:(Y,V)=>r({type:"select",kind:Y,id:V,additive:!0})}):n.map?f.jsx(zC,{map:n.map,selection:n.selection,draft:o,busy:!!n.job,agentName:n.agent.name,autoFocus:T,onDraft:i,onRemove:(Y,V)=>r({type:"select",kind:Y,id:V,additive:!0}),step:y,onRemoveStep:()=>p(null),onSend:()=>x(o)}):null;return f.jsx(M0,{children:f.jsxs("div",{className:"app",children:[f.jsxs("header",{className:"topbar",children:[f.jsxs("a",{className:"brand",href:Dt(),title:"All maps in this repo",children:[f.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate"]}),f.jsxs("div",{className:"topbar-map",children:[((P=n.meta)==null?void 0:P.parent)&&f.jsxs("a",{className:"crumb",href:Dt(n.meta.parent.mapId),title:`Back to the map this one came from: ${n.meta.parent.question}`,children:["← ",n.meta.parent.question]}),f.jsx(bj,{mapId:e,question:((H=n.map)==null?void 0:H.question)??((ee=n.job)==null?void 0:ee.question)??"",making:((K=n.job)==null?void 0:K.kind)==="make"})]}),f.jsx(Pj,{report:n.report}),f.jsx("a",{className:"pill-btn",href:Dt(),title:"Ask a new question and make a map for it",children:"New map"}),f.jsx(G0,{busy:!!n.job,agentName:n.agent.name,onStopped:t,onError:Y=>r({type:"error",message:Y})}),f.jsx("span",{className:n.connected?"live on":"live",title:n.connected?"Connected to illuminate":"Reconnecting to illuminate…"})]}),f.jsxs("div",{className:N?"body":"body full",style:{"--panel-w":`${s}px`},children:[f.jsx("div",{className:"canvas",children:n.map&&S?f.jsxs(f.Fragment,{children:[f.jsx(vj,{map:S,report:n.report,selection:n.selection,view:j,fresh:n.fresh,added:_,ghost:m??null,touring:I,onSelect:w,onClear:C}),!N&&f.jsx(FC,{state:O,dispatch:r}),mo(n.selection)>0&&f.jsx(VC,{mapId:e,map:S,report:n.report,selection:n.selection,onClose:C}),I&&mo(n.selection)===0&&f.jsx(jj,{map:n.map,stop:n.tour,onTour:Y=>r({type:"tour",stop:Y}),onAsk:d?void 0:()=>{var Y;p(n.tour),(Y=document.getElementById("ask"))==null||Y.focus()}}),f.jsx(OC,{map:n.map,mapId:e,tour:n.tour,onTour:Y=>r({type:"tour",stop:Y}),selected:mo(n.selection),children:T?null:z})]}):f.jsx("div",{className:"empty",children:n.phase==="making"?f.jsxs("div",{className:"pulse",children:[n.agent.name," is exploring the code…"]}):null})}),N&&f.jsx(_j,{width:s,onWidth:l}),N&&f.jsx($C,{state:O,dispatch:r,onFix:k,onFocus:Y=>r({type:"focus",id:Y}),onOffer:g,composer:T?z:null})]})]})})}Fm(document.getElementById("root")).render(f.jsx($.StrictMode,{children:f.jsx(Mj,{})}));export{zj as c,Ch as g};
71
+ //# sourceMappingURL=index-C_x6TUup.js.map