archik 0.12.45 → 0.12.47
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.
|
@@ -223,4 +223,4 @@ ${MXn(p)}
|
|
|
223
223
|
`)}function NXn(h,b){const p=b.get(h.from)?.name??h.from,v=b.get(h.to)?.name??h.to,T=h.label!==void 0?`: ${h.label}`:"",M=h.status&&h.status!=="active"?` _(${h.status})_`:"";return`- ${p} **${h.relationship}** ${v}${T}${M}`}function IXn(h){const b=new Map;for(const v of h.nodes)b.set(v.id,v);const p=[];if(p.push(`# ${h.name}`),h.description!==void 0&&p.push("",h.description),p.push("","## Components"),h.nodes.length===0)p.push("","_No components yet._");else for(const v of h.nodes)p.push("",_Xn(v));if(p.push("","## Connections"),h.edges.length===0)p.push("","_No connections yet._");else{p.push("");for(const v of h.edges)p.push(NXn(v,b))}return`${p.join(`
|
|
224
224
|
`)}
|
|
225
225
|
`}const DXn={name:"yaml",label:"YAML",extension:".yaml",mime:"application/yaml",export:G7e},$Xn={name:"json",label:"JSON",extension:".json",mime:"application/json",export:p0n},LXn={name:"markdown",label:"Markdown",extension:".md",mime:"text/markdown",export:IXn},RXn=[DXn,$Xn,LXn];function S0n({document:h,filename:b,getSvg:p}){const v=async j=>{try{await navigator.clipboard.writeText(j)}catch{}},T=()=>{const j=p?.();j&&g1n(w1n(b,"svg"),CXn(j))},M=async()=>{const j=p?.();if(j)try{const P=await OXn(j);g1n(w1n(b,"png"),P)}catch(P){console.error("PNG export failed:",P)}};return R.jsx(TT,{trigger:j=>R.jsxs("button",{type:"button",className:"archik-btn",children:["Export",R.jsx("span",{style:{opacity:.6},children:j?"▴":"▾"})]}),children:j=>R.jsxs(R.Fragment,{children:[h&&RXn.map(P=>R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{v(P.export(h)),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Copy"}),R.jsx("span",{children:P.label})]},P.name)),h&&R.jsxs(R.Fragment,{children:[R.jsx("hr",{style:{border:0,borderTop:"1px solid var(--archik-border)",margin:"4px 0"}}),R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{qZn(b,h),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),R.jsx("span",{children:"YAML"})]})]}),p&&R.jsxs(R.Fragment,{children:[R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{T(),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),R.jsx("span",{children:"SVG"})]}),R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{M(),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),R.jsx("span",{children:"PNG"})]})]})]})})}const E0n="archik-density",A0n="archik-view-mode",T0n="archik-show-stereotype-bands",dI=1,R8e="detailed",P8e=!1;function PXn(){if(typeof localStorage>"u")return P8e;try{const h=localStorage.getItem(T0n);return h==="true"?!0:h==="false"?!1:P8e}catch{return P8e}}function zXn(h){if(!(typeof localStorage>"u"))try{localStorage.setItem(T0n,h?"true":"false")}catch{}}function BXn(){if(typeof localStorage>"u")return R8e;try{return localStorage.getItem(A0n)==="compact"?"compact":R8e}catch{return R8e}}function FXn(h){if(!(typeof localStorage>"u"))try{localStorage.setItem(A0n,h)}catch{}}function qXn(){if(typeof localStorage>"u")return dI;try{const h=localStorage.getItem(E0n);if(!h)return dI;const b=Number.parseFloat(h);return Number.isFinite(b)?J7e(b):dI}catch{return dI}}function GXn(h){if(!(typeof localStorage>"u"))try{localStorage.setItem(E0n,String(J7e(h)))}catch{}}function J7e(h){return Math.max(.3,Math.min(4,h))}function UXn(h){const b=J7e(h);return{nodeSpacing:Math.round(60*b),layerSpacing:Math.round(100*b),padding:Math.round(40*b)}}function JXn({density:h,onChange:b}){const p=Math.round(h*100);return R.jsx(TT,{align:"end",trigger:v=>R.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":v,title:"Layout density",children:["Spacing",R.jsxs("span",{style:{opacity:.6},children:[p,"%"]})]}),children:()=>R.jsxs("div",{style:{minWidth:240,padding:8},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:6},children:[R.jsx("span",{className:"archik-label",style:{margin:0},children:"Node spacing"}),R.jsxs("span",{className:"archik-mono",style:{fontSize:11,color:"var(--archik-fg-dim)"},children:[p,"%"]})]}),R.jsx("input",{type:"range",min:.3,max:4,step:.1,value:h,onChange:v=>b(Number.parseFloat(v.target.value)),style:{width:"100%",accentColor:"var(--archik-accent)"}}),R.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--archik-fg-muted)",marginTop:4},children:[R.jsx("span",{children:"tight"}),R.jsx("span",{children:"roomy"})]}),R.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:R.jsx("button",{type:"button",className:"archik-btn",onClick:()=>b(dI),disabled:h===dI,children:"Reset"})})]})})}function HXn(){return R.jsx(TT,{align:"end",trigger:h=>R.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":h,children:["Legend",R.jsx("span",{style:{opacity:.6},children:h?"▴":"▾"})]}),children:()=>R.jsxs("div",{style:{minWidth:320,maxHeight:"min(70vh, 520px)",overflowY:"auto",padding:6},children:[R.jsx("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"4px 6px 8px",zIndex:1},children:"Node kinds"}),q7e.map(h=>{const b=Np[h],p=b.icon;return R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 80px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[R.jsx("span",{"aria-hidden":"true",style:{display:"flex",alignItems:"center",justifyContent:"center",color:b.color},children:R.jsx(p,{size:14,strokeWidth:1.8})}),R.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:h}),R.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:b.description})]},h)}),R.jsx(ZXn,{})]})})}const KXn=[{id:"boundary",varName:"--archik-stereotype-boundary",description:"talks to actors / external systems (UIs, adapters)"},{id:"control",varName:"--archik-stereotype-control",description:"orchestration logic between boundaries and entities"},{id:"entity",varName:"--archik-stereotype-entity",description:"long-lived domain state (modules, databases)"}];function ZXn(){return R.jsxs(R.Fragment,{children:[R.jsx("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"12px 6px 8px",marginTop:6,borderTop:"1px solid var(--archik-border)"},children:"Stereotype (ECB)"}),KXn.map(h=>R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 80px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[R.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:12,height:12,borderRadius:3,background:`var(${h.varName})`}}),R.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:h.id}),R.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:h.description})]},h.id))]})}function XXn({size:h=22}){return R.jsxs("svg",{width:h,height:h,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Archik",style:{display:"block"},children:[R.jsx("path",{d:"M 12 5 L 5 18",stroke:"var(--archik-accent)",strokeWidth:"1.4",strokeLinecap:"round"}),R.jsx("path",{d:"M 12 5 L 19 18",stroke:"var(--archik-accent-bright)",strokeWidth:"1.4",strokeLinecap:"round"}),R.jsx("path",{d:"M 5 18 L 19 18",stroke:"var(--archik-magenta)",strokeWidth:"1.2",strokeLinecap:"round",strokeDasharray:"2.5 2.5"}),R.jsx("circle",{cx:"12",cy:"5",r:"2.6",fill:"var(--archik-accent)"}),R.jsx("circle",{cx:"5",cy:"18",r:"2.6",fill:"var(--archik-accent-bright)"}),R.jsx("circle",{cx:"19",cy:"18",r:"2.6",fill:"var(--archik-magenta)"})]})}const VXn="archik-theme";function a7e(){return typeof document>"u"?"dark":document.documentElement.getAttribute("data-theme")==="light"?"light":"dark"}function WXn(h){if(!(typeof document>"u")){document.documentElement.setAttribute("data-theme",h);try{localStorage.setItem(VXn,h)}catch{}}}function YXn(){const h=a7e()==="dark"?"light":"dark";return WXn(h),h}function QXn(){const[h,b]=lt.useState(()=>a7e());lt.useEffect(()=>{b(a7e())},[]);const p=()=>{b(YXn())},v=h==="dark"?"Light theme":"Dark theme",T=h==="dark"?"☀":"☾";return R.jsx("button",{type:"button",onClick:p,title:v,"aria-label":v,className:"archik-btn",style:{minWidth:30,justifyContent:"center"},children:R.jsx("span",{"aria-hidden":"true",children:T})})}const eVn="/__archik/usecases",nVn="/__archik/trace";async function p1n(h,b){const p=await fetch(h,{cache:"no-store",signal:b});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function tVn(){const[h,b]=lt.useState({status:"loading"}),[p,v]=lt.useState(0);return lt.useEffect(()=>{let T=!1;const M=new AbortController;return Promise.all([p1n(eVn,M.signal),p1n(nVn,M.signal)]).then(([j,P])=>{T||b({status:"ready",useCases:j.useCases??[],trace:P.rows??[]})}).catch(j=>{T||M.signal.aborted||b({status:"error",message:j instanceof Error?j.message:String(j)})}),()=>{T=!0,M.abort()}},[p]),R.jsx(TT,{align:"end",trigger:T=>R.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":T,onClick:()=>{T||v(M=>M+1)},children:[R.jsx(iVn,{state:h}),R.jsx("span",{style:{opacity:.6,marginLeft:6},children:T?"▴":"▾"})]}),children:()=>R.jsx(rVn,{state:h})})}function iVn({state:h}){if(h.status!=="ready"||h.trace.length===0)return R.jsx(R.Fragment,{children:"Use cases"});const b=x0n(h.trace);return b.none>0?R.jsxs("span",{title:`${b.none} untraced — needs tests + seq`,children:["Use cases"," ",R.jsxs("span",{style:{color:"var(--archik-danger)"},children:["○ ",b.none," untraced"]})]}):b.partial>0?R.jsxs("span",{title:`${b.partial} partial — missing test or realisation`,children:["Use cases"," ",R.jsxs("span",{style:{color:"var(--archik-warning)"},children:["◐ ",b.partial," to finish"]})]}):R.jsxs("span",{title:`All ${b.full} slices traced — ready to ship`,children:["Use cases"," ",R.jsx("span",{style:{color:"var(--archik-success)",fontWeight:600},children:"✓ all traced"})]})}function x0n(h){let b=0,p=0,v=0;for(const T of h)T.level==="full"?b++:T.level==="partial"?p++:v++;return{full:b,partial:p,none:v}}function rVn({state:h}){return R.jsxs("div",{style:{minWidth:360,maxHeight:"min(70vh, 560px)",overflowY:"auto",padding:6},children:[R.jsx(aVn,{label:"Use cases",children:R.jsx("a",{href:"/__archik/usecases",style:{fontSize:10,letterSpacing:"0.04em",textTransform:"none",color:"var(--archik-accent)",textDecoration:"none",fontWeight:500},title:"Open the full use cases page (clickable test paths + seq links)",children:"Open page →"})}),h.status==="loading"&&R.jsx(z8e,{children:"Loading…"}),h.status==="error"&&R.jsxs(z8e,{tone:"error",children:["Couldn't load: ",h.message]}),h.status==="ready"&&h.useCases.length===0&&R.jsxs(z8e,{children:["No use cases defined. Add a ",R.jsx("code",{children:"*.archik.uc.yaml"})," file under"," ",R.jsx("code",{children:".archik/usecases/"}),"."]}),h.status==="ready"&&h.useCases.length>0&&R.jsxs(R.Fragment,{children:[R.jsx(cVn,{trace:h.trace}),R.jsx(uVn,{useCases:h.useCases,trace:h.trace})]})]})}function cVn({trace:h}){const b=lt.useMemo(()=>x0n(h),[h]),p=h.length;return p===0?R.jsx(R.Fragment,{}):R.jsxs("div",{title:"Coverage matrix — same as `npx archik trace`. ● fully traced (test + seq), ◐ partial, ○ untraced.",style:{display:"flex",alignItems:"center",gap:12,padding:"6px 10px",margin:"2px 2px 6px",borderRadius:6,background:"var(--archik-surface)",fontSize:11,color:"var(--archik-fg-dim)"},children:[R.jsx("span",{style:{fontWeight:600,color:"var(--archik-fg)"},children:"Trace"}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",b.full," full"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",b.partial," partial"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",b.none," untraced"]}),R.jsxs("span",{style:{marginLeft:"auto",color:"var(--archik-fg-muted)"},children:[p," ",p===1?"slice":"slices"]})]})}function uVn({useCases:h,trace:b}){const p=lt.useMemo(()=>{const v=new Map;for(const T of b)v.set(`${T.useCase}/${T.slice}`,T.level);return v},[b]);return R.jsx("div",{children:h.map(v=>R.jsx(sVn,{uc:v,traceByKey:p},v.id))})}function sVn({uc:h,traceByKey:b}){return R.jsxs("div",{style:{padding:"8px 8px 6px",borderTop:"1px solid var(--archik-border)"},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,marginBottom:2},children:[R.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,color:"var(--archik-fg)"},children:h.id}),R.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11},children:h.name}),h.status&&h.status!=="active"&&R.jsx("span",{className:"archik-pill",style:{fontSize:9,marginLeft:"auto"},children:h.status})]}),R.jsxs("div",{style:{color:"var(--archik-fg-muted)",fontSize:11},children:["primary ",R.jsx("code",{children:h.primaryActor}),h.secondaryActors&&h.secondaryActors.length>0&&R.jsxs(R.Fragment,{children:[" ","· secondary"," ",h.secondaryActors.map((p,v)=>R.jsxs("span",{children:[v>0&&", ",R.jsx("code",{children:p})]},p))]})]}),R.jsx("ul",{style:{marginTop:6,listStyle:"none",padding:0},children:h.slices.map(p=>{const v=b.get(`${h.id}/${p.id}`);return R.jsx(oVn,{slice:p,level:v},p.id)})})]})}function oVn({slice:h,level:b}){const[p,v]=lt.useState(!1);return R.jsxs("li",{style:{padding:"3px 0"},children:[R.jsxs("button",{type:"button",onClick:()=>v(T=>!T),className:"archik-btn",style:{display:"grid",gridTemplateColumns:"16px 1fr",alignItems:"center",gap:8,width:"100%",padding:"4px 6px",background:"transparent",border:"none",textAlign:"left",cursor:"pointer"},"aria-expanded":p,children:[R.jsx(fVn,{level:b}),R.jsxs("span",{style:{fontSize:12,color:"var(--archik-fg)",display:"flex",alignItems:"baseline",gap:6},children:[R.jsx("code",{children:h.id}),h.status&&h.status!=="active"&&R.jsxs("span",{style:{color:"var(--archik-fg-dim)",fontSize:10},children:["[",h.status,"]"]}),R.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11,marginLeft:"auto"},children:(()=>{const T=h.tests?.length??0,M=`${T} ${T===1?"test":"tests"}`,j=h.realization?"realized":"no seq";return`${M} • ${j}`})()})]})]}),p&&R.jsxs("div",{style:{paddingLeft:24,color:"var(--archik-fg-dim)",fontSize:11,paddingBottom:4},children:[R.jsx("div",{style:{color:"var(--archik-fg)",marginBottom:4,lineHeight:1.4},children:h.description}),h.tests&&h.tests.length>0&&R.jsxs("div",{children:["tests:"," ",h.tests.map((T,M)=>R.jsxs("code",{children:[M>0&&", ",T]},T))]}),h.realization&&R.jsxs("div",{children:["realises: ",R.jsx("code",{children:h.realization.seqFile})]}),!h.tests?.length&&!h.realization&&R.jsx("div",{children:"(no tests, no realisation)"})]})]})}const lVn={full:{glyph:"✓",tone:"var(--archik-status-active, #4ade80)",title:"fully traced"},partial:{glyph:"~",tone:"var(--archik-status-proposed, #fbbf24)",title:"partially traced"},none:{glyph:"✗",tone:"var(--archik-status-deprecated, #f87171)",title:"untraced"},missing:{glyph:"·",tone:"var(--archik-fg-dim)",title:"no trace data"}};function fVn({level:h}){const b=lVn[h??"missing"];return R.jsx("span",{title:b.title,"aria-label":b.title,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,fontSize:11,fontWeight:600,color:b.tone},children:b.glyph})}function aVn({label:h,children:b}){return R.jsxs("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"4px 6px 8px",zIndex:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[R.jsx("span",{children:h}),b]})}function z8e({children:h,tone:b}){return R.jsx("div",{style:{padding:"8px 8px 12px",fontSize:12,color:b==="error"?"var(--archik-status-deprecated, #f87171)":"var(--archik-fg-dim)"},children:h})}const hVn={idle:"",saving:"archik-pill archik-pill--info",saved:"archik-pill archik-pill--success",error:"archik-pill archik-pill--danger"},dVn={idle:null,saving:"Saving…",saved:"Saved",error:"Save failed"};function bVn({document:h,filename:b="architecture.archik.yaml",commandError:p,reloadError:v,saveStatus:T="idle",saveError:M,isDirty:j=!1,onSave:P,onAddNode:G,connectingFromName:J,onCancelConnect:se,density:re,onDensityChange:fe,viewMode:Ae,onViewModeChange:Ze,showStereotypeBands:ie,onToggleStereotypeBands:tn,canUndo:bn=!1,canRedo:_n=!1,onUndo:hn,onRedo:Rn,getSvg:rt,seqHighlight:dt,onToggleSeqHighlight:Wn,seqNodeCount:pt}){const wr=dVn[T],Wr=typeof navigator<"u"&&/Mac/i.test(navigator.platform)?"⌘S":"Ctrl+S";return R.jsxs("header",{className:"flex items-center gap-3 px-4 py-2.5",style:{background:"var(--archik-panel)",borderBottom:"1px solid var(--archik-border)"},children:[R.jsxs("div",{className:"flex items-center gap-2",children:[R.jsx(XXn,{}),R.jsx("span",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--archik-fg)",letterSpacing:"0.02em"},children:"Archik"})]}),R.jsx("span",{className:"archik-mono",style:{color:"var(--archik-fg-dim)",fontSize:11,opacity:.85},children:h.name}),J!==void 0&&R.jsxs("span",{className:"archik-pill archik-pill--info",children:["Connecting from ",R.jsx("strong",{children:J}),R.jsx("button",{type:"button",onClick:se,className:"underline hover:no-underline",style:{color:"var(--archik-accent)"},children:"cancel (Esc)"})]}),p!==void 0&&R.jsx("span",{className:"archik-pill archik-pill--danger",children:p}),v!==void 0&&R.jsx("span",{className:"archik-pill archik-pill--warning",title:v,children:"File reload error"}),wr!==null&&R.jsx("span",{className:hVn[T],...T==="error"&&M!==void 0?{title:M}:{},children:wr}),T==="error"&&M!==void 0&&R.jsx("span",{className:"archik-pill archik-pill--danger",style:{maxWidth:480,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:"ui-monospace, monospace",fontSize:11},title:M,children:gVn(M)}),R.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[hn!==void 0&&R.jsx("button",{type:"button",onClick:hn,disabled:!bn,title:`Undo (${Wr.replace("S","Z")})`,"aria-label":"Undo",className:"archik-btn",style:{padding:"5px 8px"},children:R.jsx(DFn,{size:14,strokeWidth:1.8})}),Rn!==void 0&&R.jsx("button",{type:"button",onClick:Rn,disabled:!_n,title:`Redo (${Wr.replace("S","⇧Z").replace("Ctrl+","Ctrl+Shift+")})`,"aria-label":"Redo",className:"archik-btn",style:{padding:"5px 8px"},children:R.jsx(wFn,{size:14,strokeWidth:1.8})}),G!==void 0&&R.jsx(wXn,{onAdd:G}),Ae!==void 0&&Ze!==void 0&&R.jsx("button",{type:"button",onClick:()=>Ze(Ae==="compact"?"detailed":"compact"),title:Ae==="compact"?"Switch to detailed view":"Switch to compact view","aria-label":"Toggle view mode",className:"archik-btn",style:{padding:"5px 8px"},children:Ae==="compact"?R.jsx(YBn,{size:14,strokeWidth:1.8}):R.jsx(yFn,{size:14,strokeWidth:1.8})}),ie!==void 0&&tn!==void 0&&R.jsx("button",{type:"button",onClick:tn,title:ie?"Hide ECB stereotype bands":"Show ECB stereotype bands (boundary / control / entity)","aria-label":"Toggle ECB stereotype bands","aria-pressed":ie,className:"archik-btn",style:{padding:"5px 8px",...ie?{background:"var(--archik-stereotype-control)",borderColor:"var(--archik-stereotype-control)",color:"white"}:{}},children:R.jsx(OFn,{size:14,strokeWidth:1.8})}),re!==void 0&&fe!==void 0&&R.jsx(JXn,{density:re,onChange:fe}),Wn!==void 0&&(pt??0)>0&&R.jsx("button",{type:"button",onClick:Wn,title:dt?"Hide sequence diagram highlights":`Show ${pt} node${pt===1?"":"s"} with sequence diagrams`,"aria-label":"Toggle sequence diagram highlights","aria-pressed":dt,className:"archik-btn",style:{padding:"5px 8px",...dt?{background:"var(--archik-status-proposed)",borderColor:"var(--archik-status-proposed)",color:"white"}:{}},children:R.jsx(R1n,{size:14,strokeWidth:1.8})}),R.jsx(tVn,{}),R.jsx(yXn,{}),R.jsx(HXn,{}),R.jsx(S0n,{document:h,filename:b,...rt!==void 0?{getSvg:rt}:{}}),R.jsx("button",{type:"button",onClick:P,disabled:!j||T==="saving",title:`Save to ${b} (${Wr})`,className:"archik-btn archik-btn-primary",children:j?"Save •":"Save"}),R.jsx(QXn,{})]})]})}function gVn(h){const b=h.indexOf(`
|
|
226
|
-
`);return b===-1?h:h.slice(0,b)}function wVn({files:h,currentPath:b,onSwitchFile:p}){const v=h.some(M=>M.hasSuggestion||M.isOrphanSuggestion);if(h.length<=1&&!v)return null;const T=h.find(M=>M.path===b)??h[0];return R.jsx(TT,{align:"start",trigger:M=>R.jsxs("button",{type:"button","aria-label":"Switch architecture file","aria-expanded":M,className:"archik-btn",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",fontSize:12,background:"transparent",color:"var(--archik-fg)"},children:[R.jsx(FBn,{size:13,strokeWidth:1.8}),R.jsx("span",{style:{fontWeight:600},children:T.name}),T.hasSuggestion&&R.jsx(pue,{}),R.jsx($1n,{size:12,strokeWidth:2,style:{opacity:.6}})]}),children:M=>R.jsxs("div",{style:{minWidth:220,padding:4},children:[R.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"6px 10px 4px"},children:"Architecture files"}),h.map(j=>{const P=j.path===T.path,G=j.isOrphanSuggestion===!0;return R.jsxs("button",{type:"button",title:G?`Pending sub-architecture (sidecar only — no main file yet). Click to view; accept via \`npx archik suggest accept ${j.path.replace(/\.archik\.suggested\.yaml$/,".archik.yaml")}\` to promote it, or /archik:accept.`:void 0,onClick:()=>{M(),!P&&p(j)},className:"archik-menu-item",style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,background:P?"var(--archik-surface-hover)":void 0,borderLeft:G?"2px dashed var(--archik-accent)":void 0,paddingLeft:G?8:void 0},children:[R.jsxs("span",{style:{fontWeight:P?600:400,color:"var(--archik-fg)"},children:[j.name,G&&R.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:500,color:"var(--archik-accent)",letterSpacing:"0.04em"},children:"(pending)"})]}),j.hasSuggestion&&!G&&R.jsx(pue,{}),R.jsx("span",{style:{flex:1,fontSize:10,fontFamily:"ui-monospace, monospace",color:"var(--archik-fg-muted)",textAlign:"right"},children:j.path})]},j.path)})]})})}function pue(){return R.jsx("span",{"aria-label":"pending suggestion",title:"Pending suggestion",style:{width:6,height:6,borderRadius:3,background:"var(--archik-accent)",flexShrink:0}})}function pVn({stack:h,onGoToFrame:b,suggestionsByPath:p}){return h.length<=1?null:R.jsx("nav",{"aria-label":"Architecture file navigation",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--archik-fg-muted)"},children:h.map((v,T)=>{const M=T===h.length-1,j=v.archikFile!==null&&p!==void 0&&p.has(v.archikFile);return R.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[M?R.jsxs("span",{style:{color:"var(--archik-fg)",fontWeight:600,display:"inline-flex",alignItems:"center",gap:6},"aria-current":"page",children:[v.label,j&&R.jsx(pue,{})]}):R.jsxs("button",{type:"button",onClick:()=>b(T),className:"archik-btn",style:{padding:"2px 6px",fontSize:12,color:"var(--archik-fg-muted)",background:"transparent",display:"inline-flex",alignItems:"center",gap:6},title:`Back to ${v.label}`,children:[v.label,j&&R.jsx(pue,{})]}),!M&&R.jsx("span",{"aria-hidden":"true",style:{opacity:.5},children:"›"})]},`${T}-${v.archikFile??"root"}`)})})}const mVn="/architecture.archik.yaml",vVn="/architecture.archik.suggested.yaml",yVn="/__archik/accept-suggestion",kVn=1500,h7e={label:"main",docUrl:mVn,sidecarUrl:vVn,acceptUrl:yVn,archikFile:null};function M0n(h,b){const p=h.replace(/\.archik\.yaml$/,".archik.suggested.yaml"),v=encodeURIComponent(h),T=encodeURIComponent(p);return{label:b,docUrl:`/__archik/file?path=${v}`,sidecarUrl:`/__archik/file?path=${T}`,acceptUrl:`/__archik/file-accept?path=${v}`,archikFile:h}}function jVn(){if(typeof window>"u")return null;const h=new URLSearchParams(window.location.search).get("file");return h!==null&&h.length>0?h:null}function SVn(h){if(typeof window>"u")return;const b=new URL(window.location.href);h===null||h.length===0?b.searchParams.delete("file"):b.searchParams.set("file",h),window.history.replaceState(null,"",b.toString())}function m1n(){const h=jVn();if(h===null)return[h7e];const p=(h.split("/").pop()??h).replace(/\.archik\.yaml$/i,"")||"main";return[M0n(h,p)]}function EVn(){const[h,b]=lt.useState({status:"loading"}),[p,v]=lt.useState(m1n),T=p[p.length-1],[M,j]=lt.useState([]),P=lt.useMemo(()=>new Set(M.filter(xn=>xn.hasSuggestion).map(xn=>xn.path)),[M]),G=lt.useMemo(()=>M.find(xn=>xn.isRoot)??null,[M]),J=T.archikFile===null?G?.path??null:T.archikFile,[se,re]=lt.useState(void 0),[fe,Ae]=lt.useState(void 0),[Ze,ie]=lt.useState("idle"),[tn,bn]=lt.useState(null),[_n,hn]=lt.useState(!1),[Rn,rt]=lt.useState(!1),[dt,Wn]=lt.useState({status:"none"}),[pt,wr]=lt.useState(!1),[Wr,Yr]=lt.useState([]),[Ui,Q]=lt.useState([]),Yo=100,[Ao,Jn]=lt.useState(()=>qXn()),ct=xn=>{Jn(xn),GXn(xn)},[ki,Br]=lt.useState(()=>BXn()),Xc=xn=>{Br(xn),FXn(xn)},[He,Yn]=lt.useState(()=>PXn()),ti=xn=>{Yn(xn),zXn(xn)},ji=lt.useMemo(()=>({...UXn(Ao),viewMode:ki}),[Ao,ki]),ar=lt.useMemo(()=>h.status==="ready"?new Set(h.document.nodes.filter(xn=>(xn.seqFiles?.length??0)>0).map(xn=>xn.id)):new Set,[h]),Jr=lt.useRef(!1),Oc=lt.useRef(null),Rs=lt.useRef(null),Wu=lt.useCallback(()=>Rs.current,[]),sh=lt.useRef(null),ds=oy(xn=>xn.selection),oa=oy(xn=>xn.connectFrom),r5=oy(xn=>xn.selectNode),Na=oy(xn=>xn.selectEdge),hy=oy(xn=>xn.toggleNode),iv=oy(xn=>xn.toggleEdge),Ab=oy(xn=>xn.clearSelection),t7=oy(xn=>xn.startConnect),su=oy(xn=>xn.cancelConnect),Vc=ds.length>0?ds.at(-1)??null:null,c5=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="node").map(xn=>xn.id)),[ds]),Ps=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="edge").map(xn=>xn.id)),[ds]);lt.useEffect(()=>{const xn=p[p.length-1];SVn(xn.archikFile)},[p]),lt.useEffect(()=>{if(typeof window>"u")return;const xn=()=>v(m1n());return window.addEventListener("popstate",xn),()=>window.removeEventListener("popstate",xn)},[]),lt.useEffect(()=>{let xn=!1;Oc.current="",Jr.current=!1;const Pt=()=>{BZn(T.docUrl).then(({document:xi,text:Dr})=>{if(xn||Dr===Oc.current)return;Oc.current=Dr,Jr.current=!0,b({status:"ready",document:xi}),hn(!1),typeof window<"u"&&xi.name&&(window.document.title=`${xi.name} — Archik`),Ae(void 0),Yr([]),Q([]);const Al=new Set(xi.nodes.map(ou=>ou.id)),To=new Set(xi.edges.map(ou=>ou.id));oy.setState(ou=>({selection:ou.selection.filter(Rc=>Rc.type==="node"?Al.has(Rc.id):To.has(Rc.id)),connectFrom:ou.connectFrom!==null&&Al.has(ou.connectFrom)?ou.connectFrom:null}))},xi=>{if(xn)return;const Dr=xi instanceof Error?xi.message:String(xi);Jr.current?Ae(Dr):b({status:"error",error:Dr})})};b({status:"loading"}),Pt();const Ji=s1n(Pt);return()=>{xn=!0,Ji()}},[T.docUrl]),lt.useEffect(()=>()=>{sh.current&&clearTimeout(sh.current)},[]),lt.useEffect(()=>{let xn=!1;const Pt=async()=>{try{const Dr=await fetch("/__archik/files",{cache:"no-store"});if(xn||!Dr.ok)return;const Al=await Dr.json();if(xn)return;Array.isArray(Al.files)&&j(Al.files)}catch{}};Pt();const Ji=s1n(()=>{Pt()}),xi=o1n(()=>{Pt()});return()=>{xn=!0,Ji(),xi()}},[]),lt.useEffect(()=>{if(h.status!=="ready")return;const xn=h.document;let Pt=!1;const Ji=async()=>{if(J!==null&&M.length>0&&M.some(Dr=>Dr.path===J)&&!P.has(J)){Wn({status:"none"});return}try{const Dr=await fetch(T.sidecarUrl,{cache:"no-store"});if(Pt)return;if(Dr.status===404){Wn({status:"none"});return}if(!Dr.ok){Wn({status:"error",message:`Sidecar fetch failed: HTTP ${Dr.status}`});return}const Al=await Dr.text();let To;try{To=w0n(Al)}catch(Rc){Wn({status:"error",message:Rc instanceof Error?Rc.message:String(Rc)});return}const ou=l7e(xn,To);Wn({status:"pending",added:ou.nodes.added.length+ou.edges.added.length,removed:ou.nodes.removed.length+ou.edges.removed.length,changed:ou.nodes.changed.length+ou.edges.changed.length,doc:To,...To.metadata?.suggestion?.note!==void 0?{note:To.metadata.suggestion.note}:{}})}catch(Dr){if(Pt)return;Wn({status:"error",message:Dr instanceof Error?Dr.message:String(Dr)})}};Ji();const xi=o1n(Ji);return()=>{Pt=!0,xi()}},[h,T.sidecarUrl,J,M,P]);const xT=lt.useCallback(async()=>{try{const xn=await fetch(T.acceptUrl,{method:"POST"});if(!xn.ok){const Pt=await xn.text();Wn({status:"error",message:`Accept failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.acceptUrl]),oh=lt.useCallback(async()=>{try{const xn=await fetch(T.sidecarUrl,{method:"DELETE"});if(!xn.ok&&xn.status!==404){const Pt=await xn.text();Wn({status:"error",message:`Reject failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.sidecarUrl]),MT=lt.useCallback(()=>{wr(xn=>!xn)},[]),dy=lt.useCallback(async()=>{let xn=null;if(b(Ji=>(Ji.status==="ready"&&(xn=Ji.document),Ji)),!xn)return;const Pt=G7e(xn);Oc.current=Pt,ie("saving"),bn(null);try{await FZn(T.docUrl,xn),ie("saved");let Ji=!1;b(xi=>(xi.status==="ready"&&xi.document===xn&&(Ji=!0),xi)),Ji&&hn(!1),sh.current&&clearTimeout(sh.current),sh.current=setTimeout(()=>ie("idle"),kVn)}catch(Ji){ie("error"),bn(Ji instanceof Error?Ji.message:String(Ji))}},[T.docUrl]),rv=G?.path??null,Zg=lt.useCallback((xn,Pt)=>rv===xn?h7e:M0n(xn,Pt),[rv]),by=lt.useCallback((xn,Pt)=>xn.archikFile===Pt?!0:xn.archikFile===null&&rv===Pt,[rv]),i7=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji.findIndex(Dr=>by(Dr,xn));return xi>=0?xi===Ji.length-1?Ji:Ji.slice(0,xi+1):[...Ji,Zg(xn,Pt)]})},[Zg,by]),u5=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji[Ji.length-1];return by(xi,xn)?Ji:[Zg(xn,Pt)]})},[Zg,by]),CT=lt.useCallback(xn=>{v(Pt=>xn<0||xn>=Pt.length-1?Pt:Pt.slice(0,xn+1))},[]),cv=lt.useCallback(xn=>{xn.isRoot?v([h7e]):u5(xn.path,xn.name)},[u5]),lh=lt.useCallback((xn,Pt)=>{if(oa===null){Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?hy(xn):r5(xn);return}if(xn===oa){su();return}let Ji=null;b(xi=>{if(xi.status!=="ready"||!xi.document.nodes.find(Rc=>Rc.id===oa))return xi;const Al=new Set(xi.document.edges.map(Rc=>Rc.id)),To=$8e(D8e(`${oa}-${xn}`),Al,"edge"),ou={id:To,from:oa,to:xn,relationship:"http_call"};try{const Rc=tI(xi.document,{type:"connect",edge:ou});return re(void 0),hn(!0),Yr(Bu=>[...Bu.slice(-(Yo-1)),xi.document]),Q([]),Ji=To,{status:"ready",document:Rc}}catch(Rc){const Bu=Rc instanceof Error?Rc.message:String(Rc);return re(Bu),xi}}),su(),Ji&&Na(Ji)},[oa,su,r5,hy,Na]),Tb=lt.useCallback((xn,Pt)=>{Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?iv(xn):Na(xn)},[Na,iv]),fh=lt.useCallback((xn,Pt)=>{let Ji=null;b(xi=>{if(xi.status!=="ready")return xi;const Dr=xi.document.nodes.find(Bu=>Bu.id===xn),Al=xi.document.nodes.find(Bu=>Bu.id===Pt);if(!Dr||!Al)return xi;const To=new Set(xi.document.edges.map(Bu=>Bu.id)),ou=$8e(D8e(`${xn}-${Pt}`),To,"edge"),Rc={id:ou,from:xn,to:Pt,relationship:"http_call"};try{const Bu=tI(xi.document,{type:"connect",edge:Rc});return re(void 0),hn(!0),Yr(Mb=>[...Mb.slice(-(Yo-1)),xi.document]),Q([]),Ji=ou,{status:"ready",document:Bu}}catch(Bu){const Mb=Bu instanceof Error?Bu.message:String(Bu);return re(Mb),xi}}),Ji&&Na(Ji)},[Na]),OT=lt.useCallback((xn,Pt,Ji)=>{b(xi=>{if(xi.status!=="ready")return xi;const Dr=new Set(xi.document.nodes.map(To=>To.id)),Al=$8e(D8e(Pt),Dr,xn);try{const To=tI(xi.document,{type:"add_node",node:{id:Al,kind:xn,name:Pt,description:Ji}});return re(void 0),hn(!0),Yr(ou=>[...ou.slice(-(Yo-1)),xi.document]),Q([]),{status:"ready",document:To}}catch(To){const ou=To instanceof Error?To.message:String(To);return re(ou),xi}})},[]),r7=lt.useCallback(xn=>{b(Pt=>{if(Pt.status!=="ready")return Pt;try{const Ji=tI(Pt.document,xn);return re(void 0),hn(!0),Yr(xi=>[...xi.slice(-(Yo-1)),Pt.document]),Q([]),{status:"ready",document:Ji}}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),Pt}})},[]),s5=lt.useCallback(()=>{ds.length!==0&&(b(xn=>{if(xn.status!=="ready")return xn;let Pt=xn.document;try{const Ji=ds.filter(Dr=>Dr.type==="edge").map(Dr=>Dr.id);for(const Dr of Ji)Pt.edges.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"disconnect",id:Dr}));const xi=ds.filter(Dr=>Dr.type==="node").map(Dr=>Dr.id);for(const Dr of xi)Pt.nodes.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"remove_node",id:Dr}));return Pt===xn.document?xn:(re(void 0),hn(!0),Yr(Dr=>[...Dr.slice(-(Yo-1)),xn.document]),Q([]),{status:"ready",document:Pt})}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),xn}}),Ab())},[ds,Ab]),$p=lt.useCallback(()=>{if(h.status!=="ready"||Wr.length===0)return;const xn=Wr[Wr.length-1];Yr(Pt=>Pt.slice(0,-1)),Q(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Wr,Ab]),Xg=lt.useCallback(()=>{if(h.status!=="ready"||Ui.length===0)return;const xn=Ui[Ui.length-1];Q(Pt=>Pt.slice(0,-1)),Yr(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Ui,Ab]);if(lt.useEffect(()=>{const xn=Pt=>{if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="s"){Pt.preventDefault(),_n&&dy();return}if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="z"||Pt.key==="Z")){Pt.preventDefault(),Pt.shiftKey?Xg():$p();return}if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="y"){Pt.preventDefault(),Xg();return}if(Pt.key==="Escape"){oa&&su();return}if(Pt.key==="Delete"||Pt.key==="Backspace"){const Ji=Pt.target;if(Ji instanceof HTMLInputElement||Ji instanceof HTMLTextAreaElement||Ji instanceof HTMLSelectElement||Ji instanceof HTMLElement&&Ji.isContentEditable||ds.length===0)return;Pt.preventDefault(),s5()}};return window.addEventListener("keydown",xn),()=>window.removeEventListener("keydown",xn)},[_n,dy,oa,su,ds,s5,$p,Xg]),h.status==="loading")return R.jsxs(v1n,{children:["Loading ",T.docUrl,"…"]});if(h.status==="error")return R.jsx(v1n,{children:R.jsx("pre",{className:"max-w-3xl whitespace-pre-wrap text-xs text-rose-700",children:h.error})});const xb=h.document,E1=pt&&dt.status==="pending",gy=E1&&dt.status==="pending"?XZn(xb,dt.doc):null,Lp=E1&&dt.status==="pending"?y0n(l7e(xb,dt.doc)):null,wy=gy??xb,c7=Vc?.type==="node"?wy.nodes.find(xn=>xn.id===Vc.id):void 0,o5=Vc?.type==="edge"?wy.edges.find(xn=>xn.id===Vc.id):void 0,Rp=oa!==null?xb.nodes.find(xn=>xn.id===oa):void 0,u7=ds.length>1;return R.jsxs("div",{className:"flex h-full flex-col",style:{background:"var(--archik-canvas)",color:"var(--archik-fg)"},children:[R.jsx(bVn,{document:xb,commandError:se,saveStatus:Ze,...tn!==null?{saveError:tn}:{},isDirty:_n,onSave:()=>{dy()},onAddNode:OT,density:Ao,onDensityChange:ct,viewMode:ki,onViewModeChange:Xc,showStereotypeBands:He,onToggleStereotypeBands:()=>ti(!He),canUndo:Wr.length>0,canRedo:Ui.length>0,onUndo:$p,onRedo:Xg,getSvg:Wu,seqHighlight:Rn,onToggleSeqHighlight:()=>rt(xn=>!xn),seqNodeCount:ar.size,...fe!==void 0?{reloadError:fe}:{},...Rp!==void 0?{connectingFromName:Rp.name,onCancelConnect:su}:{}}),dt.status==="pending"&&R.jsx(TVn,{added:dt.added,removed:dt.removed,changed:dt.changed,note:dt.note,reviewing:E1,onReview:MT,onAccept:()=>{xT()},onReject:()=>{oh()}}),dt.status==="error"&&R.jsxs("div",{role:"alert",style:{background:"rgba(217, 119, 6, 0.12)",borderBottom:"1px solid rgba(217, 119, 6, 0.45)",color:"var(--archik-warning)",padding:"8px 16px",fontSize:12,display:"flex",alignItems:"center",gap:12},children:[R.jsx("span",{style:{fontWeight:700},children:"SUGGESTION ERROR —"}),R.jsx("span",{style:{flex:1,color:"var(--archik-fg)"},children:dt.message}),R.jsx("button",{type:"button",onClick:()=>Wn({status:"none"}),"aria-label":"Dismiss",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",fontSize:16,lineHeight:1},children:"×"})]}),fe!==void 0&&R.jsxs("div",{role:"alert",style:{background:"rgba(225, 29, 72, 0.12)",borderBottom:"1px solid rgba(225, 29, 72, 0.45)",color:"var(--archik-danger)",padding:"10px 16px",display:"flex",alignItems:"flex-start",gap:12,fontSize:12,lineHeight:1.5},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:"FILE INVALID —"}),R.jsx("pre",{style:{margin:0,flex:1,whiteSpace:"pre-wrap",fontFamily:"inherit",color:"var(--archik-fg)"},children:fe}),R.jsx("button",{type:"button",onClick:()=>Ae(void 0),"aria-label":"Dismiss error",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",padding:"0 4px",fontSize:16,lineHeight:1},children:"×"})]}),R.jsxs("main",{className:"flex min-h-0 flex-1 p-4",style:{gap:0},children:[R.jsx("div",{className:"archik-panel",style:{flex:1,minWidth:0,overflow:"hidden"},children:R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"},children:[(M.length>1||p.length>1)&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--archik-surface)",borderBottom:"1px solid var(--archik-border)"},children:[R.jsx(wVn,{files:M,currentPath:J,onSwitchFile:cv}),R.jsx(pVn,{stack:p,onGoToFrame:CT,suggestionsByPath:P})]}),R.jsx(Bqn,{document:wy,className:"flex-1 archik-grid",layoutOptions:ji,viewMode:ki,showStereotypeBands:He,selectedNodeIds:c5,selectedEdgeIds:Ps,onSelectNode:lh,onSelectEdge:Tb,onSelectNothing:oa===null?Ab:su,onConnectDrag:fh,onOpenSubFile:i7,onCrossFileNavigate:u5,viewKey:T.docUrl,svgRef:Rs,...Lp?{diffStatuses:Lp}:{},...Rn&&ar.size>0?{glowNodeIds:ar}:{}})]})}),R.jsx("aside",{"aria-hidden":ds.length===0,className:`archik-drawer-shell ${ds.length>0?"archik-drawer-shell--open":"archik-drawer-shell--closed"}`,children:R.jsx("div",{className:"archik-panel archik-drawer-content archik-drawer-fade",style:{overflow:"hidden"},children:u7?R.jsx(AVn,{count:ds.length,onDelete:s5,onClear:Ab}):Vc?.type==="edge"?R.jsx(bXn,{edge:o5,dispatch:r7,readOnly:E1}):Vc?.type==="node"?R.jsx(oXn,{node:c7,dispatch:r7,onStartConnect:t7,allNodes:wy.nodes,readOnly:E1,viewKey:T.archikFile??void 0}):null},u7?`multi:${ds.length}`:Vc?`${Vc.type}:${Vc.id}`:"empty")})]})]})}function AVn({count:h,onDelete:b,onClear:p}){return R.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-sm",children:[R.jsxs("div",{children:[R.jsx("div",{className:"archik-label",children:"Selection"}),R.jsxs("div",{style:{fontSize:18,fontWeight:600,color:"var(--archik-fg)",letterSpacing:"0.01em"},children:[h," items"]}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)",marginTop:4},children:"Hold ⌘ / Ctrl while clicking to add or remove items."})]}),R.jsx("div",{className:"archik-divider"}),R.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-4",children:[R.jsx("button",{type:"button",onClick:p,className:"archik-btn",style:{justifyContent:"center",padding:"8px 12px"},children:"Clear selection"}),R.jsxs("button",{type:"button",onClick:b,className:"archik-btn archik-btn-danger",style:{justifyContent:"center",padding:"8px 12px"},children:["Delete ",h," items"]})]})]})}function v1n({children:h}){return R.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm",style:{background:"var(--archik-canvas)",color:"var(--archik-fg-dim)"},children:h})}function TVn({added:h,removed:b,changed:p,note:v,reviewing:T,onReview:M,onAccept:j,onReject:P}){const G=h+b+p;return R.jsxs("div",{role:"region","aria-label":"Pending suggestion",style:{background:"rgba(168, 85, 247, 0.12)",borderBottom:"1px solid rgba(168, 85, 247, 0.45)",padding:"10px 16px",display:"flex",alignItems:"center",gap:14,fontSize:12,lineHeight:1.4},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em",color:"#c4b5fd"},children:"📝 SUGGESTION PENDING"}),R.jsxs("span",{style:{color:"var(--archik-fg)"},children:[G===0?"(identical to current — nothing to apply)":R.jsxs(R.Fragment,{children:[R.jsxs("span",{style:{color:"var(--archik-success)"},children:["+",h]})," ",R.jsxs("span",{style:{color:"var(--archik-danger)"},children:["−",b]})," ",R.jsxs("span",{style:{color:"var(--archik-warning)"},children:["~",p]})]}),v?R.jsxs("span",{style:{marginLeft:10,color:"var(--archik-fg-dim)",fontStyle:"italic"},children:['"',v,'"']}):null]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[R.jsx("button",{type:"button",onClick:M,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,...T?{background:"#a855f7",color:"white",borderColor:"#a855f7"}:{}},children:T?"Hide diff":"Review"}),R.jsx("button",{type:"button",onClick:j,className:"archik-btn",title:G===0?"Suggestion already matches the current file — Accept just clears the sidecar.":"Apply the suggestion to the main file.",style:{padding:"5px 12px",fontSize:12,background:"var(--archik-success)",color:"white",borderColor:"var(--archik-success)"},children:"Accept"}),R.jsx("button",{type:"button",onClick:P,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"Reject"})]})]})}const xVn=n7(["sync","async","return","create","destroy"]),MVn=n7(["over","left_of","right_of"]),CVn=n7(["alt","opt","loop","par","break","ref"]),OVn=Kg({id:dd,nodeId:dd,label:hs().min(1).optional(),status:CI.optional()}),_Vn=Kg({type:oJ("message"),id:dd,from:dd,to:dd,label:hs().min(1),arrow:xVn,activate:VKn().optional(),status:CI.optional()}),NVn=Kg({type:oJ("note"),id:dd,position:MVn,participants:Jg(dd).min(1),text:hs().min(1),status:CI.optional()}),IVn=F7e(()=>Kg({label:hs().optional(),steps:Jg(C0n)})),DVn=F7e(()=>Kg({type:oJ("group"),id:dd,kind:CVn,condition:hs().optional(),label:hs().optional(),branches:Jg(IVn).optional(),seqFile:h0n.optional(),participants:Jg(dd).optional(),status:CI.optional()})),C0n=F7e(()=>o0n([_Vn,NVn,DVn]));function O0n(h,b){const p=[];for(const v of h)if(b.has(v.id)?p.push(v.id):b.add(v.id),v.type==="group"&&v.branches)for(const T of v.branches)p.push(...O0n(T.steps,b));return p}const $Vn=Kg({useCase:dd,slice:dd}),LVn=Kg({version:oJ("1.0"),name:hs().min(1),description:hs().optional(),realizes:$Vn.optional(),participants:Jg(OVn).min(1),steps:Jg(C0n)}).superRefine((h,b)=>{const p=new Set;for(let M=0;M<h.participants.length;M++){const j=h.participants[M];p.has(j.id)&&b.addIssue({code:jb.custom,path:["participants",M,"id"],message:`duplicate participant id "${j.id}"`}),p.add(j.id)}const v=new Set,T=O0n(h.steps,v);for(const M of T)b.addIssue({code:jb.custom,path:["steps"],message:`duplicate step id "${M}"`})}),kI=56,RVn=160,PVn=40,d7e=56,zVn=24,eue=12,BVn=8,FVn=6,y1n=64,pT=32,B8e=24,k1n=8,_0n="seq-arrow-filled",N0n="seq-arrow-open";function qVn(h){return Math.max(RVn,h.length*8+PVn*2)}function I0n(h,b,p,v,T,M=0){let j=p;const P=[];let G=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY;for(const se of h)if(se.type==="message"){const re=b.get(se.from),fe=b.get(se.to),Ae=re?.cx??v,Ze=fe?.cx??v;P.push({type:"message",id:se.id,fromCx:Ae,toCx:Ze,y:j,label:se.label,arrow:se.arrow,activate:se.activate??!1,isSelf:se.from===se.to,...se.status!==void 0?{status:se.status}:{}}),j+=se.from===se.to?d7e*1.5:d7e}else if(se.type==="note"){const re=se.participants.map(tn=>b.get(tn)?.cx).filter(tn=>tn!==void 0).sort((tn,bn)=>tn-bn),fe=re[0]??v,Ae=re[re.length-1]??T,Ze=Math.min(Math.max(se.text.length*7.5+24,Ae-fe+16,80),400);let ie;se.position==="left_of"?ie=fe-Ze-8:se.position==="right_of"?ie=Ae+8:ie=(fe+Ae)/2-Ze/2,G=Math.min(G,ie),J=Math.max(J,ie+Ze),P.push({type:"note",id:se.id,x:ie,y:j,width:Ze,height:y1n,text:se.text,...se.status!==void 0?{status:se.status}:{}}),j+=y1n+8}else if(se.type==="group"){const re=Math.min(M*FVn,eue),fe=v-eue+re,Ae=T-v+eue*2-re*2,Ze=j;j+=zVn;const ie=[];if(se.branches)for(let tn=0;tn<se.branches.length;tn++){const bn=se.branches[tn],_n=j,{items:hn,endY:Rn,contentMinX:rt,contentMaxX:dt}=I0n(bn.steps,b,j,v,T,M+1);j=Rn,G=Math.min(G,rt),J=Math.max(J,dt),ie.push({...bn.label!==void 0?{label:bn.label}:{},startY:_n,...tn<se.branches.length-1?{dividerY:j}:{},steps:hn}),tn<se.branches.length-1&&(j+=4)}j+=eue,P.push({type:"group",id:se.id,kind:se.kind,...se.condition!==void 0?{condition:se.condition}:{},...se.label!==void 0?{label:se.label}:{},...se.seqFile!==void 0?{seqFile:se.seqFile}:{},x:fe,y:Ze,width:Ae,height:j-Ze,branches:ie,...se.status!==void 0?{status:se.status}:{}}),G=Math.min(G,fe),J=Math.max(J,fe+Ae),j+=BVn}return{items:P,endY:j,contentMinX:G,contentMaxX:J}}function D0n(h){const b=new Map;for(const p of h)if(p.type==="message"&&p.arrow==="destroy"&&b.set(p.toCx,p.y+kI+20),p.type==="group")for(const v of p.branches)for(const[T,M]of D0n(v.steps))b.set(T,M);return b}function GVn(h){const b=[],p=new Map;function v(T){for(const M of T)if(M.type==="message"){if(M.activate&&M.arrow==="sync"&&!M.isSelf){const j=p.get(M.toCx)??[];j.push(M.y),p.set(M.toCx,j)}if(M.arrow==="return"&&!M.isSelf){const j=p.get(M.fromCx);if(j&&j.length>0){const P=j.pop();b.push({cx:M.fromCx,startY:P,endY:M.y}),j.length===0&&p.delete(M.fromCx)}}}else if(M.type==="group")for(const j of M.branches)v(j.steps)}v(h);for(const[T,M]of p)for(const j of M)b.push({cx:T,startY:j,endY:j+d7e/2});return b}function UVn(h,b){const p=h.participants.map(Wn=>qVn(Wn.label??Wn.nodeId));let v=pT;const T=h.participants.map((Wn,pt)=>{const wr=p[pt],Wr=v+wr/2;v+=wr;const Yr=b?.get(Wn.nodeId);return{id:Wn.id,nodeId:Wn.nodeId,label:Wn.label??Wn.nodeId,cx:Wr,colWidth:wr,...Yr!==void 0?{kind:Yr}:{},...Wn.status!==void 0?{status:Wn.status}:{},lifelineEndY:0}}),M=v+pT,j=new Map(T.map(Wn=>[Wn.id,Wn])),P=T[0]?.cx??pT,G=T[T.length-1]?.cx??M-pT,J=B8e,{items:se,endY:re,contentMinX:fe,contentMaxX:Ae}=I0n(h.steps,j,J,P,G),Ze=fe<pT&&Number.isFinite(fe)?pT-fe:0,ie=Number.isFinite(Ae)?Ae+Ze+pT:0,tn=Math.max(M+Ze,ie),bn=Ze>0?se.map(Wn=>$0n(Wn,Ze)):se,_n=Ze>0?T.map(Wn=>({...Wn,cx:Wn.cx+Ze})):T,hn=D0n(bn),Rn=_n.map(Wn=>({...Wn,lifelineEndY:hn.get(Wn.cx)??kI+re+B8e})),rt=kI+re+B8e,dt=GVn(bn);return{participants:Rn,steps:bn,activations:dt,totalWidth:tn,totalHeight:rt}}function $0n(h,b){return h.type==="message"?{...h,fromCx:h.fromCx+b,toCx:h.toCx+b}:h.type==="note"?{...h,x:h.x+b}:{...h,x:h.x+b,branches:h.branches.map(p=>({...p,steps:p.steps.map(v=>$0n(v,b))}))}}const nue=36,JVn=128,HVn=7,j1n=20,S1n=24;function KVn({participant:h,nodeKind:b}){const p=b?Np[b]:void 0,v=p?.color??"var(--archik-fg-muted)",T=(kI-nue)/2,M=p?.icon,j=Math.max(JVn,h.label.length*HVn+S1n+(M?j1n:0)),P=j/2,G=M?P+j1n/2:P,J=h.status,se=J==="proposed"?.55:J==="deprecated"?.35:1,re=J==="proposed"||J==="deprecated"?"4 3":void 0;return R.jsxs("g",{transform:`translate(${h.cx-P}, ${T})`,opacity:se,children:[R.jsx("rect",{width:j,height:nue,rx:8,fill:"var(--archik-node-fill)",stroke:v,strokeWidth:1.4,...re!==void 0?{strokeDasharray:re}:{}}),M&&R.jsx("g",{transform:`translate(${S1n/2}, ${(nue-14)/2})`,children:R.jsx(M,{size:14,color:v,strokeWidth:1.5})}),R.jsx("text",{x:G,y:nue/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}function ZVn({participant:h}){const b=h.status,p=b==="proposed"?.3:b==="deprecated"?.2:.5;return R.jsx("line",{x1:h.cx,y1:kI,x2:h.cx,y2:h.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:p})}const F8e=32,q8e=20,XVn=-6;function VVn({msg:h}){const b=h.arrow==="return",p=h.arrow==="async",v=h.arrow==="create",T=b||v,M=h.arrow==="destroy",j=b||p?N0n:_0n,P=h.status==="proposed"?.5:h.status==="deprecated"?.35:1;if(h.isSelf){const re=h.fromCx,fe=h.y,Ae=`M ${re} ${fe} L ${re+F8e} ${fe} L ${re+F8e} ${fe+q8e} L ${re} ${fe+q8e}`;return R.jsxs("g",{opacity:P,children:[R.jsx("path",{d:Ae,fill:"none",stroke:"var(--archik-edge-filled)",strokeWidth:1.4,markerEnd:`url(#${j})`}),R.jsx("text",{x:re+F8e+6,y:fe+q8e/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}const J=h.fromCx<h.toCx?h.toCx-6:h.toCx+6,se=(h.fromCx+h.toCx)/2;return R.jsxs("g",{opacity:P,children:[R.jsx("line",{x1:h.fromCx,y1:h.y,x2:J,y2:h.y,stroke:"var(--archik-edge-filled)",strokeWidth:1.4,strokeDasharray:T?"4 4":void 0,markerEnd:M?void 0:`url(#${j})`}),R.jsxs("text",{x:se,y:h.y+XVn,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[v&&"«create» ",h.label]}),h.arrow==="destroy"&&R.jsxs("g",{transform:`translate(${h.toCx-6}, ${h.y-6})`,children:[R.jsx("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),R.jsx("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}const WVn={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},E1n=36,G8e=18;function YVn({group:h,renderStep:b,onRefClick:p}){const v=WVn[h.kind]??"var(--archik-fg-muted)",T=h.status==="proposed"?.55:h.status==="deprecated"?.35:1,M=h.kind==="ref"&&h.seqFile!==void 0&&p!==void 0;return R.jsxs("g",{opacity:T,onClick:M?()=>p(h.seqFile):void 0,style:M?{cursor:"pointer"}:void 0,children:[R.jsx("rect",{x:h.x,y:h.y,width:h.width,height:h.height,rx:4,fill:"none",stroke:v,strokeWidth:1.2,opacity:.6}),R.jsx("rect",{x:h.x,y:h.y,width:E1n,height:G8e,rx:4,fill:v,opacity:.8}),R.jsx("text",{x:h.x+6,y:h.y+G8e-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:h.kind}),(h.condition??h.label)&&R.jsx("text",{x:h.x+E1n+6,y:h.y+G8e-5,fontSize:10,fill:v,fontFamily:"inherit",children:h.condition??h.label}),h.branches.map((j,P)=>R.jsxs("g",{children:[j.label&&R.jsx("text",{x:h.x+6,y:j.startY+12,fontSize:10,fill:v,fontFamily:"inherit",children:j.label}),j.steps.map(G=>b(G)),j.dividerY!==void 0&&R.jsx("line",{x1:h.x,y1:j.dividerY,x2:h.x+h.width,y2:j.dividerY,stroke:v,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},P))]})}const rI=10;function QVn(h,b){const p=Math.max(10,Math.floor(b/6.5));if(h.length<=p)return[h];const v=h.split(" "),T=[];let M="";for(const j of v)(M+(M?" ":"")+j).length>p&&M?(T.push(M),M=j):M=M?M+" "+j:j;return M&&T.push(M),T.slice(0,3)}function eWn({note:h}){const{x:b,y:p,width:v,height:T,text:M}=h,j=h.status==="proposed"?.55:h.status==="deprecated"?.35:1;return R.jsxs("g",{opacity:j,children:[R.jsx("path",{d:`M ${b} ${p} L ${b+v-rI} ${p} L ${b+v} ${p+rI} L ${b+v} ${p+T} L ${b} ${p+T} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),R.jsx("path",{d:`M ${b+v-rI} ${p} L ${b+v-rI} ${p+rI} L ${b+v} ${p+rI}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),QVn(M,v-16).map((P,G)=>R.jsx("text",{x:b+8,y:p+8+11+G*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:P},G))]})}function nWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}function tWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 12 12",refX:"11",refY:"6",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 1 1 L 11 6 L 1 11",fill:"none",stroke:"context-stroke",strokeWidth:"1.5",strokeLinejoin:"round"})})}function L0n({step:h,onRefClick:b}){return h.type==="message"?R.jsx(VVn,{msg:h}):h.type==="note"?R.jsx(eWn,{note:h}):h.type==="group"?R.jsx(YVn,{group:h,...b!==void 0?{onRefClick:b}:{},renderStep:p=>R.jsx(L0n,{step:p,...b!==void 0?{onRefClick:b}:{}},p.id)}):null}function iWn({laid:h,svgRef:b,onRefClick:p}){const{participants:v,steps:T,activations:M,totalWidth:j,totalHeight:P}=h;return R.jsxs("svg",{ref:b,width:j,height:P,viewBox:`0 0 ${j} ${P}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[R.jsxs("defs",{children:[R.jsx(nWn,{id:_0n}),R.jsx(tWn,{id:N0n})]}),v.map(G=>R.jsx(ZVn,{participant:G},G.id)),v.map(G=>R.jsx(KVn,{participant:G,...G.kind!==void 0?{nodeKind:G.kind}:{}},G.id)),R.jsxs("g",{transform:`translate(0, ${kI})`,children:[M.map(G=>R.jsx("rect",{x:G.cx-k1n/2,y:G.startY,width:k1n,height:G.endY-G.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${G.cx}-${G.startY}`)),T.map(G=>R.jsx(L0n,{step:G,...p!==void 0?{onRefClick:p}:{}},G.id))]})]})}const A1n="archik.seq.rail.open";function rWn({path:h,back:b}){const[p,v]=lt.useState({status:"loading"}),[T,M]=lt.useState(void 0),[j,P]=lt.useState([]),[G,J]=lt.useState(()=>{if(typeof window>"u")return!0;const hn=window.localStorage.getItem(A1n);return hn===null?!0:hn==="1"}),[se,re]=lt.useState(!1),fe=lt.useRef(null);lt.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(A1n,G?"1":"0")},[G]),lt.useEffect(()=>{fetch("/__archik/node-kinds").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&M(new Map(Object.entries(hn)))}).catch(()=>{})},[]),lt.useEffect(()=>{fetch("/__archik/usecases").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&P(hn.useCases??[])}).catch(()=>{})},[]),lt.useEffect(()=>{v({status:"loading"});const hn=encodeURIComponent(h);fetch(`/__archik/seq-file?path=${hn}`).then(async Rn=>{if(!Rn.ok)throw new Error(`${Rn.status} ${Rn.statusText}`);return Rn.text()}).then(Rn=>{const rt=I7e.parse(Rn),dt=LVn.safeParse(rt);if(!dt.success)throw new Error(dt.error.issues.map(Wn=>Wn.message).join("; "));v({status:"ready",doc:dt.data,raw:Rn})}).catch(Rn=>{v({status:"error",message:Rn instanceof Error?Rn.message:String(Rn)})})},[h]);const Ae=b?b.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(b.value)}`:`/?file=${encodeURIComponent(b.value)}`:"/",Ze=b?.type==="usecase"?"Use cases":"Architecture",ie=lt.useMemo(()=>{if(p.status!=="ready")return null;const hn=p.doc.realizes;if(!hn)return null;const Rn=j.find(dt=>dt.id===hn.useCase);if(!Rn)return{useCase:hn.useCase,slice:hn.slice,name:void 0,slice_data:void 0};const rt=Rn.slices.find(dt=>dt.id===hn.slice);return{useCase:hn.useCase,slice:hn.slice,name:Rn.name,slice_data:rt,primaryActor:Rn.primaryActor}},[p,j]);if(p.status==="loading")return R.jsx("div",{className:"flex h-screen items-center justify-center",style:{color:"var(--archik-fg-muted)"},children:"Loading sequence diagram…"});if(p.status==="error")return R.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[R.jsx("div",{style:{color:"var(--archik-fg-error, #ef4444)"},children:p.message}),R.jsxs("a",{href:Ae,style:{color:"var(--archik-fg-muted)",fontSize:13},children:["← ",Ze]})]});const tn=UVn(p.doc,T),bn=h.replace(/^.*\//,"").replace(/\.archik\.seq\.yaml$/,""),_n=hn=>{const Rn=new URLSearchParams;Rn.set("path",hn),b?.type==="usecase"?Rn.set("from-uc",b.value):b?.type==="file"&&Rn.set("from-file",b.value),window.location.href=`/__archik/seq?${Rn.toString()}`};return R.jsxs("div",{className:"flex h-screen flex-col",style:{background:"var(--archik-canvas)"},children:[R.jsx(cWn,{backHref:Ae,backLabel:Ze,realizedSlice:ie,seqName:p.doc.name,railOpen:G,onToggleRail:()=>J(hn=>!hn),filename:bn,getSvg:()=>fe.current}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[R.jsx("div",{style:{flex:1,overflow:"auto",padding:24},children:R.jsx(iWn,{laid:tn,svgRef:fe,onRefClick:_n})}),G&&R.jsx(uWn,{doc:p.doc,raw:p.raw,yamlOpen:se,onToggleYaml:()=>re(hn=>!hn),realizedSlice:ie,kinds:T})]})]})}function cWn({backHref:h,backLabel:b,realizedSlice:p,seqName:v,railOpen:T,onToggleRail:M,filename:j,getSvg:P}){return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 16px",height:48,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0,fontSize:13},children:[R.jsxs("a",{href:h,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[R.jsx(L1n,{size:14}),b]}),p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(p.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.useCase}),R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.slice})]}),!p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontWeight:500},children:v})]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[R.jsx(S0n,{filename:j,getSvg:P}),R.jsx("button",{type:"button",onClick:M,"aria-label":T?"Hide details":"Show details","aria-pressed":T,title:T?"Hide details panel":"Show details panel",className:"archik-btn",style:{padding:"5px 8px"},children:T?R.jsx(fFn,{size:14}):R.jsx(hFn,{size:14})})]})]})}function U8e(){return R.jsx(SBn,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function uWn({doc:h,raw:b,yamlOpen:p,onToggleYaml:v,realizedSlice:T,kinds:M}){return R.jsxs("aside",{style:{width:300,flexShrink:0,borderLeft:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:16,fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsx(tue,{title:"Realizes",children:T?R.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[R.jsx(T1n,{label:"Use case",children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(T.useCase)}`,style:iue({color:"var(--archik-accent)"}),children:[T.useCase,T.name?` — ${T.name}`:""]})}),R.jsx(T1n,{label:"Slice",children:R.jsx("code",{style:iue(),children:T.slice})}),T.slice_data?.description&&R.jsx("div",{style:{marginTop:4,fontSize:11,lineHeight:1.5},children:T.slice_data.description})]}):R.jsxs(x1n,{children:["No ",R.jsx("code",{children:"realizes"})," block — this is an ad-hoc / scratch flow, not bound to a use case slice."]})}),R.jsx(tue,{title:`Participants (${h.participants.length})`,children:R.jsx("ul",{style:M1n,children:h.participants.map(j=>{const P=M?.get(j.nodeId),G=P?Np[P]:void 0,J=G?.icon;return R.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 0"},children:[J?R.jsx(J,{size:12,color:G.color,strokeWidth:2}):R.jsx("span",{style:{width:12}}),R.jsx("code",{style:iue(),children:j.nodeId}),j.id!==j.nodeId&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",j.id,"]"]})]},j.id)})})}),T?.slice_data&&R.jsx(tue,{title:"Proved by",children:(T.slice_data.tests?.length??0)===0?R.jsx(x1n,{children:"No tests declared on this slice."}):R.jsx("ul",{style:{...M1n,listStyle:"none",paddingLeft:0},children:T.slice_data.tests.map(j=>R.jsxs("li",{style:{...iue(),fontSize:11,padding:"2px 0"},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",j]},j))})}),R.jsxs(tue,{title:"Source",children:[R.jsxs("button",{type:"button",onClick:v,className:"archik-btn",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 8px"},children:[R.jsx(zBn,{size:11}),p?"Hide YAML":"View YAML"]}),p&&R.jsx("pre",{style:{marginTop:8,padding:10,background:"var(--archik-surface)",border:"1px solid var(--archik-border)",borderRadius:4,fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg-dim)",overflowX:"auto",whiteSpace:"pre",maxHeight:360,overflowY:"auto"},children:b})]})]})}function tue({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:18},children:[R.jsx("h2",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",margin:"0 0 6px"},children:h}),b]})}function T1n({label:h,children:b}){return R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[R.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",width:56,flexShrink:0},children:h}),R.jsx("span",{style:{flex:1,minWidth:0},children:b})]})}function x1n({children:h}){return R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",lineHeight:1.5},children:h})}function iue(h){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...h}}const M1n={margin:0,paddingLeft:0,listStyle:"none"},sWn="/__archik/usecases",oWn="/__archik/trace";async function C1n(h,b){const p=await fetch(h,{cache:"no-store",signal:b});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function lWn({selectedId:h}){const[b,p]=lt.useState({status:"loading"});return lt.useEffect(()=>{let v=!1;const T=new AbortController;return Promise.all([C1n(sWn,T.signal),C1n(oWn,T.signal)]).then(([M,j])=>{v||p({status:"ready",useCases:M.useCases??[],trace:j.rows??[]})}).catch(M=>{v||T.signal.aborted||p({status:"error",message:M instanceof Error?M.message:String(M)})}),()=>{v=!0,T.abort()}},[]),R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[R.jsx(fWn,{state:b}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[b.status==="loading"&&R.jsx(J8e,{children:"Loading…"}),b.status==="error"&&R.jsxs(J8e,{tone:"error",children:["Couldn't load: ",b.message]}),b.status==="ready"&&b.useCases.length===0&&R.jsxs(J8e,{children:["No use cases defined yet. Add a ",R.jsx("code",{children:"*.archik.uc.yaml"})," file under ",R.jsx("code",{children:".archik/usecases/"}),"."]}),b.status==="ready"&&b.useCases.length>0&&R.jsx(aWn,{useCases:b.useCases,trace:b.trace,selectedId:h})]})]})}function fWn({state:h}){const b=lt.useMemo(()=>{if(h.status!=="ready")return null;let p=0,v=0,T=0;for(const M of h.trace)M.level==="full"?p++:M.level==="partial"?v++:T++;return{full:p,partial:v,none:T,total:h.trace.length}},[h]);return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 20px",height:52,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0},children:[R.jsxs("a",{href:"/",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-fg-dim)",fontSize:13,textDecoration:"none"},children:[R.jsx(L1n,{size:14}),"Architecture"]}),R.jsx("span",{style:{color:"var(--archik-border-strong)"},children:"|"}),R.jsx("h1",{style:{fontSize:14,fontWeight:600,margin:0,color:"var(--archik-fg)"},children:"Use cases"}),b&&b.total>0&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto",fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",b.full," full"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",b.partial," partial"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",b.none," untraced"]}),R.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:["· ",b.total," ",b.total===1?"slice":"slices"]})]})]})}function aWn({useCases:h,trace:b,selectedId:p}){const v=lt.useMemo(()=>{const j=new Map;for(const P of b){const G=j.get(P.useCase);if(!G){j.set(P.useCase,P.level);continue}G==="none"||P.level==="none"?j.set(P.useCase,"none"):(G==="partial"||P.level==="partial")&&j.set(P.useCase,"partial")}return j},[b]),T=lt.useMemo(()=>{const j=new Map;for(const P of b)j.set(`${P.useCase}/${P.slice}`,P);return j},[b]),M=h.find(j=>j.id===p)??h[0];return R.jsxs(R.Fragment,{children:[R.jsx(hWn,{useCases:h,ucLevel:v,selectedId:M.id}),R.jsx(dWn,{useCase:M,traceByKey:T})]})}function hWn({useCases:h,ucLevel:b,selectedId:p}){return R.jsx("nav",{"aria-label":"Use cases",style:{width:260,borderRight:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:"8px 0",flexShrink:0},children:R.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:h.map(v=>{const T=b.get(v.id)??"none",M=v.id===p;return R.jsx("li",{children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(v.id)}`,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",textDecoration:"none",color:"var(--archik-fg)",background:M?"var(--archik-surface-hover)":"transparent",borderLeft:M?"2px solid var(--archik-accent)":"2px solid transparent",fontSize:13},children:[R.jsx(R0n,{level:T}),R.jsxs("span",{style:{flex:1,minWidth:0},children:[R.jsx("code",{style:{fontSize:12,fontFamily:"ui-monospace, monospace"},children:v.id}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.name})]}),v.status&&v.status!=="active"&&R.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:4,background:"var(--archik-surface)",color:"var(--archik-fg-muted)"},children:v.status})]})},v.id)})})})}function R0n({level:h}){const b=h==="full"?{glyph:"●",color:"var(--archik-success)",label:"fully traced"}:h==="partial"?{glyph:"◐",color:"var(--archik-warning)",label:"partially traced"}:{glyph:"○",color:"var(--archik-fg-muted)",label:"untraced"};return R.jsx("span",{title:b.label,"aria-label":b.label,style:{color:b.color,fontSize:12,lineHeight:1,width:12},children:b.glyph})}function dWn({useCase:h,traceByKey:b}){return R.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:R.jsxs("div",{style:{maxWidth:820,margin:"0 auto"},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:4},children:[R.jsx("code",{style:{fontSize:18,fontFamily:"ui-monospace, monospace",fontWeight:600,color:"var(--archik-fg)"},children:h.id}),h.status&&h.status!=="active"&&R.jsx("span",{className:"archik-pill",style:{fontSize:10},children:h.status})]}),R.jsx("div",{style:{fontSize:15,color:"var(--archik-fg-dim)",marginBottom:18},children:h.name}),R.jsx(bWn,{useCase:h}),h.goal&&R.jsx(cI,{title:"Goal",children:R.jsx("p",{style:{margin:0,lineHeight:1.55},children:h.goal})}),(h.preconditions?.length??0)>0&&R.jsx(cI,{title:"Preconditions",children:R.jsx("ul",{style:QU,children:h.preconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),h.flows?.basic?.steps&&R.jsx(cI,{title:"Basic flow",children:R.jsx("ol",{style:{...QU,paddingLeft:22},children:h.flows.basic.steps.map((p,v)=>R.jsx("li",{style:{marginBottom:4},children:p},v))})}),(h.flows?.alternates?.length??0)>0&&R.jsx(cI,{title:"Alternate flows",children:h.flows.alternates.map(p=>R.jsxs("div",{style:{marginBottom:12,padding:12,background:"var(--archik-surface)",borderRadius:6,borderLeft:"3px solid var(--archik-warning)"},children:[R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:6},children:[R.jsx("code",{style:{fontSize:12,fontWeight:600},children:p.id}),p.branchFrom&&R.jsxs("span",{style:{fontSize:11,color:"var(--archik-fg-muted)"},children:["branches from ",p.branchFrom]})]}),R.jsx("ol",{style:{...QU,paddingLeft:22,fontSize:13},children:p.steps.map((v,T)=>R.jsx("li",{children:v},T))})]},p.id))}),(h.postconditions?.length??0)>0&&R.jsx(cI,{title:"Postconditions",children:R.jsx("ul",{style:QU,children:h.postconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),(()=>{const p=h.slices??[];return R.jsx(cI,{title:`Slices (${p.length})`,children:p.length===0?R.jsx("div",{style:{fontSize:12,color:"var(--archik-fg-muted)"},children:"— no slices declared"}):R.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map(v=>R.jsx(gWn,{slice:v,useCaseId:h.id,trace:b.get(`${h.id}/${v.id}`)},v.id))})})})(),R.jsxs("div",{style:{marginTop:32,paddingTop:16,borderTop:"1px solid var(--archik-border)",fontSize:11,color:"var(--archik-fg-muted)"},children:["Source:"," ",R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.relPath})]})]})})}function bWn({useCase:h}){return R.jsxs("div",{style:{display:"flex",gap:24,padding:"10px 14px",background:"var(--archik-surface)",borderRadius:6,marginBottom:20,fontSize:12},children:[R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Primary actor"}),R.jsx("div",{style:{marginTop:2},children:R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.primaryActor})})]}),(h.secondaryActors?.length??0)>0&&R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Secondary actors"}),R.jsx("div",{style:{marginTop:2},children:h.secondaryActors.map((b,p)=>R.jsxs("span",{children:[R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:b}),p<h.secondaryActors.length-1&&", "]},b))})]})]})}function gWn({slice:h,useCaseId:b,trace:p}){const v=p?.level??"none";return R.jsxs("div",{style:{padding:14,background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[R.jsx(R0n,{level:v}),R.jsx("code",{style:{fontSize:13,fontFamily:"ui-monospace, monospace",fontWeight:600},children:h.id}),h.status&&h.status!=="active"&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",h.status,"]"]}),R.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--archik-fg-muted)"},children:p?.realization&&p.realization.participants.length>0&&R.jsxs(R.Fragment,{children:["ECB"," ",p.realization.participants.filter(T=>T.stereotype!==void 0).length,"/",p.realization.participants.length]})})]}),h.description&&R.jsx("div",{style:{fontSize:13,color:"var(--archik-fg-dim)",marginBottom:10,lineHeight:1.5},children:h.description}),R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:14,rowGap:8,fontSize:12,alignItems:"start"},children:[R.jsx("div",{style:H8e,children:"Tests"}),R.jsx("div",{children:(h.tests?.length??0)===0?R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— none declared"}):R.jsx("ul",{style:{...QU,paddingLeft:0,listStyle:"none"},children:h.tests.map(T=>R.jsxs("li",{style:{fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",T]},T))})}),R.jsx("div",{style:H8e,children:"Realization"}),R.jsx("div",{children:h.realization?R.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(h.realization.seqFile)}&from-uc=${encodeURIComponent(b)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx(I1n,{size:11}),wWn(h.realization.seqFile),R.jsx(D1n,{size:11,style:{opacity:.7}})]}):R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no seq file yet"})}),R.jsx("div",{style:H8e,children:"Flows"}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)"},children:(h.flows??[]).join(", ")||"—"})]})]})}function wWn(h){return h.split("/").pop()?.replace(/\.archik\.seq\.yaml$/,"")??h}function cI({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:24},children:[R.jsx("h2",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",margin:"0 0 8px"},children:h}),b]})}function J8e({children:h,tone:b}){return R.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:b==="error"?"var(--archik-danger)":"var(--archik-fg-muted)",fontSize:13,padding:24,textAlign:"center"},children:h})}const b7e={fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",fontWeight:600},H8e={...b7e,fontSize:10,paddingTop:1},QU={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.55},P0n=document.getElementById("root");if(!P0n)throw new Error("#root not found");const VU=new URLSearchParams(window.location.search),mue=window.location.pathname,pWn=mue==="/__archik/seq"||mue.startsWith("/__archik/seq/"),mWn=mue==="/__archik/usecases"||mue.startsWith("/__archik/usecases/"),K8e=Nzn.createRoot(P0n);if(pWn){const h=VU.get("path")??"",b=VU.get("from-uc"),p=VU.get("from-file")??VU.get("from"),v=b?{type:"usecase",value:b}:p?{type:"file",value:p}:null;K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(rWn,{path:h,back:v})}))}else if(mWn){const h=VU.get("uc");K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(lWn,{selectedId:h})}))}else K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(EVn,{})}));
|
|
226
|
+
`);return b===-1?h:h.slice(0,b)}function wVn({files:h,currentPath:b,onSwitchFile:p}){const v=h.some(M=>M.hasSuggestion||M.isOrphanSuggestion);if(h.length<=1&&!v)return null;const T=h.find(M=>M.path===b)??h[0];return R.jsx(TT,{align:"start",trigger:M=>R.jsxs("button",{type:"button","aria-label":"Switch architecture file","aria-expanded":M,className:"archik-btn",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",fontSize:12,background:"transparent",color:"var(--archik-fg)"},children:[R.jsx(FBn,{size:13,strokeWidth:1.8}),R.jsx("span",{style:{fontWeight:600},children:T.name}),T.hasSuggestion&&R.jsx(pue,{}),R.jsx($1n,{size:12,strokeWidth:2,style:{opacity:.6}})]}),children:M=>R.jsxs("div",{style:{minWidth:220,padding:4},children:[R.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"6px 10px 4px"},children:"Architecture files"}),h.map(j=>{const P=j.path===T.path,G=j.isOrphanSuggestion===!0;return R.jsxs("button",{type:"button",title:G?`Pending sub-architecture (sidecar only — no main file yet). Click to view; accept via \`npx archik suggest accept ${j.path.replace(/\.archik\.suggested\.yaml$/,".archik.yaml")}\` to promote it, or /archik:accept.`:void 0,onClick:()=>{M(),!P&&p(j)},className:"archik-menu-item",style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,background:P?"var(--archik-surface-hover)":void 0,borderLeft:G?"2px dashed var(--archik-accent)":void 0,paddingLeft:G?8:void 0},children:[R.jsxs("span",{style:{fontWeight:P?600:400,color:"var(--archik-fg)"},children:[j.name,G&&R.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:500,color:"var(--archik-accent)",letterSpacing:"0.04em"},children:"(pending)"})]}),j.hasSuggestion&&!G&&R.jsx(pue,{}),R.jsx("span",{style:{flex:1,fontSize:10,fontFamily:"ui-monospace, monospace",color:"var(--archik-fg-muted)",textAlign:"right"},children:j.path})]},j.path)})]})})}function pue(){return R.jsx("span",{"aria-label":"pending suggestion",title:"Pending suggestion",style:{width:6,height:6,borderRadius:3,background:"var(--archik-accent)",flexShrink:0}})}function pVn({stack:h,onGoToFrame:b,suggestionsByPath:p}){return h.length<=1?null:R.jsx("nav",{"aria-label":"Architecture file navigation",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--archik-fg-muted)"},children:h.map((v,T)=>{const M=T===h.length-1,j=v.archikFile!==null&&p!==void 0&&p.has(v.archikFile);return R.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[M?R.jsxs("span",{style:{color:"var(--archik-fg)",fontWeight:600,display:"inline-flex",alignItems:"center",gap:6},"aria-current":"page",children:[v.label,j&&R.jsx(pue,{})]}):R.jsxs("button",{type:"button",onClick:()=>b(T),className:"archik-btn",style:{padding:"2px 6px",fontSize:12,color:"var(--archik-fg-muted)",background:"transparent",display:"inline-flex",alignItems:"center",gap:6},title:`Back to ${v.label}`,children:[v.label,j&&R.jsx(pue,{})]}),!M&&R.jsx("span",{"aria-hidden":"true",style:{opacity:.5},children:"›"})]},`${T}-${v.archikFile??"root"}`)})})}const mVn="/architecture.archik.yaml",vVn="/architecture.archik.suggested.yaml",yVn="/__archik/accept-suggestion",kVn=1500,h7e={label:"main",docUrl:mVn,sidecarUrl:vVn,acceptUrl:yVn,archikFile:null};function M0n(h,b){const p=h.replace(/\.archik\.yaml$/,".archik.suggested.yaml"),v=encodeURIComponent(h),T=encodeURIComponent(p);return{label:b,docUrl:`/__archik/file?path=${v}`,sidecarUrl:`/__archik/file?path=${T}`,acceptUrl:`/__archik/file-accept?path=${v}`,archikFile:h}}function jVn(){if(typeof window>"u")return null;const h=new URLSearchParams(window.location.search).get("file");return h!==null&&h.length>0?h:null}function SVn(h){if(typeof window>"u")return;const b=new URL(window.location.href);h===null||h.length===0?b.searchParams.delete("file"):b.searchParams.set("file",h),window.history.replaceState(null,"",b.toString())}function m1n(){const h=jVn();if(h===null)return[h7e];const p=(h.split("/").pop()??h).replace(/\.archik\.yaml$/i,"")||"main";return[M0n(h,p)]}function EVn(){const[h,b]=lt.useState({status:"loading"}),[p,v]=lt.useState(m1n),T=p[p.length-1],[M,j]=lt.useState([]),P=lt.useMemo(()=>new Set(M.filter(xn=>xn.hasSuggestion).map(xn=>xn.path)),[M]),G=lt.useMemo(()=>M.find(xn=>xn.isRoot)??null,[M]),J=T.archikFile===null?G?.path??null:T.archikFile,[se,re]=lt.useState(void 0),[fe,Ae]=lt.useState(void 0),[Ze,ie]=lt.useState("idle"),[tn,bn]=lt.useState(null),[_n,hn]=lt.useState(!1),[Rn,rt]=lt.useState(!1),[dt,Wn]=lt.useState({status:"none"}),[pt,wr]=lt.useState(!1),[Wr,Yr]=lt.useState([]),[Ui,Q]=lt.useState([]),Yo=100,[Ao,Jn]=lt.useState(()=>qXn()),ct=xn=>{Jn(xn),GXn(xn)},[ki,Br]=lt.useState(()=>BXn()),Xc=xn=>{Br(xn),FXn(xn)},[He,Yn]=lt.useState(()=>PXn()),ti=xn=>{Yn(xn),zXn(xn)},ji=lt.useMemo(()=>({...UXn(Ao),viewMode:ki}),[Ao,ki]),ar=lt.useMemo(()=>h.status==="ready"?new Set(h.document.nodes.filter(xn=>(xn.seqFiles?.length??0)>0).map(xn=>xn.id)):new Set,[h]),Jr=lt.useRef(!1),Oc=lt.useRef(null),Rs=lt.useRef(null),Wu=lt.useCallback(()=>Rs.current,[]),sh=lt.useRef(null),ds=oy(xn=>xn.selection),oa=oy(xn=>xn.connectFrom),r5=oy(xn=>xn.selectNode),Na=oy(xn=>xn.selectEdge),hy=oy(xn=>xn.toggleNode),iv=oy(xn=>xn.toggleEdge),Ab=oy(xn=>xn.clearSelection),t7=oy(xn=>xn.startConnect),su=oy(xn=>xn.cancelConnect),Vc=ds.length>0?ds.at(-1)??null:null,c5=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="node").map(xn=>xn.id)),[ds]),Ps=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="edge").map(xn=>xn.id)),[ds]);lt.useEffect(()=>{const xn=p[p.length-1];SVn(xn.archikFile)},[p]),lt.useEffect(()=>{if(typeof window>"u")return;const xn=()=>v(m1n());return window.addEventListener("popstate",xn),()=>window.removeEventListener("popstate",xn)},[]),lt.useEffect(()=>{let xn=!1;Oc.current="",Jr.current=!1;const Pt=()=>{BZn(T.docUrl).then(({document:xi,text:Dr})=>{if(xn||Dr===Oc.current)return;Oc.current=Dr,Jr.current=!0,b({status:"ready",document:xi}),hn(!1),typeof window<"u"&&xi.name&&(window.document.title=`${xi.name} — Archik`),Ae(void 0),Yr([]),Q([]);const Al=new Set(xi.nodes.map(ou=>ou.id)),To=new Set(xi.edges.map(ou=>ou.id));oy.setState(ou=>({selection:ou.selection.filter(Rc=>Rc.type==="node"?Al.has(Rc.id):To.has(Rc.id)),connectFrom:ou.connectFrom!==null&&Al.has(ou.connectFrom)?ou.connectFrom:null}))},xi=>{if(xn)return;const Dr=xi instanceof Error?xi.message:String(xi);Jr.current?Ae(Dr):b({status:"error",error:Dr})})};b({status:"loading"}),Pt();const Ji=s1n(Pt);return()=>{xn=!0,Ji()}},[T.docUrl]),lt.useEffect(()=>()=>{sh.current&&clearTimeout(sh.current)},[]),lt.useEffect(()=>{let xn=!1;const Pt=async()=>{try{const Dr=await fetch("/__archik/files",{cache:"no-store"});if(xn||!Dr.ok)return;const Al=await Dr.json();if(xn)return;Array.isArray(Al.files)&&j(Al.files)}catch{}};Pt();const Ji=s1n(()=>{Pt()}),xi=o1n(()=>{Pt()});return()=>{xn=!0,Ji(),xi()}},[]),lt.useEffect(()=>{if(h.status!=="ready")return;const xn=h.document;let Pt=!1;const Ji=async()=>{if(J!==null&&M.length>0&&M.some(Dr=>Dr.path===J)&&!P.has(J)){Wn({status:"none"});return}try{const Dr=await fetch(T.sidecarUrl,{cache:"no-store"});if(Pt)return;if(Dr.status===404){Wn({status:"none"});return}if(!Dr.ok){Wn({status:"error",message:`Sidecar fetch failed: HTTP ${Dr.status}`});return}const Al=await Dr.text();let To;try{To=w0n(Al)}catch(Rc){Wn({status:"error",message:Rc instanceof Error?Rc.message:String(Rc)});return}const ou=l7e(xn,To);Wn({status:"pending",added:ou.nodes.added.length+ou.edges.added.length,removed:ou.nodes.removed.length+ou.edges.removed.length,changed:ou.nodes.changed.length+ou.edges.changed.length,doc:To,...To.metadata?.suggestion?.note!==void 0?{note:To.metadata.suggestion.note}:{}})}catch(Dr){if(Pt)return;Wn({status:"error",message:Dr instanceof Error?Dr.message:String(Dr)})}};Ji();const xi=o1n(Ji);return()=>{Pt=!0,xi()}},[h,T.sidecarUrl,J,M,P]);const xT=lt.useCallback(async()=>{try{const xn=await fetch(T.acceptUrl,{method:"POST"});if(!xn.ok){const Pt=await xn.text();Wn({status:"error",message:`Accept failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.acceptUrl]),oh=lt.useCallback(async()=>{try{const xn=await fetch(T.sidecarUrl,{method:"DELETE"});if(!xn.ok&&xn.status!==404){const Pt=await xn.text();Wn({status:"error",message:`Reject failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.sidecarUrl]),MT=lt.useCallback(()=>{wr(xn=>!xn)},[]),dy=lt.useCallback(async()=>{let xn=null;if(b(Ji=>(Ji.status==="ready"&&(xn=Ji.document),Ji)),!xn)return;const Pt=G7e(xn);Oc.current=Pt,ie("saving"),bn(null);try{await FZn(T.docUrl,xn),ie("saved");let Ji=!1;b(xi=>(xi.status==="ready"&&xi.document===xn&&(Ji=!0),xi)),Ji&&hn(!1),sh.current&&clearTimeout(sh.current),sh.current=setTimeout(()=>ie("idle"),kVn)}catch(Ji){ie("error"),bn(Ji instanceof Error?Ji.message:String(Ji))}},[T.docUrl]),rv=G?.path??null,Zg=lt.useCallback((xn,Pt)=>rv===xn?h7e:M0n(xn,Pt),[rv]),by=lt.useCallback((xn,Pt)=>xn.archikFile===Pt?!0:xn.archikFile===null&&rv===Pt,[rv]),i7=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji.findIndex(Dr=>by(Dr,xn));return xi>=0?xi===Ji.length-1?Ji:Ji.slice(0,xi+1):[...Ji,Zg(xn,Pt)]})},[Zg,by]),u5=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji[Ji.length-1];return by(xi,xn)?Ji:[Zg(xn,Pt)]})},[Zg,by]),CT=lt.useCallback(xn=>{v(Pt=>xn<0||xn>=Pt.length-1?Pt:Pt.slice(0,xn+1))},[]),cv=lt.useCallback(xn=>{xn.isRoot?v([h7e]):u5(xn.path,xn.name)},[u5]),lh=lt.useCallback((xn,Pt)=>{if(oa===null){Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?hy(xn):r5(xn);return}if(xn===oa){su();return}let Ji=null;b(xi=>{if(xi.status!=="ready"||!xi.document.nodes.find(Rc=>Rc.id===oa))return xi;const Al=new Set(xi.document.edges.map(Rc=>Rc.id)),To=$8e(D8e(`${oa}-${xn}`),Al,"edge"),ou={id:To,from:oa,to:xn,relationship:"http_call"};try{const Rc=tI(xi.document,{type:"connect",edge:ou});return re(void 0),hn(!0),Yr(Bu=>[...Bu.slice(-(Yo-1)),xi.document]),Q([]),Ji=To,{status:"ready",document:Rc}}catch(Rc){const Bu=Rc instanceof Error?Rc.message:String(Rc);return re(Bu),xi}}),su(),Ji&&Na(Ji)},[oa,su,r5,hy,Na]),Tb=lt.useCallback((xn,Pt)=>{Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?iv(xn):Na(xn)},[Na,iv]),fh=lt.useCallback((xn,Pt)=>{let Ji=null;b(xi=>{if(xi.status!=="ready")return xi;const Dr=xi.document.nodes.find(Bu=>Bu.id===xn),Al=xi.document.nodes.find(Bu=>Bu.id===Pt);if(!Dr||!Al)return xi;const To=new Set(xi.document.edges.map(Bu=>Bu.id)),ou=$8e(D8e(`${xn}-${Pt}`),To,"edge"),Rc={id:ou,from:xn,to:Pt,relationship:"http_call"};try{const Bu=tI(xi.document,{type:"connect",edge:Rc});return re(void 0),hn(!0),Yr(Mb=>[...Mb.slice(-(Yo-1)),xi.document]),Q([]),Ji=ou,{status:"ready",document:Bu}}catch(Bu){const Mb=Bu instanceof Error?Bu.message:String(Bu);return re(Mb),xi}}),Ji&&Na(Ji)},[Na]),OT=lt.useCallback((xn,Pt,Ji)=>{b(xi=>{if(xi.status!=="ready")return xi;const Dr=new Set(xi.document.nodes.map(To=>To.id)),Al=$8e(D8e(Pt),Dr,xn);try{const To=tI(xi.document,{type:"add_node",node:{id:Al,kind:xn,name:Pt,description:Ji}});return re(void 0),hn(!0),Yr(ou=>[...ou.slice(-(Yo-1)),xi.document]),Q([]),{status:"ready",document:To}}catch(To){const ou=To instanceof Error?To.message:String(To);return re(ou),xi}})},[]),r7=lt.useCallback(xn=>{b(Pt=>{if(Pt.status!=="ready")return Pt;try{const Ji=tI(Pt.document,xn);return re(void 0),hn(!0),Yr(xi=>[...xi.slice(-(Yo-1)),Pt.document]),Q([]),{status:"ready",document:Ji}}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),Pt}})},[]),s5=lt.useCallback(()=>{ds.length!==0&&(b(xn=>{if(xn.status!=="ready")return xn;let Pt=xn.document;try{const Ji=ds.filter(Dr=>Dr.type==="edge").map(Dr=>Dr.id);for(const Dr of Ji)Pt.edges.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"disconnect",id:Dr}));const xi=ds.filter(Dr=>Dr.type==="node").map(Dr=>Dr.id);for(const Dr of xi)Pt.nodes.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"remove_node",id:Dr}));return Pt===xn.document?xn:(re(void 0),hn(!0),Yr(Dr=>[...Dr.slice(-(Yo-1)),xn.document]),Q([]),{status:"ready",document:Pt})}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),xn}}),Ab())},[ds,Ab]),$p=lt.useCallback(()=>{if(h.status!=="ready"||Wr.length===0)return;const xn=Wr[Wr.length-1];Yr(Pt=>Pt.slice(0,-1)),Q(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Wr,Ab]),Xg=lt.useCallback(()=>{if(h.status!=="ready"||Ui.length===0)return;const xn=Ui[Ui.length-1];Q(Pt=>Pt.slice(0,-1)),Yr(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Ui,Ab]);if(lt.useEffect(()=>{const xn=Pt=>{if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="s"){Pt.preventDefault(),_n&&dy();return}if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="z"||Pt.key==="Z")){Pt.preventDefault(),Pt.shiftKey?Xg():$p();return}if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="y"){Pt.preventDefault(),Xg();return}if(Pt.key==="Escape"){oa&&su();return}if(Pt.key==="Delete"||Pt.key==="Backspace"){const Ji=Pt.target;if(Ji instanceof HTMLInputElement||Ji instanceof HTMLTextAreaElement||Ji instanceof HTMLSelectElement||Ji instanceof HTMLElement&&Ji.isContentEditable||ds.length===0)return;Pt.preventDefault(),s5()}};return window.addEventListener("keydown",xn),()=>window.removeEventListener("keydown",xn)},[_n,dy,oa,su,ds,s5,$p,Xg]),h.status==="loading")return R.jsxs(v1n,{children:["Loading ",T.docUrl,"…"]});if(h.status==="error")return R.jsx(v1n,{children:R.jsx("pre",{className:"max-w-3xl whitespace-pre-wrap text-xs text-rose-700",children:h.error})});const xb=h.document,E1=pt&&dt.status==="pending",gy=E1&&dt.status==="pending"?XZn(xb,dt.doc):null,Lp=E1&&dt.status==="pending"?y0n(l7e(xb,dt.doc)):null,wy=gy??xb,c7=Vc?.type==="node"?wy.nodes.find(xn=>xn.id===Vc.id):void 0,o5=Vc?.type==="edge"?wy.edges.find(xn=>xn.id===Vc.id):void 0,Rp=oa!==null?xb.nodes.find(xn=>xn.id===oa):void 0,u7=ds.length>1;return R.jsxs("div",{className:"flex h-full flex-col",style:{background:"var(--archik-canvas)",color:"var(--archik-fg)"},children:[R.jsx(bVn,{document:xb,commandError:se,saveStatus:Ze,...tn!==null?{saveError:tn}:{},isDirty:_n,onSave:()=>{dy()},onAddNode:OT,density:Ao,onDensityChange:ct,viewMode:ki,onViewModeChange:Xc,showStereotypeBands:He,onToggleStereotypeBands:()=>ti(!He),canUndo:Wr.length>0,canRedo:Ui.length>0,onUndo:$p,onRedo:Xg,getSvg:Wu,seqHighlight:Rn,onToggleSeqHighlight:()=>rt(xn=>!xn),seqNodeCount:ar.size,...fe!==void 0?{reloadError:fe}:{},...Rp!==void 0?{connectingFromName:Rp.name,onCancelConnect:su}:{}}),dt.status==="pending"&&R.jsx(TVn,{added:dt.added,removed:dt.removed,changed:dt.changed,note:dt.note,reviewing:E1,onReview:MT,onAccept:()=>{xT()},onReject:()=>{oh()}}),dt.status==="error"&&R.jsxs("div",{role:"alert",style:{background:"rgba(217, 119, 6, 0.12)",borderBottom:"1px solid rgba(217, 119, 6, 0.45)",color:"var(--archik-warning)",padding:"8px 16px",fontSize:12,display:"flex",alignItems:"center",gap:12},children:[R.jsx("span",{style:{fontWeight:700},children:"SUGGESTION ERROR —"}),R.jsx("span",{style:{flex:1,color:"var(--archik-fg)"},children:dt.message}),R.jsx("button",{type:"button",onClick:()=>Wn({status:"none"}),"aria-label":"Dismiss",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",fontSize:16,lineHeight:1},children:"×"})]}),fe!==void 0&&R.jsxs("div",{role:"alert",style:{background:"rgba(225, 29, 72, 0.12)",borderBottom:"1px solid rgba(225, 29, 72, 0.45)",color:"var(--archik-danger)",padding:"10px 16px",display:"flex",alignItems:"flex-start",gap:12,fontSize:12,lineHeight:1.5},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:"FILE INVALID —"}),R.jsx("pre",{style:{margin:0,flex:1,whiteSpace:"pre-wrap",fontFamily:"inherit",color:"var(--archik-fg)"},children:fe}),R.jsx("button",{type:"button",onClick:()=>Ae(void 0),"aria-label":"Dismiss error",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",padding:"0 4px",fontSize:16,lineHeight:1},children:"×"})]}),R.jsxs("main",{className:"flex min-h-0 flex-1 p-4",style:{gap:0},children:[R.jsx("div",{className:"archik-panel",style:{flex:1,minWidth:0,overflow:"hidden"},children:R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"},children:[(M.length>1||p.length>1)&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--archik-surface)",borderBottom:"1px solid var(--archik-border)"},children:[R.jsx(wVn,{files:M,currentPath:J,onSwitchFile:cv}),R.jsx(pVn,{stack:p,onGoToFrame:CT,suggestionsByPath:P})]}),R.jsx(Bqn,{document:wy,className:"flex-1 archik-grid",layoutOptions:ji,viewMode:ki,showStereotypeBands:He,selectedNodeIds:c5,selectedEdgeIds:Ps,onSelectNode:lh,onSelectEdge:Tb,onSelectNothing:oa===null?Ab:su,onConnectDrag:fh,onOpenSubFile:i7,onCrossFileNavigate:u5,viewKey:T.docUrl,svgRef:Rs,...Lp?{diffStatuses:Lp}:{},...Rn&&ar.size>0?{glowNodeIds:ar}:{}})]})}),R.jsx("aside",{"aria-hidden":ds.length===0,className:`archik-drawer-shell ${ds.length>0?"archik-drawer-shell--open":"archik-drawer-shell--closed"}`,children:R.jsx("div",{className:"archik-panel archik-drawer-content archik-drawer-fade",style:{overflow:"hidden"},children:u7?R.jsx(AVn,{count:ds.length,onDelete:s5,onClear:Ab}):Vc?.type==="edge"?R.jsx(bXn,{edge:o5,dispatch:r7,readOnly:E1}):Vc?.type==="node"?R.jsx(oXn,{node:c7,dispatch:r7,onStartConnect:t7,allNodes:wy.nodes,readOnly:E1,viewKey:T.archikFile??void 0}):null},u7?`multi:${ds.length}`:Vc?`${Vc.type}:${Vc.id}`:"empty")})]})]})}function AVn({count:h,onDelete:b,onClear:p}){return R.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-sm",children:[R.jsxs("div",{children:[R.jsx("div",{className:"archik-label",children:"Selection"}),R.jsxs("div",{style:{fontSize:18,fontWeight:600,color:"var(--archik-fg)",letterSpacing:"0.01em"},children:[h," items"]}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)",marginTop:4},children:"Hold ⌘ / Ctrl while clicking to add or remove items."})]}),R.jsx("div",{className:"archik-divider"}),R.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-4",children:[R.jsx("button",{type:"button",onClick:p,className:"archik-btn",style:{justifyContent:"center",padding:"8px 12px"},children:"Clear selection"}),R.jsxs("button",{type:"button",onClick:b,className:"archik-btn archik-btn-danger",style:{justifyContent:"center",padding:"8px 12px"},children:["Delete ",h," items"]})]})]})}function v1n({children:h}){return R.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm",style:{background:"var(--archik-canvas)",color:"var(--archik-fg-dim)"},children:h})}function TVn({added:h,removed:b,changed:p,note:v,reviewing:T,onReview:M,onAccept:j,onReject:P}){const G=h+b+p;return R.jsxs("div",{role:"region","aria-label":"Pending suggestion",style:{background:"rgba(168, 85, 247, 0.12)",borderBottom:"1px solid rgba(168, 85, 247, 0.45)",padding:"10px 16px",display:"flex",alignItems:"center",gap:14,fontSize:12,lineHeight:1.4},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em",color:"#c4b5fd"},children:"📝 SUGGESTION PENDING"}),R.jsxs("span",{style:{color:"var(--archik-fg)"},children:[G===0?"(identical to current — nothing to apply)":R.jsxs(R.Fragment,{children:[R.jsxs("span",{style:{color:"var(--archik-success)"},children:["+",h]})," ",R.jsxs("span",{style:{color:"var(--archik-danger)"},children:["−",b]})," ",R.jsxs("span",{style:{color:"var(--archik-warning)"},children:["~",p]})]}),v?R.jsxs("span",{style:{marginLeft:10,color:"var(--archik-fg-dim)",fontStyle:"italic"},children:['"',v,'"']}):null]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[R.jsx("button",{type:"button",onClick:M,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,...T?{background:"#a855f7",color:"white",borderColor:"#a855f7"}:{}},children:T?"Hide diff":"Review"}),R.jsx("button",{type:"button",onClick:j,className:"archik-btn",title:G===0?"Suggestion already matches the current file — Accept just clears the sidecar.":"Apply the suggestion to the main file.",style:{padding:"5px 12px",fontSize:12,background:"var(--archik-success)",color:"white",borderColor:"var(--archik-success)"},children:"Accept"}),R.jsx("button",{type:"button",onClick:P,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"Reject"})]})]})}const xVn=n7(["sync","async","return","create","destroy"]),MVn=n7(["over","left_of","right_of"]),CVn=n7(["alt","opt","loop","par","break","ref"]),OVn=Kg({id:dd,nodeId:dd,label:hs().min(1).optional(),status:CI.optional()}),_Vn=Kg({type:oJ("message"),id:dd,from:dd,to:dd,label:hs().min(1),arrow:xVn,activate:VKn().optional(),status:CI.optional()}),NVn=Kg({type:oJ("note"),id:dd,position:MVn,participants:Jg(dd).min(1),text:hs().min(1),status:CI.optional()}),IVn=F7e(()=>Kg({label:hs().optional(),steps:Jg(C0n)})),DVn=F7e(()=>Kg({type:oJ("group"),id:dd,kind:CVn,condition:hs().optional(),label:hs().optional(),branches:Jg(IVn).optional(),seqFile:h0n.optional(),participants:Jg(dd).optional(),status:CI.optional()})),C0n=F7e(()=>o0n([_Vn,NVn,DVn]));function O0n(h,b){const p=[];for(const v of h)if(b.has(v.id)?p.push(v.id):b.add(v.id),v.type==="group"&&v.branches)for(const T of v.branches)p.push(...O0n(T.steps,b));return p}const $Vn=Kg({useCase:dd,slice:dd}),LVn=Kg({version:oJ("1.0"),name:hs().min(1),description:hs().optional(),realizes:$Vn.optional(),participants:Jg(OVn).min(1),steps:Jg(C0n)}).superRefine((h,b)=>{const p=new Set;for(let M=0;M<h.participants.length;M++){const j=h.participants[M];p.has(j.id)&&b.addIssue({code:jb.custom,path:["participants",M,"id"],message:`duplicate participant id "${j.id}"`}),p.add(j.id)}const v=new Set,T=O0n(h.steps,v);for(const M of T)b.addIssue({code:jb.custom,path:["steps"],message:`duplicate step id "${M}"`})}),kI=56,RVn=160,PVn=40,d7e=56,zVn=24,eue=12,BVn=20,FVn=6,y1n=64,pT=32,B8e=24,k1n=8,_0n="seq-arrow-filled",N0n="seq-arrow-open";function qVn(h){return Math.max(RVn,h.length*8+PVn*2)}function I0n(h,b,p,v,T,M=0){let j=p;const P=[];let G=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY;for(const se of h)if(se.type==="message"){const re=b.get(se.from),fe=b.get(se.to),Ae=re?.cx??v,Ze=fe?.cx??v;P.push({type:"message",id:se.id,fromCx:Ae,toCx:Ze,y:j,label:se.label,arrow:se.arrow,activate:se.activate??!1,isSelf:se.from===se.to,...se.status!==void 0?{status:se.status}:{}}),j+=se.from===se.to?d7e*1.5:d7e}else if(se.type==="note"){const re=se.participants.map(tn=>b.get(tn)?.cx).filter(tn=>tn!==void 0).sort((tn,bn)=>tn-bn),fe=re[0]??v,Ae=re[re.length-1]??T,Ze=Math.min(Math.max(se.text.length*7.5+24,Ae-fe+16,80),400);let ie;se.position==="left_of"?ie=fe-Ze-8:se.position==="right_of"?ie=Ae+8:ie=(fe+Ae)/2-Ze/2,G=Math.min(G,ie),J=Math.max(J,ie+Ze),P.push({type:"note",id:se.id,x:ie,y:j,width:Ze,height:y1n,text:se.text,...se.status!==void 0?{status:se.status}:{}}),j+=y1n+8}else if(se.type==="group"){const re=Math.min(M*FVn,eue),fe=v-eue+re,Ae=T-v+eue*2-re*2,Ze=j;j+=zVn;const ie=[];if(se.branches)for(let tn=0;tn<se.branches.length;tn++){const bn=se.branches[tn],_n=j,{items:hn,endY:Rn,contentMinX:rt,contentMaxX:dt}=I0n(bn.steps,b,j,v,T,M+1);j=Rn,G=Math.min(G,rt),J=Math.max(J,dt),ie.push({...bn.label!==void 0?{label:bn.label}:{},startY:_n,...tn<se.branches.length-1?{dividerY:j}:{},steps:hn}),tn<se.branches.length-1&&(j+=4)}j+=eue,P.push({type:"group",id:se.id,kind:se.kind,...se.condition!==void 0?{condition:se.condition}:{},...se.label!==void 0?{label:se.label}:{},...se.seqFile!==void 0?{seqFile:se.seqFile}:{},x:fe,y:Ze,width:Ae,height:j-Ze,branches:ie,...se.status!==void 0?{status:se.status}:{}}),G=Math.min(G,fe),J=Math.max(J,fe+Ae),j+=BVn}return{items:P,endY:j,contentMinX:G,contentMaxX:J}}function D0n(h){const b=new Map;for(const p of h)if(p.type==="message"&&p.arrow==="destroy"&&b.set(p.toCx,p.y+kI+20),p.type==="group")for(const v of p.branches)for(const[T,M]of D0n(v.steps))b.set(T,M);return b}function GVn(h){const b=[],p=new Map;function v(T){for(const M of T)if(M.type==="message"){if(M.activate&&M.arrow==="sync"&&!M.isSelf){const j=p.get(M.toCx)??[];j.push(M.y),p.set(M.toCx,j)}if(M.arrow==="return"&&!M.isSelf){const j=p.get(M.fromCx);if(j&&j.length>0){const P=j.pop();b.push({cx:M.fromCx,startY:P,endY:M.y}),j.length===0&&p.delete(M.fromCx)}}}else if(M.type==="group")for(const j of M.branches)v(j.steps)}v(h);for(const[T,M]of p)for(const j of M)b.push({cx:T,startY:j,endY:j+d7e/2});return b}function UVn(h,b){const p=h.participants.map(Wn=>qVn(Wn.label??Wn.nodeId));let v=pT;const T=h.participants.map((Wn,pt)=>{const wr=p[pt],Wr=v+wr/2;v+=wr;const Yr=b?.get(Wn.nodeId);return{id:Wn.id,nodeId:Wn.nodeId,label:Wn.label??Wn.nodeId,cx:Wr,colWidth:wr,...Yr!==void 0?{kind:Yr}:{},...Wn.status!==void 0?{status:Wn.status}:{},lifelineEndY:0}}),M=v+pT,j=new Map(T.map(Wn=>[Wn.id,Wn])),P=T[0]?.cx??pT,G=T[T.length-1]?.cx??M-pT,J=B8e,{items:se,endY:re,contentMinX:fe,contentMaxX:Ae}=I0n(h.steps,j,J,P,G),Ze=fe<pT&&Number.isFinite(fe)?pT-fe:0,ie=Number.isFinite(Ae)?Ae+Ze+pT:0,tn=Math.max(M+Ze,ie),bn=Ze>0?se.map(Wn=>$0n(Wn,Ze)):se,_n=Ze>0?T.map(Wn=>({...Wn,cx:Wn.cx+Ze})):T,hn=D0n(bn),Rn=_n.map(Wn=>({...Wn,lifelineEndY:hn.get(Wn.cx)??kI+re+B8e})),rt=kI+re+B8e,dt=GVn(bn);return{participants:Rn,steps:bn,activations:dt,totalWidth:tn,totalHeight:rt}}function $0n(h,b){return h.type==="message"?{...h,fromCx:h.fromCx+b,toCx:h.toCx+b}:h.type==="note"?{...h,x:h.x+b}:{...h,x:h.x+b,branches:h.branches.map(p=>({...p,steps:p.steps.map(v=>$0n(v,b))}))}}const nue=36,JVn=128,HVn=7,j1n=20,S1n=24;function KVn({participant:h,nodeKind:b}){const p=b?Np[b]:void 0,v=p?.color??"var(--archik-fg-muted)",T=(kI-nue)/2,M=p?.icon,j=Math.max(JVn,h.label.length*HVn+S1n+(M?j1n:0)),P=j/2,G=M?P+j1n/2:P,J=h.status,se=J==="proposed"?.55:J==="deprecated"?.35:1,re=J==="proposed"||J==="deprecated"?"4 3":void 0;return R.jsxs("g",{transform:`translate(${h.cx-P}, ${T})`,opacity:se,children:[R.jsx("rect",{width:j,height:nue,rx:8,fill:"var(--archik-node-fill)",stroke:v,strokeWidth:1.4,...re!==void 0?{strokeDasharray:re}:{}}),M&&R.jsx("g",{transform:`translate(${S1n/2}, ${(nue-14)/2})`,children:R.jsx(M,{size:14,color:v,strokeWidth:1.5})}),R.jsx("text",{x:G,y:nue/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}function ZVn({participant:h}){const b=h.status,p=b==="proposed"?.3:b==="deprecated"?.2:.5;return R.jsx("line",{x1:h.cx,y1:kI,x2:h.cx,y2:h.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:p})}const F8e=32,q8e=20,XVn=-6;function VVn({msg:h}){const b=h.arrow==="return",p=h.arrow==="async",v=h.arrow==="create",T=b||v,M=h.arrow==="destroy",j=b||p?N0n:_0n,P=h.status==="proposed"?.5:h.status==="deprecated"?.35:1;if(h.isSelf){const re=h.fromCx,fe=h.y,Ae=`M ${re} ${fe} L ${re+F8e} ${fe} L ${re+F8e} ${fe+q8e} L ${re} ${fe+q8e}`;return R.jsxs("g",{opacity:P,children:[R.jsx("path",{d:Ae,fill:"none",stroke:"var(--archik-edge-filled)",strokeWidth:1.4,markerEnd:`url(#${j})`}),R.jsx("text",{x:re+F8e+6,y:fe+q8e/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}const J=h.fromCx<h.toCx?h.toCx-6:h.toCx+6,se=(h.fromCx+h.toCx)/2;return R.jsxs("g",{opacity:P,children:[R.jsx("line",{x1:h.fromCx,y1:h.y,x2:J,y2:h.y,stroke:"var(--archik-edge-filled)",strokeWidth:1.4,strokeDasharray:T?"4 4":void 0,markerEnd:M?void 0:`url(#${j})`}),R.jsxs("text",{x:se,y:h.y+XVn,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[v&&"«create» ",h.label]}),h.arrow==="destroy"&&R.jsxs("g",{transform:`translate(${h.toCx-6}, ${h.y-6})`,children:[R.jsx("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),R.jsx("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}const WVn={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},E1n=36,G8e=18;function YVn({group:h,renderStep:b,onRefClick:p}){const v=WVn[h.kind]??"var(--archik-fg-muted)",T=h.status==="proposed"?.55:h.status==="deprecated"?.35:1,M=h.kind==="ref"&&h.seqFile!==void 0&&p!==void 0;return R.jsxs("g",{opacity:T,onClick:M?()=>p(h.seqFile):void 0,style:M?{cursor:"pointer"}:void 0,children:[R.jsx("rect",{x:h.x,y:h.y,width:h.width,height:h.height,rx:4,fill:"none",stroke:v,strokeWidth:1.2,opacity:.6}),R.jsx("rect",{x:h.x,y:h.y,width:E1n,height:G8e,rx:4,fill:v,opacity:.8}),R.jsx("text",{x:h.x+6,y:h.y+G8e-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:h.kind}),(h.condition??h.label)&&R.jsx("text",{x:h.x+E1n+6,y:h.y+G8e-5,fontSize:10,fill:v,fontFamily:"inherit",children:h.condition??h.label}),h.branches.map((j,P)=>R.jsxs("g",{children:[j.label&&R.jsx("text",{x:h.x+6,y:j.startY+12,fontSize:10,fill:v,fontFamily:"inherit",children:j.label}),j.steps.map(G=>b(G)),j.dividerY!==void 0&&R.jsx("line",{x1:h.x,y1:j.dividerY,x2:h.x+h.width,y2:j.dividerY,stroke:v,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},P))]})}const rI=10;function QVn(h,b){const p=Math.max(10,Math.floor(b/6.5));if(h.length<=p)return[h];const v=h.split(" "),T=[];let M="";for(const j of v)(M+(M?" ":"")+j).length>p&&M?(T.push(M),M=j):M=M?M+" "+j:j;return M&&T.push(M),T.slice(0,3)}function eWn({note:h}){const{x:b,y:p,width:v,height:T,text:M}=h,j=h.status==="proposed"?.55:h.status==="deprecated"?.35:1;return R.jsxs("g",{opacity:j,children:[R.jsx("path",{d:`M ${b} ${p} L ${b+v-rI} ${p} L ${b+v} ${p+rI} L ${b+v} ${p+T} L ${b} ${p+T} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),R.jsx("path",{d:`M ${b+v-rI} ${p} L ${b+v-rI} ${p+rI} L ${b+v} ${p+rI}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),QVn(M,v-16).map((P,G)=>R.jsx("text",{x:b+8,y:p+8+11+G*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:P},G))]})}function nWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}function tWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 12 12",refX:"11",refY:"6",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 1 1 L 11 6 L 1 11",fill:"none",stroke:"context-stroke",strokeWidth:"1.5",strokeLinejoin:"round"})})}function L0n({step:h,onRefClick:b}){return h.type==="message"?R.jsx(VVn,{msg:h}):h.type==="note"?R.jsx(eWn,{note:h}):h.type==="group"?R.jsx(YVn,{group:h,...b!==void 0?{onRefClick:b}:{},renderStep:p=>R.jsx(L0n,{step:p,...b!==void 0?{onRefClick:b}:{}},p.id)}):null}function iWn({laid:h,svgRef:b,onRefClick:p}){const{participants:v,steps:T,activations:M,totalWidth:j,totalHeight:P}=h;return R.jsxs("svg",{ref:b,width:j,height:P,viewBox:`0 0 ${j} ${P}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[R.jsxs("defs",{children:[R.jsx(nWn,{id:_0n}),R.jsx(tWn,{id:N0n})]}),v.map(G=>R.jsx(ZVn,{participant:G},G.id)),v.map(G=>R.jsx(KVn,{participant:G,...G.kind!==void 0?{nodeKind:G.kind}:{}},G.id)),R.jsxs("g",{transform:`translate(0, ${kI})`,children:[M.map(G=>R.jsx("rect",{x:G.cx-k1n/2,y:G.startY,width:k1n,height:G.endY-G.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${G.cx}-${G.startY}`)),T.map(G=>R.jsx(L0n,{step:G,...p!==void 0?{onRefClick:p}:{}},G.id))]})]})}const A1n="archik.seq.rail.open";function rWn({path:h,back:b}){const[p,v]=lt.useState({status:"loading"}),[T,M]=lt.useState(void 0),[j,P]=lt.useState([]),[G,J]=lt.useState(()=>{if(typeof window>"u")return!0;const hn=window.localStorage.getItem(A1n);return hn===null?!0:hn==="1"}),[se,re]=lt.useState(!1),fe=lt.useRef(null);lt.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(A1n,G?"1":"0")},[G]),lt.useEffect(()=>{fetch("/__archik/node-kinds").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&M(new Map(Object.entries(hn)))}).catch(()=>{})},[]),lt.useEffect(()=>{fetch("/__archik/usecases").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&P(hn.useCases??[])}).catch(()=>{})},[]),lt.useEffect(()=>{v({status:"loading"});const hn=encodeURIComponent(h);fetch(`/__archik/seq-file?path=${hn}`).then(async Rn=>{if(!Rn.ok)throw new Error(`${Rn.status} ${Rn.statusText}`);return Rn.text()}).then(Rn=>{const rt=I7e.parse(Rn),dt=LVn.safeParse(rt);if(!dt.success)throw new Error(dt.error.issues.map(Wn=>Wn.message).join("; "));v({status:"ready",doc:dt.data,raw:Rn})}).catch(Rn=>{v({status:"error",message:Rn instanceof Error?Rn.message:String(Rn)})})},[h]);const Ae=b?b.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(b.value)}`:`/?file=${encodeURIComponent(b.value)}`:"/",Ze=b?.type==="usecase"?"Use cases":"Architecture",ie=lt.useMemo(()=>{if(p.status!=="ready")return null;const hn=p.doc.realizes;if(!hn)return null;const Rn=j.find(dt=>dt.id===hn.useCase);if(!Rn)return{useCase:hn.useCase,slice:hn.slice,name:void 0,slice_data:void 0};const rt=Rn.slices.find(dt=>dt.id===hn.slice);return{useCase:hn.useCase,slice:hn.slice,name:Rn.name,slice_data:rt,primaryActor:Rn.primaryActor}},[p,j]);if(p.status==="loading")return R.jsx("div",{className:"flex h-screen items-center justify-center",style:{color:"var(--archik-fg-muted)"},children:"Loading sequence diagram…"});if(p.status==="error")return R.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[R.jsx("div",{style:{color:"var(--archik-fg-error, #ef4444)"},children:p.message}),R.jsxs("a",{href:Ae,style:{color:"var(--archik-fg-muted)",fontSize:13},children:["← ",Ze]})]});const tn=UVn(p.doc,T),bn=h.replace(/^.*\//,"").replace(/\.archik\.seq\.yaml$/,""),_n=hn=>{const Rn=new URLSearchParams;Rn.set("path",hn),b?.type==="usecase"?Rn.set("from-uc",b.value):b?.type==="file"&&Rn.set("from-file",b.value),window.location.href=`/__archik/seq?${Rn.toString()}`};return R.jsxs("div",{className:"flex h-screen flex-col",style:{background:"var(--archik-canvas)"},children:[R.jsx(cWn,{backHref:Ae,backLabel:Ze,realizedSlice:ie,seqName:p.doc.name,railOpen:G,onToggleRail:()=>J(hn=>!hn),filename:bn,getSvg:()=>fe.current}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[R.jsx("div",{style:{flex:1,overflow:"auto",padding:24},children:R.jsx(iWn,{laid:tn,svgRef:fe,onRefClick:_n})}),G&&R.jsx(uWn,{doc:p.doc,raw:p.raw,yamlOpen:se,onToggleYaml:()=>re(hn=>!hn),realizedSlice:ie,kinds:T})]})]})}function cWn({backHref:h,backLabel:b,realizedSlice:p,seqName:v,railOpen:T,onToggleRail:M,filename:j,getSvg:P}){return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 16px",height:48,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0,fontSize:13},children:[R.jsxs("a",{href:h,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[R.jsx(L1n,{size:14}),b]}),p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(p.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.useCase}),R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.slice})]}),!p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontWeight:500},children:v})]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[R.jsx(S0n,{filename:j,getSvg:P}),R.jsx("button",{type:"button",onClick:M,"aria-label":T?"Hide details":"Show details","aria-pressed":T,title:T?"Hide details panel":"Show details panel",className:"archik-btn",style:{padding:"5px 8px"},children:T?R.jsx(fFn,{size:14}):R.jsx(hFn,{size:14})})]})]})}function U8e(){return R.jsx(SBn,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function uWn({doc:h,raw:b,yamlOpen:p,onToggleYaml:v,realizedSlice:T,kinds:M}){return R.jsxs("aside",{style:{width:300,flexShrink:0,borderLeft:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:16,fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsx(tue,{title:"Realizes",children:T?R.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[R.jsx(T1n,{label:"Use case",children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(T.useCase)}`,style:iue({color:"var(--archik-accent)"}),children:[T.useCase,T.name?` — ${T.name}`:""]})}),R.jsx(T1n,{label:"Slice",children:R.jsx("code",{style:iue(),children:T.slice})}),T.slice_data?.description&&R.jsx("div",{style:{marginTop:4,fontSize:11,lineHeight:1.5},children:T.slice_data.description})]}):R.jsxs(x1n,{children:["No ",R.jsx("code",{children:"realizes"})," block — this is an ad-hoc / scratch flow, not bound to a use case slice."]})}),R.jsx(tue,{title:`Participants (${h.participants.length})`,children:R.jsx("ul",{style:M1n,children:h.participants.map(j=>{const P=M?.get(j.nodeId),G=P?Np[P]:void 0,J=G?.icon;return R.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 0"},children:[J?R.jsx(J,{size:12,color:G.color,strokeWidth:2}):R.jsx("span",{style:{width:12}}),R.jsx("code",{style:iue(),children:j.nodeId}),j.id!==j.nodeId&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",j.id,"]"]})]},j.id)})})}),T?.slice_data&&R.jsx(tue,{title:"Proved by",children:(T.slice_data.tests?.length??0)===0?R.jsx(x1n,{children:"No tests declared on this slice."}):R.jsx("ul",{style:{...M1n,listStyle:"none",paddingLeft:0},children:T.slice_data.tests.map(j=>R.jsxs("li",{style:{...iue(),fontSize:11,padding:"2px 0"},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",j]},j))})}),R.jsxs(tue,{title:"Source",children:[R.jsxs("button",{type:"button",onClick:v,className:"archik-btn",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 8px"},children:[R.jsx(zBn,{size:11}),p?"Hide YAML":"View YAML"]}),p&&R.jsx("pre",{style:{marginTop:8,padding:10,background:"var(--archik-surface)",border:"1px solid var(--archik-border)",borderRadius:4,fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg-dim)",overflowX:"auto",whiteSpace:"pre",maxHeight:360,overflowY:"auto"},children:b})]})]})}function tue({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:18},children:[R.jsx("h2",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",margin:"0 0 6px"},children:h}),b]})}function T1n({label:h,children:b}){return R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[R.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",width:56,flexShrink:0},children:h}),R.jsx("span",{style:{flex:1,minWidth:0},children:b})]})}function x1n({children:h}){return R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",lineHeight:1.5},children:h})}function iue(h){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...h}}const M1n={margin:0,paddingLeft:0,listStyle:"none"},sWn="/__archik/usecases",oWn="/__archik/trace";async function C1n(h,b){const p=await fetch(h,{cache:"no-store",signal:b});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function lWn({selectedId:h}){const[b,p]=lt.useState({status:"loading"});return lt.useEffect(()=>{let v=!1;const T=new AbortController;return Promise.all([C1n(sWn,T.signal),C1n(oWn,T.signal)]).then(([M,j])=>{v||p({status:"ready",useCases:M.useCases??[],trace:j.rows??[]})}).catch(M=>{v||T.signal.aborted||p({status:"error",message:M instanceof Error?M.message:String(M)})}),()=>{v=!0,T.abort()}},[]),R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[R.jsx(fWn,{state:b}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[b.status==="loading"&&R.jsx(J8e,{children:"Loading…"}),b.status==="error"&&R.jsxs(J8e,{tone:"error",children:["Couldn't load: ",b.message]}),b.status==="ready"&&b.useCases.length===0&&R.jsxs(J8e,{children:["No use cases defined yet. Add a ",R.jsx("code",{children:"*.archik.uc.yaml"})," file under ",R.jsx("code",{children:".archik/usecases/"}),"."]}),b.status==="ready"&&b.useCases.length>0&&R.jsx(aWn,{useCases:b.useCases,trace:b.trace,selectedId:h})]})]})}function fWn({state:h}){const b=lt.useMemo(()=>{if(h.status!=="ready")return null;let p=0,v=0,T=0;for(const M of h.trace)M.level==="full"?p++:M.level==="partial"?v++:T++;return{full:p,partial:v,none:T,total:h.trace.length}},[h]);return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 20px",height:52,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0},children:[R.jsxs("a",{href:"/",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-fg-dim)",fontSize:13,textDecoration:"none"},children:[R.jsx(L1n,{size:14}),"Architecture"]}),R.jsx("span",{style:{color:"var(--archik-border-strong)"},children:"|"}),R.jsx("h1",{style:{fontSize:14,fontWeight:600,margin:0,color:"var(--archik-fg)"},children:"Use cases"}),b&&b.total>0&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto",fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",b.full," full"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",b.partial," partial"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",b.none," untraced"]}),R.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:["· ",b.total," ",b.total===1?"slice":"slices"]})]})]})}function aWn({useCases:h,trace:b,selectedId:p}){const v=lt.useMemo(()=>{const j=new Map;for(const P of b){const G=j.get(P.useCase);if(!G){j.set(P.useCase,P.level);continue}G==="none"||P.level==="none"?j.set(P.useCase,"none"):(G==="partial"||P.level==="partial")&&j.set(P.useCase,"partial")}return j},[b]),T=lt.useMemo(()=>{const j=new Map;for(const P of b)j.set(`${P.useCase}/${P.slice}`,P);return j},[b]),M=h.find(j=>j.id===p)??h[0];return R.jsxs(R.Fragment,{children:[R.jsx(hWn,{useCases:h,ucLevel:v,selectedId:M.id}),R.jsx(dWn,{useCase:M,traceByKey:T})]})}function hWn({useCases:h,ucLevel:b,selectedId:p}){return R.jsx("nav",{"aria-label":"Use cases",style:{width:260,borderRight:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:"8px 0",flexShrink:0},children:R.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:h.map(v=>{const T=b.get(v.id)??"none",M=v.id===p;return R.jsx("li",{children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(v.id)}`,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",textDecoration:"none",color:"var(--archik-fg)",background:M?"var(--archik-surface-hover)":"transparent",borderLeft:M?"2px solid var(--archik-accent)":"2px solid transparent",fontSize:13},children:[R.jsx(R0n,{level:T}),R.jsxs("span",{style:{flex:1,minWidth:0},children:[R.jsx("code",{style:{fontSize:12,fontFamily:"ui-monospace, monospace"},children:v.id}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.name})]}),v.status&&v.status!=="active"&&R.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:4,background:"var(--archik-surface)",color:"var(--archik-fg-muted)"},children:v.status})]})},v.id)})})})}function R0n({level:h}){const b=h==="full"?{glyph:"●",color:"var(--archik-success)",label:"fully traced"}:h==="partial"?{glyph:"◐",color:"var(--archik-warning)",label:"partially traced"}:{glyph:"○",color:"var(--archik-fg-muted)",label:"untraced"};return R.jsx("span",{title:b.label,"aria-label":b.label,style:{color:b.color,fontSize:12,lineHeight:1,width:12},children:b.glyph})}function dWn({useCase:h,traceByKey:b}){return R.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:R.jsxs("div",{style:{maxWidth:820,margin:"0 auto"},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:4},children:[R.jsx("code",{style:{fontSize:18,fontFamily:"ui-monospace, monospace",fontWeight:600,color:"var(--archik-fg)"},children:h.id}),h.status&&h.status!=="active"&&R.jsx("span",{className:"archik-pill",style:{fontSize:10},children:h.status})]}),R.jsx("div",{style:{fontSize:15,color:"var(--archik-fg-dim)",marginBottom:18},children:h.name}),R.jsx(bWn,{useCase:h}),h.goal&&R.jsx(cI,{title:"Goal",children:R.jsx("p",{style:{margin:0,lineHeight:1.55},children:h.goal})}),(h.preconditions?.length??0)>0&&R.jsx(cI,{title:"Preconditions",children:R.jsx("ul",{style:QU,children:h.preconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),h.flows?.basic?.steps&&R.jsx(cI,{title:"Basic flow",children:R.jsx("ol",{style:{...QU,paddingLeft:22},children:h.flows.basic.steps.map((p,v)=>R.jsx("li",{style:{marginBottom:4},children:p},v))})}),(h.flows?.alternates?.length??0)>0&&R.jsx(cI,{title:"Alternate flows",children:h.flows.alternates.map(p=>R.jsxs("div",{style:{marginBottom:12,padding:12,background:"var(--archik-surface)",borderRadius:6,borderLeft:"3px solid var(--archik-warning)"},children:[R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:6},children:[R.jsx("code",{style:{fontSize:12,fontWeight:600},children:p.id}),p.branchFrom&&R.jsxs("span",{style:{fontSize:11,color:"var(--archik-fg-muted)"},children:["branches from ",p.branchFrom]})]}),R.jsx("ol",{style:{...QU,paddingLeft:22,fontSize:13},children:p.steps.map((v,T)=>R.jsx("li",{children:v},T))})]},p.id))}),(h.postconditions?.length??0)>0&&R.jsx(cI,{title:"Postconditions",children:R.jsx("ul",{style:QU,children:h.postconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),(()=>{const p=h.slices??[];return R.jsx(cI,{title:`Slices (${p.length})`,children:p.length===0?R.jsx("div",{style:{fontSize:12,color:"var(--archik-fg-muted)"},children:"— no slices declared"}):R.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map(v=>R.jsx(gWn,{slice:v,useCaseId:h.id,trace:b.get(`${h.id}/${v.id}`)},v.id))})})})(),R.jsxs("div",{style:{marginTop:32,paddingTop:16,borderTop:"1px solid var(--archik-border)",fontSize:11,color:"var(--archik-fg-muted)"},children:["Source:"," ",R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.relPath})]})]})})}function bWn({useCase:h}){return R.jsxs("div",{style:{display:"flex",gap:24,padding:"10px 14px",background:"var(--archik-surface)",borderRadius:6,marginBottom:20,fontSize:12},children:[R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Primary actor"}),R.jsx("div",{style:{marginTop:2},children:R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.primaryActor})})]}),(h.secondaryActors?.length??0)>0&&R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Secondary actors"}),R.jsx("div",{style:{marginTop:2},children:h.secondaryActors.map((b,p)=>R.jsxs("span",{children:[R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:b}),p<h.secondaryActors.length-1&&", "]},b))})]})]})}function gWn({slice:h,useCaseId:b,trace:p}){const v=p?.level??"none";return R.jsxs("div",{style:{padding:14,background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[R.jsx(R0n,{level:v}),R.jsx("code",{style:{fontSize:13,fontFamily:"ui-monospace, monospace",fontWeight:600},children:h.id}),h.status&&h.status!=="active"&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",h.status,"]"]}),R.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--archik-fg-muted)"},children:p?.realization&&p.realization.participants.length>0&&R.jsxs(R.Fragment,{children:["ECB"," ",p.realization.participants.filter(T=>T.stereotype!==void 0).length,"/",p.realization.participants.length]})})]}),h.description&&R.jsx("div",{style:{fontSize:13,color:"var(--archik-fg-dim)",marginBottom:10,lineHeight:1.5},children:h.description}),R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:14,rowGap:8,fontSize:12,alignItems:"start"},children:[R.jsx("div",{style:H8e,children:"Tests"}),R.jsx("div",{children:(h.tests?.length??0)===0?R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— none declared"}):R.jsx("ul",{style:{...QU,paddingLeft:0,listStyle:"none"},children:h.tests.map(T=>R.jsxs("li",{style:{fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",T]},T))})}),R.jsx("div",{style:H8e,children:"Realization"}),R.jsx("div",{children:h.realization?R.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(h.realization.seqFile)}&from-uc=${encodeURIComponent(b)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx(I1n,{size:11}),wWn(h.realization.seqFile),R.jsx(D1n,{size:11,style:{opacity:.7}})]}):R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no seq file yet"})}),R.jsx("div",{style:H8e,children:"Flows"}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)"},children:(h.flows??[]).join(", ")||"—"})]})]})}function wWn(h){return h.split("/").pop()?.replace(/\.archik\.seq\.yaml$/,"")??h}function cI({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:24},children:[R.jsx("h2",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",margin:"0 0 8px"},children:h}),b]})}function J8e({children:h,tone:b}){return R.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:b==="error"?"var(--archik-danger)":"var(--archik-fg-muted)",fontSize:13,padding:24,textAlign:"center"},children:h})}const b7e={fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",fontWeight:600},H8e={...b7e,fontSize:10,paddingTop:1},QU={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.55},P0n=document.getElementById("root");if(!P0n)throw new Error("#root not found");const VU=new URLSearchParams(window.location.search),mue=window.location.pathname,pWn=mue==="/__archik/seq"||mue.startsWith("/__archik/seq/"),mWn=mue==="/__archik/usecases"||mue.startsWith("/__archik/usecases/"),K8e=Nzn.createRoot(P0n);if(pWn){const h=VU.get("path")??"",b=VU.get("from-uc"),p=VU.get("from-file")??VU.get("from"),v=b?{type:"usecase",value:b}:p?{type:"file",value:p}:null;K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(rWn,{path:h,back:v})}))}else if(mWn){const h=VU.get("uc");K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(lWn,{selectedId:h})}))}else K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(EVn,{})}));
|
package/dist/ui/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
} catch {}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-Dl4i5i09.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-DVBaG20X.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|