@johnz4021/illuminate 0.5.14 → 0.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.mjs +1 -1
- package/package.json +1 -1
- package/viewer/assets/{elk.bundled-CkO8876G.js → elk.bundled-BdwyDyHG.js} +2 -2
- package/viewer/assets/{elk.bundled-CkO8876G.js.map → elk.bundled-BdwyDyHG.js.map} +1 -1
- package/viewer/assets/{index-Dk18BP0K.js → index-yApq3qEc.js} +3 -3
- package/viewer/assets/index-yApq3qEc.js.map +1 -0
- package/viewer/index.html +1 -1
- package/viewer/assets/index-Dk18BP0K.js.map +0 -1
|
@@ -75,9 +75,9 @@ Error generating stack: `+s.message+`
|
|
|
75
75
|
`),n=[];let r=[];const o=()=>{r.length&&n.push({kind:"p",text:r.join(`
|
|
76
76
|
`)}),r=[]};for(let s=0;s<t.length;s++){const i=t[s];if(sp.test(i)){o();const d=[];for(s++;s<t.length&&!sp.test(t[s]);s++)d.push(t[s]);n.push({kind:"code",text:d.join(`
|
|
77
77
|
`)});continue}if(!i.trim()){o();continue}const a=i$.exec(i);if(a){o(),n.push({kind:"h",text:a[1]});continue}const l=a$.exec(i),u=l?null:l$.exec(i);if(l||u){o();const d=l?"ul":"ol",f=n[n.length-1],h=l?l[1]:u[2];f&&f.kind===d?f.items.push(h):n.push(d==="ul"?{kind:d,items:[h]}:{kind:d,items:[h],start:Number(u[1])});continue}const c=n[n.length-1];if(!r.length&&c&&(c.kind==="ul"||c.kind==="ol")&&/^\s+\S/.test(i)){c.items[c.items.length-1]+=` ${i.trim()}`;continue}r.push(i)}return o(),n}const c$=new RegExp("(`+)([^`]+?)\\1|\\*\\*(.+?)\\*\\*|__(.+?)__|\\*(?!\\s)(.+?)\\*|(?<![\\w])_(?!\\s)(.+?)_(?![\\w])|\\[([^\\]]+)\\]\\(([^)\\s]+)\\)","g");function cr(e,t="i"){const n=[];let r=0,o=0;const s=i=>{i.split(`
|
|
78
|
-
`).forEach((a,l)=>{l>0&&n.push(m.jsx("br",{},`${t}-br${o++}`)),a&&n.push(a)})};for(const i of e.matchAll(c$)){s(e.slice(r,i.index));const a=`${t}-${o++}`;if(i[2]!==void 0)n.push(m.jsx("code",{children:i[2]},a));else if(i[3]!==void 0||i[4]!==void 0)n.push(m.jsx("strong",{children:cr(i[3]??i[4],a)},a));else if(i[5]!==void 0||i[6]!==void 0)n.push(m.jsx("em",{children:cr(i[5]??i[6],a)},a));else if(i[7]!==void 0){const l=i[8];n.push(/^https?:\/\//i.test(l)?m.jsx("a",{href:l,target:"_blank",rel:"noreferrer",children:cr(i[7],a)},a):m.jsx("span",{children:cr(i[7],a)},a))}r=i.index+i[0].length}return s(e.slice(r)),n}function $s({text:e,className:t}){const n=u$(e);return n.length?m.jsx("div",{className:t?`md ${t}`:"md",children:n.map((r,o)=>{const s=`b${o}`;if(r.kind==="p")return m.jsx("p",{children:cr(r.text,s)},s);if(r.kind==="h")return m.jsx("p",{className:"md-h",children:cr(r.text,s)},s);if(r.kind==="code")return m.jsx("pre",{children:m.jsx("code",{children:r.text})},s);const i=r.items.map((a,l)=>m.jsx("li",{children:cr(a,`${s}-${l}`)},`${s}-${l}`));return r.kind==="ul"?m.jsx("ul",{children:i},s):m.jsx("ol",{start:r.start,children:i},s)})}):null}const d$=/^About the walkthrough step “([^”]*)”: /,f$=(e,t)=>`About the walkthrough step “${e}”: ${t}`;function h$(e){const t=d$.exec(e);return t?{question:e.slice(t[0].length),step:t[1]}:{question:e,step:null}}function p$(e,t,n,r=12){return Math.max(0,e+(n-t)-r)}function g$(e,t,n=40){return t>e-n}const m$="modulepreload",y$=function(e){return"/"+e},ip={},w$=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(l=>{if(l=y$(l),l in ip)return;ip[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":m$,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((f,h)=>{d.addEventListener("load",f),d.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return o.then(i=>{for(const a of i||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},B0=[.5,.42,.58,.34,.66,.26,.74,.2,.8],x$=[...B0,.86,.14,.9,.1],xi=4,vi={w:26,h:18},Yl=(e,t)=>e.x<t.x+t.w+xi&&t.x<e.x+e.w+xi&&e.y<t.y+t.h+xi&&t.y<e.y+e.h+xi,ki=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,w:t,h:n});function Ad(e,t,n=[]){const r=[],o={},s=(l,u)=>!t.some(c=>Yl(l,c))&&!r.some(c=>Yl(l,c))&&(!u||!n.some(c=>Yl(l,c))),i=[...e.filter(l=>l.keep),...e.filter(l=>!l.keep)],a=(l,u,c,d=B0)=>{for(const f of[!0,!1]){if(s(ki(l.at,u,c),f))return l.at;for(const h of d){const p=l.along(h);if(p&&s(ki(p,u,c),f))return p}}return null};for(const l of i){const u=a(l,l.w,l.h)??(l.keep?l.at:null);if(!u){const c=a(l,vi.w,vi.h,x$);c?(r.push(ki(c,vi.w,vi.h)),o[l.id]={...c,dot:!0}):o[l.id]="dot";continue}r.push(ki(u,l.w,l.h)),u!==l.at&&(o[l.id]=u)}return o}function v$(e,t,n,r,o){if(o==="over"){const l=Math.max(Math.abs(n-e)/2,40),u=Math.max(70,Math.min(170,Math.abs(n-e)*.32)),c=e<n?1:0;return[`M ${e} ${t} A ${l} ${u} 0 0 ${c} ${n} ${r}`,(e+n)/2,(t+r)/2-u]}const s=Math.max(Math.abs(r-t)/2,40),i=Math.max(60,Math.min(150,Math.abs(r-t)*.32)),a=t<r?1:0;return[`M ${e} ${t} A ${i} ${s} 0 0 ${a} ${n} ${r}`,Math.max(e,n)+i,(t+r)/2]}function k$(e,t,n,r,o){const s=Math.hypot(n-e,r-t)||1,i=-(r-t)/s,a=(n-e)/s,l=(e+n)/2+i*o*2,u=(t+r)/2+a*o*2;return[`M ${e} ${t} Q ${l} ${u} ${n} ${r}`,(e+n)/2+i*o,(t+r)/2+a*o]}function H0(e,t=18,n,r){let o=`M ${e[0][0]} ${e[0][1]}`;for(let u=1;u<e.length-1;u++){const[c,d]=e[u-1],[f,h]=e[u],[p,x]=e[u+1],v=Math.min(t,Math.hypot(f-c,h-d)/2),w=Math.min(t,Math.hypot(p-f,x-h)/2),y=S=>Math.abs(S)<1?0:Math.sign(S),g=y(f-c),b=y(h-d),E=y(p-f),k=y(x-h);o+=` L ${f-g*v} ${h-b*v} Q ${f} ${h} ${f+E*w} ${h+k*w}`}const s=e[e.length-1];if(o+=` L ${s[0]} ${s[1]}`,r)return[o,r[0],r[1]];const[i,a]=n!==void 0?[e[n],e[n+1]]:[];if(i&&a)return[o,(i[0]+a[0])/2,(i[1]+a[1])/2];let l=[0,e[0][0],e[0][1]];for(let u=1;u<e.length;u++){const[c,d]=e[u-1],[f,h]=e[u];d===h&&Math.abs(f-c)>l[0]&&(l=[Math.abs(f-c),(c+f)/2,h])}return[o,l[1],l[2]]}function U0(e,t,n,r,o,s,i){if(i.loop)return v$(e,t,r,o,i.loop);if(i.route)return H0(i.route.points,18,i.route.label,i.route.at);if(i.offset)return k$(e,t,r,o,i.offset);const[a,l,u]=bd({sourceX:e,sourceY:t,sourcePosition:n,targetX:r,targetY:o,targetPosition:s});return[a,l,u]}function W0(e,t,n){var u;const r=t.flat||t.lanes?new Set:sl(e),o=c=>{const d=e.nodes.find(p=>p.id===c),f=t.nodes[c],h=d?t.areas[d.area]:void 0;return f?{x:((h==null?void 0:h.x)??0)+f.x+f.w/2,y:((h==null?void 0:h.y)??0)+f.y+f.h/2}:{x:0,y:0}},s=new Map((t.rings??[]).flatMap((c,d)=>c.map(f=>[f,d]))),i=c=>s.has(c.from)&&s.get(c.from)===s.get(c.to),a=new Map;for(const c of n){const d=c.id.startsWith("e:")&&r.has(c.id.slice(2)),f=(u=t.routes)==null?void 0:u[c.id];let h;if(d&&!f&&!i(c)){const v=Math.abs(o(c.to).x-o(c.from).x),w=Math.abs(o(c.to).y-o(c.from).y);h=v<Ze*.75?"side":w<Ye/2?"over":void 0}const[p,x]=h==="over"?["t","t"]:h==="side"?["r","r"]:W$(e,t,c.from,c.to);a.set(c.id,{sourceHandle:`s${p}`,targetHandle:`t${x}`,back:d,...h?{loop:h}:{},...f?{route:f}:{}})}const l=new Map;for(const c of n){const d=[c.from,c.to].sort().join("|");l.set(d,[...l.get(d)??[],c.id])}for(const c of l.values())c.length<2||c.some(d=>{var f;return(f=a.get(d))==null?void 0:f.route})||c.forEach((d,f)=>{const h=a.get(d);h&&(h.offset=(f-(c.length-1)/2)*44)});return a}const ap={t:ue.Top,r:ue.Right,b:ue.Bottom,l:ue.Left};function Ea(e,t,n){var s;const r=t.nodes[n];if(!r)return null;const o=t.flat?void 0:t.areas[((s=e.nodes.find(i=>i.id===n))==null?void 0:s.area)??""];return{x:((o==null?void 0:o.x)??0)+r.x,y:((o==null?void 0:o.y)??0)+r.y,w:r.w,h:r.h}}function lp(e,t){return t==="t"?[e.x+e.w/2,e.y]:t==="b"?[e.x+e.w/2,e.y+e.h]:t==="l"?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2]}function V0(e,t,n){const r=W0(e,t,n),o=new Map;for(const s of n){const i=r.get(s.id),a=Ea(e,t,s.from),l=Ea(e,t,s.to);if(!a||!l)continue;const u=i.sourceHandle.slice(1),c=i.targetHandle.slice(1),[d,f]=lp(a,u),[h,p]=lp(l,c),[x,v,w]=U0(d,f,ap[u],h,p,ap[c],i);o.set(s.id,{d:x,at:[v,w],from:s.from,to:s.to})}return o}function Na(e,t=4){const n=e.match(/[MLQCA]|-?\d*\.?\d+(?:e-?\d+)?/g)??[],r=[];let o=0,s={x:0,y:0},i="";const a=()=>Number(n[o++]),l=(u,c)=>{const d=Math.max(2,Math.ceil(c/t));for(let f=1;f<=d;f++)r.push(u(f/d))};for(;o<n.length;)if(/^[MLQCA]$/.test(n[o])&&(i=n[o++]),i==="M")s={x:a(),y:a()},r.push(s),i="L";else if(i==="L"){const u=s,c={x:a(),y:a()};l(d=>({x:u.x+(c.x-u.x)*d,y:u.y+(c.y-u.y)*d}),Math.hypot(c.x-u.x,c.y-u.y)),s=c}else if(i==="Q"){const u=s,c={x:a(),y:a()},d={x:a(),y:a()};l(f=>({x:(1-f)**2*u.x+2*(1-f)*f*c.x+f*f*d.x,y:(1-f)**2*u.y+2*(1-f)*f*c.y+f*f*d.y}),Math.hypot(c.x-u.x,c.y-u.y)+Math.hypot(d.x-c.x,d.y-c.y)),s=d}else if(i==="C"){const u=s,c={x:a(),y:a()},d={x:a(),y:a()},f={x:a(),y:a()};l(h=>{const p=1-h;return{x:p**3*u.x+3*p*p*h*c.x+3*p*h*h*d.x+h**3*f.x,y:p**3*u.y+3*p*p*h*c.y+3*p*h*h*d.y+h**3*f.y}},Math.hypot(c.x-u.x,c.y-u.y)+Math.hypot(d.x-c.x,d.y-c.y)+Math.hypot(f.x-d.x,f.y-d.y)),s=f}else if(i==="A"){let u=Math.abs(a()),c=Math.abs(a());a();const d=a(),f=a(),h={x:a(),y:a()},p=s,x=(p.x-h.x)/2,v=(p.y-h.y)/2,w=x*x/(u*u)+v*v/(c*c);w>1&&(u*=Math.sqrt(w),c*=Math.sqrt(w));const g=(d===f?-1:1)*Math.sqrt(Math.max(0,(u*u*c*c-u*u*v*v-c*c*x*x)/(u*u*v*v+c*c*x*x))),b=g*u*v/c,E=-g*c*x/u,k=b+(p.x+h.x)/2,S=E+(p.y+h.y)/2,$=(M,z,F,N)=>Math.atan2(M*N-z*F,M*F+z*N),_=$(1,0,(x-b)/u,(v-E)/c);let j=$((x-b)/u,(v-E)/c,(-x-b)/u,(-v-E)/c);!f&&j>0?j-=2*Math.PI:f&&j<0&&(j+=2*Math.PI),l(M=>({x:k+u*Math.cos(_+j*M),y:S+c*Math.sin(_+j*M)}),Math.abs(j)*Math.max(u,c)),s=h}else o++;return r}const b$=24,Xl={w:26,h:18};function S$(e,t,n){const r=e.nodes.flatMap(p=>{const x=Ea(e,t,p.id);return x?[{id:p.id,...x}]:[]}),o=Object.values(t.areas).map(p=>({x:p.x,y:p.y,w:Math.min(p.w,280),h:40})),s=V0(e,t,n),i=[...s].map(([p,x])=>({id:p,from:x.from,to:x.to,d:x.d})),a=[];for(const p of n){const x=s.get(p.id);if(!x||!p.label)continue;const v=Na(x.d,6);a.push({id:p.id,w:ol(p.label),h:b$,at:{x:x.at[0],y:x.at[1]},along:w=>v[Math.min(v.length-1,Math.max(0,Math.round(w*(v.length-1))))]??null,keep:p.id.startsWith("a:")})}const l=Ad(a,r,o);let u=0;const c=[];for(const p of a){const x=l[p.id];if(x==="dot"||x&&"dot"in x){u++;const v=x==="dot"?p.at:x;c.push({x:v.x-Xl.w/2,y:v.y-Xl.h/2,...Xl})}else{const v=x??p.at;c.push({x:v.x-p.w/2,y:v.y-p.h/2,w:p.w,h:p.h})}}const d=[...r,...Object.values(t.areas)],f=Math.max(0,...d.map(p=>p.x+p.w))-Math.min(0,...d.map(p=>p.x)),h=Math.max(0,...d.map(p=>p.y+p.h))-Math.min(0,...d.map(p=>p.y));return{boxes:r,titles:o,arrows:i,labels:c,hidden:u,width:f,height:h}}const up=16,cp={w:1400,h:620},E$={under:4,stacked:3,hidden:3,clash:3,crossings:2,detours:1.5,fit:20};function N$(e){const t=(p,x,v=3)=>p.x>x.x+v&&p.x<x.x+x.w-v&&p.y>x.y+v&&p.y<x.y+x.h-v,n=e.arrows.map(p=>{const x=Na(p.d);let v=0;for(let k=1;k<x.length;k++)v+=Math.hypot(x[k].x-x[k-1].x,x[k].y-x[k-1].y);const w=[];let y=0;for(let k=0;k<x.length;k++)k&&(y+=Math.hypot(x[k].x-x[k-1].x,x[k].y-x[k-1].y)),y>up&&y<v-up&&w.push(x[k]);const g=w.map(k=>k.x),b=w.map(k=>k.y),E=w.length?{x0:Math.min(...g),x1:Math.max(...g),y0:Math.min(...b),y1:Math.max(...b)}:null;return{...p,pts:w,total:v,bounds:E}});let r=0;for(const p of n)e.boxes.some(x=>x.id!==p.from&&x.id!==p.to&&p.pts.some(v=>t(v,x)))&&r++;const o=(p,x,v,w)=>{const y=(x.x-p.x)*(w.y-v.y)-(x.y-p.y)*(w.x-v.x);if(Math.abs(y)<1e-9)return null;const g=((v.x-p.x)*(w.y-v.y)-(v.y-p.y)*(w.x-v.x))/y,b=((v.x-p.x)*(x.y-p.y)-(v.y-p.y)*(x.x-p.x))/y;return g>0&&g<1&&b>0&&b<1?{x:p.x+g*(x.x-p.x),y:p.y+g*(x.y-p.y)}:null},s=[];let i=0;for(let p=0;p<n.length;p++)for(let x=p+1;x<n.length;x++){const v=n[p],w=n[x];if(!v.bounds||!w.bounds||v.bounds.x1<w.bounds.x0-4||w.bounds.x1<v.bounds.x0-4||v.bounds.y1<w.bounds.y0-4||w.bounds.y1<v.bounds.y0-4)continue;for(let g=1;g<v.pts.length;g++)for(let b=1;b<w.pts.length;b++){const E=o(v.pts[g-1],v.pts[g],w.pts[b-1],w.pts[b]);E&&!s.some(k=>Math.hypot(k.x-E.x,k.y-E.y)<10)&&s.push(E)}let y=0;for(const g of v.pts)w.pts.some(b=>Math.abs(b.x-g.x)<3.5&&Math.abs(b.y-g.y)<3.5)&&y++;y*4>40&&i++}const a=(p,x)=>p.x<x.x+x.w-1&&x.x<p.x+p.w-1&&p.y<x.y+x.h-1&&x.y<p.y+p.h-1;let l=0;e.labels.forEach((p,x)=>{(e.boxes.some(v=>a(p,v))||e.labels.some((v,w)=>w!==x&&a(p,v)))&&l++});const u=p=>{const x=e.boxes.find(v=>v.id===p);return x?{x:x.x+x.w/2,y:x.y+x.h/2}:null};let c=0;for(const p of n){const x=u(p.from),v=u(p.to);if(!x||!v)continue;const w=Math.max(Math.hypot(v.x-x.x,v.y-x.y)-110,40);p.total>2.5*w&&p.total-w>300&&c++}const d=Math.min(1,cp.w/Math.max(1,e.width),cp.h/Math.max(1,e.height)),f=E$,h=f.under*r+f.stacked*i+f.hidden*e.hidden+f.clash*l+f.crossings*s.length+f.detours*c+f.fit*(1-d);return{crossings:s.length,under:r,stacked:i,hidden:e.hidden,clash:l,detours:c,fit:Math.round(d*100)/100,score:Math.round(h*10)/10}}function _$(e,t,n){return N$(S$(e,t,n))}const Ze=232,Ye=96,$$=e=>e.view==="journey"&&[...e.nodes,...e.edges].some(t=>!!t.branch);function _a(e,t){var s;const n=((s=e.nodes[t])==null?void 0:s.y)??0,r=e.rowTops??[];let o=0;for(const[i,a]of r.entries())n>=a-1&&(o=i);return o}const C$=132;function lc(e,t=!1){return e==="choice"?{w:196,h:132}:e==="action"?{w:196,h:60}:t?{w:232,h:64+C$}:{w:196,h:72}}let M$=null;const rl=()=>M$??(M$=w$(()=>import("./elk.bundled-CkO8876G.js").then(e=>e.e),[]).then(e=>new e.default)),Cs={"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};function qn(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 Ee={top:52,side:26,bottom:26},on=64,gr=44,A$=56,j$=140;async function jd(e,t,n,r){const o=await e.layout({id:t,layoutOptions:{...Cs,"elk.direction":"DOWN","elk.padding":`[top=${Ee.top},left=${Ee.side},bottom=${Ee.bottom},right=${Ee.side}]`,"elk.layered.spacing.nodeNodeBetweenLayers":String(on),"elk.spacing.nodeNode":String(gr)},children:n.map(i=>({id:i.id,width:Ze,height:Ye})),edges:r.map(i=>({id:i.id,sources:[i.from],targets:[i.to]}))}),s={};for(const i of o.children??[])s[i.id]={x:i.x??0,y:i.y??0,w:Ze,h:Ye};return{nodes:s,size:{w:o.width??Ze+2*Ee.side,h:o.height??Ye+Ee.top+Ee.bottom}}}function T$(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 G0(e,t=[],n=new Set,r=new Set){if(e.view==="journey")return $$(e)?P$(e,t,r):Y0(e,t,r);const o=I$(e),s=await L$(e,t,n);return o.length?{...s,branches:o}:s}function I$(e){const t=[];for(const n of[...e.nodes,...e.edges])n.branch&&!t.includes(n.branch)&&t.push(n.branch);return t}async function L$(e,t,n){var E;if(e.view==="timeline")return z$(e,t);const r=e.nodes.filter(k=>n.has(k.id));if(!r.length)return wp(e,t);const o=T$(e,n),s=new Set(o.nodes.map(k=>k.id)),i=await wp(o,t.filter(k=>s.has(k.from)&&s.has(k.to))),a=await rl(),l=Object.fromEntries(Object.entries(i.areas).map(([k,S])=>[k,{...S}])),u={...i.nodes},c={},d={};for(const k of r)(d[E=k.area]??(d[E]=[])).push(k);for(const[k,S]of Object.entries(d)){const $=l[k];if(!$)continue;const _=Math.max(1,Math.floor(($.w-2*Ee.side+gr)/(Ze+gr))),j=Math.max(Ee.top-on,...o.nodes.filter(z=>z.area===k).map(z=>{var F;return(((F=u[z.id])==null?void 0:F.y)??0)+Ye}))+on;S.forEach((z,F)=>{u[z.id]={x:Ee.side+F%_*(Ze+gr),y:j+Math.floor(F/_)*(Ye+on),w:Ze,h:Ye}});const M=Math.max($.h,j+Math.ceil(S.length/_)*(Ye+on)-on+Ee.bottom);c[k]=M-$.h,$.h=M}const f=Object.fromEntries(Object.entries(i.areas).map(([k,S])=>[k,S])),h=Object.keys(f).sort((k,S)=>f[k].y-f[S].y),p={};for(const k of h){const S=f[k];p[k]=Math.max(0,...h.filter($=>$!==k&&p[$]!==void 0).filter($=>{const _=f[$];return _.y+_.h<=S.y+1&&_.x<S.x+S.w&&S.x<_.x+_.w}).map($=>p[$]+(c[$]??0))),l[k].y+=p[k]}const x=qn(e,t),v=new Map(e.nodes.map(k=>[k.id,k.area])),w=Math.max(0,...Object.values(l).map(k=>k.x+k.w))+j$;let y=0;for(const k of e.areas){if(l[k.id])continue;const S=e.nodes.filter(j=>j.area===k.id);if(!S.length)continue;const $=x.filter(j=>v.get(j.from)===k.id&&v.get(j.to)===k.id),_=await jd(a,k.id,S,$);Object.assign(u,_.nodes),l[k.id]={x:w,y,w:_.size.w,h:_.size.h},y+=_.size.h+A$}const g=Object.values(l);let b;if(i.routes){b={};const k=new Map(qn(o,t).map(S=>[S.id,S]));for(const[S,$]of Object.entries(i.routes)){const _=k.get(S),j=_&&p[v.get(_.from)??""],M=_&&p[v.get(_.to)??""];j===void 0||M===void 0||j!==M||(b[S]={...$,points:$.points.map(([z,F])=>[z,F+j]),...$.at?{at:[$.at[0],$.at[1]+j]}:{}})}}return{areas:l,nodes:u,width:Math.max(0,...g.map(k=>k.x+k.w)),height:Math.max(0,...g.map(k=>k.y+k.h)),...i.rings?{rings:i.rings}:{},...b?{routes:b}:{},...i.chosen?{chosen:i.chosen}:{}}}const dp=1900,uc=130;async function Y0(e,t,n){const o=await(await rl()).layout({id:"root",layoutOptions:{...Cs,"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(h=>({id:h.id,width:lc(h.kind,n.has(h.id)).w,height:lc(h.kind,n.has(h.id)).h})),edges:qn(e,t).map(h=>({id:h.id,sources:[h.from],targets:[h.to]}))}),s={};for(const h of o.children??[])s[h.id]={x:h.x??0,y:h.y??0,w:h.width??0,h:h.height??0};const i=o.width??0;if(i<=dp)return{areas:{},nodes:s,width:i,height:o.height??0,flat:!0};const a=[];for(const[h,p]of Object.entries(s).sort((x,v)=>x[1].x+x[1].w/2-(v[1].x+v[1].w/2))){const x=a[a.length-1];x&&p.x+p.w/2<x.right?(x.ids.push(h),x.left=Math.min(x.left,p.x),x.right=Math.max(x.right,p.x+p.w)):a.push({left:p.x,right:p.x+p.w,ids:[h]})}const l=Math.ceil(i/dp),u=Math.ceil(a.length/l);let c=0,d=0;const f=[];for(let h=0;h*u<a.length;h++){const p=a.slice(h*u,(h+1)*u),x=p.flatMap(y=>y.ids),v=p[0].left,w=Math.min(...x.map(y=>s[y].y));f.push(c);for(const y of x)s[y]={...s[y],x:s[y].x-v,y:s[y].y-w+c};c=Math.max(...x.map(y=>s[y].y+s[y].h))+uc,d=Math.max(d,p[p.length-1].right-v)}return{areas:{},nodes:s,width:d,height:c-uc,flat:!0,rowTops:f}}const bi=176,fp=120,hp=34,R$=14;function O$(e,t){const n=new Map(e.map(s=>[s,0]));for(const s of t)n.set(s.to,(n.get(s.to)??0)+1);const r=new Set(e),o=[];for(;r.size;){const s=e.find(i=>r.has(i)&&!n.get(i))??e.find(i=>r.has(i));r.delete(s),o.push(s);for(const i of t)i.from===s&&r.has(i.to)&&n.set(i.to,n.get(i.to)-1)}return o}async function P$(e,t,n){const r=qn(e,t),o=new Map(e.nodes.map(C=>[C.id,lc(C.kind,n.has(C.id))])),s=new Map(e.nodes.map(C=>[C.id,C.branch??null])),i=O$(e.nodes.map(C=>C.id),r),a=i.filter(C=>!s.get(C));if(!a.length)return Y0(e,t,n);const l=C=>o.get(C).w,u=C=>o.get(C).h,c=new Map,d=new Map;let f=0;for(const C of a)c.set(C,f),d.set(C,0),f+=l(C)+bi;const h=C=>c.get(C)+l(C)/2,p=C=>c.get(C)+l(C),x=[...new Set([...e.nodes,...e.edges].flatMap(C=>C.branch?[C.branch]:[]))],v=new Map;for(const C of i){const B=s.get(C);B&&v.set(B,[...v.get(B)??[],C])}const w=[],y=new Map,g=new Set(v.keys()),b=(C,B)=>{const J=v.get(C),q=new Set(J),Z=r.filter(Y=>q.has(Y.to)&&!q.has(Y.from));if(!B&&Z.length&&!Z.some(Y=>d.has(Y.from)))return null;const T=Z.filter(Y=>d.has(Y.from)).map(Y=>Y.from).sort((Y,re)=>d.get(Y)-d.get(re)||h(Y)-h(re))[0]??null,H=T&&d.get(T)===0?a[a.indexOf(T)+1]:void 0,V=J[0],X=T?H?(h(T)+h(H))/2:h(T)+(l(T)/2+bi+l(V)/2)/2:l(V)/2,ee=[];let me=X-l(V)/2;for(const Y of J)ee.push(me),me+=l(Y)+bi;const de=r.filter(Y=>q.has(Y.from)&&!q.has(Y.to)&&d.has(Y.to)),ge=de.filter(Y=>h(Y.to)>=ee[0]).map(Y=>h(Y.to)),ve=de.filter(Y=>h(Y.to)<ee[0]).map(Y=>h(Y.to));return{name:C,ids:J,anchor:T,xs:ee,kind:ve.length?2:ge.length?0:1,reach:Math.max(0,...ge),span:[Math.min(T?h(T):ee[0],...ve)-30,Math.max(me-bi,...ge)+30],verticals:[...T?[{x:h(T),from:d.get(T)}]:[],...de.map(Y=>({x:h(Y.to),from:d.get(Y.to)}))],minLane:T?d.get(T)+1:1,root:T?d.get(T)===0?a.indexOf(T):y.get(s.get(T))??a.length:a.length}};for(;g.size;){const B=[...g].flatMap(T=>b(T,!1)??[]).sort((T,H)=>(T.anchor?h(T.anchor):1/0)-(H.anchor?h(H.anchor):1/0)||T.kind-H.kind||T.reach-H.reach||x.indexOf(T.name)-x.indexOf(H.name))[0]??b(x.find(T=>g.has(T))??[...g][0],!0);g.delete(B.name);const J=T=>!w.some(H=>H.lane===T&&H.span[0]<B.span[1]&&B.span[0]<H.span[1]),q=T=>B.verticals.every(H=>w.every(V=>!(V.lane>H.from&&V.lane<T)||V.boxes.every(X=>H.x<c.get(X)-12||H.x>p(X)+12)))&&w.every(H=>H.lane<=T||H.verticals.every(V=>V.from>=T||B.xs.every((X,ee)=>V.x<X-12||V.x>X+l(B.ids[ee])+12)));let Z=B.minLane;for(;Z<B.minLane+12&&!(J(Z)&&q(Z));)Z++;if(Z>=B.minLane+12)for(Z=B.minLane;!J(Z);Z++);B.ids.forEach((T,H)=>{c.set(T,B.xs[H]),d.set(T,Z)}),w.push({name:B.name,lane:Z,span:B.span,verticals:B.verticals,boxes:B.ids,root:B.root}),y.set(B.name,B.root)}const E=[...new Set([...d.values()])].sort((C,B)=>C-B),k=new Map,S=new Map;let $=0;for(const C of E){const B=Math.max(...[...d].filter(([,J])=>J===C).map(([J])=>u(J)));k.set(C,$),S.set(C,$+B),$+=B+fp}const _={};for(const C of e.nodes){const B=d.get(C.id);_[C.id]={x:c.get(C.id),y:k.get(B)+(S.get(B)-k.get(B)-u(C.id))/2,w:l(C.id),h:u(C.id)}}const j=new Map(e.nodes.map(C=>[C.id,C.kind])),M=(C,B,J)=>{const q=_[C],Z=j.get(C)==="choice"?Math.min(q.h/2,Math.abs(B-(q.x+q.w/2))*q.h/q.w):0;return J==="top"?q.y+Z:q.y+q.h-Z},z=C=>_[C].y+_[C].h/2,F=C=>d.get(C),N=C=>[...d].filter(([,B])=>B===C).map(([B])=>B).sort((B,J)=>c.get(B)-c.get(J)),P=new Map,L=new Map,D=(C,B,J,q)=>L.set(`${C}:${B}`,[...L.get(`${C}:${B}`)??[],{link:J,key:q}]);for(const C of r){const B=F(C.from),J=F(C.to);let q;if(B===J){const Z=N(B);q=Z.indexOf(C.to)===Z.indexOf(C.from)+1?"straight":B===0?"arc":"under"}else J>B?q="down":q=h(C.to)>p(C.from)+24?"rejoin":h(C.to)<c.get(C.from)-24?"return":"up";P.set(C.id,q),q==="arc"&&(D(C.from,"t",C.id,[h(C.to)]),D(C.to,"t",C.id,[h(C.from)])),(q==="rejoin"||q==="up")&&D(C.to,"b",C.id,[0,B]),q==="return"&&D(C.to,"b",C.id,[1,-B]),q==="down"&&D(C.from,"b",C.id,[2,-J])}const I=new Map;for(const[C,B]of L){const J=C.slice(0,C.lastIndexOf(":"));B.sort((q,Z)=>q.key.reduce((T,H,V)=>T||H-(Z.key[V]??0),0)),B.forEach((q,Z)=>I.set(`${q.link}:${C}`,h(J)+(Z-(B.length-1)/2)*R$))}const A=(C,B,J)=>I.get(`${C}:${B}:${J}`)??h(B),O=r.filter(C=>P.get(C.id)==="arc").sort((C,B)=>Math.abs(h(C.to)-h(C.from))-Math.abs(h(B.to)-h(B.from))),U=new Map(O.map((C,B)=>[C.id,B])),W=new Map,oe={};for(const C of r){const B=_[C.from],J=_[C.to],q=F(C.from),Z=P.get(C.id);let T;if(Z==="straight")T={points:[[B.x+B.w,z(C.from)],[J.x,z(C.to)]],label:0};else if(Z==="arc"){const H=-58-18*U.get(C.id),V=A(C.id,C.from,"t"),X=A(C.id,C.to,"t");T={points:[[V,M(C.from,V,"top")],[V,H],[X,H],[X,M(C.to,X,"top")]],label:1}}else if(Z==="under"||Z==="return"){const H=W.get(q)??0;W.set(q,H+1);const V=S.get(q)+hp+16*H,X=h(C.from)+(Z==="under"?6:0),ee=Z==="return"?A(C.id,C.to,"b"):h(C.to)-6;T={points:[[X,B.y+B.h],[X,V],[ee,V],[ee,M(C.to,ee,"bottom")]],label:1}}else if(Z==="down"){const H=A(C.id,C.from,"b"),V=h(C.to),X=k.get(F(C.to))-hp;T=Math.abs(V-H)<4?{points:[[H,M(C.from,H,"bottom")],[H,J.y]],label:0}:{points:[[H,M(C.from,H,"bottom")],[H,X],[V,X],[V,J.y]],label:1}}else if(Z==="rejoin"){const H=A(C.id,C.to,"b"),V=N(q).some(ee=>ee!==C.from&&c.get(ee)<H&&p(ee)>B.x+B.w),X=k.get(q)-fp/2;T=V?{points:[[h(C.from),B.y],[h(C.from),X],[H,X],[H,M(C.to,H,"bottom")]],label:1}:{points:[[B.x+B.w,z(C.from)],[H,z(C.from)],[H,M(C.to,H,"bottom")]],label:H-(B.x+B.w)>=150?0:1}}else{const H=Math.min(Math.max(A(C.id,C.to,"b"),B.x+12),B.x+B.w-12);T={points:[[H,B.y],[H,M(C.to,H,"bottom")]],label:0}}oe[C.id]=T}const se=x.map(C=>{var Z;const B=w.find(T=>T.name===C);if(B)return{name:C,root:B.root};const J=(Z=e.edges.find(T=>T.branch===C))==null?void 0:Z.from,q=J?s.get(J):null;return{name:C,root:J&&d.get(J)===0?a.indexOf(J):q?y.get(q)??a.length:a.length}}).sort((C,B)=>C.root-B.root||x.indexOf(C.name)-x.indexOf(B.name)).map(C=>C.name),ie=Object.values(_),G=Object.values(oe).flatMap(C=>C.points);return{areas:{},nodes:_,width:Math.max(...ie.map(C=>C.x+C.w),...G.map(C=>C[0])),height:Math.max(...ie.map(C=>C.y+C.h),...G.map(C=>C[1])),flat:!0,routes:oe,branches:se}}const pp=132,gp=40,mp=36;function Us(e,t){const n=new Map,r=new Set;for(const c of t)(n.get(c.from)??n.set(c.from,[]).get(c.from)).push(c.to),r.add(c.to);const o=new Map,s=[],i=c=>{o.set(c,"open");for(const d of n.get(c)??[])o.has(d)||i(d);o.set(c,"done"),s.push(c)};for(const c of[...e.filter(d=>!r.has(d)),...e])o.has(c)||i(c);const a=s.reverse(),l=new Map(a.map((c,d)=>[c,d])),u=new Map(e.map(c=>[c,0]));for(const c of a)for(const d of n.get(c)??[])(l.get(d)??0)>(l.get(c)??0)&&u.set(d,Math.max(u.get(d)??0,(u.get(c)??0)+1));return u}async function z$(e,t){const n=Us(e.nodes.map(c=>c.id),qn(e,t)),r=Math.max(0,...n.values())+1,o=2*Ee.side+r*Ze+(r-1)*pp,s=c=>Math.min(...e.nodes.filter(d=>d.area===c).map(d=>n.get(d.id)??0)),i=e.areas.filter(c=>e.nodes.some(d=>d.area===c.id)).sort((c,d)=>s(c.id)-s(d.id)),a={},l={};let u=0;for(const c of i){const d=new Map;let f=1;for(const p of e.nodes.filter(x=>x.area===c.id)){const x=n.get(p.id)??0,v=d.get(x)??0;d.set(x,v+1),f=Math.max(f,v+1),l[p.id]={x:Ee.side+x*(Ze+pp),y:Ee.top+v*(Ye+gp),w:Ze,h:Ye}}const h=Ee.top+f*Ye+(f-1)*gp+Ee.bottom;a[c.id]={x:0,y:u,w:o,h},u+=h+mp}return{areas:a,nodes:l,width:o,height:Math.max(0,u-mp),lanes:!0}}function D$(e){const t=e.nodes.map(p=>p.id),n=new Map;for(const p of e.edges)p.from!==p.to&&(n.get(p.from)??n.set(p.from,[]).get(p.from)).push(p.to);let r=0;const o=new Map,s=new Map,i=[],a=new Set,l=[],u=p=>{o.set(p,r),s.set(p,r),r++,i.push(p),a.add(p);for(const x of n.get(p)??[])o.has(x)?a.has(x)&&s.set(p,Math.min(s.get(p),o.get(x))):(u(x),s.set(p,Math.min(s.get(p),s.get(x))));if(s.get(p)===o.get(p)){const x=[];for(let v=i.pop();a.delete(v),x.push(v),v!==p;v=i.pop());l.push(x)}};for(const p of t)o.has(p)||u(p);const c=Us(t,e.edges.map(p=>({from:p.from,to:p.to}))),d=new Map(e.nodes.map(p=>[p.id,p.area])),f=new Set,h=[];for(const p of l){if(p.length<3||p.length>8)continue;const x=new Set(p),v=[...p].sort((g,b)=>(c.get(g)??0)-(c.get(b)??0)||t.indexOf(g)-t.indexOf(b)),w=[v[0]];for(let g=v[0];;){const b=v.find(E=>!w.includes(E)&&(n.get(g)??[]).includes(E));if(!b)break;w.push(b),g=b}for(const g of v)w.includes(g)||w.push(g);const y=[];for(const g of w)y[y.length-1]!==d.get(g)&&y.push(d.get(g));if(y.length>1&&y[0]===y[y.length-1]&&y.pop(),!(y.length>2||y.some(g=>f.has(g))||!x.size)){for(const g of y)f.add(g);h.push({order:w,areas:y})}}return h}const Qo=70;async function yp(e,t,n,r,o,s,i){const a=n.length?await jd(e,t,n,r.filter(h=>n.some(p=>p.id===h.from)&&n.some(p=>p.id===h.to))):null,l={},u=a?a.size.w-Ee.side:0,c=s==="right"?(a?u+gr:Ee.side)+Qo:Ee.side,d=s==="left"&&a?Ze+gr+Qo:0;if(a)for(const[h,p]of Object.entries(a.nodes))l[h]={...p,x:p.x+d};o.forEach((h,p)=>{const x=Qo*Math.sin(Math.PI*(p+.5)/o.length);l[h]={x:c+(s==="right"?-x:x),y:Ee.top+i+p*(Ye+on),w:Ze,h:Ye}});const f=Object.values(l);return{nodes:l,size:{w:Math.max(...f.map(h=>h.x+h.w))+Ee.side,h:Math.max(...f.map(h=>h.y+h.h),a?a.size.h-Ee.bottom:0)+Ee.bottom}}}async function F$(e,t,n){var p;const r=await rl(),o=qn(e,t),s=new Map(e.absences.map(x=>[`a:${x.id}`,x.claim.length>28?`${x.claim.slice(0,26)}…`:x.claim])),i=new Map([...e.edges.map(x=>[`e:${x.id}`,x.label]),...s]),a=e.areas.filter(x=>e.nodes.some(v=>v.area===x.id)),l=new Set(o.map(x=>x.to)),u=await r.layout({id:"root",layoutOptions:{...Cs,"elk.direction":n,"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeRouting":"ORTHOGONAL","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"64","elk.spacing.edgeNode":"20","elk.spacing.edgeEdge":"14","elk.layered.spacing.edgeNodeBetweenLayers":"20","elk.layered.spacing.edgeEdgeBetweenLayers":"14","elk.spacing.edgeLabel":"4","elk.spacing.componentComponent":"60","elk.json.edgeCoords":"ROOT","elk.json.shapeCoords":"ROOT"},children:a.map(x=>({id:`area:${x.id}`,layoutOptions:{"elk.padding":`[top=${Ee.top},left=${Ee.side},bottom=${Ee.bottom},right=${Ee.side}]`},children:e.nodes.filter(v=>v.area===x.id).map(v=>({id:v.id,width:Ze,height:Ye,...v.kind==="entry"&&!l.has(v.id)?{layoutOptions:{"elk.layered.layering.layerConstraint":"FIRST"}}:{}}))})),edges:o.map(x=>{const v=i.get(x.id);return{id:x.id,sources:[x.from],targets:[x.to],...v?{labels:[{id:`${x.id}:label`,text:v,width:ol(v),height:X0,layoutOptions:{"elk.edgeLabels.inline":"true"}}]}:{}}})}),c={},d={};for(const x of u.children??[]){const v=x.id.slice(5),w=x.x??0,y=x.y??0;c[v]={x:w,y,w:x.width??0,h:x.height??0};for(const g of x.children??[])d[g.id]={x:(g.x??0)-w,y:(g.y??0)-y,w:Ze,h:Ye}}const f={};for(const x of u.edges??[]){const v=[];for(const _ of x.sections??[])for(const j of[_.startPoint,..._.bendPoints??[],_.endPoint]){const M=v[v.length-1];if(!(M&&Math.abs(M[0]-j.x)<.5&&Math.abs(M[1]-j.y)<.5)){if(M&&Math.abs(M[0]-j.x)>.5&&Math.abs(M[1]-j.y)>.5){const z=v[v.length-2],F=z?Math.abs(z[0]-M[0])<.5:!0;v.push(F?[M[0],j.y]:[j.x,M[1]])}v.push([j.x,j.y])}}if(v.length<2)continue;for(let _=1;_<v.length;_++){const[j,M]=[v[_-1],v[_]];Math.abs(j[0]-M[0])<1&&(M[0]=j[0]),Math.abs(j[1]-M[1])<1&&(M[1]=j[1])}const w=o.find(_=>_.id===x.id),y=_=>{const j=e.nodes.find(F=>F.id===_),M=j&&c[j.area],z=d[_];return M&&z?{x:M.x+z.x,y:M.y+z.y,w:z.w,h:z.h}:null},g=(_,j,M)=>{const z=Math.min(Math.max(j[1],M.y+10),M.y+M.h-10),F=Math.min(Math.max(j[0],M.x+12),M.x+M.w-12);return j[0]<=M.x?j[1]===z?[[M.x,z]]:[[j[0],z],[M.x,z]]:j[0]>=M.x+M.w?j[1]===z?[[M.x+M.w,z]]:[[j[0],z],[M.x+M.w,z]]:j[1]<=M.y?j[0]===F?[[F,M.y]]:[[F,j[1]],[F,M.y]]:j[1]>=M.y+M.h?j[0]===F?[[F,M.y+M.h]]:[[F,j[1]],[F,M.y+M.h]]:[_]},b=w&&y(w.from),E=w&&y(w.to);if(E&&v.length>=2){const _=g(v[v.length-1],v[v.length-2],E);v.splice(v.length-1,1,..._)}if(b&&v.length>=2){const _=g(v[0],v[1],b).reverse();v.splice(0,1,..._)}for(let _=1;_+2<v.length;_++){const j=v[_-1],M=v[_],z=v[_+1],F=v[_+2],N=Math.abs(M[0]-z[0])<.5?1:0,P=N===1?0:1;if(Math.abs(M[P]-z[P])>.5||Math.abs(M[N]-z[N])>=10||Math.abs(j[N]-M[N])>.5||Math.abs(z[N]-F[N])>.5)continue;const L=z[N];for(let D=_+1;D<v.length&&Math.abs(v[D][N]-L)<=.5;D++)v[D][N]=M[N];v.splice(_+1,1)}const k=(p=x.labels)==null?void 0:p[0],S=k&&k.x!==void 0&&k.y!==void 0?[k.x+(k.width??0)/2,k.y+(k.height??0)/2]:void 0;let $=0;if(S){let _=1/0;for(let j=1;j<v.length;j++){const[M,z]=v[j-1],[F,N]=v[j],P=Math.hypot(Math.max(Math.min(M,F)-S[0],0,S[0]-Math.max(M,F)),Math.max(Math.min(z,N)-S[1],0,S[1]-Math.max(z,N)));P<_&&([_,$]=[P,j-1])}}f[x.id]={points:v,label:$,...S?{at:S}:{}}}const h=Object.values(c);return{areas:c,nodes:d,routes:f,width:Math.max(0,...h.map(x=>x.x+x.w)),height:Math.max(0,...h.map(x=>x.y+x.h))}}async function wp(e,t){const n=new Map(e.absences.map(a=>[`a:${a.id}`,a.claim.length>28?`${a.claim.slice(0,26)}…`:a.claim])),r=qn(e,t).map(a=>{var l;return{...a,label:((l=e.edges.find(u=>`e:${u.id}`===a.id))==null?void 0:l.label)??n.get(a.id)}}),o=[["columns",await B$(e,t)]];for(const[a,l]of[["routed-down","DOWN"],["routed-right","RIGHT"]])try{o.push([a,await F$(e,t,l)])}catch{}const s={};let i=o[0];for(const a of o)s[a[0]]=_$(e,a[1],r),s[a[0]].score<s[i[0]].score&&(i=a);return{...i[1],chosen:{name:i[0],scores:s}}}async function B$(e,t){var E;const n=await rl(),r=new Map(e.nodes.map(k=>[k.id,k.area])),o=qn(e,t),s=D$(e),i=Us(e.nodes.map(k=>k.id),e.edges.map(k=>({from:k.from,to:k.to}))),a=new Set(e.nodes.map(k=>k.area)),l=()=>{const k=new Map;for(const S of o){const $=r.get(S.from),_=r.get(S.to);$!==_&&k.set(`${$}>${_}`,{from:$,to:_})}return[...k.values()]},u=new Map;if(s.some(k=>k.areas.length===2)){const k=await n.layout({id:"root",layoutOptions:{...Cs,"elk.direction":"RIGHT"},children:e.areas.filter(S=>a.has(S.id)).map(S=>({id:S.id,width:100,height:100})),edges:l().map((S,$)=>({id:`q${$}`,sources:[S.from],targets:[S.to]}))});for(const S of k.children??[])u.set(S.id,S.x??0)}const c=new Map,d=new Map,f=new Map;for(const k of s)if(k.areas.length===2){const[S,$]=k.areas,_=A=>Math.min(...e.nodes.filter(O=>O.area===A).map(O=>i.get(O.id)??0)),[j,M]=_($)<_(S)?[$,S]:[S,$];(u.get(j)??0)<(u.get(M)??0)||c.set(j,M);const z=k.order.length,F=k.order.findIndex((A,O)=>r.get(A)===j&&r.get(k.order[(O-1+z)%z])===M),N=[...k.order.slice(F),...k.order.slice(0,F)],P=N.filter(A=>r.get(A)===j).reverse(),L=N.filter(A=>r.get(A)===M),D=Math.max(P.length,L.length),I=A=>(D-A)*(Ye+on)/2;d.set(j,[{column:P,side:"right",drop:I(P.length)}]),d.set(M,[{column:L,side:"left",drop:I(L.length)}]),f.set(j,M)}else{const S=Math.ceil(k.order.length/2),$=k.order.slice(0,S).reverse(),_=k.order.slice(S),j=Math.max($.length,_.length),M=z=>(j-z)*(Ye+on)/2;d.set(k.areas[0],[{column:$,side:"right",drop:M($.length)},{column:_,side:"left",drop:M(_.length)}])}const h={},p={};for(const k of e.areas){const S=e.nodes.filter(M=>M.area===k.id);if(!S.length)continue;const $=o.filter(M=>r.get(M.from)===k.id&&r.get(M.to)===k.id),_=d.get(k.id);if((_==null?void 0:_.length)===1){const M=_[0],z=await yp(n,k.id,S.filter(F=>!M.column.includes(F.id)),$,M.column,M.side,M.drop);Object.assign(h,z.nodes),p[k.id]=z.size;continue}if((_==null?void 0:_.length)===2){const[M,z]=_,F=new Set([...M.column,...z.column]),N=await yp(n,k.id,S.filter(D=>!F.has(D.id)),$,M.column,"right",M.drop),P=Math.max(...M.column.map(D=>N.nodes[D].x))+Ze+gr+Qo;z.column.forEach((D,I)=>{const A=Qo*Math.sin(Math.PI*(I+.5)/z.column.length);N.nodes[D]={x:P+A,y:Ee.top+z.drop+I*(Ye+on),w:Ze,h:Ye}}),Object.assign(h,N.nodes);const L=Object.values(N.nodes);p[k.id]={w:Math.max(...L.map(D=>D.x+D.w))+Ee.side,h:Math.max(N.size.h,...L.map(D=>D.y+D.h+Ee.bottom))};continue}const j=await jd(n,k.id,S,$);Object.assign(h,j.nodes),p[k.id]=j.size}const x=new Map,v=new Map(e.edges.map(k=>[`${k.from}>${k.to}`,k.label]));for(const k of o){const S=r.get(k.from),$=r.get(k.to);if(S===$||!p[S]||!p[$]||c.get($)===S)continue;const _=`${S}>${$}`,j=ol(v.get(`${k.from}>${k.to}`)??"");x.set(_,{from:S,to:$,label:Math.max(((E=x.get(_))==null?void 0:E.label)??0,j)})}const w=await n.layout({id:"root",layoutOptions:{...Cs,"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.nodeNode":"48","elk.spacing.componentComponent":"64"},children:e.areas.filter(k=>p[k.id]).map(k=>({id:k.id,width:p[k.id].w,height:p[k.id].h})),edges:[...x.values()].map((k,S)=>{const $=U$(k.label);return{id:`p${S}`,sources:[k.from],targets:[k.to],...$?{labels:[{id:`p${S}l`,text:" ",width:$,height:X0}]}:{}}})}),y={};for(const k of w.children??[])y[k.id]={x:k.x??0,y:k.y??0,w:k.width??0,h:k.height??0};for(const[k,S]of f){const $=y[k],_=y[S];if(!$||!_)continue;const j=$.y-_.y,M={..._,y:_.y+j};Object.entries(y).some(([F,N])=>F!==S&&F!==k&&M.x<N.x+N.w&&N.x<M.x+M.w&&M.y<N.y+N.h&&N.y<M.y+M.h)||(y[S]=M)}const g=Object.values(y),b=Math.min(0,...g.map(k=>k.y));if(b<0)for(const k of g)k.y-=b;return{areas:y,nodes:h,width:Math.max(w.width??0,...g.map(k=>k.x+k.w)),height:Math.max(w.height??0,...g.map(k=>k.y+k.h)),...s.length?{rings:s.map(k=>k.order)}:{}}}const X0=24,ol=e=>e?Math.ceil(e.length*6.8+16):0,H$=40;function U$(e){return Math.max(0,e+2*H$-2*120)}function sl(e){const t=Us(e.nodes.map(n=>n.id),e.edges.map(n=>({from:n.from,to:n.to})));return new Set(e.edges.filter(n=>n.from!==n.to&&(t.get(n.to)??0)<=(t.get(n.from)??0)).map(n=>n.id))}function q0(e,t){const n=e.edges.find(d=>d.id===t);if(!n||!sl(e).has(t))return null;const r=e.edges.filter(d=>d.id!==t),o=(d,f)=>{const h=new Set([d]);for(let p=!0;p;){p=!1;for(const x of r){const[v,w]=f(x);h.has(v)&&!h.has(w)&&(h.add(w),p=!0)}}return h},s=o(n.to,d=>[d.from,d.to]),i=o(n.from,d=>[d.to,d.from]),a=new Set([...s].filter(d=>i.has(d))),l=Us(e.nodes.map(d=>d.id),e.edges.map(d=>({from:d.from,to:d.to}))),u=e.nodes.map(d=>d.id).filter(d=>a.has(d)).sort((d,f)=>(l.get(d)??0)-(l.get(f)??0)),c=[...r.filter(d=>a.has(d.from)&&a.has(d.to)).map(d=>d.id),t];return{nodes:u,edges:c}}function W$(e,t,n,r){var f;if(t.flat){const h=w=>{const y=t.nodes[w];return y?{x:y.x+y.w/2,y:y.y+y.h/2}:{x:0,y:0}},p=h(r).x-h(n).x,x=h(r).y-h(n).y;if(Math.abs(p)<40)return x>=0?["b","t"]:["t","b"];const v=_a(t,r)-_a(t,n);return v?v>0?["b","t"]:["r","b"]:p>=0?["r","l"]:["l","r"]}const o=h=>{var p;return((p=e.nodes.find(x=>x.id===h))==null?void 0:p.area)??""},s=h=>{const p=t.areas[o(h)],x=t.nodes[h];return p&&x?{x:p.x+x.x+x.w/2,y:p.y+x.y+x.h/2}:{x:0,y:0}},i=s(n),a=s(r),l=a.x-i.x,u=a.y-i.y,c=(f=t.rings)==null?void 0:f.find(h=>h.includes(n)),d=!!c&&c.includes(r)&&Math.abs(l)>=Ze*.75;return!t.lanes&&!d&&o(n)===o(r)||Math.abs(l)<Ze*.75?u>=0?["b","t"]:["t","b"]:l>=0?["r","l"]:["l","r"]}function V$(e,t=[],n=[],r=[]){return JSON.stringify([e.view??null,e.view==="journey"?[e.nodes.map(o=>o.kind),[...r].sort()]:null,[...e.nodes,...e.edges].map(o=>o.branch??""),[...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 Lr=()=>({nodes:[],edges:[],absences:[]}),Do=e=>e.nodes.length+e.edges.length+e.absences.length,G$=e=>({mapId:e,phase:"loading",meta:null,map:null,report:null,job:null,error:null,answers:[],shown:null,selection:Lr(),tour:null,peek:!1,views:[],viewIndex:-1,fixes:{},fresh:[],hidden:[],connected:!1,agent:L0}),Y$=e=>e.views[e.viewIndex]??null;function Ws(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 X$=e=>Ws(e).flatMap(t=>t.ids);function K0(e){if(!e.map)return null;const t=new Set(Ws(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 q$(e,t){if(!t)return e;const n=(r,o)=>r.filter(s=>o.some(i=>i.id===s));return{nodes:n(e.nodes,t.nodes),edges:n(e.edges,t.edges),absences:n(e.absences,t.absences)}}function K$(e,t){var i,a,l;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],s=(n.focus.edges??[]).length||(n.focus.absences??[]).length?[]:Z0(e,new Set(o));return{focus:((i=n.focus.nodes)==null?void 0:i[0])??((a=n.focus.edges)==null?void 0:a[0])??((l=n.focus.absences)==null?void 0:l[0])??null,highlight:[...new Set([...o,...s])]}}function Z0(e,t){return e.edges.filter(n=>t.has(n.from)&&t.has(n.to)).map(n=>n.id)}function xp(e,t){const n=[...t.moves.highlight,...t.added],r=e?[...new Set([...n,...Z0(e,new Set(n))])]:n;return r.length||t.moves.focus?{focus:t.moves.focus??r[0]??null,highlight:r}:null}function nr(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 vp(e,t,n){const r={...t};for(const o of e){if(!o.fix||r[o.fix.id]&&!n)continue;const s=n?n[o.fix.id]:{status:"proposed"};r[o.fix.id]={proposal:o.fix,answerId:o.id,status:(s==null?void 0:s.status)??"rejected",problems:[],edgeId:(s==null?void 0:s.edgeId)??null,closed:(s==null?void 0:s.closed)??[],undoable:(s==null?void 0:s.undoable)??!0}}return r}function Z$(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:vp(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=i=>i.filter(a=>r.map.nodes.some(l=>l.id===a)||r.map.edges.some(l=>l.id===a)||r.map.absences.some(l=>l.id===a)),s={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:s}}if(r.type==="answer"){const o=[...e.answers,r.answer],s={...e,answers:o,shown:r.answer.id,tour:null,peek:!1,fresh:r.answer.added,fixes:vp([r.answer],e.fixes,void 0)};return nr(s,xp(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 s=r.status,i={...e.fixes,[r.fixId]:{...o,status:s,problems:r.problems??[],edgeId:r.edgeId??o.edgeId,closed:r.closed??o.closed,undoable:r.status==="applied"?!0:o.undoable}},a={...e,fixes:i};if(r.status==="applied"&&r.edgeId){const l=o.proposal.connects;return nr(a,{focus:r.edgeId,highlight:[r.edgeId,...l?[l.from,l.to]:[]]})}return a}return e}case"select":{const r=e.selection[t.kind],o=r.includes(t.id),s=t.additive?{...e.selection,[t.kind]:o?r.filter(i=>i!==t.id):[...r,t.id]}:{...Lr(),[t.kind]:o&&Do(e.selection)===1?[]:[t.id]};return{...e,selection:s}}case"selectMany":return{...e,selection:t.selection};case"clearSelection":return{...e,selection:Lr()};case"tour":{if(!e.map)return{...e,tour:null,peek:!1};if(t.stop===null)return e.tour===null?e:nr({...e,tour:null,peek:!1},{focus:null,highlight:[]});const r=Math.max(0,Math.min(t.stop,e.map.tour.length-1));return nr({...e,tour:r,selection:Lr()},K$(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?nr({...e,tour:null,peek:!1,selection:{...Lr(),[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 nr({...e,shown:t.answerId,tour:null,peek:!1},r?xp(e.map,r):null)}case"overview":return nr({...e,shown:null,tour:null,peek:!1,selection:Lr(),fresh:[]},{focus:null,highlight:[]});case"layer":case"allLayers":{const r=t.type==="layer"?[t.answerId]:Ws(e).map(i=>i.answerId),o=t.visible?e.hidden.filter(i=>!r.includes(i)):[...new Set([...e.hidden,...r])],s={...e,hidden:o};return{...s,selection:q$(e.selection,K0(s))}}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 mr=(...e)=>e.filter(Boolean).join(" ");function dt(e,t){const n=e.nodes.find(i=>i.id===t);if(n)return n.name;const r=e.edges.find(i=>i.id===t);if(r)return`${dt(e,r.from)} → ${dt(e,r.to)}`;const o=e.absences.find(i=>i.id===t);if(o)return o.claim;const s=e.areas.find(i=>i.id===t);return(s==null?void 0:s.label)??t}const Q$={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."}},J$={added:"New since",changed:"Changed since",removed:"Removed since"};function cc(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 mt({eyebrow:e,title:t,children:n,tone:r,className:o}){return m.jsxs("section",{className:mr("card",r&&`card-${r}`,o),children:[e&&m.jsx("div",{className:"eyebrow",children:e}),t&&m.jsx("h2",{className:"card-title",children:t}),n]})}function eC({map:e,ids:t,onPick:n}){return t.length?m.jsx("div",{className:"chips",children:t.map(({id:r,status:o})=>m.jsxs("button",{className:mr("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:[m.jsx("span",{className:o==="confirmed"?"tick":o==="proposed"?"pmark":"qmark",children:o==="confirmed"?"✓":o==="proposed"?"+":"?"}),dt(e,r)]},r))}):null}function kp({lines:e,working:t}){const n=e.slice(-8);return m.jsxs("ul",{className:"progress",children:[n.map((r,o)=>m.jsxs("li",{className:mr(t&&o===n.length-1&&"running"),children:[m.jsx("span",{className:"ic",children:t&&o===n.length-1?"…":"✓"}),r]},`${o}-${r}`)),!n.length&&t&&m.jsxs("li",{className:"running",children:[m.jsx("span",{className:"ic",children:"…"}),"Starting"]})]})}function tC({fix:e,onApprove:t,onReject:n,onUndo:r,map:o}){const s=e.proposal,i=s.files.filter(a=>a.uncommitted);return e.status==="applied"?m.jsxs(mt,{eyebrow:"Fix applied · re-checked",tone:"ok",children:[m.jsxs("ul",{className:"progress",children:[m.jsxs("li",{children:[m.jsx("span",{className:"ic",children:"✓"}),"Changed ",s.files.length," ",s.files.length===1?"file":"files",": ",s.files.map(a=>a.file).join(", ")]}),e.edgeId&&m.jsxs("li",{children:[m.jsx("span",{className:"ic",children:"✓"}),"New confirmed connection: ",dt(o,e.edgeId)]}),e.closed.length>0&&m.jsxs("li",{children:[m.jsx("span",{className:"ic",children:"✓"}),"Closed: ",e.closed.length===1?"the missing connection":`${e.closed.length} missing connections`]})]}),e.undoable?m.jsx("div",{className:"btns",children:m.jsx("button",{className:"btn",onClick:r,children:"Undo this fix"})}):m.jsx("p",{className:"muted small",children:"Undo ended when illuminate stopped. Use git to reverse it."})]}):e.status==="rejected"||e.status==="undone"?m.jsxs(mt,{eyebrow:e.status==="undone"?"Fix undone":"Fix rejected",children:[m.jsx($s,{text:s.summary,className:"muted"}),e.status==="undone"&&m.jsx("div",{className:"btns",children:m.jsx("button",{className:"btn",onClick:t,children:"Apply it again"})})]}):m.jsxs(mt,{eyebrow:`Proposed fix · ${s.files.length} ${s.files.length===1?"file":"files"} · nothing changed yet`,tone:"ai",children:[m.jsx($s,{text:s.summary}),s.connects&&m.jsx("p",{className:"muted small",children:"The green dashed arrow is the connection it adds."}),m.jsx("pre",{className:"diff",children:s.diff.split(`
|
|
78
|
+
`).forEach((a,l)=>{l>0&&n.push(m.jsx("br",{},`${t}-br${o++}`)),a&&n.push(a)})};for(const i of e.matchAll(c$)){s(e.slice(r,i.index));const a=`${t}-${o++}`;if(i[2]!==void 0)n.push(m.jsx("code",{children:i[2]},a));else if(i[3]!==void 0||i[4]!==void 0)n.push(m.jsx("strong",{children:cr(i[3]??i[4],a)},a));else if(i[5]!==void 0||i[6]!==void 0)n.push(m.jsx("em",{children:cr(i[5]??i[6],a)},a));else if(i[7]!==void 0){const l=i[8];n.push(/^https?:\/\//i.test(l)?m.jsx("a",{href:l,target:"_blank",rel:"noreferrer",children:cr(i[7],a)},a):m.jsx("span",{children:cr(i[7],a)},a))}r=i.index+i[0].length}return s(e.slice(r)),n}function $s({text:e,className:t}){const n=u$(e);return n.length?m.jsx("div",{className:t?`md ${t}`:"md",children:n.map((r,o)=>{const s=`b${o}`;if(r.kind==="p")return m.jsx("p",{children:cr(r.text,s)},s);if(r.kind==="h")return m.jsx("p",{className:"md-h",children:cr(r.text,s)},s);if(r.kind==="code")return m.jsx("pre",{children:m.jsx("code",{children:r.text})},s);const i=r.items.map((a,l)=>m.jsx("li",{children:cr(a,`${s}-${l}`)},`${s}-${l}`));return r.kind==="ul"?m.jsx("ul",{children:i},s):m.jsx("ol",{start:r.start,children:i},s)})}):null}const d$=/^About the walkthrough step “([^”]*)”: /,f$=(e,t)=>`About the walkthrough step “${e}”: ${t}`;function h$(e){const t=d$.exec(e);return t?{question:e.slice(t[0].length),step:t[1]}:{question:e,step:null}}function p$(e,t,n,r=12){return Math.max(0,e+(n-t)-r)}function g$(e,t,n=40){return t>e-n}const m$="modulepreload",y$=function(e){return"/"+e},ip={},w$=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(l=>{if(l=y$(l),l in ip)return;ip[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":m$,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((f,h)=>{d.addEventListener("load",f),d.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return o.then(i=>{for(const a of i||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},B0=[.5,.42,.58,.34,.66,.26,.74,.2,.8],x$=[...B0,.86,.14,.9,.1],xi=4,vi={w:26,h:18},Yl=(e,t)=>e.x<t.x+t.w+xi&&t.x<e.x+e.w+xi&&e.y<t.y+t.h+xi&&t.y<e.y+e.h+xi,ki=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,w:t,h:n});function Ad(e,t,n=[]){const r=[],o={},s=(l,u)=>!t.some(c=>Yl(l,c))&&!r.some(c=>Yl(l,c))&&(!u||!n.some(c=>Yl(l,c))),i=[...e.filter(l=>l.keep),...e.filter(l=>!l.keep)],a=(l,u,c,d=B0)=>{for(const f of[!0,!1]){if(s(ki(l.at,u,c),f))return l.at;for(const h of d){const p=l.along(h);if(p&&s(ki(p,u,c),f))return p}}return null};for(const l of i){const u=a(l,l.w,l.h)??(l.keep?l.at:null);if(!u){const c=a(l,vi.w,vi.h,x$);c?(r.push(ki(c,vi.w,vi.h)),o[l.id]={...c,dot:!0}):o[l.id]="dot";continue}r.push(ki(u,l.w,l.h)),u!==l.at&&(o[l.id]=u)}return o}function v$(e,t,n,r,o){if(o==="over"){const l=Math.max(Math.abs(n-e)/2,40),u=Math.max(70,Math.min(170,Math.abs(n-e)*.32)),c=e<n?1:0;return[`M ${e} ${t} A ${l} ${u} 0 0 ${c} ${n} ${r}`,(e+n)/2,(t+r)/2-u]}const s=Math.max(Math.abs(r-t)/2,40),i=Math.max(60,Math.min(150,Math.abs(r-t)*.32)),a=t<r?1:0;return[`M ${e} ${t} A ${i} ${s} 0 0 ${a} ${n} ${r}`,Math.max(e,n)+i,(t+r)/2]}function k$(e,t,n,r,o){const s=Math.hypot(n-e,r-t)||1,i=-(r-t)/s,a=(n-e)/s,l=(e+n)/2+i*o*2,u=(t+r)/2+a*o*2;return[`M ${e} ${t} Q ${l} ${u} ${n} ${r}`,(e+n)/2+i*o,(t+r)/2+a*o]}function H0(e,t=18,n,r){let o=`M ${e[0][0]} ${e[0][1]}`;for(let u=1;u<e.length-1;u++){const[c,d]=e[u-1],[f,h]=e[u],[p,x]=e[u+1],v=Math.min(t,Math.hypot(f-c,h-d)/2),w=Math.min(t,Math.hypot(p-f,x-h)/2),y=S=>Math.abs(S)<1?0:Math.sign(S),g=y(f-c),b=y(h-d),E=y(p-f),k=y(x-h);o+=` L ${f-g*v} ${h-b*v} Q ${f} ${h} ${f+E*w} ${h+k*w}`}const s=e[e.length-1];if(o+=` L ${s[0]} ${s[1]}`,r)return[o,r[0],r[1]];const[i,a]=n!==void 0?[e[n],e[n+1]]:[];if(i&&a)return[o,(i[0]+a[0])/2,(i[1]+a[1])/2];let l=[0,e[0][0],e[0][1]];for(let u=1;u<e.length;u++){const[c,d]=e[u-1],[f,h]=e[u];d===h&&Math.abs(f-c)>l[0]&&(l=[Math.abs(f-c),(c+f)/2,h])}return[o,l[1],l[2]]}function U0(e,t,n,r,o,s,i){if(i.loop)return v$(e,t,r,o,i.loop);if(i.route)return H0(i.route.points,18,i.route.label,i.route.at);if(i.offset)return k$(e,t,r,o,i.offset);const[a,l,u]=bd({sourceX:e,sourceY:t,sourcePosition:n,targetX:r,targetY:o,targetPosition:s});return[a,l,u]}function W0(e,t,n){var u;const r=t.flat||t.lanes?new Set:sl(e),o=c=>{const d=e.nodes.find(p=>p.id===c),f=t.nodes[c],h=d?t.areas[d.area]:void 0;return f?{x:((h==null?void 0:h.x)??0)+f.x+f.w/2,y:((h==null?void 0:h.y)??0)+f.y+f.h/2}:{x:0,y:0}},s=new Map((t.rings??[]).flatMap((c,d)=>c.map(f=>[f,d]))),i=c=>s.has(c.from)&&s.get(c.from)===s.get(c.to),a=new Map;for(const c of n){const d=c.id.startsWith("e:")&&r.has(c.id.slice(2)),f=(u=t.routes)==null?void 0:u[c.id];let h;if(d&&!f&&!i(c)){const v=Math.abs(o(c.to).x-o(c.from).x),w=Math.abs(o(c.to).y-o(c.from).y);h=v<Ze*.75?"side":w<Ye/2?"over":void 0}const[p,x]=h==="over"?["t","t"]:h==="side"?["r","r"]:W$(e,t,c.from,c.to);a.set(c.id,{sourceHandle:`s${p}`,targetHandle:`t${x}`,back:d,...h?{loop:h}:{},...f?{route:f}:{}})}const l=new Map;for(const c of n){const d=[c.from,c.to].sort().join("|");l.set(d,[...l.get(d)??[],c.id])}for(const c of l.values())c.length<2||c.some(d=>{var f;return(f=a.get(d))==null?void 0:f.route})||c.forEach((d,f)=>{const h=a.get(d);h&&(h.offset=(f-(c.length-1)/2)*44)});return a}const ap={t:ue.Top,r:ue.Right,b:ue.Bottom,l:ue.Left};function Ea(e,t,n){var s;const r=t.nodes[n];if(!r)return null;const o=t.flat?void 0:t.areas[((s=e.nodes.find(i=>i.id===n))==null?void 0:s.area)??""];return{x:((o==null?void 0:o.x)??0)+r.x,y:((o==null?void 0:o.y)??0)+r.y,w:r.w,h:r.h}}function lp(e,t){return t==="t"?[e.x+e.w/2,e.y]:t==="b"?[e.x+e.w/2,e.y+e.h]:t==="l"?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2]}function V0(e,t,n){const r=W0(e,t,n),o=new Map;for(const s of n){const i=r.get(s.id),a=Ea(e,t,s.from),l=Ea(e,t,s.to);if(!a||!l)continue;const u=i.sourceHandle.slice(1),c=i.targetHandle.slice(1),[d,f]=lp(a,u),[h,p]=lp(l,c),[x,v,w]=U0(d,f,ap[u],h,p,ap[c],i);o.set(s.id,{d:x,at:[v,w],from:s.from,to:s.to})}return o}function Na(e,t=4){const n=e.match(/[MLQCA]|-?\d*\.?\d+(?:e-?\d+)?/g)??[],r=[];let o=0,s={x:0,y:0},i="";const a=()=>Number(n[o++]),l=(u,c)=>{const d=Math.max(2,Math.ceil(c/t));for(let f=1;f<=d;f++)r.push(u(f/d))};for(;o<n.length;)if(/^[MLQCA]$/.test(n[o])&&(i=n[o++]),i==="M")s={x:a(),y:a()},r.push(s),i="L";else if(i==="L"){const u=s,c={x:a(),y:a()};l(d=>({x:u.x+(c.x-u.x)*d,y:u.y+(c.y-u.y)*d}),Math.hypot(c.x-u.x,c.y-u.y)),s=c}else if(i==="Q"){const u=s,c={x:a(),y:a()},d={x:a(),y:a()};l(f=>({x:(1-f)**2*u.x+2*(1-f)*f*c.x+f*f*d.x,y:(1-f)**2*u.y+2*(1-f)*f*c.y+f*f*d.y}),Math.hypot(c.x-u.x,c.y-u.y)+Math.hypot(d.x-c.x,d.y-c.y)),s=d}else if(i==="C"){const u=s,c={x:a(),y:a()},d={x:a(),y:a()},f={x:a(),y:a()};l(h=>{const p=1-h;return{x:p**3*u.x+3*p*p*h*c.x+3*p*h*h*d.x+h**3*f.x,y:p**3*u.y+3*p*p*h*c.y+3*p*h*h*d.y+h**3*f.y}},Math.hypot(c.x-u.x,c.y-u.y)+Math.hypot(d.x-c.x,d.y-c.y)+Math.hypot(f.x-d.x,f.y-d.y)),s=f}else if(i==="A"){let u=Math.abs(a()),c=Math.abs(a());a();const d=a(),f=a(),h={x:a(),y:a()},p=s,x=(p.x-h.x)/2,v=(p.y-h.y)/2,w=x*x/(u*u)+v*v/(c*c);w>1&&(u*=Math.sqrt(w),c*=Math.sqrt(w));const g=(d===f?-1:1)*Math.sqrt(Math.max(0,(u*u*c*c-u*u*v*v-c*c*x*x)/(u*u*v*v+c*c*x*x))),b=g*u*v/c,E=-g*c*x/u,k=b+(p.x+h.x)/2,S=E+(p.y+h.y)/2,$=(M,z,F,N)=>Math.atan2(M*N-z*F,M*F+z*N),_=$(1,0,(x-b)/u,(v-E)/c);let j=$((x-b)/u,(v-E)/c,(-x-b)/u,(-v-E)/c);!f&&j>0?j-=2*Math.PI:f&&j<0&&(j+=2*Math.PI),l(M=>({x:k+u*Math.cos(_+j*M),y:S+c*Math.sin(_+j*M)}),Math.abs(j)*Math.max(u,c)),s=h}else o++;return r}const b$=24,Xl={w:26,h:18};function S$(e,t,n){const r=e.nodes.flatMap(p=>{const x=Ea(e,t,p.id);return x?[{id:p.id,...x}]:[]}),o=Object.values(t.areas).map(p=>({x:p.x,y:p.y,w:Math.min(p.w,280),h:40})),s=V0(e,t,n),i=[...s].map(([p,x])=>({id:p,from:x.from,to:x.to,d:x.d})),a=[];for(const p of n){const x=s.get(p.id);if(!x||!p.label)continue;const v=Na(x.d,6);a.push({id:p.id,w:ol(p.label),h:b$,at:{x:x.at[0],y:x.at[1]},along:w=>v[Math.min(v.length-1,Math.max(0,Math.round(w*(v.length-1))))]??null,keep:p.id.startsWith("a:")})}const l=Ad(a,r,o);let u=0;const c=[];for(const p of a){const x=l[p.id];if(x==="dot"||x&&"dot"in x){u++;const v=x==="dot"?p.at:x;c.push({x:v.x-Xl.w/2,y:v.y-Xl.h/2,...Xl})}else{const v=x??p.at;c.push({x:v.x-p.w/2,y:v.y-p.h/2,w:p.w,h:p.h})}}const d=[...r,...Object.values(t.areas)],f=Math.max(0,...d.map(p=>p.x+p.w))-Math.min(0,...d.map(p=>p.x)),h=Math.max(0,...d.map(p=>p.y+p.h))-Math.min(0,...d.map(p=>p.y));return{boxes:r,titles:o,arrows:i,labels:c,hidden:u,width:f,height:h}}const up=16,cp={w:1400,h:620},E$={under:4,stacked:3,hidden:3,clash:3,crossings:2,detours:1.5,fit:20};function N$(e){const t=(p,x,v=3)=>p.x>x.x+v&&p.x<x.x+x.w-v&&p.y>x.y+v&&p.y<x.y+x.h-v,n=e.arrows.map(p=>{const x=Na(p.d);let v=0;for(let k=1;k<x.length;k++)v+=Math.hypot(x[k].x-x[k-1].x,x[k].y-x[k-1].y);const w=[];let y=0;for(let k=0;k<x.length;k++)k&&(y+=Math.hypot(x[k].x-x[k-1].x,x[k].y-x[k-1].y)),y>up&&y<v-up&&w.push(x[k]);const g=w.map(k=>k.x),b=w.map(k=>k.y),E=w.length?{x0:Math.min(...g),x1:Math.max(...g),y0:Math.min(...b),y1:Math.max(...b)}:null;return{...p,pts:w,total:v,bounds:E}});let r=0;for(const p of n)e.boxes.some(x=>x.id!==p.from&&x.id!==p.to&&p.pts.some(v=>t(v,x)))&&r++;const o=(p,x,v,w)=>{const y=(x.x-p.x)*(w.y-v.y)-(x.y-p.y)*(w.x-v.x);if(Math.abs(y)<1e-9)return null;const g=((v.x-p.x)*(w.y-v.y)-(v.y-p.y)*(w.x-v.x))/y,b=((v.x-p.x)*(x.y-p.y)-(v.y-p.y)*(x.x-p.x))/y;return g>0&&g<1&&b>0&&b<1?{x:p.x+g*(x.x-p.x),y:p.y+g*(x.y-p.y)}:null},s=[];let i=0;for(let p=0;p<n.length;p++)for(let x=p+1;x<n.length;x++){const v=n[p],w=n[x];if(!v.bounds||!w.bounds||v.bounds.x1<w.bounds.x0-4||w.bounds.x1<v.bounds.x0-4||v.bounds.y1<w.bounds.y0-4||w.bounds.y1<v.bounds.y0-4)continue;for(let g=1;g<v.pts.length;g++)for(let b=1;b<w.pts.length;b++){const E=o(v.pts[g-1],v.pts[g],w.pts[b-1],w.pts[b]);E&&!s.some(k=>Math.hypot(k.x-E.x,k.y-E.y)<10)&&s.push(E)}let y=0;for(const g of v.pts)w.pts.some(b=>Math.abs(b.x-g.x)<3.5&&Math.abs(b.y-g.y)<3.5)&&y++;y*4>40&&i++}const a=(p,x)=>p.x<x.x+x.w-1&&x.x<p.x+p.w-1&&p.y<x.y+x.h-1&&x.y<p.y+p.h-1;let l=0;e.labels.forEach((p,x)=>{(e.boxes.some(v=>a(p,v))||e.labels.some((v,w)=>w!==x&&a(p,v)))&&l++});const u=p=>{const x=e.boxes.find(v=>v.id===p);return x?{x:x.x+x.w/2,y:x.y+x.h/2}:null};let c=0;for(const p of n){const x=u(p.from),v=u(p.to);if(!x||!v)continue;const w=Math.max(Math.hypot(v.x-x.x,v.y-x.y)-110,40);p.total>2.5*w&&p.total-w>300&&c++}const d=Math.min(1,cp.w/Math.max(1,e.width),cp.h/Math.max(1,e.height)),f=E$,h=f.under*r+f.stacked*i+f.hidden*e.hidden+f.clash*l+f.crossings*s.length+f.detours*c+f.fit*(1-d);return{crossings:s.length,under:r,stacked:i,hidden:e.hidden,clash:l,detours:c,fit:Math.round(d*100)/100,score:Math.round(h*10)/10}}function _$(e,t,n){return N$(S$(e,t,n))}const Ze=232,Ye=96,$$=e=>e.view==="journey"&&[...e.nodes,...e.edges].some(t=>!!t.branch);function _a(e,t){var s;const n=((s=e.nodes[t])==null?void 0:s.y)??0,r=e.rowTops??[];let o=0;for(const[i,a]of r.entries())n>=a-1&&(o=i);return o}const C$=132;function lc(e,t=!1){return e==="choice"?{w:196,h:132}:e==="action"?{w:196,h:60}:t?{w:232,h:64+C$}:{w:196,h:72}}let M$=null;const rl=()=>M$??(M$=w$(()=>import("./elk.bundled-BdwyDyHG.js").then(e=>e.e),[]).then(e=>new e.default)),Cs={"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};function qn(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 Ee={top:52,side:26,bottom:26},on=64,gr=44,A$=56,j$=140;async function jd(e,t,n,r){const o=await e.layout({id:t,layoutOptions:{...Cs,"elk.direction":"DOWN","elk.padding":`[top=${Ee.top},left=${Ee.side},bottom=${Ee.bottom},right=${Ee.side}]`,"elk.layered.spacing.nodeNodeBetweenLayers":String(on),"elk.spacing.nodeNode":String(gr)},children:n.map(i=>({id:i.id,width:Ze,height:Ye})),edges:r.map(i=>({id:i.id,sources:[i.from],targets:[i.to]}))}),s={};for(const i of o.children??[])s[i.id]={x:i.x??0,y:i.y??0,w:Ze,h:Ye};return{nodes:s,size:{w:o.width??Ze+2*Ee.side,h:o.height??Ye+Ee.top+Ee.bottom}}}function T$(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 G0(e,t=[],n=new Set,r=new Set){if(e.view==="journey")return $$(e)?P$(e,t,r):Y0(e,t,r);const o=I$(e),s=await L$(e,t,n);return o.length?{...s,branches:o}:s}function I$(e){const t=[];for(const n of[...e.nodes,...e.edges])n.branch&&!t.includes(n.branch)&&t.push(n.branch);return t}async function L$(e,t,n){var E;if(e.view==="timeline")return z$(e,t);const r=e.nodes.filter(k=>n.has(k.id));if(!r.length)return wp(e,t);const o=T$(e,n),s=new Set(o.nodes.map(k=>k.id)),i=await wp(o,t.filter(k=>s.has(k.from)&&s.has(k.to))),a=await rl(),l=Object.fromEntries(Object.entries(i.areas).map(([k,S])=>[k,{...S}])),u={...i.nodes},c={},d={};for(const k of r)(d[E=k.area]??(d[E]=[])).push(k);for(const[k,S]of Object.entries(d)){const $=l[k];if(!$)continue;const _=Math.max(1,Math.floor(($.w-2*Ee.side+gr)/(Ze+gr))),j=Math.max(Ee.top-on,...o.nodes.filter(z=>z.area===k).map(z=>{var F;return(((F=u[z.id])==null?void 0:F.y)??0)+Ye}))+on;S.forEach((z,F)=>{u[z.id]={x:Ee.side+F%_*(Ze+gr),y:j+Math.floor(F/_)*(Ye+on),w:Ze,h:Ye}});const M=Math.max($.h,j+Math.ceil(S.length/_)*(Ye+on)-on+Ee.bottom);c[k]=M-$.h,$.h=M}const f=Object.fromEntries(Object.entries(i.areas).map(([k,S])=>[k,S])),h=Object.keys(f).sort((k,S)=>f[k].y-f[S].y),p={};for(const k of h){const S=f[k];p[k]=Math.max(0,...h.filter($=>$!==k&&p[$]!==void 0).filter($=>{const _=f[$];return _.y+_.h<=S.y+1&&_.x<S.x+S.w&&S.x<_.x+_.w}).map($=>p[$]+(c[$]??0))),l[k].y+=p[k]}const x=qn(e,t),v=new Map(e.nodes.map(k=>[k.id,k.area])),w=Math.max(0,...Object.values(l).map(k=>k.x+k.w))+j$;let y=0;for(const k of e.areas){if(l[k.id])continue;const S=e.nodes.filter(j=>j.area===k.id);if(!S.length)continue;const $=x.filter(j=>v.get(j.from)===k.id&&v.get(j.to)===k.id),_=await jd(a,k.id,S,$);Object.assign(u,_.nodes),l[k.id]={x:w,y,w:_.size.w,h:_.size.h},y+=_.size.h+A$}const g=Object.values(l);let b;if(i.routes){b={};const k=new Map(qn(o,t).map(S=>[S.id,S]));for(const[S,$]of Object.entries(i.routes)){const _=k.get(S),j=_&&p[v.get(_.from)??""],M=_&&p[v.get(_.to)??""];j===void 0||M===void 0||j!==M||(b[S]={...$,points:$.points.map(([z,F])=>[z,F+j]),...$.at?{at:[$.at[0],$.at[1]+j]}:{}})}}return{areas:l,nodes:u,width:Math.max(0,...g.map(k=>k.x+k.w)),height:Math.max(0,...g.map(k=>k.y+k.h)),...i.rings?{rings:i.rings}:{},...b?{routes:b}:{},...i.chosen?{chosen:i.chosen}:{}}}const dp=1900,uc=130;async function Y0(e,t,n){const o=await(await rl()).layout({id:"root",layoutOptions:{...Cs,"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(h=>({id:h.id,width:lc(h.kind,n.has(h.id)).w,height:lc(h.kind,n.has(h.id)).h})),edges:qn(e,t).map(h=>({id:h.id,sources:[h.from],targets:[h.to]}))}),s={};for(const h of o.children??[])s[h.id]={x:h.x??0,y:h.y??0,w:h.width??0,h:h.height??0};const i=o.width??0;if(i<=dp)return{areas:{},nodes:s,width:i,height:o.height??0,flat:!0};const a=[];for(const[h,p]of Object.entries(s).sort((x,v)=>x[1].x+x[1].w/2-(v[1].x+v[1].w/2))){const x=a[a.length-1];x&&p.x+p.w/2<x.right?(x.ids.push(h),x.left=Math.min(x.left,p.x),x.right=Math.max(x.right,p.x+p.w)):a.push({left:p.x,right:p.x+p.w,ids:[h]})}const l=Math.ceil(i/dp),u=Math.ceil(a.length/l);let c=0,d=0;const f=[];for(let h=0;h*u<a.length;h++){const p=a.slice(h*u,(h+1)*u),x=p.flatMap(y=>y.ids),v=p[0].left,w=Math.min(...x.map(y=>s[y].y));f.push(c);for(const y of x)s[y]={...s[y],x:s[y].x-v,y:s[y].y-w+c};c=Math.max(...x.map(y=>s[y].y+s[y].h))+uc,d=Math.max(d,p[p.length-1].right-v)}return{areas:{},nodes:s,width:d,height:c-uc,flat:!0,rowTops:f}}const bi=176,fp=120,hp=34,R$=14;function O$(e,t){const n=new Map(e.map(s=>[s,0]));for(const s of t)n.set(s.to,(n.get(s.to)??0)+1);const r=new Set(e),o=[];for(;r.size;){const s=e.find(i=>r.has(i)&&!n.get(i))??e.find(i=>r.has(i));r.delete(s),o.push(s);for(const i of t)i.from===s&&r.has(i.to)&&n.set(i.to,n.get(i.to)-1)}return o}async function P$(e,t,n){const r=qn(e,t),o=new Map(e.nodes.map(C=>[C.id,lc(C.kind,n.has(C.id))])),s=new Map(e.nodes.map(C=>[C.id,C.branch??null])),i=O$(e.nodes.map(C=>C.id),r),a=i.filter(C=>!s.get(C));if(!a.length)return Y0(e,t,n);const l=C=>o.get(C).w,u=C=>o.get(C).h,c=new Map,d=new Map;let f=0;for(const C of a)c.set(C,f),d.set(C,0),f+=l(C)+bi;const h=C=>c.get(C)+l(C)/2,p=C=>c.get(C)+l(C),x=[...new Set([...e.nodes,...e.edges].flatMap(C=>C.branch?[C.branch]:[]))],v=new Map;for(const C of i){const B=s.get(C);B&&v.set(B,[...v.get(B)??[],C])}const w=[],y=new Map,g=new Set(v.keys()),b=(C,B)=>{const J=v.get(C),q=new Set(J),Z=r.filter(Y=>q.has(Y.to)&&!q.has(Y.from));if(!B&&Z.length&&!Z.some(Y=>d.has(Y.from)))return null;const T=Z.filter(Y=>d.has(Y.from)).map(Y=>Y.from).sort((Y,re)=>d.get(Y)-d.get(re)||h(Y)-h(re))[0]??null,H=T&&d.get(T)===0?a[a.indexOf(T)+1]:void 0,V=J[0],X=T?H?(h(T)+h(H))/2:h(T)+(l(T)/2+bi+l(V)/2)/2:l(V)/2,ee=[];let me=X-l(V)/2;for(const Y of J)ee.push(me),me+=l(Y)+bi;const de=r.filter(Y=>q.has(Y.from)&&!q.has(Y.to)&&d.has(Y.to)),ge=de.filter(Y=>h(Y.to)>=ee[0]).map(Y=>h(Y.to)),ve=de.filter(Y=>h(Y.to)<ee[0]).map(Y=>h(Y.to));return{name:C,ids:J,anchor:T,xs:ee,kind:ve.length?2:ge.length?0:1,reach:Math.max(0,...ge),span:[Math.min(T?h(T):ee[0],...ve)-30,Math.max(me-bi,...ge)+30],verticals:[...T?[{x:h(T),from:d.get(T)}]:[],...de.map(Y=>({x:h(Y.to),from:d.get(Y.to)}))],minLane:T?d.get(T)+1:1,root:T?d.get(T)===0?a.indexOf(T):y.get(s.get(T))??a.length:a.length}};for(;g.size;){const B=[...g].flatMap(T=>b(T,!1)??[]).sort((T,H)=>(T.anchor?h(T.anchor):1/0)-(H.anchor?h(H.anchor):1/0)||T.kind-H.kind||T.reach-H.reach||x.indexOf(T.name)-x.indexOf(H.name))[0]??b(x.find(T=>g.has(T))??[...g][0],!0);g.delete(B.name);const J=T=>!w.some(H=>H.lane===T&&H.span[0]<B.span[1]&&B.span[0]<H.span[1]),q=T=>B.verticals.every(H=>w.every(V=>!(V.lane>H.from&&V.lane<T)||V.boxes.every(X=>H.x<c.get(X)-12||H.x>p(X)+12)))&&w.every(H=>H.lane<=T||H.verticals.every(V=>V.from>=T||B.xs.every((X,ee)=>V.x<X-12||V.x>X+l(B.ids[ee])+12)));let Z=B.minLane;for(;Z<B.minLane+12&&!(J(Z)&&q(Z));)Z++;if(Z>=B.minLane+12)for(Z=B.minLane;!J(Z);Z++);B.ids.forEach((T,H)=>{c.set(T,B.xs[H]),d.set(T,Z)}),w.push({name:B.name,lane:Z,span:B.span,verticals:B.verticals,boxes:B.ids,root:B.root}),y.set(B.name,B.root)}const E=[...new Set([...d.values()])].sort((C,B)=>C-B),k=new Map,S=new Map;let $=0;for(const C of E){const B=Math.max(...[...d].filter(([,J])=>J===C).map(([J])=>u(J)));k.set(C,$),S.set(C,$+B),$+=B+fp}const _={};for(const C of e.nodes){const B=d.get(C.id);_[C.id]={x:c.get(C.id),y:k.get(B)+(S.get(B)-k.get(B)-u(C.id))/2,w:l(C.id),h:u(C.id)}}const j=new Map(e.nodes.map(C=>[C.id,C.kind])),M=(C,B,J)=>{const q=_[C],Z=j.get(C)==="choice"?Math.min(q.h/2,Math.abs(B-(q.x+q.w/2))*q.h/q.w):0;return J==="top"?q.y+Z:q.y+q.h-Z},z=C=>_[C].y+_[C].h/2,F=C=>d.get(C),N=C=>[...d].filter(([,B])=>B===C).map(([B])=>B).sort((B,J)=>c.get(B)-c.get(J)),P=new Map,L=new Map,D=(C,B,J,q)=>L.set(`${C}:${B}`,[...L.get(`${C}:${B}`)??[],{link:J,key:q}]);for(const C of r){const B=F(C.from),J=F(C.to);let q;if(B===J){const Z=N(B);q=Z.indexOf(C.to)===Z.indexOf(C.from)+1?"straight":B===0?"arc":"under"}else J>B?q="down":q=h(C.to)>p(C.from)+24?"rejoin":h(C.to)<c.get(C.from)-24?"return":"up";P.set(C.id,q),q==="arc"&&(D(C.from,"t",C.id,[h(C.to)]),D(C.to,"t",C.id,[h(C.from)])),(q==="rejoin"||q==="up")&&D(C.to,"b",C.id,[0,B]),q==="return"&&D(C.to,"b",C.id,[1,-B]),q==="down"&&D(C.from,"b",C.id,[2,-J])}const I=new Map;for(const[C,B]of L){const J=C.slice(0,C.lastIndexOf(":"));B.sort((q,Z)=>q.key.reduce((T,H,V)=>T||H-(Z.key[V]??0),0)),B.forEach((q,Z)=>I.set(`${q.link}:${C}`,h(J)+(Z-(B.length-1)/2)*R$))}const A=(C,B,J)=>I.get(`${C}:${B}:${J}`)??h(B),O=r.filter(C=>P.get(C.id)==="arc").sort((C,B)=>Math.abs(h(C.to)-h(C.from))-Math.abs(h(B.to)-h(B.from))),U=new Map(O.map((C,B)=>[C.id,B])),W=new Map,oe={};for(const C of r){const B=_[C.from],J=_[C.to],q=F(C.from),Z=P.get(C.id);let T;if(Z==="straight")T={points:[[B.x+B.w,z(C.from)],[J.x,z(C.to)]],label:0};else if(Z==="arc"){const H=-58-18*U.get(C.id),V=A(C.id,C.from,"t"),X=A(C.id,C.to,"t");T={points:[[V,M(C.from,V,"top")],[V,H],[X,H],[X,M(C.to,X,"top")]],label:1}}else if(Z==="under"||Z==="return"){const H=W.get(q)??0;W.set(q,H+1);const V=S.get(q)+hp+16*H,X=h(C.from)+(Z==="under"?6:0),ee=Z==="return"?A(C.id,C.to,"b"):h(C.to)-6;T={points:[[X,B.y+B.h],[X,V],[ee,V],[ee,M(C.to,ee,"bottom")]],label:1}}else if(Z==="down"){const H=A(C.id,C.from,"b"),V=h(C.to),X=k.get(F(C.to))-hp;T=Math.abs(V-H)<4?{points:[[H,M(C.from,H,"bottom")],[H,J.y]],label:0}:{points:[[H,M(C.from,H,"bottom")],[H,X],[V,X],[V,J.y]],label:1}}else if(Z==="rejoin"){const H=A(C.id,C.to,"b"),V=N(q).some(ee=>ee!==C.from&&c.get(ee)<H&&p(ee)>B.x+B.w),X=k.get(q)-fp/2;T=V?{points:[[h(C.from),B.y],[h(C.from),X],[H,X],[H,M(C.to,H,"bottom")]],label:1}:{points:[[B.x+B.w,z(C.from)],[H,z(C.from)],[H,M(C.to,H,"bottom")]],label:H-(B.x+B.w)>=150?0:1}}else{const H=Math.min(Math.max(A(C.id,C.to,"b"),B.x+12),B.x+B.w-12);T={points:[[H,B.y],[H,M(C.to,H,"bottom")]],label:0}}oe[C.id]=T}const se=x.map(C=>{var Z;const B=w.find(T=>T.name===C);if(B)return{name:C,root:B.root};const J=(Z=e.edges.find(T=>T.branch===C))==null?void 0:Z.from,q=J?s.get(J):null;return{name:C,root:J&&d.get(J)===0?a.indexOf(J):q?y.get(q)??a.length:a.length}}).sort((C,B)=>C.root-B.root||x.indexOf(C.name)-x.indexOf(B.name)).map(C=>C.name),ie=Object.values(_),G=Object.values(oe).flatMap(C=>C.points);return{areas:{},nodes:_,width:Math.max(...ie.map(C=>C.x+C.w),...G.map(C=>C[0])),height:Math.max(...ie.map(C=>C.y+C.h),...G.map(C=>C[1])),flat:!0,routes:oe,branches:se}}const pp=132,gp=40,mp=36;function Us(e,t){const n=new Map,r=new Set;for(const c of t)(n.get(c.from)??n.set(c.from,[]).get(c.from)).push(c.to),r.add(c.to);const o=new Map,s=[],i=c=>{o.set(c,"open");for(const d of n.get(c)??[])o.has(d)||i(d);o.set(c,"done"),s.push(c)};for(const c of[...e.filter(d=>!r.has(d)),...e])o.has(c)||i(c);const a=s.reverse(),l=new Map(a.map((c,d)=>[c,d])),u=new Map(e.map(c=>[c,0]));for(const c of a)for(const d of n.get(c)??[])(l.get(d)??0)>(l.get(c)??0)&&u.set(d,Math.max(u.get(d)??0,(u.get(c)??0)+1));return u}async function z$(e,t){const n=Us(e.nodes.map(c=>c.id),qn(e,t)),r=Math.max(0,...n.values())+1,o=2*Ee.side+r*Ze+(r-1)*pp,s=c=>Math.min(...e.nodes.filter(d=>d.area===c).map(d=>n.get(d.id)??0)),i=e.areas.filter(c=>e.nodes.some(d=>d.area===c.id)).sort((c,d)=>s(c.id)-s(d.id)),a={},l={};let u=0;for(const c of i){const d=new Map;let f=1;for(const p of e.nodes.filter(x=>x.area===c.id)){const x=n.get(p.id)??0,v=d.get(x)??0;d.set(x,v+1),f=Math.max(f,v+1),l[p.id]={x:Ee.side+x*(Ze+pp),y:Ee.top+v*(Ye+gp),w:Ze,h:Ye}}const h=Ee.top+f*Ye+(f-1)*gp+Ee.bottom;a[c.id]={x:0,y:u,w:o,h},u+=h+mp}return{areas:a,nodes:l,width:o,height:Math.max(0,u-mp),lanes:!0}}function D$(e){const t=e.nodes.map(p=>p.id),n=new Map;for(const p of e.edges)p.from!==p.to&&(n.get(p.from)??n.set(p.from,[]).get(p.from)).push(p.to);let r=0;const o=new Map,s=new Map,i=[],a=new Set,l=[],u=p=>{o.set(p,r),s.set(p,r),r++,i.push(p),a.add(p);for(const x of n.get(p)??[])o.has(x)?a.has(x)&&s.set(p,Math.min(s.get(p),o.get(x))):(u(x),s.set(p,Math.min(s.get(p),s.get(x))));if(s.get(p)===o.get(p)){const x=[];for(let v=i.pop();a.delete(v),x.push(v),v!==p;v=i.pop());l.push(x)}};for(const p of t)o.has(p)||u(p);const c=Us(t,e.edges.map(p=>({from:p.from,to:p.to}))),d=new Map(e.nodes.map(p=>[p.id,p.area])),f=new Set,h=[];for(const p of l){if(p.length<3||p.length>8)continue;const x=new Set(p),v=[...p].sort((g,b)=>(c.get(g)??0)-(c.get(b)??0)||t.indexOf(g)-t.indexOf(b)),w=[v[0]];for(let g=v[0];;){const b=v.find(E=>!w.includes(E)&&(n.get(g)??[]).includes(E));if(!b)break;w.push(b),g=b}for(const g of v)w.includes(g)||w.push(g);const y=[];for(const g of w)y[y.length-1]!==d.get(g)&&y.push(d.get(g));if(y.length>1&&y[0]===y[y.length-1]&&y.pop(),!(y.length>2||y.some(g=>f.has(g))||!x.size)){for(const g of y)f.add(g);h.push({order:w,areas:y})}}return h}const Qo=70;async function yp(e,t,n,r,o,s,i){const a=n.length?await jd(e,t,n,r.filter(h=>n.some(p=>p.id===h.from)&&n.some(p=>p.id===h.to))):null,l={},u=a?a.size.w-Ee.side:0,c=s==="right"?(a?u+gr:Ee.side)+Qo:Ee.side,d=s==="left"&&a?Ze+gr+Qo:0;if(a)for(const[h,p]of Object.entries(a.nodes))l[h]={...p,x:p.x+d};o.forEach((h,p)=>{const x=Qo*Math.sin(Math.PI*(p+.5)/o.length);l[h]={x:c+(s==="right"?-x:x),y:Ee.top+i+p*(Ye+on),w:Ze,h:Ye}});const f=Object.values(l);return{nodes:l,size:{w:Math.max(...f.map(h=>h.x+h.w))+Ee.side,h:Math.max(...f.map(h=>h.y+h.h),a?a.size.h-Ee.bottom:0)+Ee.bottom}}}async function F$(e,t,n){var p;const r=await rl(),o=qn(e,t),s=new Map(e.absences.map(x=>[`a:${x.id}`,x.claim.length>28?`${x.claim.slice(0,26)}…`:x.claim])),i=new Map([...e.edges.map(x=>[`e:${x.id}`,x.label]),...s]),a=e.areas.filter(x=>e.nodes.some(v=>v.area===x.id)),l=new Set(o.map(x=>x.to)),u=await r.layout({id:"root",layoutOptions:{...Cs,"elk.direction":n,"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeRouting":"ORTHOGONAL","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"64","elk.spacing.edgeNode":"20","elk.spacing.edgeEdge":"14","elk.layered.spacing.edgeNodeBetweenLayers":"20","elk.layered.spacing.edgeEdgeBetweenLayers":"14","elk.spacing.edgeLabel":"4","elk.spacing.componentComponent":"60","elk.json.edgeCoords":"ROOT","elk.json.shapeCoords":"ROOT"},children:a.map(x=>({id:`area:${x.id}`,layoutOptions:{"elk.padding":`[top=${Ee.top},left=${Ee.side},bottom=${Ee.bottom},right=${Ee.side}]`},children:e.nodes.filter(v=>v.area===x.id).map(v=>({id:v.id,width:Ze,height:Ye,...v.kind==="entry"&&!l.has(v.id)?{layoutOptions:{"elk.layered.layering.layerConstraint":"FIRST"}}:{}}))})),edges:o.map(x=>{const v=i.get(x.id);return{id:x.id,sources:[x.from],targets:[x.to],...v?{labels:[{id:`${x.id}:label`,text:v,width:ol(v),height:X0,layoutOptions:{"elk.edgeLabels.inline":"true"}}]}:{}}})}),c={},d={};for(const x of u.children??[]){const v=x.id.slice(5),w=x.x??0,y=x.y??0;c[v]={x:w,y,w:x.width??0,h:x.height??0};for(const g of x.children??[])d[g.id]={x:(g.x??0)-w,y:(g.y??0)-y,w:Ze,h:Ye}}const f={};for(const x of u.edges??[]){const v=[];for(const _ of x.sections??[])for(const j of[_.startPoint,..._.bendPoints??[],_.endPoint]){const M=v[v.length-1];if(!(M&&Math.abs(M[0]-j.x)<.5&&Math.abs(M[1]-j.y)<.5)){if(M&&Math.abs(M[0]-j.x)>.5&&Math.abs(M[1]-j.y)>.5){const z=v[v.length-2],F=z?Math.abs(z[0]-M[0])<.5:!0;v.push(F?[M[0],j.y]:[j.x,M[1]])}v.push([j.x,j.y])}}if(v.length<2)continue;for(let _=1;_<v.length;_++){const[j,M]=[v[_-1],v[_]];Math.abs(j[0]-M[0])<1&&(M[0]=j[0]),Math.abs(j[1]-M[1])<1&&(M[1]=j[1])}const w=o.find(_=>_.id===x.id),y=_=>{const j=e.nodes.find(F=>F.id===_),M=j&&c[j.area],z=d[_];return M&&z?{x:M.x+z.x,y:M.y+z.y,w:z.w,h:z.h}:null},g=(_,j,M)=>{const z=Math.min(Math.max(j[1],M.y+10),M.y+M.h-10),F=Math.min(Math.max(j[0],M.x+12),M.x+M.w-12);return j[0]<=M.x?j[1]===z?[[M.x,z]]:[[j[0],z],[M.x,z]]:j[0]>=M.x+M.w?j[1]===z?[[M.x+M.w,z]]:[[j[0],z],[M.x+M.w,z]]:j[1]<=M.y?j[0]===F?[[F,M.y]]:[[F,j[1]],[F,M.y]]:j[1]>=M.y+M.h?j[0]===F?[[F,M.y+M.h]]:[[F,j[1]],[F,M.y+M.h]]:[_]},b=w&&y(w.from),E=w&&y(w.to);if(E&&v.length>=2){const _=g(v[v.length-1],v[v.length-2],E);v.splice(v.length-1,1,..._)}if(b&&v.length>=2){const _=g(v[0],v[1],b).reverse();v.splice(0,1,..._)}for(let _=1;_+2<v.length;_++){const j=v[_-1],M=v[_],z=v[_+1],F=v[_+2],N=Math.abs(M[0]-z[0])<.5?1:0,P=N===1?0:1;if(Math.abs(M[P]-z[P])>.5||Math.abs(M[N]-z[N])>=10||Math.abs(j[N]-M[N])>.5||Math.abs(z[N]-F[N])>.5)continue;const L=z[N];for(let D=_+1;D<v.length&&Math.abs(v[D][N]-L)<=.5;D++)v[D][N]=M[N];v.splice(_+1,1)}const k=(p=x.labels)==null?void 0:p[0],S=k&&k.x!==void 0&&k.y!==void 0?[k.x+(k.width??0)/2,k.y+(k.height??0)/2]:void 0;let $=0;if(S){let _=1/0;for(let j=1;j<v.length;j++){const[M,z]=v[j-1],[F,N]=v[j],P=Math.hypot(Math.max(Math.min(M,F)-S[0],0,S[0]-Math.max(M,F)),Math.max(Math.min(z,N)-S[1],0,S[1]-Math.max(z,N)));P<_&&([_,$]=[P,j-1])}}f[x.id]={points:v,label:$,...S?{at:S}:{}}}const h=Object.values(c);return{areas:c,nodes:d,routes:f,width:Math.max(0,...h.map(x=>x.x+x.w)),height:Math.max(0,...h.map(x=>x.y+x.h))}}async function wp(e,t){const n=new Map(e.absences.map(a=>[`a:${a.id}`,a.claim.length>28?`${a.claim.slice(0,26)}…`:a.claim])),r=qn(e,t).map(a=>{var l;return{...a,label:((l=e.edges.find(u=>`e:${u.id}`===a.id))==null?void 0:l.label)??n.get(a.id)}}),o=[["columns",await B$(e,t)]];for(const[a,l]of[["routed-down","DOWN"],["routed-right","RIGHT"]])try{o.push([a,await F$(e,t,l)])}catch{}const s={};let i=o[0];for(const a of o)s[a[0]]=_$(e,a[1],r),s[a[0]].score<s[i[0]].score&&(i=a);return{...i[1],chosen:{name:i[0],scores:s}}}async function B$(e,t){var E;const n=await rl(),r=new Map(e.nodes.map(k=>[k.id,k.area])),o=qn(e,t),s=D$(e),i=Us(e.nodes.map(k=>k.id),e.edges.map(k=>({from:k.from,to:k.to}))),a=new Set(e.nodes.map(k=>k.area)),l=()=>{const k=new Map;for(const S of o){const $=r.get(S.from),_=r.get(S.to);$!==_&&k.set(`${$}>${_}`,{from:$,to:_})}return[...k.values()]},u=new Map;if(s.some(k=>k.areas.length===2)){const k=await n.layout({id:"root",layoutOptions:{...Cs,"elk.direction":"RIGHT"},children:e.areas.filter(S=>a.has(S.id)).map(S=>({id:S.id,width:100,height:100})),edges:l().map((S,$)=>({id:`q${$}`,sources:[S.from],targets:[S.to]}))});for(const S of k.children??[])u.set(S.id,S.x??0)}const c=new Map,d=new Map,f=new Map;for(const k of s)if(k.areas.length===2){const[S,$]=k.areas,_=A=>Math.min(...e.nodes.filter(O=>O.area===A).map(O=>i.get(O.id)??0)),[j,M]=_($)<_(S)?[$,S]:[S,$];(u.get(j)??0)<(u.get(M)??0)||c.set(j,M);const z=k.order.length,F=k.order.findIndex((A,O)=>r.get(A)===j&&r.get(k.order[(O-1+z)%z])===M),N=[...k.order.slice(F),...k.order.slice(0,F)],P=N.filter(A=>r.get(A)===j).reverse(),L=N.filter(A=>r.get(A)===M),D=Math.max(P.length,L.length),I=A=>(D-A)*(Ye+on)/2;d.set(j,[{column:P,side:"right",drop:I(P.length)}]),d.set(M,[{column:L,side:"left",drop:I(L.length)}]),f.set(j,M)}else{const S=Math.ceil(k.order.length/2),$=k.order.slice(0,S).reverse(),_=k.order.slice(S),j=Math.max($.length,_.length),M=z=>(j-z)*(Ye+on)/2;d.set(k.areas[0],[{column:$,side:"right",drop:M($.length)},{column:_,side:"left",drop:M(_.length)}])}const h={},p={};for(const k of e.areas){const S=e.nodes.filter(M=>M.area===k.id);if(!S.length)continue;const $=o.filter(M=>r.get(M.from)===k.id&&r.get(M.to)===k.id),_=d.get(k.id);if((_==null?void 0:_.length)===1){const M=_[0],z=await yp(n,k.id,S.filter(F=>!M.column.includes(F.id)),$,M.column,M.side,M.drop);Object.assign(h,z.nodes),p[k.id]=z.size;continue}if((_==null?void 0:_.length)===2){const[M,z]=_,F=new Set([...M.column,...z.column]),N=await yp(n,k.id,S.filter(D=>!F.has(D.id)),$,M.column,"right",M.drop),P=Math.max(...M.column.map(D=>N.nodes[D].x))+Ze+gr+Qo;z.column.forEach((D,I)=>{const A=Qo*Math.sin(Math.PI*(I+.5)/z.column.length);N.nodes[D]={x:P+A,y:Ee.top+z.drop+I*(Ye+on),w:Ze,h:Ye}}),Object.assign(h,N.nodes);const L=Object.values(N.nodes);p[k.id]={w:Math.max(...L.map(D=>D.x+D.w))+Ee.side,h:Math.max(N.size.h,...L.map(D=>D.y+D.h+Ee.bottom))};continue}const j=await jd(n,k.id,S,$);Object.assign(h,j.nodes),p[k.id]=j.size}const x=new Map,v=new Map(e.edges.map(k=>[`${k.from}>${k.to}`,k.label]));for(const k of o){const S=r.get(k.from),$=r.get(k.to);if(S===$||!p[S]||!p[$]||c.get($)===S)continue;const _=`${S}>${$}`,j=ol(v.get(`${k.from}>${k.to}`)??"");x.set(_,{from:S,to:$,label:Math.max(((E=x.get(_))==null?void 0:E.label)??0,j)})}const w=await n.layout({id:"root",layoutOptions:{...Cs,"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.nodeNode":"48","elk.spacing.componentComponent":"64"},children:e.areas.filter(k=>p[k.id]).map(k=>({id:k.id,width:p[k.id].w,height:p[k.id].h})),edges:[...x.values()].map((k,S)=>{const $=U$(k.label);return{id:`p${S}`,sources:[k.from],targets:[k.to],...$?{labels:[{id:`p${S}l`,text:" ",width:$,height:X0}]}:{}}})}),y={};for(const k of w.children??[])y[k.id]={x:k.x??0,y:k.y??0,w:k.width??0,h:k.height??0};for(const[k,S]of f){const $=y[k],_=y[S];if(!$||!_)continue;const j=$.y-_.y,M={..._,y:_.y+j};Object.entries(y).some(([F,N])=>F!==S&&F!==k&&M.x<N.x+N.w&&N.x<M.x+M.w&&M.y<N.y+N.h&&N.y<M.y+M.h)||(y[S]=M)}const g=Object.values(y),b=Math.min(0,...g.map(k=>k.y));if(b<0)for(const k of g)k.y-=b;return{areas:y,nodes:h,width:Math.max(w.width??0,...g.map(k=>k.x+k.w)),height:Math.max(w.height??0,...g.map(k=>k.y+k.h)),...s.length?{rings:s.map(k=>k.order)}:{}}}const X0=24,ol=e=>e?Math.ceil(e.length*6.8+16):0,H$=40;function U$(e){return Math.max(0,e+2*H$-2*120)}function sl(e){const t=Us(e.nodes.map(n=>n.id),e.edges.map(n=>({from:n.from,to:n.to})));return new Set(e.edges.filter(n=>n.from!==n.to&&(t.get(n.to)??0)<=(t.get(n.from)??0)).map(n=>n.id))}function q0(e,t){const n=e.edges.find(d=>d.id===t);if(!n||!sl(e).has(t))return null;const r=e.edges.filter(d=>d.id!==t),o=(d,f)=>{const h=new Set([d]);for(let p=!0;p;){p=!1;for(const x of r){const[v,w]=f(x);h.has(v)&&!h.has(w)&&(h.add(w),p=!0)}}return h},s=o(n.to,d=>[d.from,d.to]),i=o(n.from,d=>[d.to,d.from]),a=new Set([...s].filter(d=>i.has(d))),l=Us(e.nodes.map(d=>d.id),e.edges.map(d=>({from:d.from,to:d.to}))),u=e.nodes.map(d=>d.id).filter(d=>a.has(d)).sort((d,f)=>(l.get(d)??0)-(l.get(f)??0)),c=[...r.filter(d=>a.has(d.from)&&a.has(d.to)).map(d=>d.id),t];return{nodes:u,edges:c}}function W$(e,t,n,r){var f;if(t.flat){const h=w=>{const y=t.nodes[w];return y?{x:y.x+y.w/2,y:y.y+y.h/2}:{x:0,y:0}},p=h(r).x-h(n).x,x=h(r).y-h(n).y;if(Math.abs(p)<40)return x>=0?["b","t"]:["t","b"];const v=_a(t,r)-_a(t,n);return v?v>0?["b","t"]:["r","b"]:p>=0?["r","l"]:["l","r"]}const o=h=>{var p;return((p=e.nodes.find(x=>x.id===h))==null?void 0:p.area)??""},s=h=>{const p=t.areas[o(h)],x=t.nodes[h];return p&&x?{x:p.x+x.x+x.w/2,y:p.y+x.y+x.h/2}:{x:0,y:0}},i=s(n),a=s(r),l=a.x-i.x,u=a.y-i.y,c=(f=t.rings)==null?void 0:f.find(h=>h.includes(n)),d=!!c&&c.includes(r)&&Math.abs(l)>=Ze*.75;return!t.lanes&&!d&&o(n)===o(r)||Math.abs(l)<Ze*.75?u>=0?["b","t"]:["t","b"]:l>=0?["r","l"]:["l","r"]}function V$(e,t=[],n=[],r=[]){return JSON.stringify([e.view??null,e.view==="journey"?[e.nodes.map(o=>o.kind),[...r].sort()]:null,[...e.nodes,...e.edges].map(o=>o.branch??""),[...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 Lr=()=>({nodes:[],edges:[],absences:[]}),Do=e=>e.nodes.length+e.edges.length+e.absences.length,G$=e=>({mapId:e,phase:"loading",meta:null,map:null,report:null,job:null,error:null,answers:[],shown:null,selection:Lr(),tour:null,peek:!1,views:[],viewIndex:-1,fixes:{},fresh:[],hidden:[],connected:!1,agent:L0}),Y$=e=>e.views[e.viewIndex]??null;function Ws(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 X$=e=>Ws(e).flatMap(t=>t.ids);function K0(e){if(!e.map)return null;const t=new Set(Ws(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 q$(e,t){if(!t)return e;const n=(r,o)=>r.filter(s=>o.some(i=>i.id===s));return{nodes:n(e.nodes,t.nodes),edges:n(e.edges,t.edges),absences:n(e.absences,t.absences)}}function K$(e,t){var i,a,l;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],s=(n.focus.edges??[]).length||(n.focus.absences??[]).length?[]:Z0(e,new Set(o));return{focus:((i=n.focus.nodes)==null?void 0:i[0])??((a=n.focus.edges)==null?void 0:a[0])??((l=n.focus.absences)==null?void 0:l[0])??null,highlight:[...new Set([...o,...s])]}}function Z0(e,t){return e.edges.filter(n=>t.has(n.from)&&t.has(n.to)).map(n=>n.id)}function xp(e,t){const n=[...t.moves.highlight,...t.added],r=e?[...new Set([...n,...Z0(e,new Set(n))])]:n;return r.length||t.moves.focus?{focus:t.moves.focus??r[0]??null,highlight:r}:null}function nr(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 vp(e,t,n){const r={...t};for(const o of e){if(!o.fix||r[o.fix.id]&&!n)continue;const s=n?n[o.fix.id]:{status:"proposed"};r[o.fix.id]={proposal:o.fix,answerId:o.id,status:(s==null?void 0:s.status)??"rejected",problems:[],edgeId:(s==null?void 0:s.edgeId)??null,closed:(s==null?void 0:s.closed)??[],undoable:(s==null?void 0:s.undoable)??!0}}return r}function Z$(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:vp(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=i=>i.filter(a=>r.map.nodes.some(l=>l.id===a)||r.map.edges.some(l=>l.id===a)||r.map.absences.some(l=>l.id===a)),s={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:s}}if(r.type==="answer"){const o=[...e.answers,r.answer],s={...e,answers:o,shown:r.answer.id,tour:null,peek:!1,fresh:r.answer.added,fixes:vp([r.answer],e.fixes,void 0)};return nr(s,xp(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 s=r.status,i={...e.fixes,[r.fixId]:{...o,status:s,problems:r.problems??[],edgeId:r.edgeId??o.edgeId,closed:r.closed??o.closed,undoable:r.status==="applied"?!0:o.undoable}},a={...e,fixes:i};if(r.status==="applied"&&r.edgeId){const l=o.proposal.connects;return nr(a,{focus:r.edgeId,highlight:[r.edgeId,...l?[l.from,l.to]:[]]})}return a}return e}case"select":{const r=e.selection[t.kind],o=r.includes(t.id),s=t.additive?{...e.selection,[t.kind]:o?r.filter(i=>i!==t.id):[...r,t.id]}:{...Lr(),[t.kind]:o&&Do(e.selection)===1?[]:[t.id]};return{...e,selection:s}}case"selectMany":return{...e,selection:t.selection};case"clearSelection":return{...e,selection:Lr()};case"tour":{if(!e.map)return{...e,tour:null,peek:!1};if(t.stop===null)return e.tour===null?e:nr({...e,tour:null,peek:!1},{focus:null,highlight:[]});const r=Math.max(0,Math.min(t.stop,e.map.tour.length-1));return nr({...e,tour:r,selection:Lr()},K$(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?nr({...e,tour:null,peek:!1,selection:{...Lr(),[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 nr({...e,shown:t.answerId,tour:null,peek:!1},r?xp(e.map,r):null)}case"overview":return nr({...e,shown:null,tour:null,peek:!1,selection:Lr(),fresh:[]},{focus:null,highlight:[]});case"layer":case"allLayers":{const r=t.type==="layer"?[t.answerId]:Ws(e).map(i=>i.answerId),o=t.visible?e.hidden.filter(i=>!r.includes(i)):[...new Set([...e.hidden,...r])],s={...e,hidden:o};return{...s,selection:q$(e.selection,K0(s))}}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 mr=(...e)=>e.filter(Boolean).join(" ");function dt(e,t){const n=e.nodes.find(i=>i.id===t);if(n)return n.name;const r=e.edges.find(i=>i.id===t);if(r)return`${dt(e,r.from)} → ${dt(e,r.to)}`;const o=e.absences.find(i=>i.id===t);if(o)return o.claim;const s=e.areas.find(i=>i.id===t);return(s==null?void 0:s.label)??t}const Q$={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."}},J$={added:"New since",changed:"Changed since",removed:"Removed since"};function cc(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 mt({eyebrow:e,title:t,children:n,tone:r,className:o}){return m.jsxs("section",{className:mr("card",r&&`card-${r}`,o),children:[e&&m.jsx("div",{className:"eyebrow",children:e}),t&&m.jsx("h2",{className:"card-title",children:t}),n]})}function eC({map:e,ids:t,onPick:n}){return t.length?m.jsx("div",{className:"chips",children:t.map(({id:r,status:o})=>m.jsxs("button",{className:mr("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:[m.jsx("span",{className:o==="confirmed"?"tick":o==="proposed"?"pmark":"qmark",children:o==="confirmed"?"✓":o==="proposed"?"+":"?"}),dt(e,r)]},r))}):null}function kp({lines:e,working:t}){const n=e.slice(-8);return m.jsxs("ul",{className:"progress",children:[n.map((r,o)=>m.jsxs("li",{className:mr(t&&o===n.length-1&&"running"),children:[m.jsx("span",{className:"ic",children:t&&o===n.length-1?"…":"✓"}),r]},`${o}-${r}`)),!n.length&&t&&m.jsxs("li",{className:"running",children:[m.jsx("span",{className:"ic",children:"…"}),"Starting"]})]})}function tC({fix:e,onApprove:t,onReject:n,onUndo:r,map:o}){const s=e.proposal,i=s.files.filter(a=>a.uncommitted);return e.status==="applied"?m.jsxs(mt,{eyebrow:"Fix applied · re-checked",tone:"ok",children:[m.jsxs("ul",{className:"progress",children:[m.jsxs("li",{children:[m.jsx("span",{className:"ic",children:"✓"}),"Changed ",s.files.length," ",s.files.length===1?"file":"files",": ",s.files.map(a=>a.file).join(", ")]}),e.edgeId&&m.jsxs("li",{children:[m.jsx("span",{className:"ic",children:"✓"}),"New confirmed connection: ",dt(o,e.edgeId)]}),e.closed.length>0&&m.jsxs("li",{children:[m.jsx("span",{className:"ic",children:"✓"}),"Closed: ",e.closed.length===1?"the missing connection":`${e.closed.length} missing connections`]})]}),e.undoable?m.jsx("div",{className:"btns",children:m.jsx("button",{className:"btn",onClick:r,children:"Undo this fix"})}):m.jsx("p",{className:"muted small",children:"Undo ended when illuminate stopped. Use git to reverse it."})]}):e.status==="rejected"||e.status==="undone"?m.jsxs(mt,{eyebrow:e.status==="undone"?"Fix undone":"Fix rejected",children:[m.jsx($s,{text:s.summary,className:"muted"}),e.status==="undone"&&m.jsx("div",{className:"btns",children:m.jsx("button",{className:"btn",onClick:t,children:"Apply it again"})})]}):m.jsxs(mt,{eyebrow:`Proposed fix · ${s.files.length} ${s.files.length===1?"file":"files"} · nothing changed yet`,tone:"ai",children:[m.jsx($s,{text:s.summary}),s.connects&&m.jsx("p",{className:"muted small",children:"The green dashed arrow is the connection it adds."}),m.jsx("pre",{className:"diff",children:s.diff.split(`
|
|
79
79
|
`).map((a,l)=>m.jsxs("span",{className:a.startsWith("+ ")?"add":a.startsWith("- ")?"del":a.includes(" · ")?"file":"",children:[a,`
|
|
80
80
|
`]},l))}),i.length>0?m.jsxs("p",{className:"warn small",children:["⚠ ",i.map(a=>a.file).join(", ")," ",i.length===1?"has":"have"," uncommitted changes. They'll be kept; the fix applies on top."]}):null,e.problems.length>0&&m.jsx("ul",{className:"problems",children:e.problems.map(a=>m.jsx("li",{children:a},a))}),m.jsxs("div",{className:"btns",children:[m.jsx("button",{className:"btn primary",disabled:e.status==="applying",onClick:t,children:e.status==="applying"?"Applying…":"Approve"}),m.jsx("button",{className:"btn",onClick:n,children:"Reject"})]}),m.jsx("p",{className:"muted small",children:"Won't apply if these files change first."})]})}function nC({state:e,dispatch:t,onFix:n,onFocus:r,onOffer:o,composer:s}){const i=e.map,a=e.job,l=R.useRef(null),u=R.useRef(!0),[c,d]=R.useState(!1),f=()=>{var w;const v=(w=l.current)==null?void 0:w.querySelectorAll(":scope > .turn");return v!=null&&v.length?v[v.length-1]:null},h=(v=!1)=>{const w=l.current,y=f();!w||!y||w.scrollTo({top:p$(w.scrollTop,w.getBoundingClientRect().top,y.getBoundingClientRect().top),behavior:v?"smooth":"auto"})};if(R.useEffect(()=>{const v=l.current;if(!v)return;u.current=!0,d(!1),h();const w=new ResizeObserver(()=>{u.current&&h()});for(const y of Array.from(v.children))w.observe(y);return()=>w.disconnect()},[e.answers.length,!!a,!!i]),R.useEffect(()=>{const v=l.current;if(!v)return;const w=()=>{u.current=!1},y=b=>{b.target===v&&w()},g=()=>{const b=f();d(!!b&&g$(v.getBoundingClientRect().bottom,b.getBoundingClientRect().top))};return v.addEventListener("wheel",w,{passive:!0}),v.addEventListener("touchmove",w,{passive:!0}),v.addEventListener("keydown",w),v.addEventListener("pointerdown",y),v.addEventListener("scroll",g,{passive:!0}),()=>{v.removeEventListener("wheel",w),v.removeEventListener("touchmove",w),v.removeEventListener("keydown",w),v.removeEventListener("pointerdown",y),v.removeEventListener("scroll",g)}},[!!i]),e.phase==="loading")return m.jsx("aside",{className:"panel",children:m.jsx("div",{className:"panel-scroll",children:m.jsx(mt,{children:m.jsx("p",{className:"muted",children:"Loading…"})})})});if(e.phase==="missing")return m.jsx("aside",{className:"panel",children:m.jsx("div",{className:"panel-scroll",children:m.jsx(mt,{title:"No map here",children:m.jsx("p",{className:"muted",children:"This map isn't in this repo."})})})});if(!i)return m.jsx("aside",{className:"panel",children:m.jsxs("div",{className:"panel-scroll",children:[a&&m.jsx(mt,{eyebrow:"Making your map",title:a.question,tone:"ai",children:m.jsx(kp,{lines:a.progress,working:!0})}),e.phase==="failed"&&m.jsx(mt,{title:"The map couldn't be made",tone:"dead",children:m.jsx("p",{children:e.error})})]})});[...e.selection.nodes,...e.selection.edges,...e.selection.absences];const p=Ws(e),x=p.length>0&&p.every(v=>!v.visible);return m.jsxs("aside",{className:"panel","aria-label":"Conversation about this map",children:[m.jsxs("header",{className:"panel-head",children:[m.jsx("h2",{className:"panel-title",children:"Conversation"}),p.length>0&&m.jsx("button",{className:"link-btn small",onClick:()=>t({type:"allLayers",visible:x}),children:x?"Show everything":"Show the original map"}),m.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:"×"})]}),m.jsxs("div",{className:"panel-scroll",ref:l,children:[e.error&&m.jsxs("div",{className:"banner banner-dead",role:"alert",children:[e.error,m.jsx("button",{className:"link-btn",onClick:()=>t({type:"error",message:null}),children:"Dismiss"})]}),e.answers.map(v=>m.jsx(oC,{answer:v,state:e,dispatch:t,onFix:n,onFocus:r,onOffer:o},v.id)),(a==null?void 0:a.kind)==="ask"&&m.jsxs("article",{className:"turn",children:[m.jsx(Q0,{question:a.question}),m.jsx(mt,{eyebrow:`${e.agent.name} is working`,tone:"ai",children:m.jsx(kp,{lines:a.progress,working:!0})})]}),!e.answers.length&&!a&&m.jsx("p",{className:"muted small thread-empty",children:"Ask anything about this map. Click a box or arrow first to ask about it."})]}),m.jsxs("footer",{className:"panel-foot",children:[c&&m.jsx("button",{className:"to-latest",onClick:()=>{u.current=!0,h(!0)},children:"↓ Latest"}),s]})]})}function rC({map:e,edgeId:t}){const n=q0(e,t);if(!n)return null;const r=n.nodes.map(o=>dt(e,o));return m.jsxs("p",{className:"loop-note small",children:[m.jsx("strong",{children:"A loop."})," It goes back to ",r[0],", so this runs round again: ",r.join(" → ")," → ",r[0],"."]})}function Q0({question:e,about:t}){const{question:n,step:r}=h$(e),o=[r&&`the step “${r}”`,t].filter(Boolean);return m.jsxs("div",{className:"you",children:[m.jsx("p",{className:"you-q",children:n}),o.length>0&&m.jsxs("span",{className:"you-about",children:["About ",o.join(", ")]})]})}function oC({answer:e,state:t,dispatch:n,onFix:r,onFocus:o,onOffer:s}){const i=t.map,a=e.fix?t.fixes[e.fix.id]??null:null,l=e.id===t.shown&&t.tour===null,u=[...e.selection.nodes??[],...e.selection.edges??[],...e.selection.absences??[]].map(x=>dt(i,x)).join(", "),c=Ws(t).find(x=>x.answerId===e.id),d=e.problems.filter(x=>x.startsWith("The proposed fix")),f=e.problems.filter(x=>!x.startsWith("The proposed fix")),h=e.refs.filter(x=>{var v;return x.status!=="unknown"&&((v=cc(t.report,x.id))==null?void 0:v.status)==="unconfirmed"}).map(x=>x.id),p=e.moves.highlight.length>0||!!e.moves.focus||e.added.length>0||(e.screens??[]).length>0;return m.jsxs("article",{className:"turn",children:[m.jsx(Q0,{question:e.question,about:u||void 0}),e.offer?m.jsx(sC,{answer:e,busy:!!t.job,agentName:t.agent.name,onOffer:s}):m.jsxs("section",{className:mr("card","reply",l&&"card-focus"),children:[m.jsxs("div",{className:"reply-meta",children:[m.jsx("span",{children:e.source==="map"?"From the map":"Looked in the code"}),p&&(l?m.jsx("span",{className:"reply-lit",children:"Lit on the map"}):m.jsx("button",{className:"link-btn small",onClick:()=>n({type:"show",answerId:e.id}),children:"Show on the map"}))]}),m.jsx($s,{text:e.concept,className:"depth-text"}),(e.notes??[]).length>0&&m.jsx(t$,{mapId:t.mapId,answerId:e.id,stamp:t.report}),(e.screens??[]).map(x=>{const v=ac(t.report,x);return v?m.jsx(F0,{show:v,name:dt(i,x)},x):null}),h.length>0&&m.jsxs("p",{className:"warn small reply-warn",children:["Relies on ",h.length===1?"1 thing":`${h.length} things`," the checker couldn't confirm:"," ",h.map((x,v)=>m.jsxs("span",{children:[v>0&&", ",m.jsx("button",{className:"link-btn small",title:"Show it on the map",onClick:()=>o(x),children:dt(i,x)})]},x))]}),c&&m.jsxs("div",{className:"reply-added",children:[m.jsxs("span",{children:["Added ",c.ids.length," to the map"]}),m.jsx("button",{className:"link-btn small",onClick:()=>n({type:"layer",answerId:e.id,visible:!c.visible}),children:c.visible?"Hide":"Show"})]}),f.length>0&&m.jsxs("details",{className:"problems-box",children:[m.jsxs("summary",{children:[f.length," thing",f.length===1?"":"s"," Claude found but couldn't confirm or show"]}),m.jsx("ul",{className:"problems",children:f.map(x=>m.jsx("li",{children:x},x))})]})]}),a&&m.jsx(tC,{fix:a,map:i,onApprove:()=>r(a.proposal.id,"approve"),onReject:()=>r(a.proposal.id,"reject"),onUndo:()=>r(a.proposal.id,"undo")}),d.length>0&&m.jsxs(mt,{eyebrow:"The proposed fix can't be applied",tone:"dead",children:[m.jsx("ul",{className:"problems",children:d.map(x=>m.jsx("li",{children:x.replace("The proposed fix can't be applied: ","")},x))}),m.jsx("p",{className:"muted small",children:"Ask again, or ask for a smaller change."})]})]})}function sC({answer:e,busy:t,agentName:n,onOffer:r}){const o=e.offer;return o.status==="mapped"?m.jsxs(mt,{eyebrow:"A different part of the app",children:[m.jsx("p",{className:"muted",children:"You made a new map for this."}),o.mapId&&m.jsx("div",{className:"btns",children:m.jsx("a",{className:"btn primary",href:sn(o.mapId),children:"Open it"})})]}):o.status==="answered"?m.jsx(mt,{eyebrow:"A different part of the app",children:m.jsx("p",{className:"muted",children:"Answered in words, below."})}):m.jsxs(mt,{eyebrow:"A different part of the app",tone:"ai",children:[m.jsx("p",{children:"This is about a different part of the app than this map shows."}),o.existing&&m.jsxs("p",{children:["There's already a map for it: “",o.existing.question,"”."]}),m.jsxs("div",{className:"btns",children:[o.existing&&m.jsx("a",{className:"btn primary",href:sn(o.existing.id),children:"Open that map"}),m.jsx("button",{className:o.existing?"btn":"btn primary",onClick:()=>r(e.id,"map"),children:"Make a new map for this"}),m.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 _,j,M,z,F;const[s,i]=n$(),[a,l]=r$(),[u,c]=R.useState(null),d=m.jsx("button",{className:"card-close","aria-label":"Close",title:"Close (Esc)",onClick:o,children:"×"});if(r.length>1)return m.jsxs(mt,{eyebrow:`Asking about ${r.length} things`,className:"card-selected",children:[d,m.jsx(eC,{map:t,ids:r.map(N=>{var P;return{id:N,status:((P=cc(n,N))==null?void 0:P.status)??"unknown"}}),onPick:()=>{}})]});const f=r[0],h=t.nodes.find(N=>N.id===f),p=t.edges.find(N=>N.id===f),x=t.absences.find(N=>N.id===f),v=cc(n,f),w=(h==null?void 0:h.evidence)??(p==null?void 0:p.evidence)??[],y=v&&"evidence"in v&&v.evidence?v.evidence:[],g=h?"Step":p?"Connection":"Missing connection",b=(v==null?void 0:v.proposal)??null,E=(j=(_=h??p)==null?void 0:_.proposed)==null?void 0:j.note,k=v&&"change"in v?v.change??null:null,S=((z=(M=n==null?void 0:n.since)==null?void 0:M.commit)==null?void 0:z.slice(0,7))??"the commit this map is compared with",$=x?(n==null?void 0:n.absences[x.id])??null:null;return m.jsxs(mt,{eyebrow:g,title:dt(t,f),tone:x?"dead":void 0,className:"card-selected",children:[d,((F=h==null?void 0:h.explain)==null?void 0:F.concept)&&m.jsx($s,{text:h.explain.concept,className:"depth-text"}),p&&m.jsx(rC,{map:t,edgeId:p.id}),h&&ac(n,h.id)&&m.jsx(F0,{show:ac(n,h.id),name:h.name}),b&&m.jsxs("div",{className:mr("proposal-note",`proposal-note-${b.state}`),children:[m.jsx("strong",{children:Q$[b.kind][b.state]}),E&&m.jsxs(m.Fragment,{children:[" ",E]})]}),k&&m.jsxs("div",{className:mr("change-note",`change-note-${k.kind}`),children:[m.jsxs("div",{className:"change-head",children:[m.jsxs("span",{children:[m.jsxs("strong",{children:[J$[k.kind]," ",S,"."]}),k.kind==="changed"&&!k.diff&&" A line it cites wasn’t there then.",k.kind==="removed"&&" It was in the code then and is gone now.",k.diff&&m.jsx(aC,{diff:k.diff})]}),k.diff&&m.jsx("button",{className:"link-btn small",onClick:()=>l(!a),children:a?"Hide what changed":"Show what changed"})]}),k.diff&&a&&m.jsx("pre",{className:"diff",children:k.diff.map((N,P)=>m.jsxs("span",{className:N.startsWith("+ ")?"add":N.startsWith("- ")?"del":"",children:[N,`
|
|
81
81
|
`]},P))})]}),x&&$&&m.jsxs("p",{children:[$.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 ",$.searched??"?"," ",$.searched===1?"file":"files",x.search.paths?m.jsxs(m.Fragment,{children:[" in ",m.jsx("code",{children:x.search.paths.join(", ")})]}):" (the whole repo)"," for ",m.jsx("code",{children:x.search.pattern}),": ",$.found," ",$.found===1?"match":"matches","."]}),v&&v.status==="unconfirmed"&&m.jsxs("div",{className:"warn small",children:["Couldn't confirm against the code: ",v.reasons.join("; ")]}),w.length>0&&m.jsxs("div",{className:"basis",children:[m.jsx("div",{className:"eyebrow",children:(k==null?void 0:k.kind)==="removed"?`In the code as it was at ${S}`:"In the code"}),m.jsx("div",{className:"chips",children:w.map((N,P)=>{var O,U;const L=((O=y[P])==null?void 0:O.ok)??!1,D=((U=y[P])==null?void 0:U.foundAt)??N.line,I=`${N.file}:${D}`,A=s&&((u==null?void 0:u.at)===I||!u&&w.length===1);return L?m.jsxs("button",{className:mr("chip cite",A&&"chip-open"),"aria-pressed":A,title:A?"Hide the code":"Show the code at this line",onClick:()=>{if(A){i(!1),c(null);return}i(!0),c(W=>({at:I,n:((W==null?void 0:W.n)??0)+1}))},children:[m.jsx("span",{className:"tick",children:"✓"}),N.file,":",D]},P):m.jsxs("span",{className:"chip static chip-unconfirmed",children:[m.jsx("span",{className:"qmark",children:"?"}),N.file,":",D]},P)})}),s&&(h||p)&&m.jsx(e$,{mapId:e,itemId:f,change:(k==null?void 0:k.kind)??null,since:S,stamp:n,jump:u})]})]})}function aC({diff:e}){const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return m.jsxs("span",{className:"diff-size",children:[t>0&&m.jsxs("span",{className:"add",children:[" +",t]}),n>0&&m.jsxs("span",{className:"del",children:[" −",n]})]})}function lC({map:e,selection:t,draft:n,busy:r,agentName:o="Claude",autoFocus:s,onDraft:i,onRemove:a,step:l,onRemoveStep:u,onSend:c}){const d=R.useRef(null),f=["nodes","edges","absences"].flatMap(h=>t[h].map(p=>({kind:h,id:p})));return R.useEffect(()=>{const h=d.current;h&&(h.style.height="auto",h.style.height=`${Math.min(h.scrollHeight,140)}px`)},[n]),R.useEffect(()=>{var h;n&&((h=d.current)==null||h.focus())},[n===""]),R.useEffect(()=>{var h;s&&((h=d.current)==null||h.focus({preventScroll:!0}))},[]),m.jsxs("form",{className:"composer",onSubmit:h=>{h.preventDefault(),!r&&n.trim()&&c()},children:[l&&m.jsxs("span",{className:"sel-chip sel-step",children:[m.jsxs("span",{className:"sel-text",title:`Walkthrough step: ${l}`,children:["▸ ",l]}),m.jsx("button",{type:"button","aria-label":`Don't ask about the step “${l}”`,onClick:u,children:"×"})]}),f.map(h=>m.jsxs("span",{className:`sel-chip sel-${h.kind}`,children:[m.jsxs("span",{className:"sel-text",title:dt(e,h.id),children:[h.kind==="absences"?"✕ ":"◉ ",dt(e,h.id)]}),m.jsx("button",{type:"button","aria-label":`Remove ${dt(e,h.id)}`,onClick:()=>a(h.kind,h.id),children:"×"})]},`${h.kind}:${h.id}`)),m.jsx("textarea",{ref:d,id:"ask",rows:1,value:n,placeholder:r?`${o} is working…`:f.length===1&&f[0].kind==="nodes"?"Ask, or try “what if it fails?”":f.length?"Ask about what you selected…":l?"Ask about this step…":"Ask about this map…",onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),!r&&n.trim()&&c())},"aria-label":"Ask a question about the map"}),m.jsx("button",{type:"submit",className:"send",disabled:r||!n.trim(),"aria-label":"Send",children:"↑"})]})}function uC({map:e,agent:t,selection:n,step:r,onRemove:o}){const s=["nodes","edges","absences"].flatMap(a=>n[a].map(l=>({kind:a,id:l}))),i=H2(t,s.length,r);return m.jsxs("div",{className:"composer composer-chat",role:"note","aria-label":"Where to ask",children:[s.map(a=>m.jsxs("span",{className:`sel-chip sel-${a.kind}`,children:[m.jsxs("span",{className:"sel-text",title:dt(e,a.id),children:[a.kind==="absences"?"✕ ":"◉ ",dt(e,a.id)]}),m.jsx("button",{type:"button","aria-label":`Remove ${dt(e,a.id)}`,onClick:()=>o(a.kind,a.id),children:"×"})]},`${a.kind}:${a.id}`)),m.jsxs("p",{className:"chat-hint",children:[m.jsx("strong",{children:i.title})," ",m.jsx("span",{className:"muted",children:i.detail})]})]})}const ql="illuminate-toured",cC=100;function bp(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function dC(e,t,n=cC){return[...e.filter(r=>r!==t),t].slice(-n)}function fC(e,t){const[n,r]=R.useState(()=>bp(_s(ql)).includes(e));return R.useEffect(()=>{!t||n||!e||(nl(ql,JSON.stringify(dC(bp(_s(ql)),e))),r(!0))},[e,t,n]),n}function hC({map:e,mapId:t,tour:n,onTour:r,selected:o,children:s}){const i=fC(t,n!==null),a=e.tour.length,l=a>0&&n===null;return!l&&!s?null:m.jsxs("div",{className:"dock",children:[l&&m.jsxs("section",{className:"dock-part dock-walk","aria-label":"Walkthrough",children:[m.jsx("h2",{className:"dock-title",children:"Walkthrough"}),m.jsxs("button",{className:i?"dock-start":"dock-start glow",onClick:()=>r(0),children:["Take the walkthrough ",m.jsxs("span",{className:"muted",children:[a," ",a===1?"stop":"stops"]})]})]}),s&&m.jsxs("section",{className:"dock-part dock-ask","aria-label":"Ask about the map",children:[m.jsxs("div",{className:"dock-head",children:[m.jsx("h2",{className:"dock-title",children:"Ask about the map"}),m.jsx("span",{className:"dock-hint",children:o?"Shift-click to add more":"Click a box or arrow to ask about it"})]}),s]})]})}function pC({state:e,dispatch:t}){const n=e.answers[e.answers.length-1];return n?m.jsx("div",{className:"history-corner",children:m.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:[m.jsx("span",{className:"history-arrow",children:"‹"})," Conversation ",m.jsx("span",{className:"muted",children:e.answers.length})]})}):null}const Ir=14,Je=12;function gC(e,t){const n=a=>a[a.length-1],r=n(t.nodes),o=n(t.edges),s=n(t.absences),i=r!==void 0?`.react-flow__node[data-id="${CSS.escape(r)}"]`:o!==void 0?`.link-label[data-id="${CSS.escape(`e:${o}`)}"]`:s!==void 0?`.link-label[data-id="${CSS.escape(`a:${s}`)}"]`:null;return i?e.querySelector(i):null}const dc="illuminate-bubble-size",J0=300,ew=180;function mC(){try{const e=JSON.parse(_s(dc)??"null");if(e&&typeof e=="object"&&"w"in e&&"h"in e&&typeof e.w=="number"&&typeof e.h=="number")return{w:Math.max(J0,e.w),h:Math.max(ew,e.h)}}catch{}return null}function yC({mapId:e,map:t,report:n,selection:r,onClose:o}){const s=[...r.nodes,...r.edges,...r.absences],i=s.join(" "),a=R.useRef(null),[l,u]=R.useState(null),c=R.useRef(null),d=Bs(),f=xe(g=>g.transform.join(",")),[h,p]=R.useState(""),[x,v]=R.useState(mC),w=g=>{const b=a.current,E=b==null?void 0:b.querySelector(".card-selected"),k=b==null?void 0:b.parentElement;if(!b||!E||!k||!l)return;g.preventDefault();const S=g.clientX,$=g.clientY,_=b.offsetWidth,j=E.offsetHeight,M=k.clientWidth-2*Je,z=l.side==="right"?1:-1;let F={w:_,h:j};const N=L=>{F={w:Math.round(Math.max(J0,Math.min(M,_+z*(L.clientX-S)))),h:Math.round(Math.max(ew,j+L.clientY-$))},v(F)},P=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",P),document.body.classList.remove("resizing-bubble"),nl(dc,JSON.stringify(F))};window.addEventListener("pointermove",N),window.addEventListener("pointerup",P),document.body.classList.add("resizing-bubble")},y=()=>{try{localStorage.removeItem(dc)}catch{}v(null)};return R.useLayoutEffect(()=>{const g=a.current;if(!g)return;const b=new ResizeObserver(()=>p(`${g.offsetWidth}x${g.offsetHeight}`));return b.observe(g),()=>b.disconnect()},[i]),R.useLayoutEffect(()=>{const g=a.current,b=g==null?void 0:g.parentElement;if(!g||!b)return;const E=gC(b,r);if(!E){u(null);return}const k=b.getBoundingClientRect(),S=E.getBoundingClientRect(),$={left:S.left-k.left,right:S.right-k.left,top:S.top-k.top,bottom:S.bottom-k.top},_=b.querySelector(".dock"),j=_?_.getBoundingClientRect().top-k.top-Je:k.height-Je,M=Math.max(160,j-Je),z=g.offsetWidth,F=Math.min(g.offsetHeight,M),N=k.width-Je-$.right-Ir,P=$.left-Ir-Je,L=N>=z||N>=P?"right":"left",D=L==="right"?$.right+Ir:$.left-Ir-z,I=Math.max(Je,Math.min(D,k.width-Je-z)),A=Math.max(Je,Math.min($.top,j-F)),O=Math.max(16,Math.min(($.top+$.bottom)/2-A,F-16));if(u({left:I,top:A,side:L,pointer:O,maxHeight:M}),c.current===i)return;c.current=i;const U=L==="right"?$.left:$.left-Ir-z,W=L==="right"?$.right+Ir+z:$.right,oe=W-U<=k.width-2*Je,K=oe?U:$.left,se=oe?W:$.right,ie=K<Je?Je-K:se>k.width-Je?k.width-Je-se:0,G=$.top<Je?Je-$.top:$.bottom>j?Math.max(j-$.bottom,Je-$.top):0;if(ie||G){const C=d.getViewport();d.setViewport({...C,x:C.x+ie,y:C.y+G},{duration:300})}},[i,f,h]),s.length?m.jsxs("div",{ref:a,className:`box-bubble box-bubble-${(l==null?void 0:l.side)??"right"}`,style:{...l?{left:l.left,top:l.top,"--bubble-max":`${l.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:[l&&m.jsx("i",{className:"box-bubble-pointer",style:{top:l.pointer},"aria-hidden":"true"}),m.jsx(iC,{mapId:e,map:t,report:n,ids:s,onClose:o},i),m.jsx("span",{className:"box-bubble-grip",onPointerDown:w,onDoubleClick:y,title:"Drag to resize. Double-click for the usual size.","aria-hidden":"true"})]}):null}function wC(e,t){const n=[];let r=!1;for(const o of e.nodes)t("node",o.id)&&(r=!0,o.branch&&!n.includes(o.branch)&&n.push(o.branch));for(const o of e.edges)t("edge",o.id)&&(r=!0,o.branch&&!n.includes(o.branch)&&n.push(o.branch));return r?["now",...n.length>=2?n.map(o=>`option:${o}`):["proposed"],"both"]:[]}function fc(e,t){return e==="proposed"?!0:e.startsWith("option:")?!t||t===e.slice(7):!1}function Td(e,t,n){return e==="both"||!t||t.state!=="pending"?null:t.kind==="add"?fc(e,n)?null:e.startsWith("option:")?"other":"unbuilt":t.kind==="remove"&&fc(e,n)?"dropped":null}function xC(e,t,n){return t?e==="both"||t.state!=="pending"?!0:fc(e,n)&&!Td(e,t,n):!1}function hc(e){if(e==="now")return{label:"Now",title:"The code as it is; what is proposed is a shadow",heading:"The code as it is"};if(e==="proposed")return{label:"With the change",title:"The code as it would be; what would go is a shadow",heading:"With the change"};if(e==="both")return{label:"Both",title:"The code as it is, with the change drawn on top",heading:"The change on top of the code"};const t=e.slice(7);return{label:t,title:`The code as it would be with ${t}; the other options are shadows`,heading:`With ${t}`}}const il=e=>{var t;return!!((t=e==null?void 0:e.since)!=null&&t.commit)};function Id(e,t){return wC(e,(n,r)=>{var o,s;return((s=(o=n==="node"?t==null?void 0:t.nodes[r]:t==null?void 0:t.edges[r])==null?void 0:o.proposal)==null?void 0:s.state)==="pending"})}function tw(e,t){if(il(t)){const n=t.since.commit.slice(0,7);return[{id:"before",version:{when:"before",plan:"both"},label:"Before",title:`The code as it was at ${n}`},{id:"after",version:{when:"after",plan:"both"},label:"After",title:"The code as it is now"},{id:"both",version:{when:"both",plan:"both"},label:"Both",title:`What changed since ${n}`}]}return Id(e,t).map(n=>{const r=hc(n);return{id:n,version:{when:"both",plan:n},label:r.label,title:r.heading}})}function nw(e,t,n){const r=il(t)?n.when:"both",s=Id(e,t).includes(n.plan)?n.plan:"both",i=u=>{var c,d,f,h;return((d=(c=t==null?void 0:t.nodes[u])==null?void 0:c.change)==null?void 0:d.kind)??((h=(f=t==null?void 0:t.edges[u])==null?void 0:f.change)==null?void 0:h.kind)??null},a=u=>{const c=e.nodes.find(h=>h.id===u);if(c)return c.branch??null;const d=e.edges.find(h=>h.id===u),f=h=>{var p;return(p=e.nodes.find(x=>x.id===h))==null?void 0:p.branch};return(d==null?void 0:d.branch)??f(d==null?void 0:d.to)??f(d==null?void 0:d.from)??null},l=u=>{var c,d;return((c=t==null?void 0:t.nodes[u])==null?void 0:c.proposal)??((d=t==null?void 0:t.edges[u])==null?void 0:d.proposal)??null};return{when:r,plan:s,changeOf:i,proposalOf:l,wayOf:a,proposal:u=>{const c=l(u);return c&&xC(s,c,a(u))?{...c,quiet:s!=="both"}:null},ghost:u=>r==="before"&&i(u)==="added"?"later":r==="after"&&i(u)==="removed"?"gone":Td(s,l(u),a(u)),drawnAs:u=>r==="both"||u==="changed"?u:null}}function vC(e,t,n){const r=tw(e,t).find(s=>s.version.when===n.when&&s.version.plan===n.plan);if(!r)return null;if(il(t))return`${r.label}: ${r.title}`;const o=r.version.plan;return o==="now"?"Now: the code as it is":o==="proposed"?"With the change":o==="both"?"Both: the change drawn on top of the code":`With ${o.slice(7)}`}const kC={light:{ink:"#1e2421",muted:"#69716c",line:"#8b938d",area:"rgba(30,36,33,0.035)",areaLine:"#dcdfd8",box:"#ffffff",chip:"#f3f4f1",chipLine:"#dcdfd8",ok:"#2d7a55",dead:"#cf4a33",ai:"#6b4bb0",changed:"#a8620c",label:"rgba(251,251,249,0.94)",action:"#eef5f4"},dark:{ink:"#eef1ee",muted:"#9da7a2",line:"#7d8782",area:"rgba(238,241,238,0.04)",areaLine:"#3b4344",box:"#23292a",chip:"#2d3435",chipLine:"#3b4344",ok:"#5fbf8f",dead:"#ef7a63",ai:"#a98be0",changed:"#e3a24f",label:"rgba(35,41,42,0.94)",action:"#26393a"}},Si={light:["#2f6bd3","#c23b7c","#12838c","#5d6b80","#8a5a3b"],dark:["#7ea8f5","#ef8bbb","#5ec4cc","#a3afc0","#cf9e7c"]},bC="'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",SC="ui-monospace, 'SF Mono', Menlo, Consolas, monospace",EC={entry:"Where it starts",store:"Saved data",external:"Outside the app",job:"Background job",screen:"Screen",action:"Action",choice:"Choice"},NC={add:{pending:"Proposed",done:"Now in the code"},change:{pending:"Would change",done:"Changed"},remove:{pending:"Would be removed",done:"Removed"}},_C={add:"New",change:"Changed",remove:"Removed"},Kl={added:{label:"Added",mark:"+"},changed:{label:"Changed",mark:"~"},removed:{label:"Removed",mark:"−"}},$C={later:"Not there yet",gone:"Gone",unbuilt:"Not built yet",other:"Other option",dropped:"Would go"},Zl=24,zt=24,Sp=20,et=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),Q=e=>Math.round(e*10)/10;function Ql(e,t,n){const r=[];let o="";for(const s of e.split(/\s+/).filter(Boolean))`${o} ${s}`.trim().length<=t?o=`${o} ${s}`.trim():(o&&r.push(o),o=s.length>t?`${s.slice(0,t-1)}…`:s);return o&&r.push(o),r.length>n&&(r.length=n,r[n-1]=`${r[n-1].slice(0,t-1)}…`),r}function CC(e,t){const n=t?` · checked ${t}`:"";if(!e)return`Made with illuminate${n}`;const r=e.summary.claims-e.summary.confirmed;return r?`Made with illuminate · ${r} part${r===1?"":"s"} didn't match the code (marked ?)${n}`:`Made with illuminate · every part is in the code${n}`}function MC(e,t,n,r){var C,B,J,q,Z;const o=kC[r.theme],s=!!n.flat,i=e.nodes.flatMap(T=>{const H=Ea(e,n,T.id);return H?[{n:T,...H}]:[]}),a=new Map(e.nodes.map(T=>[T.id,T.name])),l=[...e.edges.map(T=>{var H;return{id:`e:${T.id}`,from:T.from,to:T.to,label:T.label,absence:!1,ok:((H=t==null?void 0:t.edges[T.id])==null?void 0:H.status)!=="unconfirmed",proposed:!!T.proposed}}),...e.absences.flatMap(T=>T.between?[{id:`a:${T.id}`,from:T.between.from,to:T.between.to,label:T.claim.length>28?`${T.claim.slice(0,26)}…`:T.claim,absence:!0,ok:!0,proposed:!1}]:[])],u=V0(e,n,l),c=s||n.lanes?new Set:sl(e),d=e.view==="journey",f=r.version??{when:"both",plan:"both"},h=nw(e,t,f),p=(T,H)=>t?h.proposal(T):H?{kind:H.kind,state:"pending"}:null,x=T=>T==="added"?o.ok:T==="removed"?o.dead:T==="changed"?o.changed:null,v={ghost:!1,change:new Set},w=n.branches??[],y=T=>T&&w.includes(T)?Si[r.theme][w.indexOf(T)%Si[r.theme].length]:null,g=T=>{var H;return y((H=e.nodes.find(V=>V.id===T))==null?void 0:H.branch)},b=T=>{var V,X;const H=e.edges.find(ee=>`e:${ee.id}`===T.id);return H?y(H.branch??((V=e.nodes.find(ee=>ee.id===H.to))==null?void 0:V.branch)??((X=e.nodes.find(ee=>ee.id===H.from))==null?void 0:X.branch)):null},E=new Map;if(d){const T=H=>w.length&&H.branch?1:0;for(const H of e.areas){const V=e.nodes.filter(X=>X.area===H.id&&n.nodes[X.id]).sort((X,ee)=>T(X)-T(ee)||n.nodes[X.id].x-n.nodes[ee.id].x||n.nodes[X.id].y-n.nodes[ee.id].y)[0];V&&E.set(V.id,H.label)}}const k=s?[]:Object.values(n.areas).map(T=>({x:T.x,y:T.y,w:Math.min(T.w,280),h:40})),S=[];for(const T of l){const H=u.get(T.id);if(!H||!T.label)continue;const V=Na(H.d,6);S.push({id:T.id,w:ol(T.label),h:Zl,at:{x:H.at[0],y:H.at[1]},along:X=>V[Math.min(V.length-1,Math.max(0,Math.round(X*(V.length-1))))]??null,keep:T.absence})}const $=Ad(S,i,k),_=[],j=[],M=[];for(const T of[...i,...s?[]:Object.values(n.areas)])j.push(T.x,T.x+T.w),M.push(T.y,T.y+T.h);for(const{n:T,y:H}of i)E.has(T.id)&&M.push(H-26);for(const T of u.values())for(const H of Na(T.d,12))j.push(H.x),M.push(H.y);const z=Math.min(...j)-zt,F=Math.min(...M)-zt,N=Math.max(...j)-z+zt,P=Math.max(...M)-F+zt,L=[],D=L.length;if(L.push(""),!s)for(const[T,H]of Object.entries(n.areas)){const V=((C=e.areas.find(X=>X.id===T))==null?void 0:C.label)??"";L.push(`<rect x="${Q(H.x)}" y="${Q(H.y)}" width="${Q(H.w)}" height="${Q(H.h)}" rx="18" fill="${o.area}" stroke="${o.areaLine}"/>`),L.push(`<text x="${Q(H.x+16)}" y="${Q(H.y+26)}" font-size="12.5" font-weight="600" fill="${o.muted}">${et(V)}</text>`)}const I=new Map,A=T=>(I.has(T)||I.set(T,`arrow-${r.theme}-${I.size}`),I.get(T)),O=l.filter(T=>!(T.absence&&h.when==="before")),U=new Map;for(const T of O){const H=u.get(T.id);if(!H)continue;const V=T.id.startsWith("e:")?T.id.slice(2):null,X=V?e.edges.find(Ne=>Ne.id===V):void 0,ee=(V?h.ghost(V):null)??h.ghost(T.from)??h.ghost(T.to),me=V&&!ee?p(V,X==null?void 0:X.proposed):null,de=V&&!ee?h.drawnAs(h.changeOf(V)):null,ge=!!me&&me.state==="pending"&&!me.quiet;ee&&(v.ghost=!0),de&&v.change.add(de);const ve=!!V&&c.has(V),Y=T.absence||ee?null:b(T),re=ee?o.line:T.absence?o.dead:ge?Y??o.ai:x(de)??Y??(ve?o.ink:o.line),ke=ee?' stroke-dasharray="4 4"':T.absence?' stroke-dasharray="6 5"':ve?' stroke-dasharray="0.1 6" stroke-linecap="round"':!T.ok||ge||de==="removed"?' stroke-dasharray="5 4"':"",fe=(me==null?void 0:me.kind)==="add"&&ge?"+ ":de?`${Kl[de].mark} `:"";U.set(T.id,{colour:re,faint:!!ee,mark:fe}),L.push(`<path data-link="${et(T.id)}" d="${H.d}" fill="none" stroke="${re}" stroke-width="${ve?2.2:Y||de?1.8:1.5}"${ke}${ee?' opacity="0.45"':""} marker-end="url(#${A(re)})"/>`)}for(const{n:T,x:H,y:V,w:X,h:ee}of i){const me=((B=t==null?void 0:t.nodes[T.id])==null?void 0:B.status)!=="unconfirmed",de=h.ghost(T.id),ge=de?null:p(T.id,T.proposed),ve=de?null:h.drawnAs(h.changeOf(T.id)),Y=!!ge&&ge.state==="pending"&&!ge.quiet;de&&(v.ghost=!0),ve&&v.change.add(ve);const re=de?null:g(T.id),ke=de?o.line:x(ve)??re??(Y?o.ai:o.ink),fe=de?$C[de]:ge?ge.quiet&&ge.state==="pending"?_C[ge.kind]:NC[ge.kind][ge.state]:ve?ve==="changed"&&h.when==="before"?"Changes later":Kl[ve].label:null,Ne=de?o.muted:ge?re??o.ai:x(ve)??o.muted,ae=de?o.muted:o.ink,ce=ve==="removed"?' text-decoration="line-through"':"",he=de?' stroke-dasharray="4 4"':Y||!me?' stroke-dasharray="5 4"':T.kind==="external"?' stroke-dasharray="2 3"':"";if(L.push(de?'<g opacity="0.55">':"<g>"),d){const _e=he,ne=de?"none":T.kind==="action"?o.action:o.box,Ce=re?`<rect x="${Q(H)}" y="${Q(V)}" width="${Q(X)}" height="${Q(ee)}" rx="${T.kind==="action"?Q(ee/2):12}" fill="${re}" fill-opacity="0.07"/>`:"";T.kind==="choice"?(L.push(`<polygon data-box="${et(T.id)}" points="${Q(H+X/2)},${Q(V)} ${Q(H+X)},${Q(V+ee/2)} ${Q(H+X/2)},${Q(V+ee)} ${Q(H)},${Q(V+ee/2)}" fill="${de?"none":o.box}" stroke="${ke}" stroke-width="1.6"${_e}/>`),re&&L.push(`<polygon points="${Q(H+X/2)},${Q(V)} ${Q(H+X)},${Q(V+ee/2)} ${Q(H+X/2)},${Q(V+ee)} ${Q(H)},${Q(V+ee/2)}" fill="${re}" fill-opacity="0.09"/>`)):(L.push(`<rect data-box="${et(T.id)}" x="${Q(H)}" y="${Q(V)}" width="${Q(X)}" height="${Q(ee)}" rx="${T.kind==="action"?Q(ee/2):12}" fill="${ne}" stroke="${ke}" stroke-width="${re?2:1.4}"${_e}/>`),Ce&&L.push(Ce));const Me=T.kind==="choice"?X*.6:X-24,Qe=Ql(T.name,Math.max(8,Math.floor(Me/7.6)),T.kind==="choice"?3:Math.max(1,Math.floor((ee-12)/17))),Re=[fe,me||de?null:"?"].filter(Boolean).join(" · "),Be=T.kind==="external"?"Outside the app":"",Xe=Qe.length+(Re?1:0)+(Be?1:0);let lt=V+ee/2-(Xe-1)*17/2+5;Re&&(L.push(`<text x="${Q(H+X/2)}" y="${Q(lt)}" text-anchor="middle" font-size="10.5" font-weight="600" fill="${fe?Ne:o.dead}">${et(Re)}</text>`),lt+=17);for(const pt of Qe)L.push(`<text x="${Q(H+X/2)}" y="${Q(lt)}" text-anchor="middle" font-size="${T.kind==="choice"?13:14}" font-weight="600" fill="${ae}"${ce}>${et(pt)}</text>`),lt+=17;Be&&L.push(`<text x="${Q(H+X/2)}" y="${Q(lt)}" text-anchor="middle" font-size="10.5" fill="${o.muted}">${Be}</text>`);const Se=E.get(T.id);Se&&L.push(`<text x="${Q(H+2)}" y="${Q(V-10)}" font-size="11.5" font-weight="600" letter-spacing="0.5" fill="${o.muted}">${et(Se.toUpperCase())}</text>`),L.push("</g>");continue}L.push(`<rect data-box="${et(T.id)}" x="${Q(H)}" y="${Q(V)}" width="${Q(X)}" height="${Q(ee)}" rx="12" fill="${de?"none":o.box}" stroke="${ke}" stroke-width="${re||ve?1.8:1.4}"${he}/>`),re&&L.push(`<path d="M ${Q(H+1)} ${Q(V+12)} Q ${Q(H+1)} ${Q(V+1)} ${Q(H+12)} ${Q(V+1)} L ${Q(H+X-12)} ${Q(V+1)} Q ${Q(H+X-1)} ${Q(V+1)} ${Q(H+X-1)} ${Q(V+12)} L ${Q(H+X-1)} ${Q(V+5)} L ${Q(H+1)} ${Q(V+5)} Z" fill="${re}" fill-opacity="0.7"/>`);const pe=fe??EC[T.kind];let ye=V+22;pe&&(L.push(`<text x="${Q(H+14)}" y="${Q(ye)}" font-size="10.5"${fe?' font-weight="600"':""} fill="${fe?Ne:o.muted}">${et(pe)}</text>`),ye+=18);for(const _e of Ql(T.name,Math.floor((X-28)/8.4),ee>80?2:1))L.push(`<text x="${Q(H+14)}" y="${Q(ye)}" font-size="14.5" font-weight="600" fill="${ae}"${ce}>${et(_e)}</text>`),ye+=18;if(ee>=80){const _e=T.evidence[0],ne=T.symbol?T.symbol.slice(T.symbol.indexOf("#")+1):_e?`${_e.file.split("/").pop()}:${_e.line}`:"not in the code yet",Ce=(ge==null?void 0:ge.kind)==="add"&&Y||de==="unbuilt"||de==="other"?"+":ve&&me?Kl[ve].mark:me?"✓":"?",Me=ne.length>30?`${ne.slice(0,29)}…`:ne,Qe=Math.min(X-28,(Me.length+2)*6.6+16),Re=V+ee-30;L.push(`<rect x="${Q(H+14)}" y="${Q(Re)}" width="${Q(Qe)}" height="20" rx="10" fill="${o.chip}" stroke="${o.chipLine}"/>`),L.push(`<text x="${Q(H+22)}" y="${Q(Re+14)}" font-size="10.5" font-family="${SC}" fill="${o.muted}"><tspan fill="${Ce==="?"?o.dead:Ce==="+"&&!ve?o.ai:x(ve)??o.ok}">${Ce}</tspan> ${et(Me)}</text>`)}L.push("</g>")}for(const T of S){const H=l.find(de=>de.id===T.id),V=U.get(T.id);if(!V)continue;const X=$[T.id];if(X==="dot"||X&&"dot"in X){const de=X==="dot"?T.at:X;_.push(T.id);const ge=_.length;L.push(`<circle cx="${Q(de.x)}" cy="${Q(de.y)}" r="10" fill="${o.box}" stroke="${H.absence?o.dead:o.ink}" stroke-width="1.2"/>`),L.push(`<text x="${Q(de.x)}" y="${Q(de.y+4.5)}" text-anchor="middle" font-size="12" font-weight="700" fill="${H.absence?o.dead:o.ink}">${ge}</text>`);continue}const ee=X??T.at,me=`${V.mark}${H.label}${H.ok?"":" ?"}`;L.push(`<rect x="${Q(ee.x-T.w/2)}" y="${Q(ee.y-Zl/2+1)}" width="${Q(T.w)}" height="${Zl-2}" rx="6" fill="${o.label}"/>`),L.push(`<text x="${Q(ee.x)}" y="${Q(ee.y+4)}" text-anchor="middle" font-size="12" fill="${H.absence?o.dead:V.faint?o.muted:V.colour!==o.line&&V.colour!==o.ink?V.colour:o.muted}"${V.faint?' opacity="0.6"':""}>${et(me)}</text>`)}const W=[],oe=r.version?vC(e,t,r.version):null;oe&&W.push({text:oe,tone:"ink",bold:!0}),w.length&&W.push({text:"",tone:"ink",ways:!0}),_.forEach((T,H)=>{var X;const V=l.find(ee=>ee.id===T);W.push({mark:H+1,text:`${a.get(V.from)} → ${a.get(V.to)}: ${V.absence?((X=e.absences.find(ee=>`a:${ee.id}`===T))==null?void 0:X.claim)??V.label:V.label}`,tone:V.absence?"dead":"ink"})});const K=[];if(l.some(T=>T.id.startsWith("e:")&&c.has(T.id.slice(2)))&&K.push("dotted arrows go back to an earlier step (a loop)"),l.some(T=>T.absence)&&K.push("red dashed arrows are missing connections"),(l.some(T=>!T.ok)||e.nodes.some(T=>{var H;return((H=t==null?void 0:t.nodes[T.id])==null?void 0:H.status)==="unconfirmed"}))&&K.push("? marks what the checker couldn't find in the code"),v.ghost&&K.push("faint outlines aren't in this version"),v.change.size&&K.push([...v.change].map(T=>`${T==="added"?"green":T==="changed"?"amber":"red"}: ${T}`).join(", ")+((J=t==null?void 0:t.since)!=null&&J.commit?` since ${t.since.commit.slice(0,7)}`:"")),(e.nodes.some(T=>T.proposed)||l.some(T=>T.proposed))&&K.push(w.length?"dashed parts are proposed, not built (in their way's colour)":"purple dashed parts are proposed, not built"),K.length&&W.push({text:`Key: ${K.join(" · ")}`,tone:"muted"}),r.notes)for(const T of e.nodes){const H=(Z=(q=T.explain)==null?void 0:q.concept)==null?void 0:Z.trim();if(H)for(const[V,X]of Ql(`${T.name}: ${H}`,Math.max(40,Math.floor((N-2*zt)/7)),6).entries())W.push({text:V?` ${X}`:X,tone:"muted"})}const se=F+P+4;W.forEach((T,H)=>{const V=se+14+H*Sp;if(T.ways){let X=z+zt;L.push(`<text x="${Q(X)}" y="${Q(V)}" font-size="12.5" font-weight="600" fill="${o.ink}">Ways through</text>`),X+=96;for(const[ee,me]of[[d?"Main path":"Shared",o.ink],...w.map((de,ge)=>[de,Si[r.theme][ge%Si[r.theme].length]])])L.push(`<rect x="${Q(X)}" y="${Q(V-10)}" width="12" height="12" rx="3" fill="${me}" fill-opacity="${me===o.ink?0:.18}" stroke="${me}" stroke-width="1.5"/>`),L.push(`<text x="${Q(X+18)}" y="${Q(V)}" font-size="12.5" fill="${o.ink}">${et(ee)}</text>`),X+=18+ee.length*7+22;return}T.mark?(L.push(`<circle cx="${Q(z+zt+9)}" cy="${Q(V-4)}" r="9" fill="${o.box}" stroke="${o[T.tone]}" stroke-width="1.1"/><text x="${Q(z+zt+9)}" y="${Q(V)}" text-anchor="middle" font-size="11" font-weight="700" fill="${o[T.tone]}">${T.mark}</text>`),L.push(`<text x="${Q(z+zt+26)}" y="${Q(V)}" font-size="12.5" fill="${o[T.tone]}">${et(T.text)}</text>`)):L.push(`<text x="${Q(z+zt)}" y="${Q(V)}" font-size="12.5"${T.bold?' font-weight="600"':""} fill="${o[T.tone]}">${et(T.text)}</text>`)});const ie=se+14+W.length*Sp+(W.length?12:0);L.push(`<text x="${Q(z+zt)}" y="${Q(ie)}" font-size="11" fill="${o.muted}">${et(CC(t,r.checkedOn))}</text>`);const G=ie-F+14;return L[D]=`<defs>${[...I].map(([T,H])=>`<marker id="${H}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0 L10 5 L0 10 z" fill="${T}"/></marker>`).join("")}</defs>`,[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${Q(z)} ${Q(F)} ${Q(N)} ${Q(G)}" width="${Math.ceil(N)}" height="${Math.ceil(G)}" font-family="${bC}">`,`<title>${et(e.question)}</title>`,...L,"</svg>"].join(`
|
|
82
|
-
`)}async function AC(e,t,n,r){return MC(e,t,await G0(e,[],n),r)}function jC(e,t){const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function TC(e){const t=new Image;await new Promise((s,i)=>{t.onload=()=>s(),t.onerror=()=>i(new Error("The picture couldn't be drawn.")),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`});const n=2,r=document.createElement("canvas");r.width=Math.ceil(t.naturalWidth*n),r.height=Math.ceil(t.naturalHeight*n);const o=r.getContext("2d");if(!o)throw new Error("This browser can't draw the picture.");return o.scale(n,n),o.drawImage(t,0,0),new Promise((s,i)=>r.toBlob(a=>a?s(a):i(new Error("The picture couldn't be saved.")),"image/png"))}function IC({mapId:e,map:t,report:n,added:r,version:o}){const[s,i]=R.useState(!1),a=R.useMemo(()=>tw(t,n),[t,n]),l=a.find(b=>o&&b.version.when===o.when&&b.version.plan===o.plan)??a.find(b=>b.id==="both")??a[0],[u,c]=R.useState(null),d=a.find(b=>b.id===u)??l,[f,h]=R.useState(!1),[p,x]=R.useState(!1),[v,w]=R.useState(null),y=R.useRef(null);R.useEffect(()=>{if(!s)return;const b=k=>{var S;return!((S=y.current)!=null&&S.contains(k.target))&&i(!1)},E=k=>k.key==="Escape"&&i(!1);return document.addEventListener("mousedown",b),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",E)}},[s]);const g=async(b,E)=>{x(!0),w(null);try{const k=new Date().toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),S=await AC(t,n,new Set(r),{theme:E,notes:f,checkedOn:k,...d?{version:d.version}:{}}),$=d&&a.length>1?`-${d.label.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`:"",_=`${e}${$}${E==="dark"?"-dark":""}.${b}`;jC(_,b==="svg"?new Blob([S],{type:"image/svg+xml"}):await TC(S)),i(!1)}catch(k){w(k instanceof Error?k.message:String(k))}finally{x(!1)}};return m.jsxs("div",{className:"export",ref:y,children:[m.jsx("button",{className:"pill-btn","aria-expanded":s,"aria-haspopup":"menu",title:"Save this map as a picture for documentation",onClick:()=>{s||c(null),i(!s)},children:"Export"}),s&&m.jsxs("div",{className:"export-menu",role:"menu",children:[m.jsx("p",{className:"export-note",children:"A picture of the map, with a transparent background. Labels with no room are numbered and listed under it."}),a.length>1&&d&&m.jsxs("div",{className:"export-row",children:[m.jsx("span",{className:"export-theme",children:"Version"}),m.jsx("div",{className:"seg",role:"group","aria-label":"Which version to export",children:a.map(b=>m.jsx("button",{className:b.id===d.id?"seg-btn on":"seg-btn","aria-pressed":b.id===d.id,title:b.title,onClick:()=>c(b.id),children:b.label},b.id))})]}),["light","dark"].map(b=>m.jsxs("div",{className:"export-row",children:[m.jsx("span",{className:"export-theme",children:b==="light"?"For light pages":"For dark pages"}),m.jsx("button",{className:"pill-btn small",role:"menuitem",disabled:p,onClick:()=>void g("svg",b),children:"SVG"}),m.jsx("button",{className:"pill-btn small",role:"menuitem",disabled:p,onClick:()=>void g("png",b),children:"PNG"})]},b)),m.jsxs("label",{className:"export-notes",children:[m.jsx("input",{type:"checkbox",checked:f,onChange:b=>h(b.target.checked)})," Add each box's explanation under the map"]}),v&&m.jsx("p",{className:"export-problem",children:v})]})]})}const cn=(...e)=>e.filter(Boolean).join(" "),yr={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"}},al=e=>e&&`proposal proposal-${e.kind} proposal-${e.state}${e.quiet&&e.state==="pending"?" proposal-quiet":""}`,LC={add:"New",change:"Changed",remove:"Removed"},wr={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"}},ll=e=>e&&`change change-${e}`,$a={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"},unbuilt:{label:"Not built yet",title:"Proposed: only there with the change"},other:{label:"Other option",title:"Part of another option of the change, not this one"},dropped:{label:"Would go",title:"Proposed to be removed: not there with the change"}};function RC(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 OC=[["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 PC({commit:e,when:t,onWhen:n}){return m.jsxs("div",{className:"change-key",children:[m.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the code to show",children:OC.map(([r,o,s])=>m.jsx("button",{className:cn("seg-btn",t===r&&"on"),title:s,"aria-pressed":t===r,onClick:()=>n(r),children:o},r))}),m.jsx("span",{className:"change-key-title",children:t==="before"?`The code at ${e}`:t==="after"?"The code now":`Now, compared with ${e}`}),t==="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch"}),"Same as before"]}),t==="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-added"}),"Added"]}),m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:cn("key-swatch key-changed",t!=="both"&&"key-quiet")}),t==="before"?"Changes later":"Changed"]}),t==="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-removed"}),"Removed (only in the before)"]}),t!=="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),t==="before"?"Not there yet":"Gone"]})]})}const zC=5,Vs=e=>e&&`branch branch-${e.colour}`;function DC({branches:e,journey:t}){return m.jsxs("div",{className:"change-key branch-key",children:[m.jsx("span",{className:"change-key-title",children:"Ways through"}),t?m.jsxs("span",{className:"key-item",title:"What most people do, start to finish",children:[m.jsx("i",{className:"key-swatch"}),"Main path"]}):m.jsxs("span",{className:"key-item",title:"On every way through",children:[m.jsx("i",{className:"key-swatch"}),"Shared"]}),e.map(n=>m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:cn("key-swatch",Vs(n))}),n.name]},n.name))]})}function FC({views:e,plan:t,onPlan:n,shown:r}){return m.jsxs("div",{className:"change-key plan-key",children:[m.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the proposal to show",children:e.map(o=>{const{label:s,title:i}=hc(o);return m.jsx("button",{className:cn("seg-btn",t===o&&"on"),title:i,"aria-pressed":t===o,onClick:()=>n(o),children:s},o)})}),m.jsx("span",{className:"change-key-title",children:hc(t).heading}),r.has("new")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-new"}),"New"]}),r.has("unbuilt")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),"Not built yet"]}),r.has("other")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),"Other option"]}),r.has("dropped")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),"Would go"]})]})}const Ei={entry:["Where it starts","▸"],store:["Saved data","▤"],external:["Outside the app","↗"],job:["Background job","◷"]},Ep=[["t",ue.Top],["r",ue.Right],["b",ue.Bottom],["l",ue.Left]];function rw(){return m.jsxs(m.Fragment,{children:[Ep.map(([e,t])=>m.jsx(yo,{id:`s${e}`,type:"source",position:t,className:"handle",isConnectable:!1},`s${e}`)),Ep.map(([e,t])=>m.jsx(yo,{id:`t${e}`,type:"target",position:t,className:"handle",isConnectable:!1},`t${e}`))]})}function BC({data:e}){var t,n,r;return e.journey?m.jsx(HC,{data:e}):m.jsxs("div",{className:cn("step","nopan",`kind-${e.kind}`,!e.confirmed&&"unconfirmed",al(e.proposal),ll(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(e.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),onClick:o=>{o.stopPropagation(),e.onClick(o.shiftKey||o.metaKey)},onMouseEnter:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!0)},onMouseLeave:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!1)},children:[m.jsx(rw,{}),(Ei[e.kind]||e.fresh||e.screen||e.proposal||e.change||e.ghost)&&m.jsxs("div",{className:"step-head",children:[e.ghost&&m.jsx("span",{className:"badge-ghost",title:$a[e.ghost].title,children:$a[e.ghost].label}),e.proposal&&m.jsx("span",{className:"badge-proposal",children:e.proposal.quiet&&e.proposal.state==="pending"?LC[e.proposal.kind]:yr[e.proposal.kind][e.proposal.state]}),e.change&&m.jsxs("span",{className:"badge-change",title:wr[e.change].title,children:[e.quiet==="before"?"Changes later":wr[e.change].label,e.changeSize&&!e.quiet&&m.jsxs("span",{className:"change-size",children:[" ",e.changeSize]})]}),Ei[e.kind]&&!e.proposal&&!e.change&&!e.ghost&&m.jsxs(m.Fragment,{children:[m.jsx("i",{className:"step-mark","aria-hidden":"true",children:Ei[e.kind][1]}),Ei[e.kind][0]]}),e.screen&&m.jsx("span",{className:"badge-screen",title:"Select this step to see the screen",children:"▣ Screen"}),e.fresh&&m.jsx("span",{className:"badge-new",children:"New"})]}),m.jsx("div",{className:"step-name",title:e.name,children:e.name}),m.jsxs("div",{className:"step-code",title:((t=e.proposal)==null?void 0:t.state)==="pending"?yr[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"||e.ghost==="unbuilt"||e.ghost==="other"?m.jsx("span",{className:"pmark",children:"+"}):((r=e.proposal)==null?void 0:r.state)==="done"&&e.proposal.kind!=="add"?m.jsx("span",{className:"pmark",children:yr[e.proposal.kind].mark}):e.change&&e.confirmed?m.jsx("span",{className:"cmark",children:wr[e.change].mark}):m.jsx("span",{className:e.confirmed?"tick":"qmark",children:e.confirmed?"✓":"?"}),m.jsx("span",{className:"step-sub",children:e.sub})]})]})}function HC({data:e}){const t=e.journey,n=e.proposal;return m.jsxs("div",{className:cn("step","jstep","nopan",`j-${t.shape}`,t.show&&"j-pictured",t.outside&&"j-outside",!e.confirmed&&"unconfirmed",al(n),ll(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(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)},onMouseEnter:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!0)},onMouseLeave:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!1)},children:[m.jsx(rw,{}),t.stage&&m.jsx("div",{className:"j-stage",children:t.stage}),t.shape==="choice"&&m.jsx("svg",{className:"j-diamond",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:m.jsx("polygon",{points:"50,1 99,50 50,99 1,50",vectorEffect:"non-scaling-stroke"})}),m.jsxs("div",{className:"j-tags",children:[n&&m.jsx("span",{className:"badge-proposal",children:yr[n.kind][n.state]}),e.ghost&&m.jsx("span",{className:"badge-ghost",title:$a[e.ghost].title,children:$a[e.ghost].label}),e.change&&m.jsx("span",{className:"badge-change",title:wr[e.change].title,children:e.quiet==="before"?"Changes later":wr[e.change].label}),!e.confirmed&&m.jsx("span",{className:"j-q",title:"The checker couldn't confirm this against the code",children:"?"}),e.fresh&&m.jsx("span",{className:"badge-new",children:"New"})]}),t.show&&m.jsx(o$,{show:t.show,name:e.name}),m.jsx("div",{className:"j-name",title:e.name,children:e.name}),t.outside&&t.shape!=="choice"&&m.jsx("div",{className:"j-note",children:"Outside the app"})]})}function UC({data:e}){return m.jsx("div",{className:cn("area",e.dim&&"dim"),children:m.jsxs("div",{className:"area-label",children:[e.label,e.note&&m.jsxs("span",{className:"area-note",children:[" ",e.note]})]})})}function WC({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,markerEnd:a,data:l}){const[u,c,d]=!l||l.loop||l.route||l.wrapY===void 0?U0(t,n,s,r,o,i,{loop:l==null?void 0:l.loop,route:l==null?void 0:l.route,offset:l==null?void 0:l.offset}):s===ue.Right?H0([[t,n],[t+30,n],[t+30,l.wrapY],[r,l.wrapY],[r,o]]):ka({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i,borderRadius:18,centerY:l.wrapY});if(!l)return null;const f=l.place&&l.place!=="dot"?l.place:null,h=(l.place==="dot"||typeof l.place=="object"&&"dot"in l.place)&&!l.selected;return m.jsxs(m.Fragment,{children:[l.selected&&m.jsx("path",{d:u,className:"edge-halo"}),m.jsx(Hs,{id:e,path:u,markerEnd:a,interactionWidth:18}),m.jsx(f2,{children:m.jsxs("div",{className:cn("link-label",h&&"dot",`link-${l.variant}`,!l.confirmed&&"unconfirmed",al(l.proposal),ll(l.change),l.ghost&&"ghost",Vs(l.branch),l.hl&&"hl",l.dim&&"dim",l.selected&&"selected","nodrag nopan"),"data-id":e,"data-x":c,"data-y":d,title:h?l.label:void 0,onMouseEnter:l.onHover&&(()=>l.onHover(!0)),onMouseLeave:l.onHover&&(()=>l.onHover(!1)),style:{transform:`translate(-50%, -50%) translate(${(f==null?void 0:f.x)??c}px, ${(f==null?void 0:f.y)??d}px)`},onClick:p=>{var x;p.stopPropagation(),(x=l.onClick)==null||x.call(l,p.shiftKey||p.metaKey)},children:[l.variant==="absence"&&m.jsx("span",{className:"gap-q","aria-hidden":"true",children:"?"}),l.proposal&&!(l.proposal.quiet&&l.proposal.state==="pending"&&l.proposal.kind==="add")&&m.jsx("span",{className:"pmark",title:l.proposal.state==="done"?yr[l.proposal.kind].done:yr[l.proposal.kind].title,children:l.proposal.state==="done"&&l.proposal.kind==="add"?"✓":yr[l.proposal.kind].mark}),l.change&&m.jsx("span",{className:"cmark",title:wr[l.change].title,children:wr[l.change].mark}),m.jsx("span",{className:"link-text",children:l.label}),!l.confirmed&&l.variant==="edge"&&m.jsx("span",{className:"q",children:" ?"})]})})]})}const VC={step:BC,area:UC},GC={link:WC};function Np(e,t){const n=new Set;for(const r of t){e.nodes.some(i=>i.id===r)&&n.add(r);const o=e.edges.find(i=>i.id===r);o&&n.add(o.from).add(o.to);const s=e.absences.find(i=>i.id===r);s!=null&&s.between&&n.add(s.between.from).add(s.between.to)}return[...n]}const YC="440px",XC=e=>e.length>28?`${e.slice(0,26)}…`:e;function qC(e){var T,H,V,X,ee,me,de,ge,ve;const t=(T=e.ghost)!=null&&T.connects&&e.map.nodes.some(Y=>Y.id===e.ghost.connects.from)&&e.map.nodes.some(Y=>Y.id===e.ghost.connects.to)?e.ghost:null,n=R.useMemo(()=>t!=null&&t.connects?[{id:t.id,from:t.connects.from,to:t.connects.to}]:[],[t]),r=R.useMemo(()=>e.map.view==="journey"?e.map.nodes.filter(Y=>{var re,ke,fe;return Y.kind!=="action"&&Y.kind!=="choice"&&((fe=(ke=(re=e.report)==null?void 0:re.screens)==null?void 0:ke[Y.id])==null?void 0:fe.status)==="confirmed"}).map(Y=>Y.id):[],[e.map,e.report]),o=V$(e.map,n,e.added,r),[s,i]=R.useState(null),a=Bs(),[l,u]=R.useState({key:"",at:{}}),[c,d]=R.useState("both");il(e.report);const[f,h]=R.useState("both"),p=R.useMemo(()=>Id(e.map,e.report),[e.map,e.report]),x=nw(e.map,e.report,{when:c,plan:f}),v=x.when,w=x.plan,{wayOf:y,proposalOf:g}=x,b=x.proposal,E=x.ghost,k=x.drawnAs,S=e.onVersion;R.useEffect(()=>S==null?void 0:S({when:v,plan:w}),[v,w,S]);const $=JSON.stringify([(s==null?void 0:s.key)??null,v,w,(t==null?void 0:t.id)??null]),_=new Set;if(w!=="both")for(const Y of e.map.nodes.map(re=>re.id)){const re=Td(w,g(Y),y(Y));re?_.add(re):((H=b(Y))==null?void 0:H.kind)==="add"&&_.add("new")}R.useEffect(()=>{let Y=!0;return G0(e.map,n,new Set(e.added),new Set(r)).then(re=>Y&&i({key:o,layout:re}),re=>console.error("illuminate: the map could not be laid out",re)),()=>{Y=!1}},[o]);const j=R.useMemo(()=>!s||s.layout.flat||s.layout.lanes?new Set:sl(e.map),[e.map,s]),M=R.useMemo(()=>[...j].flatMap(Y=>q0(e.map,Y)??[]),[j,e.map]),z=Y=>M.find(re=>re.edges.includes(Y))??null,F=R.useRef(void 0),N=R.useRef([]),P=R.useRef(z);P.current=z;const L=(Y,re,ke)=>{window.clearTimeout(F.current),F.current=window.setTimeout(()=>{for(const he of N.current)he.classList.remove("pointed");if(N.current=[],!ke)return;const fe=Y==="edge"?P.current(re):null,Ne=fe?fe.nodes:Y==="node"?[re]:[],ae=fe?fe.edges:Y==="edge"?[re]:[],ce=[...Ne.flatMap(he=>[...document.querySelectorAll(`.react-flow__node[data-id="${CSS.escape(he)}"] .step`)]),...ae.flatMap(he=>[...document.querySelectorAll(`.react-flow__edge[data-id="${CSS.escape(`e:${he}`)}"], .link-label[data-id="${CSS.escape(`e:${he}`)}"]`)])];for(const he of ce)he.classList.add("pointed");N.current=ce},ke?150:80)};R.useEffect(()=>()=>window.clearTimeout(F.current),[]);const D=e.selection.edges.map(z).find(Y=>!!Y)??null,I=D?new Set([...D.nodes,...D.edges]):(V=e.view)!=null&&V.highlight.length?new Set(e.view.highlight):null,A=R.useMemo(()=>I?new Set(Np(e.map,[...I])):null,[I,e.map]),O=e.selection,U=R.useMemo(()=>((s==null?void 0:s.layout.branches)??[]).map((Y,re)=>({name:Y,colour:re%zC+1})),[s]),W=p.some(Y=>Y.startsWith("option:")),oe=Y=>!W||w==="both"||w===`option:${Y}`,K=Y=>Y&&oe(Y)?U.find(re=>re.name===Y)??null:null,se=U.filter(Y=>oe(Y.name)),ie=(Y,re,ke)=>{var ae;if(!U.length||!ke)return null;if(Y==="node")return K((ae=e.map.nodes.find(ce=>ce.id===re))==null?void 0:ae.branch);const fe=e.map.edges.find(ce=>ce.id===re),Ne=ce=>{var he;return(he=e.map.nodes.find(pe=>pe.id===ce))==null?void 0:he.branch};return K((fe==null?void 0:fe.branch)??Ne(fe==null?void 0:fe.to)??Ne(fe==null?void 0:fe.from))},G=R.useMemo(()=>{if(!s)return[];const Y=s.layout,re=ae=>!A||e.map.nodes.some(ce=>ce.area===ae&&A.has(ce.id)),ke=e.map.areas.flatMap(ae=>{const ce=Y.areas[ae.id];return ce?[{id:`area:${ae.id}`,type:"area",position:{x:ce.x,y:ce.y},style:{width:ce.w,height:ce.h},initialWidth:ce.w,initialHeight:ce.h,measured:{width:ce.w,height:ce.h},data:{label:ae.label,note:null,dim:!re(ae.id)},selectable:!1,draggable:!1,zIndex:0}]:[]}),fe=new Map;if(Y.flat){const ae=ce=>Y.branches&&ce.branch?1:0;for(const ce of e.map.areas){const he=e.map.nodes.filter(pe=>pe.area===ce.id&&Y.nodes[pe.id]).sort((pe,ye)=>ae(pe)-ae(ye)||Y.nodes[pe.id].x-Y.nodes[ye.id].x||Y.nodes[pe.id].y-Y.nodes[ye.id].y)[0];he&&fe.set(he.id,ce.label)}}const Ne=e.map.nodes.flatMap(ae=>{var ne,Ce,Me,Qe,Re,Be,Xe,lt,Se,pt,Jt,Jn,er,tr,_n;const ce=Y.nodes[ae.id];if(!ce)return[];const he=ae.evidence[0],pe=ae.symbol?ae.symbol.slice(ae.symbol.indexOf("#")+1):he?`${he.file.split("/").pop()}:${he.line}`:"not in the code yet",ye=(ne=e.report)==null?void 0:ne.nodes[ae.id],_e=ie("node",ae.id,!!ye&&(ye.status!=="unconfirmed"||!!ye.proposal)&&!k(((Ce=ye.change)==null?void 0:Ce.kind)??null)&&!E(ae.id));return[{id:ae.id,type:"step",...Y.flat?{}:{parentId:`area:${ae.area}`,extent:"parent"},position:{x:ce.x,y:ce.y},initialWidth:ce.w,initialHeight:ce.h,measured:{width:ce.w,height:ce.h},data:{name:ae.name,sub:pe,kind:ae.kind,confirmed:!!e.report&&((Me=e.report.nodes[ae.id])==null?void 0:Me.status)!=="unconfirmed",proposal:b(ae.id),screen:((Be=(Re=(Qe=e.report)==null?void 0:Qe.screens)==null?void 0:Re[ae.id])==null?void 0:Be.status)==="confirmed",selected:O.nodes.includes(ae.id),hl:!!(A!=null&&A.has(ae.id)),dim:!!A&&!A.has(ae.id)&&!O.nodes.includes(ae.id),fresh:e.fresh.includes(ae.id),change:k(((Se=(lt=(Xe=e.report)==null?void 0:Xe.nodes[ae.id])==null?void 0:lt.change)==null?void 0:Se.kind)??null),changeSize:RC((Jn=(Jt=(pt=e.report)==null?void 0:pt.nodes[ae.id])==null?void 0:Jt.change)==null?void 0:Jn.diff),ghost:E(ae.id),quiet:v==="both"?null:v,branch:_e,...Y.flat&&{journey:{w:ce.w,h:ce.h,shape:ae.kind==="choice"?"choice":ae.kind==="action"?"action":"screen",outside:ae.kind==="external",stage:fe.get(ae.id)??null,show:r.includes(ae.id)?((_n=(tr=(er=e.report)==null?void 0:er.screens)==null?void 0:tr[ae.id])==null?void 0:_n.show)??null:null,branch:_e}},onClick:bo=>e.onSelect("nodes",ae.id,bo),onHover:bo=>L("node",ae.id,bo)},draggable:!1,zIndex:3}]});return[...ke,...Ne]},[s,e.map,e.report,O,A,e.fresh,e.onSelect,r,v,w,U]),C=R.useMemo(()=>{var ye,_e;if(!s)return[];const Y=ne=>({type:bs.ArrowClosed,width:16,height:16,color:ne}),re=ne=>!!(I!=null&&I.has(ne)),ke=new Map,fe=(ne,Ce)=>{const Me=s.layout.rowTops,Qe=_a(s.layout,ne),Re=_a(s.layout,Ce);if(!Me||Qe===Re)return;const Be=Math.max(Qe,Re),Xe=ke.get(Be)??0;return ke.set(Be,Xe+1),Me[Be]-uc/2+(Xe%2?1:-1)*Math.ceil(Xe/2)*18},Ne=ne=>{var Ce;return((Ce=t==null?void 0:t.connects)==null?void 0:Ce.from)===ne.from&&t.connects.to===ne.to},ae=[...e.map.edges.map(ne=>({id:`e:${ne.id}`,from:ne.from,to:ne.to})),...e.map.absences.flatMap(ne=>ne.between&&!Ne(ne.between)?[{id:`a:${ne.id}`,from:ne.between.from,to:ne.between.to}]:[]),...t!=null&&t.connects?[{id:`x:${t.id}`,from:t.connects.from,to:t.connects.to}]:[]],ce=W0(e.map,s.layout,ae),he=ne=>ce.get(ne)??{sourceHandle:"sb",targetHandle:"tt",back:!1},pe=e.map.edges.map(ne=>{var Jt,Jn,er,tr;const Ce=!!e.report&&((Jt=e.report.edges[ne.id])==null?void 0:Jt.status)!=="unconfirmed",Me=he(`e:${ne.id}`),Qe=Me.loop,Re=b(ne.id),Be=k(((tr=(er=(Jn=e.report)==null?void 0:Jn.edges[ne.id])==null?void 0:er.change)==null?void 0:tr.kind)??null),Xe=E(ne.id)??E(ne.from)??E(ne.to),lt=re(ne.id)||!!A&&A.has(ne.from)&&A.has(ne.to)&&!I,Se="edge",pt=ie("edge",ne.id,!Be&&!Xe);return{id:`e:${ne.id}`,source:ne.from,target:ne.to,sourceHandle:Me.sourceHandle,targetHandle:Me.targetHandle,type:"link",className:cn("link",`link-${Se}`,Me.back&&"link-loop",!Ce&&"unconfirmed",al(Re),ll(Be),Xe&&"ghost",Vs(pt),re(ne.id)&&"hl",!!I&&!re(ne.id)&&"dim",O.edges.includes(ne.id)&&"selected"),markerEnd:Y(Xe?"var(--line)":pt?`var(--branch-${pt.colour})`:Qe?"var(--path)":(Re==null?void 0:Re.state)==="pending"&&Re.kind!=="remove"?"var(--ai)":Be==="added"?"var(--ok)":Be==="removed"?"var(--dead)":re(ne.id)?"var(--path)":"var(--line-strong)"),zIndex:1,data:{label:ne.label,loop:Qe,onHover:_n=>L("edge",ne.id,_n),wrapY:fe(ne.from,ne.to),route:Me.route,offset:Me.offset,branch:pt,variant:Se,proposal:Re,change:Be,ghost:Xe,confirmed:Ce,hl:lt,dim:!!I&&!re(ne.id)&&!O.edges.includes(ne.id),selected:O.edges.includes(ne.id),onClick:_n=>e.onSelect("edges",ne.id,_n)}}});for(const ne of e.map.absences){if(!ne.between||Ne(ne.between))continue;const Ce=((_e=(ye=e.report)==null?void 0:ye.absences[ne.id])==null?void 0:_e.status)==="confirmed";pe.push({id:`a:${ne.id}`,hidden:v==="before",source:ne.between.from,target:ne.between.to,sourceHandle:he(`a:${ne.id}`).sourceHandle,targetHandle:he(`a:${ne.id}`).targetHandle,type:"link",className:cn("link","link-absence",!Ce&&"unconfirmed",re(ne.id)&&"hl",!!I&&!re(ne.id)&&"dim",O.absences.includes(ne.id)&&"selected"),markerEnd:Y("var(--dead)"),zIndex:1,data:{label:XC(ne.claim),route:he(`a:${ne.id}`).route,offset:he(`a:${ne.id}`).offset,variant:"absence",confirmed:Ce,hl:re(ne.id),dim:!!I&&!re(ne.id)&&!O.absences.includes(ne.id),selected:O.absences.includes(ne.id),onClick:Me=>e.onSelect("absences",ne.id,Me)}})}if(t!=null&&t.connects&&pe.push({id:`g:${t.id}`,source:t.connects.from,target:t.connects.to,sourceHandle:he(`x:${t.id}`).sourceHandle,targetHandle:he(`x:${t.id}`).targetHandle,type:"link",className:"link link-ghost",markerEnd:Y("var(--ok)"),zIndex:2,data:{label:`+ ${t.connects.label}`,route:he(`x:${t.id}`).route,offset:he(`x:${t.id}`).offset,variant:"ghost",confirmed:!0,hl:!0,dim:!1,selected:!1}}),l.key===$)for(const ne of pe)ne.data&&l.at[ne.id]&&(ne.data.place=l.at[ne.id]);return pe},[s,e.map,e.report,O,I,A,t,e.onSelect,v,w,U,l,$]);R.useEffect(()=>{if(!s)return;let Y=0,re=0;const ke=()=>{const fe=[...document.querySelectorAll(".react-flow__edgelabel-renderer .link-label[data-id]")],Ne=fe.length>0&&fe.every(pe=>pe.offsetWidth>0)&&a.getNodes().every(pe=>{var ye,_e;return(_e=(ye=a.getInternalNode(pe.id))==null?void 0:ye.measured)==null?void 0:_e.width});if(Y++<2||!Ne){Y<60&&(re=requestAnimationFrame(ke));return}const ae=[],ce=[];for(const pe of a.getNodes()){const ye=a.getInternalNode(pe.id);if(!ye||pe.hidden)continue;const _e=ye.internals.positionAbsolute,ne=ye.measured.width??0,Ce=ye.measured.height??0;pe.type==="step"?ae.push({x:_e.x,y:_e.y,w:ne,h:Ce}):pe.type==="area"&&ce.push({x:_e.x,y:_e.y,w:Math.min(ne,280),h:40})}const he=fe.map(pe=>{var ne;const ye=document.getElementById(pe.dataset.id),_e=((ne=ye==null?void 0:ye.getTotalLength)==null?void 0:ne.call(ye))??0;return{id:pe.dataset.id,w:pe.offsetWidth,h:pe.offsetHeight,at:{x:Number(pe.dataset.x),y:Number(pe.dataset.y)},keep:pe.dataset.id.startsWith("a:"),along:Ce=>{if(!ye||!_e)return null;const Me=ye.getPointAtLength(_e*Ce);return{x:Me.x,y:Me.y}}}});u({key:$,at:Ad(he,ae,ce)})};return re=requestAnimationFrame(ke),()=>cancelAnimationFrame(re)},[$]);const B=xe(Y=>Y.width),J=R.useRef(0);R.useEffect(()=>{const Y=J.current;if(J.current=B,!Y||!B||Y===B||e.touring)return;const re=a.getViewport();a.setViewport({...re,x:re.x+(B-Y)/2})},[B]);const q=JSON.stringify([s==null?void 0:s.key,(X=e.view)==null?void 0:X.focus,(ee=e.view)==null?void 0:ee.highlight,e.touring,e.touring?B:null]),Z=R.useRef(!0);return R.useEffect(()=>{if(!s)return;const Y=e.view?Np(e.map,e.view.highlight.length?e.view.highlight:e.view.focus?[e.view.focus]:[]):[];let re=0,ke=0;const fe=()=>{var lt;const Ne=a.getNodes();if(re<2||!Ne.length||!Ne.every(Se=>{var pt,Jt;return(Jt=(pt=a.getInternalNode(Se.id))==null?void 0:pt.measured)==null?void 0:Jt.width})){re++<60&&(ke=requestAnimationFrame(fe));return}const ae=Z.current?0:650;Z.current=!1;const ce=s.layout.flat?Object.values(s.layout.nodes):Object.values(s.layout.areas),he=Object.values(s.layout.routes??{}).flatMap(Se=>Se.points),pe=he.map(Se=>Se[1]),ye=he.map(Se=>Se[0]),_e=Math.min(...ce.map(Se=>Se.y)),ne=Math.max(...ce.map(Se=>Se.y+Se.h)),Ce=he.length?Math.max(0,_e-Math.min(...pe)):0,Me=he.length?Math.max(0,Math.max(...pe)-ne)+16:0,Qe=he.length?Math.max(0,Math.min(...ce.map(Se=>Se.x))-Math.min(...ye)):0,Re=he.length?Math.max(0,Math.max(...ye)-Math.max(...ce.map(Se=>Se.x+Se.w))):0,Be=(lt=s.layout.branches)!=null&<.length?56:0,Xe=Y.length?{top:`${60+Be}px`,left:e.touring?YC:"60px",right:"60px",bottom:"150px"}:{top:`${64+Ce+Be}px`,left:`${32+Qe}px`,right:`${32+Re}px`,bottom:`${130+Me}px`};a.fitView(Y.length?{nodes:Y.map(Se=>({id:Se})),duration:ae,padding:Xe,maxZoom:1.15}:{duration:ae,padding:Xe,maxZoom:1.1})};return ke=requestAnimationFrame(fe),()=>cancelAnimationFrame(ke)},[q]),m.jsxs(c2,{className:s!=null&&s.layout.flat?"journey":s!=null&&s.layout.lanes?"lanes":void 0,nodes:G,edges:C,zIndexMode:"manual",nodeTypes:VC,edgeTypes:GC,onNodeClick:()=>{},onEdgeClick:(Y,re)=>{re.id.startsWith("e:")&&e.onSelect("edges",re.id.slice(2),Y.shiftKey||Y.metaKey),re.id.startsWith("a:")&&e.onSelect("absences",re.id.slice(2),Y.shiftKey||Y.metaKey)},onEdgeMouseEnter:(Y,re)=>{re.id.startsWith("e:")&&L("edge",re.id.slice(2),!0)},onEdgeMouseLeave:(Y,re)=>{re.id.startsWith("e:")&&L("edge",re.id.slice(2),!1)},onPaneClick:e.onClear,panOnDrag:!0,elementsSelectable:!1,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,maxZoom:2,children:[m.jsx(y2,{variant:xn.Dots,gap:22,size:1.3}),(((de=(me=e.report)==null?void 0:me.since)==null?void 0:de.commit)||p.length>0||U.length>0)&&m.jsx(Fs,{position:"top-left",children:m.jsxs("div",{className:"map-keys",children:[((ve=(ge=e.report)==null?void 0:ge.since)==null?void 0:ve.commit)&&m.jsx(PC,{commit:e.report.since.commit.slice(0,7),when:v,onWhen:d}),p.length>0&&m.jsx(FC,{views:p,plan:w,onPlan:h,shown:_}),se.length>0&&m.jsx(DC,{branches:se,journey:e.map.view==="journey"})]})})]})}function ul(e){e!==`${location.pathname}${location.search}`&&(history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")))}function KC(){const[e,t]=R.useState(location.pathname);return R.useEffect(()=>{const n=()=>t(location.pathname),r=o=>{var i,a;if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;const s=(a=(i=o.target)==null?void 0:i.closest)==null?void 0:a.call(i,"a[href]");!(s instanceof HTMLAnchorElement)||s.target||s.origin!==location.origin||(o.preventDefault(),ul(`${s.pathname}${s.search}`))};return window.addEventListener("popstate",n),document.addEventListener("click",r),()=>{window.removeEventListener("popstate",n),document.removeEventListener("click",r)}},[]),e}const ZC=8e3;function ow({busy:e,agentName:t="Claude",onStopped:n,onError:r}){const[o,s]=R.useState(!1);return R.useEffect(()=>{if(!o)return;const i=setTimeout(()=>s(!1),ZC),a=l=>{l.key==="Escape"&&s(!1)};return window.addEventListener("keydown",a),()=>{clearTimeout(i),window.removeEventListener("keydown",a)}},[o]),o&&!e?m.jsxs("span",{className:"stop-ask",role:"group","aria-label":"Stop illuminate?",children:[m.jsx("span",{className:"stop-ask-text",children:"Stop illuminate? Maps stay saved."}),m.jsx("button",{className:"pill-btn stop-yes",autoFocus:!0,onClick:()=>{s(!1),Wt.stop().then(n,i=>r(i.message))},children:"Stop"}),m.jsx("button",{className:"pill-btn",onClick:()=>s(!1),children:"Keep running"})]}):m.jsx("button",{className:"pill-btn",disabled:e,title:e?`${t} is still working`:"Maps stay saved. Undo for applied fixes ends.",onClick:()=>s(!0),children:"Stop illuminate"})}function QC(){return m.jsxs("main",{className:"home",children:[m.jsx("h1",{children:"illuminate has stopped"}),m.jsx("p",{className:"muted lede",children:"You can close this tab."}),m.jsxs("p",{className:"muted lede",children:["Maps are saved in ",m.jsx("code",{children:".illuminate/maps"}),". Run ",m.jsx("code",{children:"illume open"})," in the repo to see them again."]})]})}function JC({onStopped:e}){const[t,n]=R.useState(""),[r,o]=R.useState(null),[s,i]=R.useState([]),[a,l]=R.useState(""),[u,c]=R.useState(null),[d,f]=R.useState(!1),[h,p]=R.useState(L0);R.useEffect(()=>I0(()=>{},()=>{},e),[e]),R.useEffect(()=>{Wt.list().then(v=>{n(v.repo),o(v.maps),i(v.making),v.agent&&p(v.agent)},v=>c(v.message))},[]);const x=async()=>{if(a.trim()){f(!0);try{const{id:v}=await Wt.make(a.trim());ul(sn(v))}catch(v){c(v.message),f(!1)}}};return m.jsxs("main",{className:"home",children:[m.jsxs("div",{className:"home-brand",children:[m.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate",t&&m.jsx("span",{className:"muted",children:t})]}),m.jsx("h1",{children:"Ask how your code works"}),m.jsx("p",{className:"muted lede",children:"Every box and arrow is checked against the code."}),tl(h)?m.jsxs("p",{className:"home-ask chat-hint",children:[m.jsxs("strong",{children:["Ask for a new map in the ",h.name," chat beside this page"]})," ",m.jsx("span",{className:"muted",children:"for example: “Map what happens when a user signs up.”"})]}):m.jsxs("form",{className:"home-ask",onSubmit:v=>{v.preventDefault(),x()},children:[m.jsx("input",{id:"question",value:a,onChange:v=>l(v.target.value),placeholder:"What happens when a user signs up?","aria-label":"Your question",autoFocus:!0}),m.jsx("button",{className:"btn primary",disabled:d||!a.trim(),children:d?"Starting…":"Map it"})]}),u&&m.jsx("div",{className:"banner banner-dead",role:"alert",children:u}),s.length>0&&m.jsxs("section",{children:[m.jsx("h2",{className:"section-title",children:"Being made now"}),m.jsx("ul",{className:"maplist",children:s.map(v=>m.jsxs("li",{children:[m.jsx("a",{href:sn(v.id),children:v.question}),m.jsxs("span",{className:"muted small",children:[h.name," is exploring…"]})]},v.id))})]}),m.jsxs("section",{children:[m.jsx("h2",{className:"section-title",children:"Maps in this repo"}),r===null?m.jsx("p",{className:"muted",children:"Loading…"}):r.length===0?m.jsx("p",{className:"muted",children:"None yet."}):m.jsx("ul",{className:"maplist",children:r.map(v=>m.jsxs("li",{children:[m.jsx("a",{href:sn(v.id),children:v.question}),m.jsxs("span",{className:"muted small",children:[new Date(v.updatedAt).toLocaleString(),v.commit?` · ${v.commit.slice(0,7)}`:""]})]},v.id))})]}),m.jsx("footer",{className:"home-foot",children:m.jsx(ow,{busy:s.length>0,agentName:h.name,onStopped:e,onError:c})})]})}const _p="illuminate-panel-width",pc=300,sw=400,eM=360,Jl=e=>Math.round(Math.max(pc,Math.min(e,Math.max(pc,window.innerWidth-eM))));function tM(){const[e,t]=R.useState(()=>{const r=Number(localStorage.getItem(_p));return Jl(r>0?r:sw)}),n=R.useCallback(r=>{const o=Jl(r);t(o),localStorage.setItem(_p,String(o))},[]);return R.useEffect(()=>{const r=()=>t(o=>Jl(o));return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),[e,n]}function nM({width:e,onWidth:t}){return m.jsx("div",{className:"panel-handle",role:"separator","aria-orientation":"vertical","aria-label":"Panel width","aria-valuenow":e,"aria-valuemin":pc,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=i=>t(window.innerWidth-i.clientX),s=()=>{r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",s),r.removeEventListener("pointercancel",s),document.body.classList.remove("resizing")};r.addEventListener("pointermove",o),r.addEventListener("pointerup",s),r.addEventListener("pointercancel",s)},onDoubleClick:()=>t(sw),onKeyDown:n=>{n.key==="ArrowLeft"&&(n.preventDefault(),t(e+24)),n.key==="ArrowRight"&&(n.preventDefault(),t(e-24))}})}const rM=(...e)=>e.filter(Boolean).join(" ");function oM({map:e,stop:t,onTour:n,onAsk:r}){var i;const o=e.tour[t];if(!o)return null;const s=t===e.tour.length-1;return m.jsxs("section",{className:"card card-focus tour-bubble","aria-label":"Walkthrough","aria-live":"polite",children:[m.jsx("button",{className:"card-close","aria-label":"Leave the walkthrough",title:"Leave the walkthrough (Esc)",onClick:()=>n(null),children:"×"}),m.jsxs("div",{className:"tour-head",children:[m.jsxs("span",{className:"eyebrow",children:["Walkthrough, stop ",t+1," of ",e.tour.length]}),m.jsx("span",{className:"dots","aria-hidden":"true",children:e.tour.map((a,l)=>m.jsx("i",{className:rM(l===t&&"on",l<t&&"done")},a.id))})]}),m.jsx("h2",{className:"card-title",children:o.title}),m.jsx($s,{text:o.text,className:"depth-text"}),(i=o.terms)!=null&&i.length?m.jsxs("p",{className:"muted small",children:["Terms: ",o.terms.join(", ")]}):null,m.jsxs("div",{className:"tour-nav",children:[m.jsx("button",{className:"btn",disabled:t===0,onClick:()=>n(t-1),children:"‹ Back"}),r&&m.jsx("button",{className:"btn",onClick:r,children:"Ask about this step"}),m.jsx("span",{className:"grow"}),s?m.jsx("button",{className:"btn primary",onClick:()=>n(null),children:"Done"}):m.jsx("button",{className:"btn primary",onClick:()=>n(t+1),children:"Next ›"})]}),m.jsx("div",{className:"kbd",children:"← → to step, Esc to leave"})]})}function sM(){return wo?m.jsx(iM,{}):m.jsxs("main",{className:"home",children:[m.jsx("h1",{children:"Open illuminate from its link"}),m.jsxs("p",{className:"muted lede",children:["Use the link illuminate printed in your terminal (it ends in ",m.jsx("code",{children:"?t=…"}),")."]})]})}function iM(){const[e,t]=R.useState(!1),n=R.useCallback(()=>{window.close(),t(!0)},[]),r=KC();if(e)return m.jsx(QC,{});const o=/^\/m\/([a-z0-9-]{1,80})\/?$/.exec(r);return o?m.jsx(cM,{mapId:o[1],onStopped:n},o[1]):m.jsx(JC,{onStopped:n})}function aM({mapId:e,question:t,making:n}){const[r,o]=R.useState([]);R.useEffect(()=>{Wt.list().then(i=>o([...i.making.map(a=>({...a,making:!0})),...i.maps.map(a=>({id:a.id,question:a.question}))]),()=>{})},[e,n]);const s=r.some(i=>i.id===e)?r:[{id:e,question:t},...r];return m.jsx("select",{className:"switcher",value:e,onChange:i=>ul(sn(i.target.value)),"aria-label":"Switch to another map",title:"Switch to another map in this repo",children:s.map(i=>m.jsxs("option",{value:i.id,children:[i.question||i.id,i.making?" (being made)":""]},i.id))})}function lM({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,s=o?m.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,i=m.jsxs(m.Fragment,{children:[s,m.jsx(uM,{report:e})]});return t?m.jsxs(m.Fragment,{children:[m.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`}),i]}):m.jsxs(m.Fragment,{children:[m.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"}),i]})}function uM({report:e}){const t=e.since;if(!t)return null;if(!t.commit)return m.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},s=t.date?new Date(t.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):null,i=[n&&`${n} added`,r&&`${r} changed`,o&&`${o} removed`].filter(Boolean).join(" · ");return m.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),s?` (${s})`:"",i?`: ${i}`:": nothing on this map differs"]})}function cM({mapId:e,onStopped:t}){var A,O,U,W,oe,K,se,ie;const[n,r]=R.useReducer(Z$,e,G$),[o,s]=R.useState(""),[i,a]=tM(),l=R.useRef(!1),u=R.useCallback(()=>{Wt.get(e).then(G=>r({type:"loaded",payload:G}),G=>r(G instanceof T0&&/No such map/.test(G.message)?{type:"missing"}:{type:"error",message:G.message}))},[e]);R.useEffect(u,[u]),R.useEffect(()=>I0(G=>r({type:"event",event:G}),G=>{r({type:"connected",value:G}),G&&l.current===!1&&n.phase!=="loading"&&u(),l.current=G},t,e),[]);const c=n.map&&n.tour!==null?((A=n.map.tour[n.tour])==null?void 0:A.title)??null:null;R.useEffect(()=>{const G=n.phase==="ready"?U2(n.agent,n.selection,c):null;if(!G)return;const C=setTimeout(()=>void Wt.selection(e,G.selection,G.step).catch(()=>{}),250);return()=>clearTimeout(C)},[e,n.phase,n.agent,n.selection,c]);const d=tl(n.agent),[f,h]=R.useState(null);R.useEffect(()=>h(null),[n.tour]);const p=n.map&&n.tour!==null&&f===n.tour?((O=n.map.tour[n.tour])==null?void 0:O.title)??null:null,x=R.useCallback(G=>{const C=G.trim();if(!C||n.job)return;const B=p?f$(p,C):C;Wt.ask(e,B,n.selection).then(()=>s(""),J=>r({type:"error",message:J.message}))},[e,n.job,n.selection,p]),v=(G,C)=>{C==="approve"&&r({type:"fixStatus",fixId:G,status:"applying",problems:[]}),Wt[C](e,G).catch(B=>{r(C==="approve"?{type:"fixStatus",fixId:G,status:"failed",problems:B.problems.length?B.problems:[B.message]}:{type:"error",message:[B.message,...B.problems].join(" ")})})},w=(G,C)=>{Wt.offer(e,G,C).then(B=>{B.id&&ul(sn(B.id))},B=>r({type:"error",message:B.message}))};R.useEffect(()=>{const G=C=>{const B=C.target instanceof HTMLTextAreaElement||C.target instanceof HTMLInputElement;if(C.key==="Escape"){Do(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}B||n.tour===null||(C.key==="ArrowRight"&&r({type:"tour",stop:n.tour+1}),C.key==="ArrowLeft"&&r({type:"tour",stop:n.tour-1}))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[n.tour,n.peek,n.selection]);const y=n.answers.find(G=>G.id===n.shown),g=y!=null&&y.fix&&["proposed","applying","failed"].includes(((U=n.fixes[y.fix.id])==null?void 0:U.status)??"")?y.fix:null,b=R.useCallback((G,C,B)=>r({type:"select",kind:G,id:C,additive:B}),[]),E=R.useCallback(()=>r({type:"clearSelection"}),[]),k=K0(n),[S,$]=R.useState(null),_=X$(n),j=Y$(n),M=!!n.map&&n.tour!==null,z=R.useMemo(()=>({...n,answers:V2(n.agent,n.answers,n.fixes)}),[n]),F=n.shown!==null&&z.answers.some(G=>G.id===n.shown),N=((W=n.job)==null?void 0:W.kind)==="ask"&&!d,L=(!n.map||!!n.error||!!n.job&&(n.job.kind==="make"||N)||F)&&(!M||n.peek||!!n.error||N),D=L&&!!n.map,I=n.map&&d?m.jsx(uC,{map:n.map,agent:n.agent,selection:n.selection,step:c,onRemove:(G,C)=>r({type:"select",kind:G,id:C,additive:!0})}):n.map?m.jsx(lC,{map:n.map,selection:n.selection,draft:o,busy:!!n.job,agentName:n.agent.name,autoFocus:D,onDraft:s,onRemove:(G,C)=>r({type:"select",kind:G,id:C,additive:!0}),step:p,onRemoveStep:()=>h(null),onSend:()=>x(o)}):null;return m.jsx(C0,{children:m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("a",{className:"brand",href:sn(),title:"All maps in this repo",children:[m.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate"]}),m.jsxs("div",{className:"topbar-map",children:[((oe=n.meta)==null?void 0:oe.parent)&&m.jsxs("a",{className:"crumb",href:sn(n.meta.parent.mapId),title:`Back to the map this one came from: ${n.meta.parent.question}`,children:["← ",n.meta.parent.question]}),m.jsx(aM,{mapId:e,question:((K=n.map)==null?void 0:K.question)??((se=n.job)==null?void 0:se.question)??"",making:((ie=n.job)==null?void 0:ie.kind)==="make"})]}),m.jsx(lM,{report:n.report}),k&&m.jsx(IC,{mapId:e,map:k,report:n.report,added:_,version:S}),m.jsx("a",{className:"pill-btn",href:sn(),title:"Ask a new question and make a map for it",children:"New map"}),m.jsx(ow,{busy:!!n.job,agentName:n.agent.name,onStopped:t,onError:G=>r({type:"error",message:G})}),m.jsx("span",{className:n.connected?"live on":"live",title:n.connected?"Connected to illuminate":"Reconnecting to illuminate…"})]}),m.jsxs("div",{className:L?"body":"body full",style:{"--panel-w":`${i}px`},children:[m.jsx("div",{className:"canvas",children:n.map&&k?m.jsxs(m.Fragment,{children:[m.jsx(qC,{map:k,report:n.report,selection:n.selection,view:j,fresh:n.fresh,added:_,ghost:g??null,touring:M,onSelect:b,onClear:E,onVersion:$}),!L&&m.jsx(pC,{state:z,dispatch:r}),Do(n.selection)>0&&m.jsx(yC,{mapId:e,map:k,report:n.report,selection:n.selection,onClose:E}),M&&Do(n.selection)===0&&m.jsx(oM,{map:n.map,stop:n.tour,onTour:G=>r({type:"tour",stop:G}),onAsk:d?void 0:()=>{var G;h(n.tour),(G=document.getElementById("ask"))==null||G.focus()}}),m.jsx(hC,{map:n.map,mapId:e,tour:n.tour,onTour:G=>r({type:"tour",stop:G}),selected:Do(n.selection),children:D?null:I})]}):m.jsx("div",{className:"empty",children:n.phase==="making"?m.jsxs("div",{className:"pulse",children:[n.agent.name," is exploring the code…"]}):null})}),L&&m.jsx(nM,{width:i,onWidth:a}),L&&m.jsx(nC,{state:z,dispatch:r,onFix:v,onFocus:G=>r({type:"focus",id:G}),onOffer:w,composer:D?I:null})]})]})})}Fm(document.getElementById("root")).render(m.jsx(R.StrictMode,{children:m.jsx(sM,{})}));export{Bd as c,gc as g};
|
|
83
|
-
//# sourceMappingURL=index-
|
|
82
|
+
`)}async function AC(e,t,n,r){return MC(e,t,await G0(e,[],n),r)}function jC(e,t){const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function TC(e){const t=new Image;await new Promise((s,i)=>{t.onload=()=>s(),t.onerror=()=>i(new Error("The picture couldn't be drawn.")),t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`});const n=2,r=document.createElement("canvas");r.width=Math.ceil(t.naturalWidth*n),r.height=Math.ceil(t.naturalHeight*n);const o=r.getContext("2d");if(!o)throw new Error("This browser can't draw the picture.");return o.scale(n,n),o.drawImage(t,0,0),new Promise((s,i)=>r.toBlob(a=>a?s(a):i(new Error("The picture couldn't be saved.")),"image/png"))}function IC({mapId:e,map:t,report:n,added:r,version:o}){const[s,i]=R.useState(!1),a=R.useMemo(()=>tw(t,n),[t,n]),l=a.find(b=>o&&b.version.when===o.when&&b.version.plan===o.plan)??a.find(b=>b.id==="both")??a[0],[u,c]=R.useState(null),d=a.find(b=>b.id===u)??l,[f,h]=R.useState(!1),[p,x]=R.useState(!1),[v,w]=R.useState(null),y=R.useRef(null);R.useEffect(()=>{if(!s)return;const b=k=>{var S;return!((S=y.current)!=null&&S.contains(k.target))&&i(!1)},E=k=>k.key==="Escape"&&i(!1);return document.addEventListener("mousedown",b),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",E)}},[s]);const g=async(b,E)=>{x(!0),w(null);try{const k=new Date().toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),S=await AC(t,n,new Set(r),{theme:E,notes:f,checkedOn:k,...d?{version:d.version}:{}}),$=d&&a.length>1?`-${d.label.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`:"",_=`${e}${$}${E==="dark"?"-dark":""}.${b}`;jC(_,b==="svg"?new Blob([S],{type:"image/svg+xml"}):await TC(S)),i(!1)}catch(k){w(k instanceof Error?k.message:String(k))}finally{x(!1)}};return m.jsxs("div",{className:"export",ref:y,children:[m.jsx("button",{className:"pill-btn","aria-expanded":s,"aria-haspopup":"menu",title:"Save this map as a picture for documentation",onClick:()=>{s||c(null),i(!s)},children:"Export"}),s&&m.jsxs("div",{className:"export-menu",role:"menu",children:[m.jsx("p",{className:"export-note",children:"A picture of the map, with a transparent background. Labels with no room are numbered and listed under it."}),a.length>1&&d&&m.jsxs("div",{className:"export-row",children:[m.jsx("span",{className:"export-theme",children:"Version"}),m.jsx("div",{className:"seg",role:"group","aria-label":"Which version to export",children:a.map(b=>m.jsx("button",{className:b.id===d.id?"seg-btn on":"seg-btn","aria-pressed":b.id===d.id,title:b.title,onClick:()=>c(b.id),children:b.label},b.id))})]}),["light","dark"].map(b=>m.jsxs("div",{className:"export-row",children:[m.jsx("span",{className:"export-theme",children:b==="light"?"For light pages":"For dark pages"}),m.jsx("button",{className:"pill-btn small",role:"menuitem",disabled:p,onClick:()=>void g("svg",b),children:"SVG"}),m.jsx("button",{className:"pill-btn small",role:"menuitem",disabled:p,onClick:()=>void g("png",b),children:"PNG"})]},b)),m.jsxs("label",{className:"export-notes",children:[m.jsx("input",{type:"checkbox",checked:f,onChange:b=>h(b.target.checked)})," Add each box's explanation under the map"]}),v&&m.jsx("p",{className:"export-problem",children:v})]})]})}const cn=(...e)=>e.filter(Boolean).join(" "),yr={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"}},al=e=>e&&`proposal proposal-${e.kind} proposal-${e.state}${e.quiet&&e.state==="pending"?" proposal-quiet":""}`,LC={add:"New",change:"Changed",remove:"Removed"},wr={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"}},ll=e=>e&&`change change-${e}`,$a={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"},unbuilt:{label:"Not built yet",title:"Proposed: only there with the change"},other:{label:"Other option",title:"Part of another option of the change, not this one"},dropped:{label:"Would go",title:"Proposed to be removed: not there with the change"}};function RC(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 OC=[["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 PC({commit:e,when:t,onWhen:n}){return m.jsxs("div",{className:"change-key",children:[m.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the code to show",children:OC.map(([r,o,s])=>m.jsx("button",{className:cn("seg-btn",t===r&&"on"),title:s,"aria-pressed":t===r,onClick:()=>n(r),children:o},r))}),m.jsx("span",{className:"change-key-title",children:t==="before"?`The code at ${e}`:t==="after"?"The code now":`Now, compared with ${e}`}),t==="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch"}),"Same as before"]}),t==="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-added"}),"Added"]}),m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:cn("key-swatch key-changed",t!=="both"&&"key-quiet")}),t==="before"?"Changes later":"Changed"]}),t==="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-removed"}),"Removed (only in the before)"]}),t!=="both"&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),t==="before"?"Not there yet":"Gone"]})]})}const zC=5,Vs=e=>e&&`branch branch-${e.colour}`;function DC({branches:e,journey:t}){return m.jsxs("div",{className:"change-key branch-key",children:[m.jsx("span",{className:"change-key-title",children:"Ways through"}),t?m.jsxs("span",{className:"key-item",title:"What most people do, start to finish",children:[m.jsx("i",{className:"key-swatch"}),"Main path"]}):m.jsxs("span",{className:"key-item",title:"On every way through",children:[m.jsx("i",{className:"key-swatch"}),"Shared"]}),e.map(n=>m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:cn("key-swatch",Vs(n))}),n.name]},n.name))]})}function FC({views:e,plan:t,onPlan:n,shown:r}){return m.jsxs("div",{className:"change-key plan-key",children:[m.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the proposal to show",children:e.map(o=>{const{label:s,title:i}=hc(o);return m.jsx("button",{className:cn("seg-btn",t===o&&"on"),title:i,"aria-pressed":t===o,onClick:()=>n(o),children:s},o)})}),m.jsx("span",{className:"change-key-title",children:hc(t).heading}),r.has("new")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-new"}),"New"]}),r.has("unbuilt")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),"Not built yet"]}),r.has("other")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),"Other option"]}),r.has("dropped")&&m.jsxs("span",{className:"key-item",children:[m.jsx("i",{className:"key-swatch key-ghost"}),"Would go"]})]})}const Ei={entry:["Where it starts","▸"],store:["Saved data","▤"],external:["Outside the app","↗"],job:["Background job","◷"]},Ep=[["t",ue.Top],["r",ue.Right],["b",ue.Bottom],["l",ue.Left]];function rw(){return m.jsxs(m.Fragment,{children:[Ep.map(([e,t])=>m.jsx(yo,{id:`s${e}`,type:"source",position:t,className:"handle",isConnectable:!1},`s${e}`)),Ep.map(([e,t])=>m.jsx(yo,{id:`t${e}`,type:"target",position:t,className:"handle",isConnectable:!1},`t${e}`))]})}function BC({data:e}){var t,n,r;return e.journey?m.jsx(HC,{data:e}):m.jsxs("div",{className:cn("step","nopan",`kind-${e.kind}`,!e.confirmed&&"unconfirmed",al(e.proposal),ll(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(e.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),onClick:o=>{o.stopPropagation(),e.onClick(o.shiftKey||o.metaKey)},onMouseEnter:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!0)},onMouseLeave:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!1)},children:[m.jsx(rw,{}),(Ei[e.kind]||e.fresh||e.screen||e.proposal||e.change||e.ghost)&&m.jsxs("div",{className:"step-head",children:[e.ghost&&m.jsx("span",{className:"badge-ghost",title:$a[e.ghost].title,children:$a[e.ghost].label}),e.proposal&&m.jsx("span",{className:"badge-proposal",children:e.proposal.quiet&&e.proposal.state==="pending"?LC[e.proposal.kind]:yr[e.proposal.kind][e.proposal.state]}),e.change&&m.jsxs("span",{className:"badge-change",title:wr[e.change].title,children:[e.quiet==="before"?"Changes later":wr[e.change].label,e.changeSize&&!e.quiet&&m.jsxs("span",{className:"change-size",children:[" ",e.changeSize]})]}),Ei[e.kind]&&!e.proposal&&!e.change&&!e.ghost&&m.jsxs(m.Fragment,{children:[m.jsx("i",{className:"step-mark","aria-hidden":"true",children:Ei[e.kind][1]}),Ei[e.kind][0]]}),e.screen&&m.jsx("span",{className:"badge-screen",title:"Select this step to see the screen",children:"▣ Screen"}),e.fresh&&m.jsx("span",{className:"badge-new",children:"New"})]}),m.jsx("div",{className:"step-name",title:e.name,children:e.name}),m.jsxs("div",{className:"step-code",title:((t=e.proposal)==null?void 0:t.state)==="pending"?yr[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"||e.ghost==="unbuilt"||e.ghost==="other"?m.jsx("span",{className:"pmark",children:"+"}):((r=e.proposal)==null?void 0:r.state)==="done"&&e.proposal.kind!=="add"?m.jsx("span",{className:"pmark",children:yr[e.proposal.kind].mark}):e.change&&e.confirmed?m.jsx("span",{className:"cmark",children:wr[e.change].mark}):m.jsx("span",{className:e.confirmed?"tick":"qmark",children:e.confirmed?"✓":"?"}),m.jsx("span",{className:"step-sub",children:e.sub})]})]})}function HC({data:e}){const t=e.journey,n=e.proposal;return m.jsxs("div",{className:cn("step","jstep","nopan",`j-${t.shape}`,t.show&&"j-pictured",t.outside&&"j-outside",!e.confirmed&&"unconfirmed",al(n),ll(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(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)},onMouseEnter:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!0)},onMouseLeave:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!1)},children:[m.jsx(rw,{}),t.stage&&m.jsx("div",{className:"j-stage",children:t.stage}),t.shape==="choice"&&m.jsx("svg",{className:"j-diamond",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:m.jsx("polygon",{points:"50,1 99,50 50,99 1,50",vectorEffect:"non-scaling-stroke"})}),m.jsxs("div",{className:"j-tags",children:[n&&m.jsx("span",{className:"badge-proposal",children:yr[n.kind][n.state]}),e.ghost&&m.jsx("span",{className:"badge-ghost",title:$a[e.ghost].title,children:$a[e.ghost].label}),e.change&&m.jsx("span",{className:"badge-change",title:wr[e.change].title,children:e.quiet==="before"?"Changes later":wr[e.change].label}),!e.confirmed&&m.jsx("span",{className:"j-q",title:"The checker couldn't confirm this against the code",children:"?"}),e.fresh&&m.jsx("span",{className:"badge-new",children:"New"})]}),t.show&&m.jsx(o$,{show:t.show,name:e.name}),m.jsx("div",{className:"j-name",title:e.name,children:e.name}),t.outside&&t.shape!=="choice"&&m.jsx("div",{className:"j-note",children:"Outside the app"})]})}function UC({data:e}){return m.jsx("div",{className:cn("area",e.dim&&"dim"),children:m.jsxs("div",{className:"area-label",children:[e.label,e.note&&m.jsxs("span",{className:"area-note",children:[" ",e.note]})]})})}function WC({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,markerEnd:a,data:l}){const[u,c,d]=!l||l.loop||l.route||l.wrapY===void 0?U0(t,n,s,r,o,i,{loop:l==null?void 0:l.loop,route:l==null?void 0:l.route,offset:l==null?void 0:l.offset}):s===ue.Right?H0([[t,n],[t+30,n],[t+30,l.wrapY],[r,l.wrapY],[r,o]]):ka({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i,borderRadius:18,centerY:l.wrapY});if(!l)return null;const f=l.place&&l.place!=="dot"?l.place:null,h=(l.place==="dot"||typeof l.place=="object"&&"dot"in l.place)&&!l.selected;return m.jsxs(m.Fragment,{children:[l.selected&&m.jsx("path",{d:u,className:"edge-halo"}),m.jsx(Hs,{id:e,path:u,markerEnd:a,interactionWidth:18}),m.jsx(f2,{children:m.jsxs("div",{className:cn("link-label",h&&"dot",`link-${l.variant}`,!l.confirmed&&"unconfirmed",al(l.proposal),ll(l.change),l.ghost&&"ghost",Vs(l.branch),l.hl&&"hl",l.dim&&"dim",l.selected&&"selected","nodrag nopan"),"data-id":e,"data-x":c,"data-y":d,title:h?l.label:void 0,onMouseEnter:l.onHover&&(()=>l.onHover(!0)),onMouseLeave:l.onHover&&(()=>l.onHover(!1)),style:{transform:`translate(-50%, -50%) translate(${(f==null?void 0:f.x)??c}px, ${(f==null?void 0:f.y)??d}px)`},onClick:p=>{var x;p.stopPropagation(),(x=l.onClick)==null||x.call(l,p.shiftKey||p.metaKey)},children:[l.variant==="absence"&&m.jsx("span",{className:"gap-q","aria-hidden":"true",children:"?"}),l.proposal&&!(l.proposal.quiet&&l.proposal.state==="pending"&&l.proposal.kind==="add")&&m.jsx("span",{className:"pmark",title:l.proposal.state==="done"?yr[l.proposal.kind].done:yr[l.proposal.kind].title,children:l.proposal.state==="done"&&l.proposal.kind==="add"?"✓":yr[l.proposal.kind].mark}),l.change&&m.jsx("span",{className:"cmark",title:wr[l.change].title,children:wr[l.change].mark}),m.jsx("span",{className:"link-text",children:l.label}),!l.confirmed&&l.variant==="edge"&&m.jsx("span",{className:"q",children:" ?"})]})})]})}const VC={step:BC,area:UC},GC={link:WC};function Np(e,t){const n=new Set;for(const r of t){e.nodes.some(i=>i.id===r)&&n.add(r);const o=e.edges.find(i=>i.id===r);o&&n.add(o.from).add(o.to);const s=e.absences.find(i=>i.id===r);s!=null&&s.between&&n.add(s.between.from).add(s.between.to)}return[...n]}const YC="440px",XC=e=>e.length>28?`${e.slice(0,26)}…`:e;function qC(e){var T,H,V,X,ee,me,de,ge,ve;const t=(T=e.ghost)!=null&&T.connects&&e.map.nodes.some(Y=>Y.id===e.ghost.connects.from)&&e.map.nodes.some(Y=>Y.id===e.ghost.connects.to)?e.ghost:null,n=R.useMemo(()=>t!=null&&t.connects?[{id:t.id,from:t.connects.from,to:t.connects.to}]:[],[t]),r=R.useMemo(()=>e.map.view==="journey"?e.map.nodes.filter(Y=>{var re,ke,fe;return Y.kind!=="action"&&Y.kind!=="choice"&&((fe=(ke=(re=e.report)==null?void 0:re.screens)==null?void 0:ke[Y.id])==null?void 0:fe.status)==="confirmed"}).map(Y=>Y.id):[],[e.map,e.report]),o=V$(e.map,n,e.added,r),[s,i]=R.useState(null),a=Bs(),[l,u]=R.useState({key:"",at:{}}),[c,d]=R.useState("both");il(e.report);const[f,h]=R.useState("both"),p=R.useMemo(()=>Id(e.map,e.report),[e.map,e.report]),x=nw(e.map,e.report,{when:c,plan:f}),v=x.when,w=x.plan,{wayOf:y,proposalOf:g}=x,b=x.proposal,E=x.ghost,k=x.drawnAs,S=e.onVersion;R.useEffect(()=>S==null?void 0:S({when:v,plan:w}),[v,w,S]);const $=JSON.stringify([(s==null?void 0:s.key)??null,v,w,(t==null?void 0:t.id)??null]),_=new Set;if(w!=="both")for(const Y of e.map.nodes.map(re=>re.id)){const re=Td(w,g(Y),y(Y));re?_.add(re):((H=b(Y))==null?void 0:H.kind)==="add"&&_.add("new")}R.useEffect(()=>{let Y=!0;return G0(e.map,n,new Set(e.added),new Set(r)).then(re=>Y&&i({key:o,layout:re}),re=>console.error("illuminate: the map could not be laid out",re)),()=>{Y=!1}},[o]);const j=R.useMemo(()=>!s||s.layout.flat||s.layout.lanes?new Set:sl(e.map),[e.map,s]),M=R.useMemo(()=>[...j].flatMap(Y=>q0(e.map,Y)??[]),[j,e.map]),z=Y=>M.find(re=>re.edges.includes(Y))??null,F=R.useRef(void 0),N=R.useRef([]),P=R.useRef(z);P.current=z;const L=(Y,re,ke)=>{window.clearTimeout(F.current),F.current=window.setTimeout(()=>{for(const he of N.current)he.classList.remove("pointed");if(N.current=[],!ke)return;const fe=Y==="edge"?P.current(re):null,Ne=fe?fe.nodes:Y==="node"?[re]:[],ae=fe?fe.edges:Y==="edge"?[re]:[],ce=[...Ne.flatMap(he=>[...document.querySelectorAll(`.react-flow__node[data-id="${CSS.escape(he)}"] .step`)]),...ae.flatMap(he=>[...document.querySelectorAll(`.react-flow__edge[data-id="${CSS.escape(`e:${he}`)}"], .link-label[data-id="${CSS.escape(`e:${he}`)}"]`)])];for(const he of ce)he.classList.add("pointed");N.current=ce},ke?150:80)};R.useEffect(()=>()=>window.clearTimeout(F.current),[]);const D=e.selection.edges.map(z).find(Y=>!!Y)??null,I=D?new Set([...D.nodes,...D.edges]):(V=e.view)!=null&&V.highlight.length?new Set(e.view.highlight):null,A=R.useMemo(()=>I?new Set(Np(e.map,[...I])):null,[I,e.map]),O=e.selection,U=R.useMemo(()=>((s==null?void 0:s.layout.branches)??[]).map((Y,re)=>({name:Y,colour:re%zC+1})),[s]),W=p.some(Y=>Y.startsWith("option:")),oe=Y=>!W||w==="both"||w===`option:${Y}`,K=Y=>Y&&oe(Y)?U.find(re=>re.name===Y)??null:null,se=U.filter(Y=>oe(Y.name)),ie=(Y,re,ke)=>{var ae;if(!U.length||!ke)return null;if(Y==="node")return K((ae=e.map.nodes.find(ce=>ce.id===re))==null?void 0:ae.branch);const fe=e.map.edges.find(ce=>ce.id===re),Ne=ce=>{var he;return(he=e.map.nodes.find(pe=>pe.id===ce))==null?void 0:he.branch};return K((fe==null?void 0:fe.branch)??Ne(fe==null?void 0:fe.to)??Ne(fe==null?void 0:fe.from))},G=R.useMemo(()=>{if(!s)return[];const Y=s.layout,re=ae=>!A||e.map.nodes.some(ce=>ce.area===ae&&A.has(ce.id)),ke=e.map.areas.flatMap(ae=>{const ce=Y.areas[ae.id];return ce?[{id:`area:${ae.id}`,type:"area",position:{x:ce.x,y:ce.y},style:{width:ce.w,height:ce.h},initialWidth:ce.w,initialHeight:ce.h,measured:{width:ce.w,height:ce.h},data:{label:ae.label,note:null,dim:!re(ae.id)},selectable:!1,draggable:!1,zIndex:0}]:[]}),fe=new Map;if(Y.flat){const ae=ce=>Y.branches&&ce.branch?1:0;for(const ce of e.map.areas){const he=e.map.nodes.filter(pe=>pe.area===ce.id&&Y.nodes[pe.id]).sort((pe,ye)=>ae(pe)-ae(ye)||Y.nodes[pe.id].x-Y.nodes[ye.id].x||Y.nodes[pe.id].y-Y.nodes[ye.id].y)[0];he&&fe.set(he.id,ce.label)}}const Ne=e.map.nodes.flatMap(ae=>{var ne,Ce,Me,Qe,Re,Be,Xe,lt,Se,pt,Jt,Jn,er,tr,_n;const ce=Y.nodes[ae.id];if(!ce)return[];const he=ae.evidence[0],pe=ae.symbol?ae.symbol.slice(ae.symbol.indexOf("#")+1):he?`${he.file.split("/").pop()}:${he.line}`:"not in the code yet",ye=(ne=e.report)==null?void 0:ne.nodes[ae.id],_e=ie("node",ae.id,!!ye&&(ye.status!=="unconfirmed"||!!ye.proposal)&&!k(((Ce=ye.change)==null?void 0:Ce.kind)??null)&&!E(ae.id));return[{id:ae.id,type:"step",...Y.flat?{}:{parentId:`area:${ae.area}`,extent:"parent"},position:{x:ce.x,y:ce.y},initialWidth:ce.w,initialHeight:ce.h,measured:{width:ce.w,height:ce.h},data:{name:ae.name,sub:pe,kind:ae.kind,confirmed:!!e.report&&((Me=e.report.nodes[ae.id])==null?void 0:Me.status)!=="unconfirmed",proposal:b(ae.id),screen:((Be=(Re=(Qe=e.report)==null?void 0:Qe.screens)==null?void 0:Re[ae.id])==null?void 0:Be.status)==="confirmed",selected:O.nodes.includes(ae.id),hl:!!(A!=null&&A.has(ae.id)),dim:!!A&&!A.has(ae.id)&&!O.nodes.includes(ae.id),fresh:e.fresh.includes(ae.id),change:k(((Se=(lt=(Xe=e.report)==null?void 0:Xe.nodes[ae.id])==null?void 0:lt.change)==null?void 0:Se.kind)??null),changeSize:RC((Jn=(Jt=(pt=e.report)==null?void 0:pt.nodes[ae.id])==null?void 0:Jt.change)==null?void 0:Jn.diff),ghost:E(ae.id),quiet:v==="both"?null:v,branch:_e,...Y.flat&&{journey:{w:ce.w,h:ce.h,shape:ae.kind==="choice"?"choice":ae.kind==="action"?"action":"screen",outside:ae.kind==="external",stage:fe.get(ae.id)??null,show:r.includes(ae.id)?((_n=(tr=(er=e.report)==null?void 0:er.screens)==null?void 0:tr[ae.id])==null?void 0:_n.show)??null:null,branch:_e}},onClick:bo=>e.onSelect("nodes",ae.id,bo),onHover:bo=>L("node",ae.id,bo)},draggable:!1,zIndex:3}]});return[...ke,...Ne]},[s,e.map,e.report,O,A,e.fresh,e.onSelect,r,v,w,U]),C=R.useMemo(()=>{var ye,_e;if(!s)return[];const Y=ne=>({type:bs.ArrowClosed,width:16,height:16,color:ne}),re=ne=>!!(I!=null&&I.has(ne)),ke=new Map,fe=(ne,Ce)=>{const Me=s.layout.rowTops,Qe=_a(s.layout,ne),Re=_a(s.layout,Ce);if(!Me||Qe===Re)return;const Be=Math.max(Qe,Re),Xe=ke.get(Be)??0;return ke.set(Be,Xe+1),Me[Be]-uc/2+(Xe%2?1:-1)*Math.ceil(Xe/2)*18},Ne=ne=>{var Ce;return((Ce=t==null?void 0:t.connects)==null?void 0:Ce.from)===ne.from&&t.connects.to===ne.to},ae=[...e.map.edges.map(ne=>({id:`e:${ne.id}`,from:ne.from,to:ne.to})),...e.map.absences.flatMap(ne=>ne.between&&!Ne(ne.between)?[{id:`a:${ne.id}`,from:ne.between.from,to:ne.between.to}]:[]),...t!=null&&t.connects?[{id:`x:${t.id}`,from:t.connects.from,to:t.connects.to}]:[]],ce=W0(e.map,s.layout,ae),he=ne=>ce.get(ne)??{sourceHandle:"sb",targetHandle:"tt",back:!1},pe=e.map.edges.map(ne=>{var Jt,Jn,er,tr;const Ce=!!e.report&&((Jt=e.report.edges[ne.id])==null?void 0:Jt.status)!=="unconfirmed",Me=he(`e:${ne.id}`),Qe=Me.loop,Re=b(ne.id),Be=k(((tr=(er=(Jn=e.report)==null?void 0:Jn.edges[ne.id])==null?void 0:er.change)==null?void 0:tr.kind)??null),Xe=E(ne.id)??E(ne.from)??E(ne.to),lt=re(ne.id)||!!A&&A.has(ne.from)&&A.has(ne.to)&&!I,Se="edge",pt=ie("edge",ne.id,!Be&&!Xe);return{id:`e:${ne.id}`,source:ne.from,target:ne.to,sourceHandle:Me.sourceHandle,targetHandle:Me.targetHandle,type:"link",className:cn("link",`link-${Se}`,Me.back&&"link-loop",!Ce&&"unconfirmed",al(Re),ll(Be),Xe&&"ghost",Vs(pt),re(ne.id)&&"hl",!!I&&!re(ne.id)&&"dim",O.edges.includes(ne.id)&&"selected"),markerEnd:Y(Xe?"var(--line)":pt?`var(--branch-${pt.colour})`:Qe?"var(--path)":(Re==null?void 0:Re.state)==="pending"&&Re.kind!=="remove"?"var(--ai)":Be==="added"?"var(--ok)":Be==="removed"?"var(--dead)":re(ne.id)?"var(--path)":"var(--line-strong)"),zIndex:1,data:{label:ne.label,loop:Qe,onHover:_n=>L("edge",ne.id,_n),wrapY:fe(ne.from,ne.to),route:Me.route,offset:Me.offset,branch:pt,variant:Se,proposal:Re,change:Be,ghost:Xe,confirmed:Ce,hl:lt,dim:!!I&&!re(ne.id)&&!O.edges.includes(ne.id),selected:O.edges.includes(ne.id),onClick:_n=>e.onSelect("edges",ne.id,_n)}}});for(const ne of e.map.absences){if(!ne.between||Ne(ne.between))continue;const Ce=((_e=(ye=e.report)==null?void 0:ye.absences[ne.id])==null?void 0:_e.status)==="confirmed";pe.push({id:`a:${ne.id}`,hidden:v==="before",source:ne.between.from,target:ne.between.to,sourceHandle:he(`a:${ne.id}`).sourceHandle,targetHandle:he(`a:${ne.id}`).targetHandle,type:"link",className:cn("link","link-absence",!Ce&&"unconfirmed",re(ne.id)&&"hl",!!I&&!re(ne.id)&&"dim",O.absences.includes(ne.id)&&"selected"),markerEnd:Y("var(--dead)"),zIndex:1,data:{label:XC(ne.claim),route:he(`a:${ne.id}`).route,offset:he(`a:${ne.id}`).offset,variant:"absence",confirmed:Ce,hl:re(ne.id),dim:!!I&&!re(ne.id)&&!O.absences.includes(ne.id),selected:O.absences.includes(ne.id),onClick:Me=>e.onSelect("absences",ne.id,Me)}})}if(t!=null&&t.connects&&pe.push({id:`g:${t.id}`,source:t.connects.from,target:t.connects.to,sourceHandle:he(`x:${t.id}`).sourceHandle,targetHandle:he(`x:${t.id}`).targetHandle,type:"link",className:"link link-ghost",markerEnd:Y("var(--ok)"),zIndex:2,data:{label:`+ ${t.connects.label}`,route:he(`x:${t.id}`).route,offset:he(`x:${t.id}`).offset,variant:"ghost",confirmed:!0,hl:!0,dim:!1,selected:!1}}),l.key===$)for(const ne of pe)ne.data&&l.at[ne.id]&&(ne.data.place=l.at[ne.id]);return pe},[s,e.map,e.report,O,I,A,t,e.onSelect,v,w,U,l,$]);R.useEffect(()=>{if(!s)return;let Y=0,re=0;const ke=()=>{const fe=[...document.querySelectorAll(".react-flow__edgelabel-renderer .link-label[data-id]")],Ne=fe.length>0&&fe.every(pe=>pe.offsetWidth>0)&&a.getNodes().every(pe=>{var ye,_e;return(_e=(ye=a.getInternalNode(pe.id))==null?void 0:ye.measured)==null?void 0:_e.width});if(Y++<2||!Ne){Y<60&&(re=requestAnimationFrame(ke));return}const ae=[],ce=[];for(const pe of a.getNodes()){const ye=a.getInternalNode(pe.id);if(!ye||pe.hidden)continue;const _e=ye.internals.positionAbsolute,ne=ye.measured.width??0,Ce=ye.measured.height??0;pe.type==="step"?ae.push({x:_e.x,y:_e.y,w:ne,h:Ce}):pe.type==="area"&&ce.push({x:_e.x,y:_e.y,w:Math.min(ne,280),h:40})}const he=fe.map(pe=>{var ne;const ye=document.getElementById(pe.dataset.id),_e=((ne=ye==null?void 0:ye.getTotalLength)==null?void 0:ne.call(ye))??0;return{id:pe.dataset.id,w:pe.offsetWidth,h:pe.offsetHeight,at:{x:Number(pe.dataset.x),y:Number(pe.dataset.y)},keep:pe.dataset.id.startsWith("a:"),along:Ce=>{if(!ye||!_e)return null;const Me=ye.getPointAtLength(_e*Ce);return{x:Me.x,y:Me.y}}}});u({key:$,at:Ad(he,ae,ce)})};return re=requestAnimationFrame(ke),()=>cancelAnimationFrame(re)},[$]);const B=xe(Y=>Y.width),J=R.useRef(0);R.useEffect(()=>{const Y=J.current;if(J.current=B,!Y||!B||Y===B||e.touring)return;const re=a.getViewport();a.setViewport({...re,x:re.x+(B-Y)/2})},[B]);const q=JSON.stringify([s==null?void 0:s.key,(X=e.view)==null?void 0:X.focus,(ee=e.view)==null?void 0:ee.highlight,e.touring,e.touring?B:null]),Z=R.useRef(!0);return R.useEffect(()=>{if(!s)return;const Y=e.view?Np(e.map,e.view.highlight.length?e.view.highlight:e.view.focus?[e.view.focus]:[]):[];let re=0,ke=0;const fe=()=>{var lt;const Ne=a.getNodes();if(re<2||!Ne.length||!Ne.every(Se=>{var pt,Jt;return(Jt=(pt=a.getInternalNode(Se.id))==null?void 0:pt.measured)==null?void 0:Jt.width})){re++<60&&(ke=requestAnimationFrame(fe));return}const ae=Z.current?0:650;Z.current=!1;const ce=s.layout.flat?Object.values(s.layout.nodes):Object.values(s.layout.areas),he=Object.values(s.layout.routes??{}).flatMap(Se=>Se.points),pe=he.map(Se=>Se[1]),ye=he.map(Se=>Se[0]),_e=Math.min(...ce.map(Se=>Se.y)),ne=Math.max(...ce.map(Se=>Se.y+Se.h)),Ce=he.length?Math.max(0,_e-Math.min(...pe)):0,Me=he.length?Math.max(0,Math.max(...pe)-ne)+16:0,Qe=he.length?Math.max(0,Math.min(...ce.map(Se=>Se.x))-Math.min(...ye)):0,Re=he.length?Math.max(0,Math.max(...ye)-Math.max(...ce.map(Se=>Se.x+Se.w))):0,Be=(lt=s.layout.branches)!=null&<.length?56:0,Xe=Y.length?{top:`${60+Be}px`,left:e.touring?YC:"60px",right:"60px",bottom:"150px"}:{top:`${64+Ce+Be}px`,left:`${32+Qe}px`,right:`${32+Re}px`,bottom:`${130+Me}px`};a.fitView(Y.length?{nodes:Y.map(Se=>({id:Se})),duration:ae,padding:Xe,maxZoom:1.15}:{duration:ae,padding:Xe,maxZoom:1.1})};return ke=requestAnimationFrame(fe),()=>cancelAnimationFrame(ke)},[q]),m.jsxs(c2,{className:s!=null&&s.layout.flat?"journey":s!=null&&s.layout.lanes?"lanes":void 0,nodes:G,edges:C,zIndexMode:"manual",nodeTypes:VC,edgeTypes:GC,onNodeClick:()=>{},onEdgeClick:(Y,re)=>{re.id.startsWith("e:")&&e.onSelect("edges",re.id.slice(2),Y.shiftKey||Y.metaKey),re.id.startsWith("a:")&&e.onSelect("absences",re.id.slice(2),Y.shiftKey||Y.metaKey)},onEdgeMouseEnter:(Y,re)=>{re.id.startsWith("e:")&&L("edge",re.id.slice(2),!0)},onEdgeMouseLeave:(Y,re)=>{re.id.startsWith("e:")&&L("edge",re.id.slice(2),!1)},onPaneClick:e.onClear,panOnDrag:!0,elementsSelectable:!1,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,maxZoom:2,children:[m.jsx(y2,{variant:xn.Dots,gap:22,size:1.3}),(((de=(me=e.report)==null?void 0:me.since)==null?void 0:de.commit)||p.length>0||U.length>0)&&m.jsx(Fs,{position:"top-left",children:m.jsxs("div",{className:"map-keys",children:[((ve=(ge=e.report)==null?void 0:ge.since)==null?void 0:ve.commit)&&m.jsx(PC,{commit:e.report.since.commit.slice(0,7),when:v,onWhen:d}),p.length>0&&m.jsx(FC,{views:p,plan:w,onPlan:h,shown:_}),se.length>0&&m.jsx(DC,{branches:se,journey:e.map.view==="journey"})]})})]})}function ul(e){e!==`${location.pathname}${location.search}`&&(history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")))}function KC(){const[e,t]=R.useState(location.pathname);return R.useEffect(()=>{const n=()=>t(location.pathname),r=o=>{var i,a;if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;const s=(a=(i=o.target)==null?void 0:i.closest)==null?void 0:a.call(i,"a[href]");!(s instanceof HTMLAnchorElement)||s.target||s.hasAttribute("download")||s.protocol!==location.protocol||s.origin!==location.origin||(o.preventDefault(),ul(`${s.pathname}${s.search}`))};return window.addEventListener("popstate",n),document.addEventListener("click",r),()=>{window.removeEventListener("popstate",n),document.removeEventListener("click",r)}},[]),e}const ZC=8e3;function ow({busy:e,agentName:t="Claude",onStopped:n,onError:r}){const[o,s]=R.useState(!1);return R.useEffect(()=>{if(!o)return;const i=setTimeout(()=>s(!1),ZC),a=l=>{l.key==="Escape"&&s(!1)};return window.addEventListener("keydown",a),()=>{clearTimeout(i),window.removeEventListener("keydown",a)}},[o]),o&&!e?m.jsxs("span",{className:"stop-ask",role:"group","aria-label":"Stop illuminate?",children:[m.jsx("span",{className:"stop-ask-text",children:"Stop illuminate? Maps stay saved."}),m.jsx("button",{className:"pill-btn stop-yes",autoFocus:!0,onClick:()=>{s(!1),Wt.stop().then(n,i=>r(i.message))},children:"Stop"}),m.jsx("button",{className:"pill-btn",onClick:()=>s(!1),children:"Keep running"})]}):m.jsx("button",{className:"pill-btn",disabled:e,title:e?`${t} is still working`:"Maps stay saved. Undo for applied fixes ends.",onClick:()=>s(!0),children:"Stop illuminate"})}function QC(){return m.jsxs("main",{className:"home",children:[m.jsx("h1",{children:"illuminate has stopped"}),m.jsx("p",{className:"muted lede",children:"You can close this tab."}),m.jsxs("p",{className:"muted lede",children:["Maps are saved in ",m.jsx("code",{children:".illuminate/maps"}),". Run ",m.jsx("code",{children:"illume open"})," in the repo to see them again."]})]})}function JC({onStopped:e}){const[t,n]=R.useState(""),[r,o]=R.useState(null),[s,i]=R.useState([]),[a,l]=R.useState(""),[u,c]=R.useState(null),[d,f]=R.useState(!1),[h,p]=R.useState(L0);R.useEffect(()=>I0(()=>{},()=>{},e),[e]),R.useEffect(()=>{Wt.list().then(v=>{n(v.repo),o(v.maps),i(v.making),v.agent&&p(v.agent)},v=>c(v.message))},[]);const x=async()=>{if(a.trim()){f(!0);try{const{id:v}=await Wt.make(a.trim());ul(sn(v))}catch(v){c(v.message),f(!1)}}};return m.jsxs("main",{className:"home",children:[m.jsxs("div",{className:"home-brand",children:[m.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate",t&&m.jsx("span",{className:"muted",children:t})]}),m.jsx("h1",{children:"Ask how your code works"}),m.jsx("p",{className:"muted lede",children:"Every box and arrow is checked against the code."}),tl(h)?m.jsxs("p",{className:"home-ask chat-hint",children:[m.jsxs("strong",{children:["Ask for a new map in the ",h.name," chat beside this page"]})," ",m.jsx("span",{className:"muted",children:"for example: “Map what happens when a user signs up.”"})]}):m.jsxs("form",{className:"home-ask",onSubmit:v=>{v.preventDefault(),x()},children:[m.jsx("input",{id:"question",value:a,onChange:v=>l(v.target.value),placeholder:"What happens when a user signs up?","aria-label":"Your question",autoFocus:!0}),m.jsx("button",{className:"btn primary",disabled:d||!a.trim(),children:d?"Starting…":"Map it"})]}),u&&m.jsx("div",{className:"banner banner-dead",role:"alert",children:u}),s.length>0&&m.jsxs("section",{children:[m.jsx("h2",{className:"section-title",children:"Being made now"}),m.jsx("ul",{className:"maplist",children:s.map(v=>m.jsxs("li",{children:[m.jsx("a",{href:sn(v.id),children:v.question}),m.jsxs("span",{className:"muted small",children:[h.name," is exploring…"]})]},v.id))})]}),m.jsxs("section",{children:[m.jsx("h2",{className:"section-title",children:"Maps in this repo"}),r===null?m.jsx("p",{className:"muted",children:"Loading…"}):r.length===0?m.jsx("p",{className:"muted",children:"None yet."}):m.jsx("ul",{className:"maplist",children:r.map(v=>m.jsxs("li",{children:[m.jsx("a",{href:sn(v.id),children:v.question}),m.jsxs("span",{className:"muted small",children:[new Date(v.updatedAt).toLocaleString(),v.commit?` · ${v.commit.slice(0,7)}`:""]})]},v.id))})]}),m.jsx("footer",{className:"home-foot",children:m.jsx(ow,{busy:s.length>0,agentName:h.name,onStopped:e,onError:c})})]})}const _p="illuminate-panel-width",pc=300,sw=400,eM=360,Jl=e=>Math.round(Math.max(pc,Math.min(e,Math.max(pc,window.innerWidth-eM))));function tM(){const[e,t]=R.useState(()=>{const r=Number(localStorage.getItem(_p));return Jl(r>0?r:sw)}),n=R.useCallback(r=>{const o=Jl(r);t(o),localStorage.setItem(_p,String(o))},[]);return R.useEffect(()=>{const r=()=>t(o=>Jl(o));return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),[e,n]}function nM({width:e,onWidth:t}){return m.jsx("div",{className:"panel-handle",role:"separator","aria-orientation":"vertical","aria-label":"Panel width","aria-valuenow":e,"aria-valuemin":pc,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=i=>t(window.innerWidth-i.clientX),s=()=>{r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",s),r.removeEventListener("pointercancel",s),document.body.classList.remove("resizing")};r.addEventListener("pointermove",o),r.addEventListener("pointerup",s),r.addEventListener("pointercancel",s)},onDoubleClick:()=>t(sw),onKeyDown:n=>{n.key==="ArrowLeft"&&(n.preventDefault(),t(e+24)),n.key==="ArrowRight"&&(n.preventDefault(),t(e-24))}})}const rM=(...e)=>e.filter(Boolean).join(" ");function oM({map:e,stop:t,onTour:n,onAsk:r}){var i;const o=e.tour[t];if(!o)return null;const s=t===e.tour.length-1;return m.jsxs("section",{className:"card card-focus tour-bubble","aria-label":"Walkthrough","aria-live":"polite",children:[m.jsx("button",{className:"card-close","aria-label":"Leave the walkthrough",title:"Leave the walkthrough (Esc)",onClick:()=>n(null),children:"×"}),m.jsxs("div",{className:"tour-head",children:[m.jsxs("span",{className:"eyebrow",children:["Walkthrough, stop ",t+1," of ",e.tour.length]}),m.jsx("span",{className:"dots","aria-hidden":"true",children:e.tour.map((a,l)=>m.jsx("i",{className:rM(l===t&&"on",l<t&&"done")},a.id))})]}),m.jsx("h2",{className:"card-title",children:o.title}),m.jsx($s,{text:o.text,className:"depth-text"}),(i=o.terms)!=null&&i.length?m.jsxs("p",{className:"muted small",children:["Terms: ",o.terms.join(", ")]}):null,m.jsxs("div",{className:"tour-nav",children:[m.jsx("button",{className:"btn",disabled:t===0,onClick:()=>n(t-1),children:"‹ Back"}),r&&m.jsx("button",{className:"btn",onClick:r,children:"Ask about this step"}),m.jsx("span",{className:"grow"}),s?m.jsx("button",{className:"btn primary",onClick:()=>n(null),children:"Done"}):m.jsx("button",{className:"btn primary",onClick:()=>n(t+1),children:"Next ›"})]}),m.jsx("div",{className:"kbd",children:"← → to step, Esc to leave"})]})}function sM(){return wo?m.jsx(iM,{}):m.jsxs("main",{className:"home",children:[m.jsx("h1",{children:"Open illuminate from its link"}),m.jsxs("p",{className:"muted lede",children:["Use the link illuminate printed in your terminal (it ends in ",m.jsx("code",{children:"?t=…"}),")."]})]})}function iM(){const[e,t]=R.useState(!1),n=R.useCallback(()=>{window.close(),t(!0)},[]),r=KC();if(e)return m.jsx(QC,{});const o=/^\/m\/([a-z0-9-]{1,80})\/?$/.exec(r);return o?m.jsx(cM,{mapId:o[1],onStopped:n},o[1]):m.jsx(JC,{onStopped:n})}function aM({mapId:e,question:t,making:n}){const[r,o]=R.useState([]);R.useEffect(()=>{Wt.list().then(i=>o([...i.making.map(a=>({...a,making:!0})),...i.maps.map(a=>({id:a.id,question:a.question}))]),()=>{})},[e,n]);const s=r.some(i=>i.id===e)?r:[{id:e,question:t},...r];return m.jsx("select",{className:"switcher",value:e,onChange:i=>ul(sn(i.target.value)),"aria-label":"Switch to another map",title:"Switch to another map in this repo",children:s.map(i=>m.jsxs("option",{value:i.id,children:[i.question||i.id,i.making?" (being made)":""]},i.id))})}function lM({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,s=o?m.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,i=m.jsxs(m.Fragment,{children:[s,m.jsx(uM,{report:e})]});return t?m.jsxs(m.Fragment,{children:[m.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`}),i]}):m.jsxs(m.Fragment,{children:[m.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"}),i]})}function uM({report:e}){const t=e.since;if(!t)return null;if(!t.commit)return m.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},s=t.date?new Date(t.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):null,i=[n&&`${n} added`,r&&`${r} changed`,o&&`${o} removed`].filter(Boolean).join(" · ");return m.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),s?` (${s})`:"",i?`: ${i}`:": nothing on this map differs"]})}function cM({mapId:e,onStopped:t}){var A,O,U,W,oe,K,se,ie;const[n,r]=R.useReducer(Z$,e,G$),[o,s]=R.useState(""),[i,a]=tM(),l=R.useRef(!1),u=R.useCallback(()=>{Wt.get(e).then(G=>r({type:"loaded",payload:G}),G=>r(G instanceof T0&&/No such map/.test(G.message)?{type:"missing"}:{type:"error",message:G.message}))},[e]);R.useEffect(u,[u]),R.useEffect(()=>I0(G=>r({type:"event",event:G}),G=>{r({type:"connected",value:G}),G&&l.current===!1&&n.phase!=="loading"&&u(),l.current=G},t,e),[]);const c=n.map&&n.tour!==null?((A=n.map.tour[n.tour])==null?void 0:A.title)??null:null;R.useEffect(()=>{const G=n.phase==="ready"?U2(n.agent,n.selection,c):null;if(!G)return;const C=setTimeout(()=>void Wt.selection(e,G.selection,G.step).catch(()=>{}),250);return()=>clearTimeout(C)},[e,n.phase,n.agent,n.selection,c]);const d=tl(n.agent),[f,h]=R.useState(null);R.useEffect(()=>h(null),[n.tour]);const p=n.map&&n.tour!==null&&f===n.tour?((O=n.map.tour[n.tour])==null?void 0:O.title)??null:null,x=R.useCallback(G=>{const C=G.trim();if(!C||n.job)return;const B=p?f$(p,C):C;Wt.ask(e,B,n.selection).then(()=>s(""),J=>r({type:"error",message:J.message}))},[e,n.job,n.selection,p]),v=(G,C)=>{C==="approve"&&r({type:"fixStatus",fixId:G,status:"applying",problems:[]}),Wt[C](e,G).catch(B=>{r(C==="approve"?{type:"fixStatus",fixId:G,status:"failed",problems:B.problems.length?B.problems:[B.message]}:{type:"error",message:[B.message,...B.problems].join(" ")})})},w=(G,C)=>{Wt.offer(e,G,C).then(B=>{B.id&&ul(sn(B.id))},B=>r({type:"error",message:B.message}))};R.useEffect(()=>{const G=C=>{const B=C.target instanceof HTMLTextAreaElement||C.target instanceof HTMLInputElement;if(C.key==="Escape"){Do(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}B||n.tour===null||(C.key==="ArrowRight"&&r({type:"tour",stop:n.tour+1}),C.key==="ArrowLeft"&&r({type:"tour",stop:n.tour-1}))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[n.tour,n.peek,n.selection]);const y=n.answers.find(G=>G.id===n.shown),g=y!=null&&y.fix&&["proposed","applying","failed"].includes(((U=n.fixes[y.fix.id])==null?void 0:U.status)??"")?y.fix:null,b=R.useCallback((G,C,B)=>r({type:"select",kind:G,id:C,additive:B}),[]),E=R.useCallback(()=>r({type:"clearSelection"}),[]),k=K0(n),[S,$]=R.useState(null),_=X$(n),j=Y$(n),M=!!n.map&&n.tour!==null,z=R.useMemo(()=>({...n,answers:V2(n.agent,n.answers,n.fixes)}),[n]),F=n.shown!==null&&z.answers.some(G=>G.id===n.shown),N=((W=n.job)==null?void 0:W.kind)==="ask"&&!d,L=(!n.map||!!n.error||!!n.job&&(n.job.kind==="make"||N)||F)&&(!M||n.peek||!!n.error||N),D=L&&!!n.map,I=n.map&&d?m.jsx(uC,{map:n.map,agent:n.agent,selection:n.selection,step:c,onRemove:(G,C)=>r({type:"select",kind:G,id:C,additive:!0})}):n.map?m.jsx(lC,{map:n.map,selection:n.selection,draft:o,busy:!!n.job,agentName:n.agent.name,autoFocus:D,onDraft:s,onRemove:(G,C)=>r({type:"select",kind:G,id:C,additive:!0}),step:p,onRemoveStep:()=>h(null),onSend:()=>x(o)}):null;return m.jsx(C0,{children:m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("a",{className:"brand",href:sn(),title:"All maps in this repo",children:[m.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate"]}),m.jsxs("div",{className:"topbar-map",children:[((oe=n.meta)==null?void 0:oe.parent)&&m.jsxs("a",{className:"crumb",href:sn(n.meta.parent.mapId),title:`Back to the map this one came from: ${n.meta.parent.question}`,children:["← ",n.meta.parent.question]}),m.jsx(aM,{mapId:e,question:((K=n.map)==null?void 0:K.question)??((se=n.job)==null?void 0:se.question)??"",making:((ie=n.job)==null?void 0:ie.kind)==="make"})]}),m.jsx(lM,{report:n.report}),k&&m.jsx(IC,{mapId:e,map:k,report:n.report,added:_,version:S}),m.jsx("a",{className:"pill-btn",href:sn(),title:"Ask a new question and make a map for it",children:"New map"}),m.jsx(ow,{busy:!!n.job,agentName:n.agent.name,onStopped:t,onError:G=>r({type:"error",message:G})}),m.jsx("span",{className:n.connected?"live on":"live",title:n.connected?"Connected to illuminate":"Reconnecting to illuminate…"})]}),m.jsxs("div",{className:L?"body":"body full",style:{"--panel-w":`${i}px`},children:[m.jsx("div",{className:"canvas",children:n.map&&k?m.jsxs(m.Fragment,{children:[m.jsx(qC,{map:k,report:n.report,selection:n.selection,view:j,fresh:n.fresh,added:_,ghost:g??null,touring:M,onSelect:b,onClear:E,onVersion:$}),!L&&m.jsx(pC,{state:z,dispatch:r}),Do(n.selection)>0&&m.jsx(yC,{mapId:e,map:k,report:n.report,selection:n.selection,onClose:E}),M&&Do(n.selection)===0&&m.jsx(oM,{map:n.map,stop:n.tour,onTour:G=>r({type:"tour",stop:G}),onAsk:d?void 0:()=>{var G;h(n.tour),(G=document.getElementById("ask"))==null||G.focus()}}),m.jsx(hC,{map:n.map,mapId:e,tour:n.tour,onTour:G=>r({type:"tour",stop:G}),selected:Do(n.selection),children:D?null:I})]}):m.jsx("div",{className:"empty",children:n.phase==="making"?m.jsxs("div",{className:"pulse",children:[n.agent.name," is exploring the code…"]}):null})}),L&&m.jsx(nM,{width:i,onWidth:a}),L&&m.jsx(nC,{state:z,dispatch:r,onFix:v,onFocus:G=>r({type:"focus",id:G}),onOffer:w,composer:D?I:null})]})]})})}Fm(document.getElementById("root")).render(m.jsx(R.StrictMode,{children:m.jsx(sM,{})}));export{Bd as c,gc as g};
|
|
83
|
+
//# sourceMappingURL=index-yApq3qEc.js.map
|