@memoarchitect/architect 0.6.5 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -4
- package/dist/assets/AiWorkspace-Bu9TlIWg.js +7 -0
- package/dist/assets/AnalysisWorkspace-CodmoI-v.js +39 -0
- package/dist/assets/{ComplianceWizard-DWolzleI.js → ComplianceWizard-CTihkUi-.js} +1 -1
- package/dist/assets/DSMView-BiC845df.js +1 -0
- package/dist/assets/Dashboard-CgnNLhKq.js +1 -0
- package/dist/assets/{DhfDashboard-D9JxRAbD.js → DhfDashboard-w-dJoJHU.js} +1 -1
- package/dist/assets/{DhfWorkbench-BQv2WQ9o.js → DhfWorkbench-o6B_MT-0.js} +15 -15
- package/dist/assets/DiagramCanvas-CqGqDbgT.js +3 -0
- package/dist/assets/DiagramEditor-UJDHcAUF.js +4 -0
- package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +1 -0
- package/dist/assets/ElementDetailView-10U0rr33.js +2 -0
- package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +3 -0
- package/dist/assets/{ImportView-33dFwj6A.js → ImportView-D8svP04Q.js} +1 -1
- package/dist/assets/{LayerGrid-B3MBWswK.js → LayerGrid-DEe0Ryz-.js} +1 -1
- package/dist/assets/{LayerTable-DyIzIt5M.js → LayerTable-CN_b2rDr.js} +2 -2
- package/dist/assets/{MaxGraphCanvas-BS5wYazZ.js → MaxGraphCanvas-bo8oPBct.js} +6 -6
- package/dist/assets/{ModelDiff-BoFREnpg.js → ModelDiff-xe95oVua.js} +1 -1
- package/dist/assets/{OntologyDecompositionDiagram-IG1gj1c3.js → OntologyDecompositionDiagram-BL9R8bdB.js} +1 -1
- package/dist/assets/{OntologyViewer-CQTEg-GI.js → OntologyViewer-CtqNkkCn.js} +2 -2
- package/dist/assets/{RelationshipOverlay-B9bqt4zl.js → RelationshipOverlay-DL0N8Vmk.js} +1 -1
- package/dist/assets/{RelationshipsSection-DttMvF2i.js → RelationshipsSection-BoJ0aUXe.js} +1 -1
- package/dist/assets/{ReviewDashboard-BJ_smBGS.js → ReviewDashboard-DeTge2oC.js} +1 -1
- package/dist/assets/ScenarioEditor-FAEYTHgP.js +3 -0
- package/dist/assets/{StatisticsDashboard-CBYJGUPH.js → StatisticsDashboard-BAZRqIPN.js} +1 -1
- package/dist/assets/{SysmlCodeEditor-Die2RUsz.js → SysmlCodeEditor-BBfup_Ni.js} +1 -1
- package/dist/assets/TabularView-I4LjHhoH.js +1 -0
- package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +3 -0
- package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +1 -0
- package/dist/assets/{WorkflowWizard-CbkDyd1W.js → WorkflowWizard-VwpEHt3R.js} +1 -1
- package/dist/assets/element-options-B7AgTB8R.js +3 -0
- package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
- package/dist/assets/index-BWMNo4wW.css +1 -0
- package/dist/assets/index-Bij8Q4Kg.js +45 -0
- package/dist/assets/index.es-ClbJxlAQ.js +18 -0
- package/dist/assets/jspdf.es.min-DZ68BGxk.js +170 -0
- package/dist/assets/notation-scene-DT8LpWVK.js +1 -0
- package/dist/assets/purify.es-DP5U8-sc.js +3 -0
- package/dist/assets/{reactflow-CsCqNKB-.js → reactflow-s7jmJtXx.js} +5 -5
- package/dist/index.html +3 -3
- package/lib/__tests__/compiler-bundling.test.d.ts +2 -0
- package/lib/__tests__/compiler-bundling.test.d.ts.map +1 -0
- package/lib/__tests__/compiler-bundling.test.js +32 -0
- package/lib/__tests__/compiler-bundling.test.js.map +1 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts +2 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts.map +1 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.js +22 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.js.map +1 -0
- package/lib/__tests__/supervised-child-args.test.d.ts +2 -0
- package/lib/__tests__/supervised-child-args.test.d.ts.map +1 -0
- package/lib/__tests__/supervised-child-args.test.js +35 -0
- package/lib/__tests__/supervised-child-args.test.js.map +1 -0
- package/lib/bin/memo-architect.js +30 -4
- package/lib/bin/memo-architect.js.map +1 -1
- package/lib/commands/dev.d.ts +18 -2
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +56 -8
- package/lib/commands/dev.js.map +1 -1
- package/lib/commands/example.d.ts +1 -0
- package/lib/commands/example.d.ts.map +1 -1
- package/lib/commands/example.js +2 -0
- package/lib/commands/example.js.map +1 -1
- package/lib/feature-grants.d.ts.map +1 -1
- package/lib/feature-grants.js +2 -2
- package/lib/feature-grants.js.map +1 -1
- package/package.json +12 -6
- package/dist/assets/AiWorkspace-DHZ6a9HJ.js +0 -3
- package/dist/assets/DSMView-TdC3EADB.js +0 -1
- package/dist/assets/Dashboard-DBfAOCJv.js +0 -1
- package/dist/assets/DhfSettingsPanel-Firov0IF.js +0 -1
- package/dist/assets/DiagramCanvas-BfwO8YE5.js +0 -1
- package/dist/assets/DiagramEditor-Cp9ORYoN.js +0 -4
- package/dist/assets/ElementDetailView-DOrG8v7V.js +0 -2
- package/dist/assets/ScenarioEditor-D06nbX4h.js +0 -3
- package/dist/assets/TabularView-BLzDtgmK.js +0 -1
- package/dist/assets/TraceabilityMatrix-DbL_FkAC.js +0 -1
- package/dist/assets/index-B8HDzVLs.css +0 -1
- package/dist/assets/index-D0vtjNjX.js +0 -3280
- package/dist/assets/layout-selection-DIQaaOIC.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-DZ68BGxk.js","assets/index-Bij8Q4Kg.js","assets/reactflow-s7jmJtXx.js","assets/zustand-CrhqMOHB.js","assets/index-BWMNo4wW.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Wi=Object.defineProperty;var _i=(e,t,s)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var qo=(e,t,s)=>_i(e,typeof t!="symbol"?t+"":t,s);import{j as o,u as or,H as K,P as V,N as mt,b as hn,B as nr,E as an,R as Hi,c as Vi,d as Gi,e as Ui,g as Ki,f as Xi,h as Yi,i as qi,C as Zi,k as Ji,l as Qi,m as vs,M as ea}from"./reactflow-s7jmJtXx.js";import{b as ta,a as u}from"./zustand-CrhqMOHB.js";/* empty css */import{F as W,S as nt,u as Z,i as sr,h as ln,_ as oa,g as na,D as sa,I as He,m as Ss,J as ra,K as Cs,C as js}from"./index-Bij8Q4Kg.js";import{c as ia,a as aa,b as la,d as ca,e as da,f as ua,g as pa,h as ha,i as ma,j as fa,k as ga,I as mn,l as xa,P as vo,s as ba,u as ya,m as wa,G as Zo,n as Fa,o as ka,C as So,p as va,r as Sa,q as Jo,A as Ca,t as ja,v as Ea,w as Ia,x as Aa,y as Ra,z as Es,B as Ma,D as za,E as La,F as Na,H as Ta,J as Da,R as Ba,K as $a,L as Pa,M as Oa,N as Wa}from"./notation-scene-DT8LpWVK.js";import{S as _a}from"./ExplorerTreeRow-DqhF_qoO.js";import{I as H,c as fe,b as Pe,a as Be,S as Is}from"./DiagramToolbarControls-B2gZFJlg.js";import"./layout-providers-Dr743WlP.js";import"./elk-6l8mIQnQ.js";function Ha(e,t,s="both",r=10){const i=e.elements[t];if(!i)return{rootId:t,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const c=new Map,a=new Map;for(const k of e.relationships)c.has(k.sourceId)||c.set(k.sourceId,[]),c.get(k.sourceId).push(k),a.has(k.targetId)||a.set(k.targetId,[]),a.get(k.targetId).push(k);const p=new Set;p.add(t);const b=[],g=[],S=[[t,0]];for(;S.length>0;){const[k,R]=S.shift();if(R>=r)continue;const M=R+1;if(s==="downstream"||s==="both")for(const z of c.get(k)||[]){const D=z.targetId;if(g.push({fromId:k,toId:D,relType:z.type,relId:z.id}),!p.has(D)){p.add(D);const h=e.elements[D];h&&(b.push({elementId:D,name:h.name,kind:h.kind,layer:h.layer,depth:M,viaRelType:z.type,direction:"downstream"}),S.push([D,M]))}}if(s==="upstream"||s==="both")for(const z of a.get(k)||[]){const D=z.sourceId;if(g.push({fromId:D,toId:k,relType:z.type,relId:z.id}),!p.has(D)){p.add(D);const h=e.elements[D];h&&(b.push({elementId:D,name:h.name,kind:h.kind,layer:h.layer,depth:M,viaRelType:z.type,direction:"upstream"}),S.push([D,M]))}}}return b.sort((k,R)=>k.depth-R.depth||k.name.localeCompare(R.name)),{rootId:t,rootName:i.name,rootKind:i.kind,nodes:b,edges:g}}function Va(e,t=[]){let r=e.replace(/[^A-Za-z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map((a,p)=>p===0?a.charAt(0).toLowerCase()+a.slice(1):a.charAt(0).toUpperCase()+a.slice(1)).join("");r||(r="element"),/^[0-9]/.test(r)&&(r=`n${r}`);const i=new Set(t);if(!i.has(r))return r;let c=2;for(;i.has(`${r}${c}`);)c++;return`${r}${c}`}function Ga(e){return e&&e.replace(/\s+(def|usage)$/,"").trim()||"part"}const Ua=[{value:"",label:"Default"},{value:"#FEF3C7",label:"Amber"},{value:"#DCFCE7",label:"Green"},{value:"#DBEAFE",label:"Blue"},{value:"#FCE7F3",label:"Pink"},{value:"#E5E7EB",label:"Grey"}],Pt={display:"flex",alignItems:"center",gap:2},Ot={width:1,height:18,background:"#E2E8F0",margin:"0 4px",flexShrink:0};function ze({title:e,label:t,onClick:s}){return o.jsx("button",{title:e,"aria-label":e,onClick:s,style:{minWidth:26,height:26,padding:"0 5px",borderRadius:5,border:"1px solid #E2E8F0",background:"#FFFFFF",color:"#374151",fontSize:13,lineHeight:1,cursor:"pointer",fontWeight:600},children:t})}function Ka({count:e,onAlign:t,onMatchSize:s,onDistribute:r,onFill:i,onOpacity:c,opacity:a}){return o.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",top:10,left:"50%",transform:"translateX(-50%)",zIndex:25,display:"flex",alignItems:"center",gap:4,padding:"6px 8px",borderRadius:9,background:"#FFFFFF",border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.14)",flexWrap:"wrap",maxWidth:"calc(100% - 24px)"},children:[o.jsxs("span",{style:{fontSize:W.xs,color:"#6B7280",fontWeight:700,paddingRight:2},children:[e," selected"]}),o.jsx("span",{style:Ot}),o.jsxs("div",{style:Pt,children:[o.jsx(ze,{title:"Align left edges",label:"⇤",onClick:()=>t("left")}),o.jsx(ze,{title:"Align horizontal centres",label:"⇹",onClick:()=>t("centerX")}),o.jsx(ze,{title:"Align right edges",label:"⇥",onClick:()=>t("right")}),o.jsx(ze,{title:"Align top edges",label:"⤒",onClick:()=>t("top")}),o.jsx(ze,{title:"Align vertical centres",label:"⇳",onClick:()=>t("centerY")}),o.jsx(ze,{title:"Align bottom edges",label:"⤓",onClick:()=>t("bottom")})]}),o.jsx("span",{style:Ot}),o.jsxs("div",{style:Pt,children:[o.jsx(ze,{title:"Match width to the widest",label:"↔",onClick:()=>s("width")}),o.jsx(ze,{title:"Match height to the tallest",label:"↕",onClick:()=>s("height")}),o.jsx(ze,{title:"Match width and height",label:"⤢",onClick:()=>s("both")})]}),o.jsx("span",{style:Ot}),o.jsxs("div",{style:Pt,children:[o.jsx(ze,{title:e>=3?"Even horizontal gaps":"Even horizontal gaps (needs 3 blocks)",label:"⇿",onClick:()=>r("horizontal")}),o.jsx(ze,{title:e>=3?"Even vertical gaps":"Even vertical gaps (needs 3 blocks)",label:"⇕",onClick:()=>r("vertical")})]}),o.jsx("span",{style:Ot}),o.jsx("div",{style:Pt,children:Ua.map(p=>o.jsx("button",{title:`Fill: ${p.label}`,"aria-label":`Fill ${p.label}`,onClick:()=>i(p.value),style:{width:20,height:20,padding:0,borderRadius:4,cursor:"pointer",border:"1px solid #CBD5E1",background:p.value||"#FFFFFF",color:"#94A3B8",fontSize:11,lineHeight:1,fontWeight:700},children:p.value?"":"⌫"},p.label))}),o.jsx("span",{style:Ot}),o.jsxs("label",{title:"Fill opacity",style:{display:"flex",alignItems:"center",gap:5,fontSize:W.xs,color:"#6B7280"},children:[o.jsx("span",{style:{fontWeight:700},children:"Opacity"}),o.jsx("input",{type:"range",min:20,max:100,step:5,value:Math.round(a*100),onChange:p=>c(Number(p.target.value)/100),style:{width:72,accentColor:"#2DD4A8"}}),o.jsxs("span",{style:{width:30,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[Math.round(a*100),"%"]})]}),o.jsx("div",{style:Pt,"aria-label":"Opacity presets",children:[1,.75,.5].map(p=>o.jsx("button",{"aria-label":`Set opacity to ${Math.round(p*100)}%`,title:`Set opacity to ${Math.round(p*100)}%`,onClick:()=>c(p),style:{height:22,minWidth:30,padding:"0 4px",borderRadius:4,border:"1px solid #CBD5E1",background:"#FFFFFF",color:"#475569",cursor:"pointer",fontSize:10,fontWeight:700},children:Math.round(p*100)},p))})]})}function Xa(e,t){if(e.length===0)return;const s=r=>e.reduce((i,c)=>r(c,i)?c:i);switch(t){case"left":return s((r,i)=>r.x<i.x);case"right":return s((r,i)=>r.x+r.width>i.x+i.width);case"top":return s((r,i)=>r.y<i.y);case"bottom":return s((r,i)=>r.y+r.height>i.y+i.height);case"centerX":return s((r,i)=>r.width>i.width);case"centerY":return s((r,i)=>r.height>i.height)}}function Ya(e,t){const s=new Map,r=Xa(e,t);if(!r||e.length<2)return s;for(const i of e){let c;switch(t){case"left":c=r.x;break;case"right":c=r.x+r.width-i.width;break;case"centerX":c=r.x+r.width/2-i.width/2;break;case"top":c=r.y;break;case"bottom":c=r.y+r.height-i.height;break;case"centerY":c=r.y+r.height/2-i.height/2;break}const a=t==="left"||t==="right"||t==="centerX",p=a?i.x:i.y;Math.abs(p-c)<.5||s.set(i.id,a?{x:c}:{y:c})}return s}function qa(e,t){const s=new Map;if(e.length<2)return s;const r=Math.max(...e.map(c=>c.width)),i=Math.max(...e.map(c=>c.height));for(const c of e){const a={};t!=="height"&&Math.abs(c.width-r)>=.5&&(a.width=r),t!=="width"&&Math.abs(c.height-i)>=.5&&(a.height=i),Object.keys(a).length>0&&s.set(c.id,a)}return s}function Za(e,t){const s=new Map;if(e.length<3)return s;const r=t==="horizontal",i=M=>r?M.x:M.y,c=M=>r?M.width:M.height,a=[...e].sort((M,z)=>i(M)-i(z)),p=a[0],b=a[a.length-1],g=i(b)+c(b)-i(p),S=a.reduce((M,z)=>M+c(z),0),k=(g-S)/(a.length-1);if(!Number.isFinite(k)||k<0)return s;let R=i(p)+c(p)+k;for(const M of a.slice(1,-1))Math.abs(i(M)-R)>=.5&&s.set(M.id,r?{x:R}:{y:R}),R+=c(M)+k;return s}const Ht=ta(e=>({subject:null,publish:t=>e({subject:t})})),_t=e=>Ht.getState().publish(e),rr=e=>{var t,s;return[e.source,e.target,(t=e.data)==null?void 0:t.sourcePortId,(s=e.data)==null?void 0:s.targetPortId].filter(r=>!!r)},Ja=(e,t)=>e.edgeId===t.id||rr(t).some(s=>e.endpointIds.includes(s)),fn=()=>Ht(e=>e.subject!==null),Qa=e=>Ht(t=>{var s;return((s=t.subject)==null?void 0:s.endpointIds.includes(e))??!1}),ir=(e,t)=>Ht(s=>{const r=s.subject;return r?r.edgeId===e||t.some(i=>i!==void 0&&r.endpointIds.includes(i)):!1}),el=e=>`.react-flow__edge[data-id="${CSS.escape(e)}"]`;function tl(){const e=Ht(r=>r.subject),t=or(r=>e?r.edges.filter(i=>Ja(e,i)).map(i=>i.id).join("\0"):"");if(!e)return null;const s=t?t.split("\0").map(el).join(","):"";return o.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",s?`${s}{opacity:1}`:""]})}class ol{constructor(){qo(this,"providers",[]);qo(this,"byId",new Map)}register(t,s){const r=this.byId.get(t.descriptor.id);if(r&&r!==t)throw new Error(`Template provider already registered: ${t.descriptor.id}`);if(r)return;this.byId.set(t.descriptor.id,t);const i=s?this.providers.findIndex(c=>c.descriptor.id===s):-1;i>=0?this.providers.splice(i,0,t):this.providers.push(t)}unregister(t){const s=this.byId.get(t);return s?(this.byId.delete(t),this.providers.splice(this.providers.indexOf(s),1),!0):!1}get(t){return this.byId.get(t)}has(t){return this.byId.has(t)}list(){return this.providers.map(t=>t.descriptor)}select(t){const s=this.providers.find(r=>r.matches(t));if(!s)throw new Error("No diagram template matches this view — register a catch-all provider");return s}}const ar=new ol,nl=[{descriptor:{id:"memo.template.fbs",name:"Functional Breakdown",label:"FBS",contractVersion:"1",interactive:!0,description:"Functional breakdown structure — functions per realising component."},matches:e=>e.isFBSDiagram,compute:(e,t)=>ia(e,t.fbs)},{descriptor:{id:"memo.template.decomposition",name:"Decomposition Tree",label:"Decomposition",contractVersion:"1",interactive:!0,description:"Expandable decomposition tree over composition relationships."},matches:e=>e.isDecompDiagram&&e.layoutStyle==="decomposition",compute:(e,t)=>aa(e,t.decomposition)},{descriptor:{id:"memo.template.containment",name:"Containment Blocks",label:"Containment",contractVersion:"1",interactive:!0,description:"Nested containment blocks over composition relationships."},matches:e=>e.isDecompDiagram,compute:(e,t)=>la(e,t.containment)},{descriptor:{id:"memo.template.usecase",name:"Use Case",label:"Use case",contractVersion:"1",interactive:!1,description:"Actors outside a system boundary, use cases inside (KK-7)."},matches:e=>e.diagramType==="ucd",compute:(e,t)=>ca(e,t.useCase)},{descriptor:{id:"memo.template.context",name:"System Context",label:"Context",contractVersion:"1",interactive:!1,description:"Black-box system of interest with external actors and peer systems."},matches:e=>e.diagramType==="context",compute:(e,t)=>da(e,t.context.systemName,t.context)},{descriptor:{id:"memo.template.interconnection",name:"Interconnection",label:"Interconnection",contractVersion:"1",interactive:!1,description:"IBD — parts with boundary ports, typed connectors, nested containment (KK-3)."},matches:e=>e.viewKind==="interconnection",compute:(e,t)=>ua(e,t.interconnection)},{descriptor:{id:"memo.template.actionflow",name:"Action Flow",label:"Action flow",contractVersion:"1",interactive:!1,description:"Actions with parameter ports, item flows, successions, optional swimlanes (KK-4)."},matches:e=>e.viewKind==="actionflow",compute:(e,t)=>pa(e,t.actionflow)},{descriptor:{id:"memo.template.statetransition",name:"State Transition",label:"State transition",contractVersion:"1",interactive:!1,description:"Nested states with routed transition edges and trigger [guard] labels (KK-5)."},matches:e=>e.viewKind==="statetransition",compute:(e,t)=>ha(e,t.statetransition)},{descriptor:{id:"memo.template.sequence",name:"Sequence",label:"Sequence",contractVersion:"1",interactive:!1,description:"Lifelines with chronological messages (KK-6)."},matches:e=>e.viewKind==="sequence",compute:(e,t)=>ma(e,t.sequence)},{descriptor:{id:"memo.template.general",name:"General (structured)",label:"General",contractVersion:"1",interactive:!0,description:"General template tree/containment modes (KK-2)."},matches:e=>e.isGeneralTemplate&&e.generalMode!=="graph",compute:(e,t)=>fa(e,t.general)},{descriptor:{id:"memo.template.standard",name:"Standard Graph",label:"Standard",contractVersion:"1",interactive:!0,description:"Relationship graph with optional compartments — the catch-all."},matches:()=>!0,compute:(e,t)=>ga(e,t.standard)}];for(const e of nl)ar.register(e);const lr="context-child-v1";function sl(e){var t;return((t=e==null?void 0:e.canvas)==null?void 0:t.coordinateSpace)===lr}function rl(e){return{...e,canvas:{...e.canvas,coordinateSpace:lr}}}function il(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Vt({color:e="#334155",size:t=38}){const s=Math.round(t*1.42);return o.jsxs("svg",{width:t,height:s,viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:e,strokeWidth:"2",children:[o.jsx("circle",{cx:"19",cy:"8",r:"6",fill:"#FFFFFF"}),o.jsx("path",{d:"M19 14v18M6 23h26M19 32L8 49M19 32l11 17",strokeLinecap:"round"})]})}const gn=e=>e==="Actor"||e==="User";function al({data:e}){const t=e,{element:s,layerColor:r,isExpanded:i,hasChildren:c,childCount:a,direction:p,onToggleExpand:b,onToggleDirection:g,showDirectionButton:S,depthBgColor:k,isContainer:R}=t,M=p==="vertical"?"V":"H",z=R&&i;return o.jsxs("div",{style:{background:z?k||"#FAFAF9":"#FFFFFF",borderLeft:z?`2px solid ${r}40`:`3px solid ${r}`,borderTop:`1px solid ${z?r+"30":"#E5E5E0"}`,borderRight:`1px solid ${z?r+"30":"#E5E5E0"}`,borderBottom:`1px solid ${z?r+"30":"#E5E5E0"}`,borderRadius:3,padding:z?"0":"8px 12px",minWidth:z?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[o.jsx(K,{type:"target",position:V.Top,id:"top",style:fo}),o.jsx(K,{type:"source",position:V.Bottom,id:"bottom",style:fo}),o.jsx(K,{type:"target",position:V.Left,id:"left",style:fo}),o.jsx(K,{type:"source",position:V.Right,id:"right",style:fo}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:z?"8px 12px":"0"},children:[gn(s.kind)&&o.jsx(Vt,{size:24,color:r}),c&&o.jsx("button",{onClick:D=>{D.stopPropagation(),b()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${r}`,background:i?r+"12":"#FFFFFF",color:r,fontSize:W.md,fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,flexShrink:0,transition:"background 200ms ease, color 200ms ease"},title:i?"Collapse":"Expand",children:i?"−":"+"}),c&&S&&o.jsx("button",{onClick:D=>{D.stopPropagation(),g()},style:{width:"20px",height:"20px",borderRadius:"4px",border:"1.5px solid #10b981",background:"transparent",color:"#10b981",fontSize:"9px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0,transition:"background 200ms ease"},title:`Direction: ${p}. Click to toggle`,children:M}),o.jsx("span",{style:{fontSize:W.md,fontWeight:600,color:z?r:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name})]}),!z&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:c?"26px":"14px"},children:[o.jsx("span",{style:{fontSize:W.badge,color:"#9CA3AF"},children:s.kind}),c&&o.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[a," parts",i?"":" (collapsed)"]})]})]})}const fo={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},ll=u.memo(al);function cr(e){var t,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(s=cr(e[t]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function cl(){for(var e,t,s=0,r="",i=arguments.length;s<i;s++)(e=arguments[s])&&(t=cr(e))&&(r&&(r+=" "),r+=t);return r}const dl=(e,t)=>{const s=new Array(e.length+t.length);for(let r=0;r<e.length;r++)s[r]=e[r];for(let r=0;r<t.length;r++)s[e.length+r]=t[r];return s},ul=(e,t)=>({classGroupId:e,validator:t}),dr=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),jo="-",As=[],pl="arbitrary..",hl=e=>{const t=fl(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return ml(a);const p=a.split(jo),b=p[0]===""&&p.length>1?1:0;return ur(p,b,t)},getConflictingClassGroupIds:(a,p)=>{if(p){const b=r[a],g=s[a];return b?g?dl(g,b):b:g||As}return s[a]||As}}},ur=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const i=e[t],c=s.nextPart.get(i);if(c){const g=ur(e,t+1,c);if(g)return g}const a=s.validators;if(a===null)return;const p=t===0?e.join(jo):e.slice(t).join(jo),b=a.length;for(let g=0;g<b;g++){const S=a[g];if(S.validator(p))return S.classGroupId}},ml=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),r=t.slice(0,s);return r?pl+r:void 0})(),fl=e=>{const{theme:t,classGroups:s}=e;return gl(s,t)},gl=(e,t)=>{const s=dr();for(const r in e){const i=e[r];xn(i,s,r,t)}return s},xn=(e,t,s,r)=>{const i=e.length;for(let c=0;c<i;c++){const a=e[c];xl(a,t,s,r)}},xl=(e,t,s,r)=>{if(typeof e=="string"){bl(e,t,s);return}if(typeof e=="function"){yl(e,t,s,r);return}wl(e,t,s,r)},bl=(e,t,s)=>{const r=e===""?t:pr(t,e);r.classGroupId=s},yl=(e,t,s,r)=>{if(Fl(e)){xn(e(r),t,s,r);return}t.validators===null&&(t.validators=[]),t.validators.push(ul(s,e))},wl=(e,t,s,r)=>{const i=Object.entries(e),c=i.length;for(let a=0;a<c;a++){const[p,b]=i[a];xn(b,pr(t,p),s,r)}},pr=(e,t)=>{let s=e;const r=t.split(jo),i=r.length;for(let c=0;c<i;c++){const a=r[c];let p=s.nextPart.get(a);p||(p=dr(),s.nextPart.set(a,p)),s=p}return s},Fl=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,kl=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),r=Object.create(null);const i=(c,a)=>{s[c]=a,t++,t>e&&(t=0,r=s,s=Object.create(null))};return{get(c){let a=s[c];if(a!==void 0)return a;if((a=r[c])!==void 0)return i(c,a),a},set(c,a){c in s?s[c]=a:i(c,a)}}},cn="!",Rs=":",vl=[],Ms=(e,t,s,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:r,isExternal:i}),Sl=e=>{const{prefix:t,experimentalParseClassName:s}=e;let r=i=>{const c=[];let a=0,p=0,b=0,g;const S=i.length;for(let D=0;D<S;D++){const h=i[D];if(a===0&&p===0){if(h===Rs){c.push(i.slice(b,D)),b=D+1;continue}if(h==="/"){g=D;continue}}h==="["?a++:h==="]"?a--:h==="("?p++:h===")"&&p--}const k=c.length===0?i:i.slice(b);let R=k,M=!1;k.endsWith(cn)?(R=k.slice(0,-1),M=!0):k.startsWith(cn)&&(R=k.slice(1),M=!0);const z=g&&g>b?g-b:void 0;return Ms(c,M,R,z)};if(t){const i=t+Rs,c=r;r=a=>a.startsWith(i)?c(a.slice(i.length)):Ms(vl,!1,a,void 0,!0)}if(s){const i=r;r=c=>s({className:c,parseClassName:i})}return r},Cl=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,r)=>{t.set(s,1e6+r)}),s=>{const r=[];let i=[];for(let c=0;c<s.length;c++){const a=s[c],p=a[0]==="[",b=t.has(a);p||b?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(a)):i.push(a)}return i.length>0&&(i.sort(),r.push(...i)),r}},jl=e=>({cache:kl(e.cacheSize),parseClassName:Sl(e),sortModifiers:Cl(e),postfixLookupClassGroupIds:El(e),...hl(e)}),El=e=>{const t=Object.create(null),s=e.postfixLookupClassGroups;if(s)for(let r=0;r<s.length;r++)t[s[r]]=!0;return t},Il=/\s+/,Al=(e,t)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:c,postfixLookupClassGroupIds:a}=t,p=[],b=e.trim().split(Il);let g="";for(let S=b.length-1;S>=0;S-=1){const k=b[S],{isExternal:R,modifiers:M,hasImportantModifier:z,baseClassName:D,maybePostfixModifierPosition:h}=s(k);if(R){g=k+(g.length>0?" "+g:g);continue}let w=!!h,F;if(w){const Q=D.substring(0,h);F=r(Q);const v=F&&a[F]?r(D):void 0;v&&v!==F&&(F=v,w=!1)}else F=r(D);if(!F){if(!w){g=k+(g.length>0?" "+g:g);continue}if(F=r(D),!F){g=k+(g.length>0?" "+g:g);continue}w=!1}const P=M.length===0?"":M.length===1?M[0]:c(M).join(":"),I=z?P+cn:P,O=I+F;if(p.indexOf(O)>-1)continue;p.push(O);const re=i(F,w);for(let Q=0;Q<re.length;++Q){const v=re[Q];p.push(I+v)}g=k+(g.length>0?" "+g:g)}return g},Rl=(...e)=>{let t=0,s,r,i="";for(;t<e.length;)(s=e[t++])&&(r=hr(s))&&(i&&(i+=" "),i+=r);return i},hr=e=>{if(typeof e=="string")return e;let t,s="";for(let r=0;r<e.length;r++)e[r]&&(t=hr(e[r]))&&(s&&(s+=" "),s+=t);return s},Ml=(e,...t)=>{let s,r,i,c;const a=b=>{const g=t.reduce((S,k)=>k(S),e());return s=jl(g),r=s.cache.get,i=s.cache.set,c=p,p(b)},p=b=>{const g=r(b);if(g)return g;const S=Al(b,s);return i(b,S),S};return c=a,(...b)=>c(Rl(...b))},zl=[],ue=e=>{const t=s=>s[e]||zl;return t.isThemeGetter=!0,t},mr=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,fr=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ll=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Nl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Tl=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Dl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Bl=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$l=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ot=e=>Ll.test(e),U=e=>!!e&&!Number.isNaN(Number(e)),$e=e=>!!e&&Number.isInteger(Number(e)),Qo=e=>e.endsWith("%")&&U(e.slice(0,-1)),Ve=e=>Nl.test(e),gr=()=>!0,Pl=e=>Tl.test(e)&&!Dl.test(e),bn=()=>!1,Ol=e=>Bl.test(e),Wl=e=>$l.test(e),_l=e=>!E(e)&&!A(e),Hl=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Vl=e=>rt(e,yr,bn),E=e=>mr.test(e),ht=e=>rt(e,wr,Pl),zs=e=>rt(e,Jl,U),Gl=e=>rt(e,kr,gr),Ul=e=>rt(e,Fr,bn),Ls=e=>rt(e,xr,bn),Kl=e=>rt(e,br,Wl),go=e=>rt(e,vr,Ol),A=e=>fr.test(e),Wt=e=>ft(e,wr),Xl=e=>ft(e,Fr),Ns=e=>ft(e,xr),Yl=e=>ft(e,yr),ql=e=>ft(e,br),xo=e=>ft(e,vr,!0),Zl=e=>ft(e,kr,!0),rt=(e,t,s)=>{const r=mr.exec(e);return r?r[1]?t(r[1]):s(r[2]):!1},ft=(e,t,s=!1)=>{const r=fr.exec(e);return r?r[1]?t(r[1]):s:!1},xr=e=>e==="position"||e==="percentage",br=e=>e==="image"||e==="url",yr=e=>e==="length"||e==="size"||e==="bg-size",wr=e=>e==="length",Jl=e=>e==="number",Fr=e=>e==="family-name",kr=e=>e==="number"||e==="weight",vr=e=>e==="shadow",Ql=()=>{const e=ue("color"),t=ue("font"),s=ue("text"),r=ue("font-weight"),i=ue("tracking"),c=ue("leading"),a=ue("breakpoint"),p=ue("container"),b=ue("spacing"),g=ue("radius"),S=ue("shadow"),k=ue("inset-shadow"),R=ue("text-shadow"),M=ue("drop-shadow"),z=ue("blur"),D=ue("perspective"),h=ue("aspect"),w=ue("ease"),F=ue("animate"),P=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...I(),A,E],re=()=>["auto","hidden","clip","visible","scroll"],Q=()=>["auto","contain","none"],v=()=>[A,E,b],N=()=>[ot,"full","auto",...v()],$=()=>[$e,"none","subgrid",A,E],G=()=>["auto",{span:["full",$e,A,E]},$e,A,E],be=()=>[$e,"auto",A,E],oe=()=>["auto","min","max","fr",A,E],pe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ge=()=>["start","end","center","stretch","center-safe","end-safe"],le=()=>["auto",...v()],he=()=>[ot,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],ye=()=>[ot,"screen","full","dvw","lvw","svw","min","max","fit",...v()],Re=()=>[ot,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],L=()=>[e,A,E],je=()=>[...I(),Ns,Ls,{position:[A,E]}],ve=()=>["no-repeat",{repeat:["","x","y","space","round"]}],vt=()=>["auto","cover","contain",Yl,Vl,{size:[A,E]}],Ge=()=>[Qo,Wt,ht],ce=()=>["","none","full",g,A,E],ie=()=>["",U,Wt,ht],Ue=()=>["solid","dashed","dotted","double"],Oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>[U,Qo,Ns,Ls],Ee=()=>["","none",z,A,E],Ke=()=>["none",U,A,E],it=()=>["none",U,A,E],Se=()=>[U,A,E],at=()=>[ot,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ve],breakpoint:[Ve],color:[gr],container:[Ve],"drop-shadow":[Ve],ease:["in","out","in-out"],font:[_l],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ve],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ve],shadow:[Ve],spacing:["px",U],text:[Ve],"text-shadow":[Ve],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ot,E,A,h]}],container:["container"],"container-type":[{"@container":["","normal","size",A,E]}],"container-named":[Hl],columns:[{columns:[U,E,A,p]}],"break-after":[{"break-after":P()}],"break-before":[{"break-before":P()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:re()}],"overflow-x":[{"overflow-x":re()}],"overflow-y":[{"overflow-y":re()}],overscroll:[{overscroll:Q()}],"overscroll-x":[{"overscroll-x":Q()}],"overscroll-y":[{"overscroll-y":Q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{"inset-s":N(),start:N()}],end:[{"inset-e":N(),end:N()}],"inset-bs":[{"inset-bs":N()}],"inset-be":[{"inset-be":N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[$e,"auto",A,E]}],basis:[{basis:[ot,"full","auto",p,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[U,ot,"auto","initial","none",E]}],grow:[{grow:["",U,A,E]}],shrink:[{shrink:["",U,A,E]}],order:[{order:[$e,"first","last","none",A,E]}],"grid-cols":[{"grid-cols":$()}],"col-start-end":[{col:G()}],"col-start":[{"col-start":be()}],"col-end":[{"col-end":be()}],"grid-rows":[{"grid-rows":$()}],"row-start-end":[{row:G()}],"row-start":[{"row-start":be()}],"row-end":[{"row-end":be()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":oe()}],"auto-rows":[{"auto-rows":oe()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:[...pe(),"normal"]}],"justify-items":[{"justify-items":[...ge(),"normal"]}],"justify-self":[{"justify-self":["auto",...ge()]}],"align-content":[{content:["normal",...pe()]}],"align-items":[{items:[...ge(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ge(),{baseline:["","last"]}]}],"place-content":[{"place-content":pe()}],"place-items":[{"place-items":[...ge(),"baseline"]}],"place-self":[{"place-self":["auto",...ge()]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:le()}],mx:[{mx:le()}],my:[{my:le()}],ms:[{ms:le()}],me:[{me:le()}],mbs:[{mbs:le()}],mbe:[{mbe:le()}],mt:[{mt:le()}],mr:[{mr:le()}],mb:[{mb:le()}],ml:[{ml:le()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:he()}],"inline-size":[{inline:["auto",...ye()]}],"min-inline-size":[{"min-inline":["auto",...ye()]}],"max-inline-size":[{"max-inline":["none",...ye()]}],"block-size":[{block:["auto",...Re()]}],"min-block-size":[{"min-block":["auto",...Re()]}],"max-block-size":[{"max-block":["none",...Re()]}],w:[{w:[p,"screen",...he()]}],"min-w":[{"min-w":[p,"screen","none",...he()]}],"max-w":[{"max-w":[p,"screen","none","prose",{screen:[a]},...he()]}],h:[{h:["screen","lh",...he()]}],"min-h":[{"min-h":["screen","lh","none",...he()]}],"max-h":[{"max-h":["screen","lh",...he()]}],"font-size":[{text:["base",s,Wt,ht]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Zl,Gl]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Qo,E]}],"font-family":[{font:[Xl,Ul,t]}],"font-features":[{"font-features":[E]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,A,E]}],"line-clamp":[{"line-clamp":[U,"none",A,zs]}],leading:[{leading:[c,...v()]}],"list-image":[{"list-image":["none",A,E]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",A,E]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ue(),"wavy"]}],"text-decoration-thickness":[{decoration:[U,"from-font","auto",A,ht]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[U,"auto",A,E]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[$e,A,E]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",A,E]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",A,E]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:je()}],"bg-repeat":[{bg:ve()}],"bg-size":[{bg:vt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},$e,A,E],radial:["",A,E],conic:[$e,A,E]},ql,Kl]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:Ge()}],"gradient-via-pos":[{via:Ge()}],"gradient-to-pos":[{to:Ge()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:ie()}],"border-w-x":[{"border-x":ie()}],"border-w-y":[{"border-y":ie()}],"border-w-s":[{"border-s":ie()}],"border-w-e":[{"border-e":ie()}],"border-w-bs":[{"border-bs":ie()}],"border-w-be":[{"border-be":ie()}],"border-w-t":[{"border-t":ie()}],"border-w-r":[{"border-r":ie()}],"border-w-b":[{"border-b":ie()}],"border-w-l":[{"border-l":ie()}],"divide-x":[{"divide-x":ie()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ie()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ue(),"hidden","none"]}],"divide-style":[{divide:[...Ue(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-bs":[{"border-bs":L()}],"border-color-be":[{"border-be":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...Ue(),"none","hidden"]}],"outline-offset":[{"outline-offset":[U,A,E]}],"outline-w":[{outline:["",U,Wt,ht]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",S,xo,go]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",k,xo,go]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:ie()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[U,ht]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":ie()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",R,xo,go]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[U,A,E]}],"mix-blend":[{"mix-blend":[...Oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[U]}],"mask-image-linear-from-pos":[{"mask-linear-from":ne()}],"mask-image-linear-to-pos":[{"mask-linear-to":ne()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":ne()}],"mask-image-t-to-pos":[{"mask-t-to":ne()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":ne()}],"mask-image-r-to-pos":[{"mask-r-to":ne()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":ne()}],"mask-image-b-to-pos":[{"mask-b-to":ne()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":ne()}],"mask-image-l-to-pos":[{"mask-l-to":ne()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":ne()}],"mask-image-x-to-pos":[{"mask-x-to":ne()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":ne()}],"mask-image-y-to-pos":[{"mask-y-to":ne()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[A,E]}],"mask-image-radial-from-pos":[{"mask-radial-from":ne()}],"mask-image-radial-to-pos":[{"mask-radial-to":ne()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":I()}],"mask-image-conic-pos":[{"mask-conic":[U]}],"mask-image-conic-from-pos":[{"mask-conic-from":ne()}],"mask-image-conic-to-pos":[{"mask-conic-to":ne()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:je()}],"mask-repeat":[{mask:ve()}],"mask-size":[{mask:vt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",A,E]}],filter:[{filter:["","none",A,E]}],blur:[{blur:Ee()}],brightness:[{brightness:[U,A,E]}],contrast:[{contrast:[U,A,E]}],"drop-shadow":[{"drop-shadow":["","none",M,xo,go]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",U,A,E]}],"hue-rotate":[{"hue-rotate":[U,A,E]}],invert:[{invert:["",U,A,E]}],saturate:[{saturate:[U,A,E]}],sepia:[{sepia:["",U,A,E]}],"backdrop-filter":[{"backdrop-filter":["","none",A,E]}],"backdrop-blur":[{"backdrop-blur":Ee()}],"backdrop-brightness":[{"backdrop-brightness":[U,A,E]}],"backdrop-contrast":[{"backdrop-contrast":[U,A,E]}],"backdrop-grayscale":[{"backdrop-grayscale":["",U,A,E]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[U,A,E]}],"backdrop-invert":[{"backdrop-invert":["",U,A,E]}],"backdrop-opacity":[{"backdrop-opacity":[U,A,E]}],"backdrop-saturate":[{"backdrop-saturate":[U,A,E]}],"backdrop-sepia":[{"backdrop-sepia":["",U,A,E]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",A,E]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[U,"initial",A,E]}],ease:[{ease:["linear","initial",w,A,E]}],delay:[{delay:[U,A,E]}],animate:[{animate:["none",F,A,E]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[D,A,E]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:Ke()}],"rotate-x":[{"rotate-x":Ke()}],"rotate-y":[{"rotate-y":Ke()}],"rotate-z":[{"rotate-z":Ke()}],scale:[{scale:it()}],"scale-x":[{"scale-x":it()}],"scale-y":[{"scale-y":it()}],"scale-z":[{"scale-z":it()}],"scale-3d":["scale-3d"],skew:[{skew:Se()}],"skew-x":[{"skew-x":Se()}],"skew-y":[{"skew-y":Se()}],transform:[{transform:[A,E,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:at()}],"translate-x":[{"translate-x":at()}],"translate-y":[{"translate-y":at()}],"translate-z":[{"translate-z":at()}],"translate-none":["translate-none"],zoom:[{zoom:[$e,A,E]}],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",A,E]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":L()}],"scrollbar-track-color":[{"scrollbar-track":L()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",A,E]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[U,Wt,ht,zs]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ec=Ml(Ql);function tc(...e){return ec(cl(e))}function Ts({className:e,children:t,...s}){return o.jsx(K,{...s,className:tc("dark:border-secondary dark:bg-secondary h-[11px] w-[11px] rounded-full border border-slate-300 bg-slate-100 transition",e),children:t})}const Ds={top:V.Top,bottom:V.Bottom,left:V.Left,right:V.Right},oc={top:"bottom",bottom:"top",left:"right",right:"left"},nc="#6B7280",Sr=e=>e?vo[e]:nc;function Cr(e,t){if(e==="inout")return"⇄";if(!e)return"";const s=e==="in";switch(t){case"left":return s?"→":"←";case"right":return s?"←":"→";case"top":return s?"↓":"↑";default:return s?"↑":"↓"}}const sc=104,Bs=40,jr=e=>({opacity:0,width:e,height:e,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"}),rc=e=>({...jr(e),pointerEvents:"auto",cursor:"crosshair",zIndex:12});function ic({port:e,onMove:t}){const{getZoom:s}=hn(),r=or(R=>R.transform[2]),i=Qa(e.id),c=fn()&&!i,a=e.size??mn,p=a+5,b=Sr(e.direction),g=t?R=>{R.preventDefault(),R.stopPropagation();const M=R.clientY,z=e.y,D=w=>t(z+(w.clientY-M)/s()),h=()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",h)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",h,{once:!0})}:void 0,S=e.side==="left"||e.side==="right",k={position:"absolute",fontSize:e.nested?"9.5px":"10.5px",fontWeight:i?750:e.nested?600:650,color:i?"#0F172A":e.nested?"#6B7280":"#374151",opacity:c?.45:1,transition:"color 120ms ease, opacity 120ms ease",whiteSpace:"normal",pointerEvents:t?"auto":"none",cursor:t?"ns-resize":"default",touchAction:"none",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,width:S?sc:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...e.side==="left"?{left:p,bottom:"50%",marginBottom:2}:e.side==="right"?{right:p,bottom:"50%",marginBottom:2,textAlign:"right"}:e.side==="top"?{top:p,left:"50%",transform:"translateX(-50%)"}:{bottom:p,left:"50%",transform:"translateX(-50%)"}};return o.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:e.x,top:e.y,width:a,height:a,zIndex:e.nested?11:10},children:[o.jsx("div",{onPointerEnter:()=>_t({endpointIds:[e.id]}),onPointerLeave:()=>_t(null),onPointerDown:g,title:`${e.name}${e.direction?` (${e.direction})`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:Bs,height:Bs,transform:`translate(-50%, -50%) scale(${1/Math.max(r,.1)})`,cursor:t?"grab":"default",touchAction:"none"}}),o.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${b}`,borderRadius:5,boxShadow:i?`0 0 0 4px ${b}33, 0 2px 8px rgba(15,23,42,0.24)`:"0 1px 3px rgba(15,23,42,0.18)",opacity:c?.5:1,display:"flex",alignItems:"center",justifyContent:"center",color:b,fontSize:e.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[Cr(e.direction,e.side),o.jsx("span",{onPointerDown:g,style:k,children:e.name.replace(/([a-z0-9])([A-Z])/g,"$1$2")}),[{suffix:"",pos:Ds[e.side],connectable:!0},{suffix:xa,pos:Ds[oc[e.side]],connectable:!1}].flatMap(R=>{const M=R.connectable?"ibd-port-connect":"ibd-port-anchor",z=R.connectable?rc(a):jr(a);return[o.jsx(Ts,{className:M,type:"source",id:`${e.id}${R.suffix}`,position:R.pos,style:z,isConnectable:R.connectable},`s${R.suffix}`),o.jsx(Ts,{className:M,type:"target",id:`${e.id}${R.suffix}`,position:R.pos,style:z,isConnectable:R.connectable},`t${R.suffix}`)]})]})]})}function $s({side:e,direction:t}){const s=Sr(t),r=mn;return o.jsx("div",{"aria-label":`implicit ${t} port`,title:`Implicit ${t} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:e==="left"?-r/2:void 0,right:e==="right"?-r/2:void 0,transform:"translateY(-50%)",width:r,height:r,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${s}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:s,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:Cr(t,e)})}function Ps({name:e,kind:t,nameColor:s,typeColor:r,frame:i=!1}){return o.jsxs("span",{title:`${e} : ${t}`,style:{display:"flex",flexDirection:i?"row":"column",alignItems:i?"baseline":"flex-start",gap:i?6:1,minWidth:0,overflow:"hidden",flex:1},children:[o.jsx("span",{style:{display:i?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:i?W.md:W.sm,lineHeight:1.2,fontWeight:700,color:s,whiteSpace:i?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:i?void 0:2,overflowWrap:"anywhere"},children:e}),o.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:r,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?`: ${t}`:`«${t}»`})]})}function ac({label:e,onDrillIn:t,color:s,onColor:r}){return o.jsx("button",{"aria-label":`Drill into ${e}`,title:`Open ${e} as its own internal block diagram`,className:"nodrag",onClick:i=>{i.stopPropagation(),t()},onDoubleClick:i=>i.stopPropagation(),style:{width:18,height:18,padding:0,borderRadius:3,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:r?"1px solid rgba(255,255,255,0.7)":`1px solid ${s}88`,background:r?"rgba(255,255,255,0.18)":"#FFFFFF",color:r?"#FFFFFF":s,fontSize:11,lineHeight:1,cursor:"pointer",fontWeight:700},children:"↳"})}function Os({label:e,isCollapsed:t,onToggle:s,color:r,onColor:i}){return o.jsx("button",{"aria-label":t?`Expand ${e}`:`Collapse ${e}`,onClick:c=>{c.stopPropagation(),s()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:i?"1px solid rgba(255,255,255,0.7)":`1px solid ${r}88`,background:i?"rgba(255,255,255,0.18)":"#FFFFFF",color:i?"#FFFFFF":r,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:t?"+":"−"})}function lc({id:e,data:t,selected:s,height:r}){const i=t,{label:c,kind:a,color:p,isContainer:b,isFrame:g,ports:S,implicitIn:k,implicitOut:R,onPortMove:M,hasChildren:z,isCollapsed:D,onToggleCollapse:h,onDrillIn:w,minWidth:F,minHeight:P,bgColor:I,fillOpacity:O}=i,[re,Q]=u.useState(!1),v=s?nt.selected:g?"none":re?"0 8px 20px rgba(15,23,42,0.12)":b?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)";return o.jsxs("div",{onMouseEnter:()=>Q(!0),onMouseLeave:()=>Q(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:I||"#FFFFFF",opacity:O??1,border:g?"1.5px solid #94A3B8":`1px solid ${re?p+"9A":"#CBD5E1"}`,...g?{}:{borderTop:`3px solid ${p}`},borderRadius:g?10:8,boxShadow:v,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[o.jsx(mt,{nodeId:e,isVisible:s,minWidth:F??180,minHeight:P??100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),g?o.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,height:38,display:"flex",alignItems:"center",gap:8,padding:"0 10px",background:"#F8FAFC",borderBottom:"1px solid #E2E8F0",borderRadius:"9px 9px 0 0"},children:[o.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:p,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),o.jsx(Ps,{name:c,kind:a,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),z&&h&&o.jsx(Os,{label:c,isCollapsed:D,onToggle:h,color:p})]}):o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:z?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[gn(a)&&o.jsx(Vt,{size:24,color:p}),o.jsx(Ps,{name:c,kind:a,nameColor:"#0F172A",typeColor:b?p:"#64748B"}),z&&w&&o.jsx(ac,{label:c,onDrillIn:w,color:p}),z&&h&&o.jsx(Os,{label:c,isCollapsed:D,onToggle:h,color:p})]}),S.map(N=>o.jsx(ic,{port:N,onMove:M?$=>{const G=N.size??mn,be=(g||b?70:62)-G/2,oe=Math.max(be,(r??be+G+18)-G-18);M(N.id,Math.min(Math.max($,be),oe))}:void 0},N.id)),k&&o.jsx($s,{side:"left",direction:"in"}),R&&o.jsx($s,{side:"right",direction:"out"})]})}const cc=u.memo(lc);function Ws(e,t){const s=e.map(i=>({...i}));let r=t;for(;s.length>=2&&r>0;){const i=s[0],c=s[1],a=Math.hypot(c.x-i.x,c.y-i.y);if(a<=r)r-=a,s.shift();else{const p=r/a;s[0]={x:i.x+(c.x-i.x)*p,y:i.y+(c.y-i.y)*p},r=0}}return s}function dc(e,t){const s=Ws(e,t);return Ws([...s].reverse(),t).reverse()}const uc=e=>e.slice(1).reduce((t,s,r)=>t+Math.hypot(s.x-e[r].x,s.y-e[r].y),0);function bo(e,t=7){if(e.length<2)return"";let s=`M ${e[0].x},${e[0].y}`;for(let i=1;i<e.length-1;i++){const c=e[i-1],a=e[i],p=e[i+1],b=Math.hypot(a.x-c.x,a.y-c.y),g=Math.hypot(p.x-a.x,p.y-a.y),S=Math.min(t,b/2,g/2),k=a.x-Math.sign(a.x-c.x)*S,R=a.y-Math.sign(a.y-c.y)*S,M=a.x+Math.sign(p.x-a.x)*S,z=a.y+Math.sign(p.y-a.y)*S;s+=` L ${k},${R} Q ${a.x},${a.y} ${M},${z}`}const r=e[e.length-1];return`${s} L ${r.x},${r.y}`}function pc(e){let t=0,s=-1;for(let a=1;a<e.length;a++){const p=Math.abs(e[a].x-e[a-1].x)+Math.abs(e[a].y-e[a-1].y);p>s&&(s=p,t=a)}const r=e[t-1],i=e[t],c=Math.abs(i.x-r.x)>=Math.abs(i.y-r.y)?{x:0,y:-14}:{x:14,y:0};return{x:(r.x+i.x)/2+c.x,y:(r.y+i.y)/2+c.y}}function hc(e){var D,h,w,F,P,I,O,re,Q,v,N;const{getZoom:t}=hn(),s=ir(e.id,[e.source,e.target,(D=e.data)==null?void 0:D.sourcePortId,(h=e.data)==null?void 0:h.targetPortId]),r=fn()&&!s,i=((w=e.data)==null?void 0:w.points)??[];if(i.length<2)return null;const c=String(((F=e.style)==null?void 0:F.stroke)??"#2563EB"),a=Number(((P=e.style)==null?void 0:P.strokeWidth)??2),p=s?{...e.style,strokeWidth:a+1.4}:e.style,b=((I=e.data)==null?void 0:I.labelPoint)??pc(i),g=Math.min(28/Math.max(t(),.1),uc(i)*.3),S=dc(i,g),k=(O=e.data)==null?void 0:O.onRouteChange,R=(re=e.data)==null?void 0:re.onSelect,M=!!((Q=e.data)!=null&&Q.flowAnimation),z=i.length===2?[{index:1,a:i[0],b:i[1],straight:!0}]:i.slice(1).map(($,G)=>({index:G+1,a:i[G],b:$,straight:!1})).filter($=>$.index>=2&&$.index<=i.length-2);return o.jsxs(o.Fragment,{children:[s&&o.jsx("path",{d:bo(i),fill:"none",stroke:c,strokeOpacity:.22,strokeWidth:a+9,strokeLinecap:"round",pointerEvents:"none"}),o.jsx(nr,{id:e.id,path:bo(i),style:p,markerEnd:e.markerEnd}),M&&o.jsx("path",{d:bo(i),fill:"none",stroke:String(((v=e.style)==null?void 0:v.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((N=e.style)==null?void 0:N.strokeWidth)??2)),className:"memo-ibd-flow"}),S.length>=2&&o.jsx("path",{d:bo(S),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(t(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:$=>R==null?void 0:R($)}),e.label?o.jsx(an,{children:o.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${b.x}px, ${b.y}px)`,fontSize:W.badge,fontWeight:s?700:600,color:s?"#0F172A":"#475569",background:"rgba(255,255,255,0.96)",border:`1px solid ${s?c:"#E2E8F0"}`,opacity:r?.25:1,padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:e.label})}):null,e.selected&&k?z.map($=>{const G=($.a.x+$.b.x)/2,be=($.a.y+$.b.y)/2;return o.jsx(an,{children:o.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:oe=>{oe.preventDefault(),oe.stopPropagation();const pe=oe.clientX,ge=oe.clientY,le=ye=>{const Re=(ye.clientX-pe)/t(),L=(ye.clientY-ge)/t();if($.straight){if(Math.abs(L)>=Math.abs(Re)){const ve=$.a.y+L;k([$.a,{x:$.a.x,y:ve},{x:$.b.x,y:ve},$.b])}else{const ve=($.a.x+$.b.x)/2+Re;k([$.a,{x:ve,y:$.a.y},{x:ve,y:$.b.y},$.b])}return}const je=i.map(ve=>({...ve}));$.a.y===$.b.y?(je[$.index-1].y=$.a.y+L,je[$.index].y=$.b.y+L):(je[$.index-1].x=$.a.x+Re,je[$.index].x=$.b.x+Re),k(je)},he=()=>{window.removeEventListener("pointermove",le),window.removeEventListener("pointerup",he)};window.addEventListener("pointermove",le),window.addEventListener("pointerup",he,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${G}px, ${be}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:$.a.y===$.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${$.index}`)}):null]})}const mc=u.memo(hc);function _s({onDrillIn:e,color:t,label:s}){return o.jsx("button",{onClick:r=>{r.stopPropagation(),e()},onDoubleClick:r=>r.stopPropagation(),className:"nodrag",title:`Open ${s} as its own diagram`,"aria-label":`Drill into ${s}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${t}66`,borderRadius:4,background:"#FFFFFF",color:t,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Hs({collapsed:e,onToggle:t,color:s}){return o.jsx("button",{onClick:r=>{r.stopPropagation(),t()},onDoubleClick:r=>r.stopPropagation(),className:"nodrag",title:e?"Show substates":"Hide substates","aria-label":e?"Show substates":"Hide substates",style:{width:16,height:16,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${s}66`,borderRadius:4,background:"#FFFFFF",color:s,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:e?"+":"−"})}const yo={width:8,height:8,border:"none",background:"transparent",opacity:0};function en(){return o.jsxs(o.Fragment,{children:[o.jsx(K,{type:"target",position:V.Top,id:"top",style:yo}),o.jsx(K,{type:"source",position:V.Bottom,id:"bottom",style:yo}),o.jsx(K,{type:"target",position:V.Left,id:"left",style:yo}),o.jsx(K,{type:"source",position:V.Right,id:"right",style:yo})]})}function fc({data:e,selected:t}){const s=e,[r,i]=u.useState(!1);if(s.isNote)return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${s.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:nt.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:s.kind,children:[o.jsx(en,{}),o.jsx("span",{style:{fontSize:W.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.label}),o.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:s.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:s.kind})]});if(s.isContainer)return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:s.isMachine?"transparent":`${s.color}06`,borderTop:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderRight:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderBottom:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderLeft:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderRadius:14,boxShadow:t?nt.selected:"none",position:"relative"},children:[o.jsx(en,{}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[s.onToggleCollapse&&!s.isMachine&&o.jsx(Hs,{collapsed:!1,onToggle:s.onToggleCollapse,color:s.color}),s.onDrillIn&&!s.isMachine&&o.jsx(_s,{onDrillIn:s.onDrillIn,color:s.color,label:s.label}),o.jsx("span",{style:{fontSize:W.md,fontWeight:700,color:s.isMachine?"#334155":s.color,whiteSpace:"nowrap"},children:s.label}),o.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:s.isMachine?"#94A3B8":`${s.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:s.kind})]})]});const c=!!s.hasChildren;return o.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:c?`${s.hiddenCount??0} substate${s.hiddenCount===1?"":"s"} hidden — double-click to drill in`:void 0,style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",borderTop:`3px solid ${s.color}`,borderRight:`1px solid ${r?`${s.color}9A`:"#CBD5E1"}`,borderBottom:`1px solid ${r?`${s.color}9A`:"#CBD5E1"}`,borderLeft:`1px solid ${r?`${s.color}9A`:"#CBD5E1"}`,borderRadius:12,boxShadow:t?nt.selected:r?"0 8px 20px rgba(15,23,42,0.12)":nt.md,transition:"box-shadow 150ms ease, border-color 150ms ease",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[o.jsx(en,{}),o.jsx("span",{style:{fontSize:W.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:s.label}),s.subtitle&&o.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:s.subtitle}),c&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[s.onToggleCollapse&&o.jsx(Hs,{collapsed:!0,onToggle:s.onToggleCollapse,color:s.color}),s.onDrillIn&&o.jsx(_s,{onDrillIn:s.onDrillIn,color:s.color,label:s.label}),o.jsxs("span",{style:{fontSize:"8px",fontWeight:700,color:s.color,letterSpacing:"0.05em"},children:["⊞ ",s.hiddenCount??0]})]})]})}const gc=u.memo(fc),dn="#3498DB";function xc({data:e}){const t=e;return o.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[o.jsx("div",{style:{position:"absolute",top:0,left:"50%",transform:"translateX(-50%)",minWidth:140,maxWidth:"90%",padding:"10px 16px",background:"#FFFFFF",border:`1.5px solid ${dn}`,borderRadius:8,boxShadow:nt.md,textAlign:"center",fontSize:W.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),o.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${dn}66`}})]})}const bc=u.memo(xc);function yc({data:e}){const t=e;return o.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#1B3A4B06",border:"1px solid #1B3A4B22",borderRadius:10,pointerEvents:"none"},children:o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 14px"},children:[o.jsx("span",{style:{fontSize:W.sm,fontWeight:700,color:"#1B3A4B"},children:t.label}),t.scenario&&o.jsxs("span",{style:{fontSize:W.xs,color:"#6B7280"},children:["realizes ",t.scenario]})]})})}const wc=u.memo(yc),wo={width:6,height:6,border:"none",background:"transparent",opacity:0};function Fc({data:e,selected:t}){const s=e;return o.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${dn}`,boxShadow:t?nt.selected:nt.sm,position:"relative"},title:s.kind,children:[o.jsx(K,{type:"source",id:"right",position:V.Right,style:wo}),o.jsx(K,{type:"target",id:"right",position:V.Right,style:wo}),o.jsx(K,{type:"source",id:"left",position:V.Left,style:wo}),o.jsx(K,{type:"target",id:"left",position:V.Left,style:wo}),o.jsx("span",{style:{position:"absolute",top:-20,left:"50%",transform:"translateX(-50%)",fontSize:"9px",fontWeight:600,color:"#374151",whiteSpace:"nowrap",background:"#FFFFFFCC",padding:"1px 5px",borderRadius:4},children:s.label})]})}const kc=u.memo(Fc),Eo={opacity:0,width:1,height:1},vc=u.memo(function({data:t}){const s=t;return o.jsxs("div",{style:{width:"100%",height:"100%",display:"grid",placeItems:"center",textAlign:"center",padding:"12px 22px",border:`2px solid ${s.color??"#E67E22"}`,borderRadius:"50%",background:"#FFF9F2",color:"#2D3748",fontSize:13,fontWeight:600,lineHeight:1.25},children:[s.label,o.jsx(K,{type:"target",position:V.Left,style:Eo}),o.jsx(K,{type:"source",position:V.Right,style:Eo})]})}),Sc=u.memo(function({data:t}){const s=t,r=s.side==="right"?V.Left:V.Right;return o.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#334155",fontSize:12,fontWeight:600,textAlign:"center",gap:3},children:[o.jsx(Vt,{color:s.color??"#334155"}),o.jsx("span",{children:s.label}),o.jsx(K,{type:"source",position:r,style:Eo}),o.jsx(K,{type:"target",position:r,style:Eo})]})}),Cc=u.memo(function({data:t}){const s=t;return o.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1.5px solid #64748B",background:"rgba(255,255,255,0.32)",padding:"10px 14px",color:"#475569",fontSize:12,fontWeight:700},children:s.label})});u.memo(function({data:t}){const s=t;return o.jsx("div",{style:{width:"100%",textAlign:"center",color:"#64748B",fontSize:11,fontWeight:700,letterSpacing:".03em"},children:s.label})});function jc(e,t=0){if(e.length<2)return"";if(t===0||e.length===2)return`M ${e.map(i=>`${i.x},${i.y}`).join(" L ")}`;let s=`M ${e[0].x},${e[0].y}`;for(let i=1;i<e.length-1;i++){const c=e[i-1],a=e[i],p=e[i+1],b=Math.min(t,Math.abs(a.x-c.x)/2+Math.abs(a.y-c.y)/2),g=Math.min(t,Math.abs(p.x-a.x)/2+Math.abs(p.y-a.y)/2),S={x:a.x+Math.sign(c.x-a.x)*b,y:a.y+Math.sign(c.y-a.y)*b},k={x:a.x+Math.sign(p.x-a.x)*g,y:a.y+Math.sign(p.y-a.y)*g};s+=` L ${S.x},${S.y} Q ${a.x},${a.y} ${k.x},${k.y}`}const r=e[e.length-1];return`${s} L ${r.x},${r.y}`}const Ec=u.memo(function(t){var R,M,z,D,h;const s=ir(t.id,[t.source,t.target]),r=fn()&&!s,i=((R=t.data)==null?void 0:R.routing)??"rounded",c=Array.isArray((M=t.data)==null?void 0:M.points)?t.data.points:[],a=c.length>=2?c:[{x:t.sourceX,y:t.sourceY},{x:t.targetX,y:t.targetY}],b=i==="straight"?`M ${t.sourceX},${t.sourceY} L ${t.targetX},${t.targetY}`:jc(a,i==="elbow"?0:i==="rounded"?16:i==="curved"?30:42),g=((z=t.data)==null?void 0:z.labelPoint)??a[Math.floor(a.length/2)]??{x:(t.sourceX+t.targetX)/2,y:(t.sourceY+t.targetY)/2},S=String(((D=t.style)==null?void 0:D.stroke)??"#64748B"),k=Number(((h=t.style)==null?void 0:h.strokeWidth)??1.5);return o.jsxs(o.Fragment,{children:[s&&o.jsx("path",{d:b,fill:"none",stroke:S,strokeOpacity:.22,strokeWidth:k+9,strokeLinecap:"round",pointerEvents:"none"}),o.jsx(nr,{path:b,style:s?{...t.style,strokeWidth:k+1.4}:t.style}),t.label&&o.jsx(an,{children:o.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${g.x}px,${g.y}px)`,background:"#FFFFFF",padding:"2px 5px",borderRadius:3,color:s?"#0F172A":"#334155",fontSize:12,pointerEvents:"all",fontWeight:s?700:void 0,opacity:r?.25:1},children:t.label})})]})}),Fo={opacity:0,width:1,height:1};function Er({nodeId:e,selected:t,data:s}){return o.jsx(mt,{nodeId:e,isVisible:t,minWidth:s.minWidth??140,minHeight:s.minHeight??64,color:"#0F766E",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}})}function Ir(){return o.jsxs(o.Fragment,{children:[o.jsx(K,{type:"target",position:V.Left,style:Fo}),o.jsx(K,{type:"source",position:V.Right,style:Fo}),o.jsx(K,{type:"target",position:V.Top,style:Fo}),o.jsx(K,{type:"source",position:V.Bottom,style:Fo})]})}const Ic=u.memo(function({id:t,data:s,selected:r}){const i=s;return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"grid",placeItems:"center",padding:"14px 18px",textAlign:"center",border:"2px solid #0F766E",borderRadius:8,background:"#F0FDFA",color:"#134E4A",fontSize:15,fontWeight:700,lineHeight:1.25,boxShadow:"0 2px 7px rgba(15, 118, 110, 0.16)"},children:[o.jsx(Er,{nodeId:t,selected:!!r,data:i}),o.jsxs("span",{children:[o.jsx("small",{style:{display:"block",marginBottom:5,color:"#0F766E",fontSize:10,letterSpacing:".08em"},children:"SYSTEM OF INTEREST"}),i.label]}),o.jsx(Ir,{})]})}),Ac=u.memo(function({id:t,data:s,selected:r}){const i=s,c=i.category==="environment"?{border:"#7C3AED",fill:"#F5F3FF",text:"#4C1D95",tag:"ENVIRONMENT"}:i.category==="person"?{border:"#2563EB",fill:"#EFF6FF",text:"#1E3A8A",tag:"ACTOR"}:{border:"#64748B",fill:"#F8FAFC",text:"#334155",tag:"EXTERNAL SYSTEM"};return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,padding:"10px 14px",textAlign:"center",border:`1.5px solid ${c.border}`,borderRadius:7,background:c.fill,color:c.text,fontSize:13,fontWeight:650,lineHeight:1.25},children:[o.jsx(Er,{nodeId:t,selected:!!r,data:i}),i.category==="person"&&o.jsx(Vt,{size:26,color:c.border}),o.jsxs("span",{children:[o.jsx("small",{style:{display:"block",marginBottom:4,color:c.border,fontSize:9,letterSpacing:".07em"},children:c.tag}),i.label]}),o.jsx(Ir,{})]})}),Rc=u.memo(function({id:t,data:s,selected:r}){const i=s;return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"2px solid #0F766E",borderRadius:12,background:"rgba(240, 253, 250, 0.34)",padding:"12px 16px",color:"#0F766E",fontSize:12,fontWeight:750,letterSpacing:".04em"},children:[o.jsx(mt,{nodeId:t,isVisible:!!r,minWidth:i.minWidth??240,minHeight:i.minHeight??140,color:"#0F766E",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),i.label]})}),Mc=u.memo(function({id:t,data:s,selected:r}){var P;const i=s,[c,a]=u.useState(!1),[p,b]=u.useState(""),[g,S]=u.useState(!1),k=u.useRef(null),R=u.useCallback(()=>{b(i.label),a(!0),setTimeout(()=>{var I;(I=k.current)==null||I.select()},10)},[i.label]),M=u.useCallback(()=>{var O;a(!1);const I=p.trim();I&&I!==i.label&&((O=i.onInlineEdit)==null||O.call(i,t,I))},[p,i,t]),z=u.useCallback(I=>{I.key==="Enter"&&(I.preventDefault(),M()),I.key==="Escape"&&a(!1)},[M]),D=u.useCallback(I=>{var O;I.preventDefault(),(O=i.onContextMenu)==null||O.call(i,I,t)},[i,t]),h=i.bgColor??"#FFFFFF",w=i.color,F={background:w,border:"2px solid #FFFFFF",width:10,height:10,opacity:g||r?1:0,transition:"opacity 0.15s"};return o.jsxs("div",{onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),onContextMenu:D,onDoubleClick:R,style:{minWidth:120,minHeight:40,background:h,borderLeft:`3px solid ${w}`,borderRadius:8,boxShadow:r?`0 0 0 2px ${w}, 0 4px 12px ${w}44`:g?"0 4px 16px rgba(0,0,0,0.14)":"0 1px 4px rgba(0,0,0,0.08)",cursor:c?"text":"grab",position:"relative",transition:"box-shadow 0.15s",opacity:i.isNew?.7:1},children:[r&&o.jsx(mt,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:w,lineStyle:{borderColor:w},handleStyle:{background:w,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),o.jsxs("div",{style:{padding:"8px 12px",userSelect:"none",display:"flex",gap:8,alignItems:"center"},children:[gn(i.kind)&&o.jsx(Vt,{size:26,color:w}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:w,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:i.kind}),c?o.jsx("input",{ref:k,value:p,onChange:I=>b(I.target.value),onBlur:M,onKeyDown:z,onClick:I=>I.stopPropagation(),autoFocus:!0,style:{fontSize:W.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):o.jsx("div",{style:{fontSize:W.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:i.label||i.kind}),i.isNew&&o.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]})]}),!!((P=i.compartments)!=null&&P.length)&&o.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:i.compartments.map(I=>o.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline",fontSize:"10px",lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden"},children:[o.jsx("span",{style:{color:"#9CA3AF"},children:I.key}),o.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:I.value})]},I.key))}),o.jsx(K,{type:"target",position:V.Top,style:{...F,top:-5}}),o.jsx(K,{type:"source",position:V.Bottom,style:{...F,bottom:-5},id:"bottom"}),o.jsx(K,{type:"source",position:V.Right,style:{...F,right:-5},id:"right"}),o.jsx(K,{type:"target",position:V.Left,style:{...F,left:-5}})]})}),Ar="application/memo-kind";function tn({collapsed:e,onToggleCollapse:t,elementIds:s=[],eligibleKinds:r}){const i=Z(h=>h.model),c=Z(h=>h.selectedElementId),a=Z(h=>h.inspectElement),[p,b]=u.useState(""),[g,S]=u.useState(new Set),[k,R]=u.useState(!0),M=u.useMemo(()=>{if(!(r!=null&&r.size))return[];const h=p.trim().toLowerCase();return sr(i).kinds.filter(w=>r.has(w.name)&&!w.isAbstract).filter(w=>!h||w.name.toLowerCase().includes(h)||(w.label??"").toLowerCase().includes(h)).map(w=>({name:w.name,label:w.label||w.name,layer:w.layer??"",construct:Ga(w.construct)})).sort((w,F)=>w.label.localeCompare(F.label))},[i,r,p]),z=u.useMemo(()=>{var P;if(!i)return[];const h=p.trim().toLowerCase(),w=new Map,F=new Set(s);for(const I of s){const O=(P=i.elements[I])==null?void 0:P.allocatedTo;O&&F.add(O)}for(const I of F){const O=i.elements[I];O&&(h&&!O.name.toLowerCase().includes(h)&&!O.kind.toLowerCase().includes(h)||(w.has(O.kind)||w.set(O.kind,[]),w.get(O.kind).push(O)))}return[...w.entries()].map(([I,O])=>({kind:I,elements:O.sort((re,Q)=>re.name.localeCompare(Q.name))})).sort((I,O)=>I.kind.localeCompare(O.kind))},[i,s,p]),D=h=>S(w=>{const F=new Set(w);return F.has(h)?F.delete(h):F.add(h),F});return e?null:o.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:240,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{background:"#F0F0ED",borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[o.jsx("span",{style:{fontSize:W.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),o.jsx("button",{onClick:t,title:"Hide Diagram Elements","aria-label":"Hide Diagram Elements",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:5,cursor:"pointer",color:"#6B7280",fontSize:20,lineHeight:1},children:"×"})]}),o.jsx("div",{className:"px-2 pt-2 pb-1",style:{flexShrink:0},children:o.jsx("input",{value:p,onChange:h=>b(h.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:W.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),o.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[M.length>0&&o.jsxs("div",{style:{borderBottom:"1px solid #E5E5E0",paddingBottom:4,marginBottom:4},children:[o.jsxs("button",{onClick:()=>R(h=>!h),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[o.jsx("span",{style:{fontSize:10,color:"#6B7280"},children:k?"▼":"▶"}),o.jsx("span",{style:{fontSize:10,color:"#374151",fontWeight:700,letterSpacing:"0.04em"},children:"SHAPES"}),o.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:M.length})]}),k&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-3 pb-1",style:{fontSize:9,color:"#9CA3AF"},children:"Drag onto the canvas to create"}),M.map(h=>{const w=ln[h.layer]??"#6B7280";return o.jsxs("div",{draggable:!0,onDragStart:F=>{F.dataTransfer.setData(Ar,JSON.stringify({kind:h.name,layer:h.layer,construct:h.construct})),F.dataTransfer.effectAllowed="copy"},title:`Drag to create a ${h.label} (${h.construct})`,className:"flex items-center gap-2 px-3 py-1.5",style:{cursor:"grab",fontSize:W.xs,color:"#374151"},children:[o.jsx("span",{style:{width:12,height:12,flexShrink:0,borderRadius:h.construct==="port"?2:3,border:`2px solid ${w}`,background:h.construct==="port"?"#FFFFFF":`${w}22`}}),o.jsx("span",{className:"truncate flex-1",children:h.label})]},h.name)})]})]}),z.map(h=>{var P;const w=g.has(h.kind),F=ln[(P=h.elements[0])==null?void 0:P.layer]??"#6B7280";return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>D(h.kind),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[o.jsx("span",{style:{fontSize:10,color:F},children:w?"▶":"▼"}),o.jsx("span",{className:"truncate",style:{fontSize:10,color:F,fontWeight:700},children:h.kind}),o.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:h.elements.length})]}),!w&&h.elements.map(I=>{const O=c===I.id;return o.jsxs("button",{onClick:()=>a(I.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:W.xs,background:O?"#DDF7EF":"transparent",color:O?"#116149":"#374151",fontWeight:O?600:400},title:`Highlight ${I.name} in diagram`,children:[o.jsx("span",{style:{width:8,height:8,borderRadius:2,background:F,flexShrink:0}}),o.jsx("span",{className:"truncate flex-1",children:I.name})]},I.id)})]},h.kind)}),z.length===0&&o.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:W.xs},children:p?"No matching elements":"No elements in this diagram"})]})]})}function Ce({label:e,icon:t,danger:s,onClick:r}){return o.jsxs("button",{onClick:r,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:W.xs},onMouseEnter:i=>{i.currentTarget.style.background=s?"#FEF2F2":"#F7F7F5"},onMouseLeave:i=>{i.currentTarget.style.background="none"},children:[t&&o.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:t}),o.jsx("span",{style:{color:s?"#DC2626":"#1a1a1a"},children:e})]})}function Co(){return o.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Rr({x:e,y:t,onClose:s,children:r}){const i=u.useRef(null);u.useEffect(()=>{const b=S=>{i.current&&!i.current.contains(S.target)&&s()},g=S=>{S.key==="Escape"&&s()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g)}},[s]);const c=210,a=Math.min(e,window.innerWidth-c-8),p=Math.min(t,window.innerHeight-200);return o.jsx("div",{ref:i,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:a,top:p,minWidth:c,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:r})}const zc=[{label:"Layer default",value:""},{label:"Mint",value:"#E8F5E9"},{label:"Sky",value:"#E3F2FD"},{label:"Amber",value:"#FFF8E1"},{label:"Rose",value:"#FFF0F0"},{label:"Lavender",value:"#F3E5F5"},{label:"Peach",value:"#FBE9E7"}];function Lc({x:e,y:t,nodeId:s,nodeKind:r,onClose:i,onEditName:c,onChangeColor:a,onRemoveFromDiagram:p,onDeleteFromModel:b,onLinkRisk:g,onLinkRequirement:S,onShowProperties:k,onFocusElement:R,onShowInCatalog:M,onShowRelMatrix:z,onOpenSource:D,onViewKindInOntology:h}){const[w,F]=u.useState(!1);return o.jsxs(Rr,{x:e,y:t,onClose:i,children:[o.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:r}),o.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:s})]}),k&&o.jsx(Ce,{label:"Show Properties",icon:"ℹ",onClick:()=>{i(),k()}}),M&&o.jsx(Ce,{label:"Show in Catalog",icon:"☰",onClick:()=>{i(),M()}}),R&&o.jsx(Ce,{label:"Focus on Element",icon:"◎",onClick:()=>{i(),R()}}),z&&o.jsx(Ce,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{i(),z()}}),h&&o.jsx(Ce,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{i(),h()}}),D&&o.jsx(Ce,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{i(),D()}}),(k||M||R||z||h||D)&&o.jsx(Co,{}),o.jsx(Ce,{label:"Edit name",icon:"✏️",onClick:()=>{i(),c()}}),o.jsxs("div",{className:"relative",children:[o.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer",fontSize:W.xs},onMouseEnter:P=>{F(!0),P.currentTarget.style.background="#F7F7F5"},onMouseLeave:P=>{P.currentTarget.style.background="none"},children:[o.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:"🎨"}),o.jsx("span",{style:{flex:1,textAlign:"left",color:"#1a1a1a"},children:"Change color"}),o.jsx("span",{style:{color:"#9CA3AF",fontSize:"10px"},children:"▶"})]}),w&&o.jsx("div",{className:"absolute left-full top-0 rounded-xl overflow-hidden py-1",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",minWidth:160},onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),children:zc.map(P=>o.jsxs("button",{onClick:()=>{i(),a(P.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:I=>{I.currentTarget.style.background="#F7F7F5"},onMouseLeave:I=>{I.currentTarget.style.background="none"},children:[o.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:P.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),o.jsx("span",{style:{fontSize:W.xs,color:"#374151"},children:P.label})]},P.value))})]}),o.jsx(Co,{}),g&&o.jsx(Ce,{label:"Link Risk",icon:"⚠️",onClick:()=>{i(),g()}}),S&&o.jsx(Ce,{label:"Link Requirement",icon:"📋",onClick:()=>{i(),S()}}),(g||S)&&o.jsx(Co,{}),o.jsx(Ce,{label:"Remove from diagram",icon:"↩️",onClick:()=>{i(),p()}}),o.jsx(Ce,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${s} from the model? This cannot be undone.`)&&(i(),b())}})]})}const Nc=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function Tc({x:e,y:t,edgeId:s,relType:r,onClose:i,onChangeStyle:c,onChangeColor:a,onToggleLabel:p,onDelete:b}){return o.jsxs(Rr,{x:e,y:t,onClose:i,children:[o.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:r}),o.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:s})]}),o.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[o.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40},children:"Style"}),["solid","dashed","dotted"].map(g=>o.jsx("button",{onClick:()=>{i(),c(g)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:g},g))]}),o.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5 flex-wrap",children:[o.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40,flexShrink:0},children:"Color"}),Nc.map(g=>o.jsx("button",{onClick:()=>{i(),a(g.value)},title:g.label,style:{width:16,height:16,borderRadius:"50%",background:g.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},g.value))]}),o.jsx(Co,{}),o.jsx(Ce,{label:"Toggle label",icon:"🏷️",onClick:()=>{i(),p()}}),o.jsx(Ce,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{i(),b()}})]})}const Dc=u.memo(function({id:t,data:s,selected:r}){const i=s,c=i.color??i.layerColor??"#E67E22",a=80,p=u.useCallback(b=>{var g;b.preventDefault(),(g=i.onContextMenu)==null||g.call(i,b,t)},[i,t]);return o.jsxs("div",{style:{width:a,height:a,position:"relative"},onContextMenu:p,children:[r&&o.jsx(mt,{minWidth:60,minHeight:60}),o.jsx("svg",{width:a,height:a,style:{position:"absolute",top:0,left:0},children:o.jsx("polygon",{points:`${a/2},4 ${a-4},${a/2} ${a/2},${a-4} 4,${a/2}`,fill:i.color?i.color+"44":"#FFF8E1",stroke:c,strokeWidth:r?2.5:1.5})}),o.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:600,color:"#374151",textAlign:"center",padding:"4px 8px",pointerEvents:"none"},children:i.condition||i.label||"?"}),o.jsx(K,{type:"target",position:V.Top,style:{background:c,border:"2px solid #fff"}}),o.jsx(K,{type:"source",position:V.Right,style:{background:c,border:"2px solid #fff"},id:"right"}),o.jsx(K,{type:"source",position:V.Bottom,style:{background:c,border:"2px solid #fff"},id:"bottom"}),o.jsx(K,{type:"target",position:V.Left,style:{background:c,border:"2px solid #fff"}})]})}),Bc=u.memo(function({id:t,data:s,selected:r}){const i=s,c=(i.orientation??"horizontal")==="horizontal",a=c?120:8,p=c?8:60,b=u.useCallback(g=>{var S;g.preventDefault(),(S=i.onContextMenu)==null||S.call(i,g,t)},[i,t]);return o.jsxs("div",{style:{width:a,height:p,background:"#1a1a1a",borderRadius:4,position:"relative"},title:i.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:b,children:[r&&o.jsx(mt,{minWidth:40,minHeight:6}),c?o.jsxs(o.Fragment,{children:[o.jsx(K,{type:"target",position:V.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),o.jsx(K,{type:"source",position:V.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),o.jsx(K,{type:"source",position:V.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),o.jsx(K,{type:"source",position:V.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):o.jsxs(o.Fragment,{children:[o.jsx(K,{type:"target",position:V.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),o.jsx(K,{type:"source",position:V.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),o.jsx(K,{type:"source",position:V.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),o.jsx(K,{type:"source",position:V.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),$c=u.memo(function({id:t,data:s}){const r=s,i=r.nodeType==="start",c=32,a=u.useCallback(p=>{var b;p.preventDefault(),(b=r.onContextMenu)==null||b.call(r,p,t)},[r,t]);return o.jsxs("div",{style:{width:c,height:c,position:"relative"},onContextMenu:a,children:[o.jsx("svg",{width:c,height:c,children:i?o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-2,fill:"#1a1a1a"}):o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-2,fill:"#1a1a1a"}),o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-6,fill:"#FFFFFF"}),o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-10,fill:"#1a1a1a"})]})}),i?o.jsx(K,{type:"source",position:V.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):o.jsx(K,{type:"target",position:V.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),Pc=["grid","route","export","autoLayout"],Oc={actionflow:["expandCollapse","flowSwimlanes","flowHierarchy","flowNesting","flowDirection","flowLegend","flowFilters"],interconnection:["expandCollapse","interconnectionPorts","interconnectionConnections"],statetransition:["expandCollapse"],general:["expandCollapse","generalMode","useCaseOptions"]};function Wc(e){return new Set([...Pc,...e?Oc[e]??[]:[]])}function _c(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const s=document.implementation.createHTMLDocument(),r=s.createElement("base"),i=s.createElement("a");return s.head.appendChild(r),s.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const Hc=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function st(e){const t=[];for(let s=0,r=e.length;s<r;s++)t.push(e[s]);return t}let Ft=null;function Mr(e={}){return Ft||(e.includeStyleProperties?(Ft=e.includeStyleProperties,Ft):(Ft=st(window.getComputedStyle(document.documentElement)),Ft))}function Io(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Vc(e){const t=Io(e,"border-left-width"),s=Io(e,"border-right-width");return e.clientWidth+t+s}function Gc(e){const t=Io(e,"border-top-width"),s=Io(e,"border-bottom-width");return e.clientHeight+t+s}function Uc(e,t={}){const s=t.width||Vc(e),r=t.height||Gc(e);return{width:s,height:r}}function un(e){return new Promise((t,s)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=s,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function Kc(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Xc(e,t,s){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),c=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${s}`),i.setAttribute("viewBox",`0 0 ${t} ${s}`),c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("externalResourcesRequired","true"),i.appendChild(c),c.appendChild(e),Kc(i)}const ke=(e,t)=>{if(e instanceof t)return!0;const s=Object.getPrototypeOf(e);return s===null?!1:s.constructor.name===t.name||ke(s,t)};function Yc(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function qc(e,t){return Mr(t).map(s=>{const r=e.getPropertyValue(s),i=e.getPropertyPriority(s);return`${s}: ${r}${i?" !important":""};`}).join(" ")}function Zc(e,t,s,r){const i=`.${e}:${t}`,c=s.cssText?Yc(s):qc(s,r);return document.createTextNode(`${i}{${c}}`)}function Vs(e,t,s,r){const i=window.getComputedStyle(e,s),c=i.getPropertyValue("content");if(c===""||c==="none")return;const a=Hc();try{t.className=`${t.className} ${a}`}catch{return}const p=document.createElement("style");p.appendChild(Zc(a,s,i,r)),t.appendChild(p)}function Jc(e,t,s){Vs(e,t,":before",s),Vs(e,t,":after",s)}const Gs="application/font-woff",Us="image/jpeg",Qc={woff:Gs,woff2:Gs,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Us,jpeg:Us,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function ed(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function yn(e){const t=ed(e).toLowerCase();return Qc[t]||""}function td(e){return e.split(/,/)[1]}function pn(e){return e.search(/^(data:)/)!==-1}function od(e,t){return`data:${t};base64,${e}`}async function zr(e,t,s){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((c,a)=>{const p=new FileReader;p.onerror=a,p.onloadend=()=>{try{c(s({res:r,result:p.result}))}catch(b){a(b)}},p.readAsDataURL(i)})}const on={};function nd(e,t,s){let r=e.replace(/\?.*/,"");return s&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function wn(e,t,s){const r=nd(e,t,s.includeQueryParams);if(on[r]!=null)return on[r];s.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const c=await zr(e,s.fetchRequestInit,({res:a,result:p})=>(t||(t=a.headers.get("Content-Type")||""),td(p)));i=od(c,t)}catch(c){i=s.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;c&&(a=typeof c=="string"?c:c.message),a&&console.warn(a)}return on[r]=i,i}async function sd(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):un(t)}async function rd(e,t){if(e.currentSrc){const c=document.createElement("canvas"),a=c.getContext("2d");c.width=e.clientWidth,c.height=e.clientHeight,a==null||a.drawImage(e,0,0,c.width,c.height);const p=c.toDataURL();return un(p)}const s=e.poster,r=yn(s),i=await wn(s,r,t);return un(i)}async function id(e,t){var s;try{if(!((s=e==null?void 0:e.contentDocument)===null||s===void 0)&&s.body)return await Ao(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function ad(e,t){return ke(e,HTMLCanvasElement)?sd(e):ke(e,HTMLVideoElement)?rd(e,t):ke(e,HTMLIFrameElement)?id(e,t):e.cloneNode(Lr(e))}const ld=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Lr=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function cd(e,t,s){var r,i;if(Lr(t))return t;let c=[];return ld(e)&&e.assignedNodes?c=st(e.assignedNodes()):ke(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?c=st(e.contentDocument.body.childNodes):c=st(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),c.length===0||ke(e,HTMLVideoElement)||await c.reduce((a,p)=>a.then(()=>Ao(p,s)).then(b=>{b&&t.appendChild(b)}),Promise.resolve()),t}function dd(e,t,s){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Mr(s).forEach(c=>{let a=i.getPropertyValue(c);c==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),ke(e,HTMLIFrameElement)&&c==="display"&&a==="inline"&&(a="block"),c==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),r.setProperty(c,a,i.getPropertyPriority(c))})}function ud(e,t){ke(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),ke(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function pd(e,t){if(ke(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function hd(e,t,s){return ke(t,Element)&&(dd(e,t,s),Jc(e,t,s),ud(e,t),pd(e,t)),t}async function md(e,t){const s=e.querySelectorAll?e.querySelectorAll("use"):[];if(s.length===0)return e;const r={};for(let c=0;c<s.length;c++){const p=s[c].getAttribute("xlink:href");if(p){const b=e.querySelector(p),g=document.querySelector(p);!b&&g&&!r[p]&&(r[p]=await Ao(g,t,!0))}}const i=Object.values(r);if(i.length){const c="http://www.w3.org/1999/xhtml",a=document.createElementNS(c,"svg");a.setAttribute("xmlns",c),a.style.position="absolute",a.style.width="0",a.style.height="0",a.style.overflow="hidden",a.style.display="none";const p=document.createElementNS(c,"defs");a.appendChild(p);for(let b=0;b<i.length;b++)p.appendChild(i[b]);e.appendChild(a)}return e}async function Ao(e,t,s){return!s&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>ad(r,t)).then(r=>cd(e,r,t)).then(r=>hd(e,r,t)).then(r=>md(r,t))}const Nr=/url\((['"]?)([^'"]+?)\1\)/g,fd=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,gd=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function xd(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function bd(e){const t=[];return e.replace(Nr,(s,r,i)=>(t.push(i),s)),t.filter(s=>!pn(s))}async function yd(e,t,s,r,i){try{const c=s?_c(t,s):t,a=yn(t);let p;return i||(p=await wn(c,a,r)),e.replace(xd(t),`$1${p}$3`)}catch{}return e}function wd(e,{preferredFontFormat:t}){return t?e.replace(gd,s=>{for(;;){const[r,,i]=fd.exec(s)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function Tr(e){return e.search(Nr)!==-1}async function Dr(e,t,s){if(!Tr(e))return e;const r=wd(e,s);return bd(r).reduce((c,a)=>c.then(p=>yd(p,a,t,s)),Promise.resolve(r))}async function kt(e,t,s){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const c=await Dr(i,null,s);return t.style.setProperty(e,c,t.style.getPropertyPriority(e)),!0}return!1}async function Fd(e,t){await kt("background",e,t)||await kt("background-image",e,t),await kt("mask",e,t)||await kt("-webkit-mask",e,t)||await kt("mask-image",e,t)||await kt("-webkit-mask-image",e,t)}async function kd(e,t){const s=ke(e,HTMLImageElement);if(!(s&&!pn(e.src))&&!(ke(e,SVGImageElement)&&!pn(e.href.baseVal)))return;const r=s?e.src:e.href.baseVal,i=await wn(r,yn(r),t);await new Promise((c,a)=>{e.onload=c,e.onerror=t.onImageErrorHandler?(...b)=>{try{c(t.onImageErrorHandler(...b))}catch(g){a(g)}}:a;const p=e;p.decode&&(p.decode=c),p.loading==="lazy"&&(p.loading="eager"),s?(e.srcset="",e.src=i):e.href.baseVal=i})}async function vd(e,t){const r=st(e.childNodes).map(i=>Br(i,t));await Promise.all(r).then(()=>e)}async function Br(e,t){ke(e,Element)&&(await Fd(e,t),await kd(e,t),await vd(e,t))}function Sd(e,t){const{style:s}=e;t.backgroundColor&&(s.backgroundColor=t.backgroundColor),t.width&&(s.width=`${t.width}px`),t.height&&(s.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{s[i]=r[i]}),e}const Ks={};async function Xs(e){let t=Ks[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},Ks[e]=t,t}async function Ys(e,t){let s=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,c=(s.match(/url\([^)]+\)/g)||[]).map(async a=>{let p=a.replace(r,"$1");return p.startsWith("https://")||(p=new URL(p,e.url).href),zr(p,t.fetchRequestInit,({result:b})=>(s=s.replace(a,`url(${b})`),[a,b]))});return Promise.all(c).then(()=>s)}function qs(e){if(e==null)return[];const t=[],s=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(s,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const b=i.exec(r);if(b===null)break;t.push(b[0])}r=r.replace(i,"");const c=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",p=new RegExp(a,"gi");for(;;){let b=c.exec(r);if(b===null){if(b=p.exec(r),b===null)break;c.lastIndex=p.lastIndex}else p.lastIndex=c.lastIndex;t.push(b[0])}return t}async function Cd(e,t){const s=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{st(i.cssRules||[]).forEach((c,a)=>{if(c.type===CSSRule.IMPORT_RULE){let p=a+1;const b=c.href,g=Xs(b).then(S=>Ys(S,t)).then(S=>qs(S).forEach(k=>{try{i.insertRule(k,k.startsWith("@import")?p+=1:i.cssRules.length)}catch(R){console.error("Error inserting rule from remote css",{rule:k,error:R})}})).catch(S=>{console.error("Error loading remote css",S.toString())});r.push(g)}})}catch(c){const a=e.find(p=>p.href==null)||document.styleSheets[0];i.href!=null&&r.push(Xs(i.href).then(p=>Ys(p,t)).then(p=>qs(p).forEach(b=>{a.insertRule(b,a.cssRules.length)})).catch(p=>{console.error("Error loading remote stylesheet",p)})),console.error("Error inlining remote css file",c)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{st(i.cssRules||[]).forEach(c=>{s.push(c)})}catch(c){console.error(`Error while reading CSS rules from ${i.href}`,c)}}),s))}function jd(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Tr(t.style.getPropertyValue("src")))}async function Ed(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const s=st(e.ownerDocument.styleSheets),r=await Cd(s,t);return jd(r)}function $r(e){return e.trim().replace(/["']/g,"")}function Id(e){const t=new Set;function s(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(c=>{t.add($r(c))}),Array.from(r.children).forEach(c=>{c instanceof HTMLElement&&s(c)})}return s(e),t}async function Ad(e,t){const s=await Ed(e,t),r=Id(e);return(await Promise.all(s.filter(c=>r.has($r(c.style.fontFamily))).map(c=>{const a=c.parentStyleSheet?c.parentStyleSheet.href:null;return Dr(c.cssText,a,t)}))).join(`
|
|
3
|
+
`)}async function Rd(e,t){const s=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Ad(e,t);if(s){const r=document.createElement("style"),i=document.createTextNode(s);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function Md(e,t={}){const{width:s,height:r}=Uc(e,t),i=await Ao(e,t,!0);return await Rd(i,t),await Br(i,t),Sd(i,t),await Xc(i,s,r)}const Pr="#FFFFFF",ko=24,zd=2;function Ld(e){const t=/translate\(\s*(-?[\d.]+)px[,\s]+(-?[\d.]+)px/.exec(e.style.transform);return t?[Number(t[1]),Number(t[2])]:[0,0]}function Nd(e){const t=[...e.querySelectorAll(".react-flow__node")];let s=1/0,r=1/0,i=-1/0,c=-1/0;for(const a of t){const[p,b]=Ld(a);s=Math.min(s,p),r=Math.min(r,b),i=Math.max(i,p+a.offsetWidth),c=Math.max(c,b+a.offsetHeight)}return Number.isFinite(s)?{x:s,y:r,width:i-s,height:c-r}:{x:0,y:0,width:e.scrollWidth||1,height:e.scrollHeight||1}}async function Td(e){const t=e.querySelector(".react-flow__viewport");if(!t)throw new Error("No diagram canvas to export");const s=Nd(t),r=Math.max(1,Math.ceil(s.width)+ko*2),i=Math.max(1,Math.ceil(s.height)+ko*2);return{dataUrl:await Md(t,{width:r,height:i,backgroundColor:Pr,skipFonts:!0,filter:a=>!(a instanceof Element&&(a.classList.contains("react-flow__controls")||a.classList.contains("react-flow__minimap")||a.classList.contains("react-flow__background")||a.classList.contains("react-flow__attribution"))),style:{width:`${r}px`,height:`${i}px`,transform:`translate(${ko-s.x}px, ${ko-s.y}px) scale(1)`}}),width:r,height:i}}async function Dd(e,t,s,r){const i=new Image;i.src=e,await i.decode();const c=document.createElement("canvas");c.width=Math.max(1,Math.round(t*r)),c.height=Math.max(1,Math.round(s*r));const a=c.getContext("2d");if(!a)throw new Error("Canvas 2D context unavailable");return a.fillStyle=Pr,a.fillRect(0,0,c.width,c.height),a.drawImage(i,0,0,c.width,c.height),c}function Zs(e,t){const s=document.createElement("a");s.href=e,s.download=t,s.click()}function Bd(e,t){return`${(e??"diagram").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").toLowerCase()||"diagram"}.${t}`}async function $d(e,t,s){const r=Bd(s,t),{dataUrl:i,width:c,height:a}=await Td(e);if(t==="svg"){Zs(i,r);return}const p=await Dd(i,c,a,zd);if(t==="png"){Zs(p.toDataURL("image/png"),r);return}const{jsPDF:b}=await oa(async()=>{const{jsPDF:S}=await import("./jspdf.es.min-DZ68BGxk.js").then(k=>k.j);return{jsPDF:S}},__vite__mapDeps([0,1,2,3,4])),g=new b({orientation:c>=a?"landscape":"portrait",unit:"px",format:[c,a],compress:!0});g.addImage(p.toDataURL("image/png"),"PNG",0,0,c,a),g.save(r)}const Pd=1,Js="memo-layout-progress";if(typeof document<"u"&&!document.getElementById(Js)){const e=document.createElement("style");e.id=Js,e.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(e)}const Qs={background:"#F7F7F5"},Od={padding:.08,maxZoom:2},Wd={background:"#FFFFFF"},_d={hideAttribution:!0},Hd=[20,20],Vd=50,er=8e3,Gd=90;function Ud(e,t){return new Promise((s,r)=>{const i=window.setTimeout(()=>r(new Error(`${t} layout exceeded ${er/1e3}s`)),er);e.then(c=>{window.clearTimeout(i),s(c)},c=>{window.clearTimeout(i),r(c)})})}function Kd({data:e,selected:t}){const s=e.kind,r=s==="note",i=s==="constraint";return o.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",padding:r?"12px 14px":i?"10px 12px":"4px",background:r?String(e.color??"#FEF3C7"):i?"#FFFFFF":"transparent",border:i?"1.5px dashed #7C3AED":r?"1px solid #F59E0B":"1px solid transparent",borderRadius:r?3:i?5:0,boxShadow:r?"0 2px 6px rgba(0,0,0,.12)":"none",color:"#292524",fontSize:12,lineHeight:1.4},children:[o.jsx(mt,{isVisible:t,minWidth:100,minHeight:48,color:"#2563EB"}),o.jsx("button",{className:"nodrag","aria-label":"Delete annotation",title:"Delete annotation",onPointerDown:c=>{var a;c.preventDefault(),c.stopPropagation(),(a=e.onDelete)==null||a.call(e)},onClick:c=>{var a;c.stopPropagation(),(a=e.onDelete)==null||a.call(e)},style:{position:"absolute",top:3,right:5,border:0,background:"transparent",color:"#64748B",cursor:"pointer",fontSize:14,lineHeight:1,pointerEvents:"all",zIndex:30},children:"×"}),i&&o.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#7C3AED",marginBottom:4},children:"constraint"}),o.jsx("div",{contentEditable:!0,suppressContentEditableWarning:!0,className:"nodrag",style:{outline:"none",whiteSpace:"pre-wrap",minHeight:20},onBlur:c=>{var a;return(a=e.onTextChange)==null?void 0:a.call(e,c.currentTarget.textContent??"")},children:String(e.text??"")})]})}function nn(e,t,s="direct"){const r=new Map(e.map(h=>[h.id,h])),i=new Map,c=h=>{const w=i.get(h);if(w)return w;const F=r.get(h),P=F.parentId?c(F.parentId):{x:0,y:0},I={x:P.x+F.position.x,y:P.y+F.position.y};return i.set(h,I),I},a=h=>{var w,F;return{width:Number(h.width??((w=h.style)==null?void 0:w.width)??0),height:Number(h.height??((F=h.style)==null?void 0:F.height)??0)}},p=t.flatMap(h=>{var re,Q,v,N,$,G;const w=(be,oe,pe)=>{var ge,le;if(typeof oe=="string"){const he=(((le=(ge=r.get(be))==null?void 0:ge.data)==null?void 0:le.ports)??[]).find(ye=>ye.id===oe);if(he){const ye=he.size??20;return{x:he.x+ye/2,y:he.y+ye/2}}}return pe},F=w(h.source,(re=h.data)==null?void 0:re.sourcePortId,(Q=h.data)==null?void 0:Q.sourceOffset),P=w(h.target,(v=h.data)==null?void 0:v.targetPortId,(N=h.data)==null?void 0:N.targetOffset);if(!F||!P||!r.has(h.source)||!r.has(h.target))return[];const I=c(h.source),O=c(h.target);return[{id:h.id,source:{x:I.x+F.x,y:I.y+F.y},target:{x:O.x+P.x,y:O.y+P.y},sourceNodeId:h.source,targetNodeId:h.target,sourceSide:($=h.data)==null?void 0:$.sourceSide,targetSide:(G=h.data)==null?void 0:G.targetSide}]});if(p.length===0)return t;const b=e.filter(h=>!h.data.isFrame).map(h=>({id:h.id,...c(h.id),...a(h)})),g=new Map(p.map(h=>[h.id,h])),S=new Set(t.filter(h=>{var w;return(w=h.data)==null?void 0:w.manualRoute}).map(h=>h.id)),k=p.filter(h=>!S.has(h.id)),R=s==="tidy"?$a(k,b):Pa(k),M=(h,w)=>{const{labelPoint:F,...P}=h.data??{};return{...h,data:{...P,points:w}}},z=t.map(h=>{var P;const w=g.get(h.id);if(!w)return h;if((P=h.data)!=null&&P.manualRoute){const I=[...h.data.points??[]];if(I.length>=2)return I[0]=w.source,I[I.length-1]=w.target,M(h,I)}const F=R.get(h.id);return F?M(h,F):h});if(s!=="tidy")return z;const D=Oa(z.flatMap(h=>{var P;const w=(P=h.data)==null?void 0:P.points,F=typeof h.label=="string"?h.label:"";return w&&w.length>=2&&F?[{id:h.id,points:w,width:F.length*6.2+16,height:18}]:[]}),b);return z.map(h=>D.has(h.id)?{...h,data:{...h.data,labelPoint:D.get(h.id)}}:h)}function Xd({x:e,y:t,onConfirm:s,onCancel:r}){const[i,c]=u.useState(""),a=u.useRef(null);u.useEffect(()=>{var g;(g=a.current)==null||g.focus()},[]),u.useEffect(()=>{const g=S=>{const k=document.getElementById("quick-create-popup");k&&!k.contains(S.target)&&r()};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[r]);const p=Math.min(e,window.innerWidth-220),b=Math.min(t,window.innerHeight-80);return o.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:p,top:b,width:200,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:[o.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",fontSize:W.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),o.jsxs("div",{className:"px-2 py-2",children:[o.jsx("input",{ref:a,value:i,onChange:g=>c(g.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:W.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:g=>{g.key==="Enter"&&i.trim()&&(g.preventDefault(),s(i.trim())),g.key==="Escape"&&r()}}),o.jsxs("div",{className:"flex gap-2 mt-2",children:[o.jsx("button",{onClick:()=>i.trim()&&s(i.trim()),style:{flex:1,fontSize:W.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),o.jsx("button",{onClick:r,style:{fontSize:W.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function sn({color:e,glyph:t}){return o.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:e+"22",border:`1.5px solid ${e}`,color:e,fontSize:9,fontWeight:800,lineHeight:1},children:t})}function tr(e,t){if(!e||!t)return[];const s=new Map;for(const a of e.relationships)So.has(a.type)&&!s.has(a.targetId)&&s.set(a.targetId,a.sourceId);const r=[t],i=new Set(r);let c=t;for(;s.has(c);){const a=s.get(c);if(i.has(a))break;r.unshift(a),i.add(a),c=a}return r}function rn({path:e,nameOf:t,onFocus:s,rootLabel:r}){if(e.length===0)return null;const i=e.length>1?e[e.length-2]:null;return o.jsxs(o.Fragment,{children:[o.jsx(Pe,{}),o.jsx(fe,{icon:o.jsx(H.back,{}),label:"Parent",onClick:()=>s(i),title:i?`Back to ${t(i)}`:r}),o.jsx("button",{onClick:()=>s(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:r,children:"⌂ All"}),e.map((c,a)=>{const p=a===e.length-1;return o.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[o.jsx("span",{children:"›"}),o.jsx("button",{onClick:()=>s(c),disabled:p,className:"text-xs font-medium",style:{color:p?"#1a1a1a":"#2563EB",fontWeight:p?700:500,cursor:p?"default":"pointer"},title:p?void 0:`Focus ${t(c)}`,children:t(c)})]},c)})]})}function Yd(){var cs,ds,us,ps,hs,ms,fs,gs,xs,bs;const e=Vi(),t=Z(n=>n.model),s=Z(n=>n.createRelationship),r=u.useMemo(()=>sr(t),[t]),i=Z(n=>n.selectedElementId),c=Z(n=>n.selectedViewpointId),a=Z(n=>n.selectedDiagramId),p=Z(n=>n.hiddenLayers),b=Z(n=>n.selectElement),g=Z(n=>n.inspectElement),S=Z(n=>n.inspectRelationship),k=Z(n=>n.setActiveMode),R=Z(n=>n.setActiveView),M=Z(n=>n.setExplorerTab),z=Z(n=>n.availableOntologies),D=Z(n=>n.setSelectedOntologyKind),h=Z(n=>n.diagramLayouts),w=Z(n=>n.setNodeLayout),F=Z(n=>n.mergeDiagramLayouts),P=Z(n=>n.updateDiagramElementIds),{fitView:I,screenToFlowPosition:O,getViewport:re,setViewport:Q}=hn(),[v,N]=Gi([]),[$,G,be]=Ui([]),oe=u.useRef([]),pe=u.useRef([]),ge=u.useRef(null),[le,he]=u.useState(!1),[ye,Re]=u.useState(null),[L,je]=u.useState(null),ve=u.useRef(t),vt=u.useRef(a),Ge=u.useRef(null),ce=u.useRef(null),ie=u.useRef(!1),Ue=u.useRef(null),Oe=u.useRef(0);u.useEffect(()=>{ce.current===null&&(oe.current=v)},[v]),u.useEffect(()=>{pe.current=$},[$]);const ne=u.useCallback((n,l=!0)=>{oe.current=n,ie.current||(ie.current=l),ce.current===null&&(ce.current=requestAnimationFrame(()=>{ce.current=null;const d=oe.current,m=ie.current;if(ie.current=!1,!m){N(d);return}const x=nn(d,pe.current);pe.current=x,N(d),G(x)}))},[N,G]),[Ee,Ke]=u.useState(!1),[it,Se]=u.useState(0),[at,Fn]=u.useState(null),[Gt,Or]=u.useState(0),[Wr,Ut]=u.useState(0),[St,Kt]=u.useState(!0),[Xt,Ro]=u.useState(!1),[Mo,_r]=u.useState(!1),Le="left",[Hr,kn]=u.useState(!0),[zo,Vr]=u.useState(!0),[Xe,vn]=u.useState(!0),[Ye,Gr]=u.useState("horizontal"),[qe,Ur]=u.useState(!0),[Ze,Kr]=u.useState("overlay"),[Yt,Sn]=u.useState("allocation"),[Ct,Cn]=u.useState("all"),[jn,En]=u.useState(!1),[In,Xr]=u.useState(!1),[Je,Yr]=u.useState(new Set(["control","data","energy","material"]));u.useEffect(()=>{const n=()=>Ro(d=>!d),l=()=>Kt(d=>!d);return window.addEventListener("memo:toggle-diagram-toolbar",n),window.addEventListener("memo:toggle-diagram-elements",l),()=>{window.removeEventListener("memo:toggle-diagram-toolbar",n),window.removeEventListener("memo:toggle-diagram-elements",l)}},[]),u.useEffect(()=>{const n=()=>{var d;const l=document.fullscreenElement;_r(!!(l&&((d=ge.current)!=null&&d.contains(l))))};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]);const[Ie,jt]=u.useState(null),[Qe,qt]=u.useState(null),[we,Et]=u.useState(null),[We,Zt]=u.useState(null),[It,An]=u.useState(null),[Jt,qr]=u.useState(2),[Qt,Rn]=u.useState(null),At=u.useRef([]),Lo=u.useRef([]),Mn=u.useCallback(n=>{At.current.push(n),At.current.length>Vd&&At.current.shift(),Lo.current=[]},[]),f=na(t,a),No=f?sa[f.diagramType]:null,eo=!!((cs=f==null?void 0:f.properties)!=null&&cs.layoutStyle),lt=((ds=f==null?void 0:f.properties)==null?void 0:ds.layoutStyle)==="fbs",ct=a?h[a]:void 0,dt=ba(ct),Rt=((us=ct==null?void 0:ct.canvas)==null?void 0:us.autoLayout)!==!1,et=((ps=ct==null?void 0:ct.canvas)==null?void 0:ps.flowAnimation)===!0,zn=u.useCallback((n,l)=>{var C;if(!a)return;const d=Z.getState().diagramLayouts[a]??{nodes:{},edges:{}},m=(C=d.annotations)==null?void 0:C[n];if(!m)return;const x={...d,annotations:{...d.annotations,[n]:{...m,text:l}}};F({[a]:x}),He(a,x),N(y=>y.map(T=>T.id===n?{...T,data:{...T.data,text:l}}:T))},[a,F,N]),Ln=u.useCallback(n=>{if(!a)return;const l=Z.getState().diagramLayouts[a]??{nodes:{},edges:{}},d={...l.annotations};delete d[n];const m={...l,annotations:d};F({[a]:m}),He(a,m),N(x=>x.filter(C=>C.id!==n))},[a,F,N]),to=u.useCallback(n=>Object.entries((n==null?void 0:n.annotations)??{}).map(([l,d])=>({id:l,type:"annotationNode",zIndex:1e3,position:{x:d.x,y:d.y},style:{width:d.width??180,height:d.height??92},data:{kind:d.kind,text:d.text,color:d.color,onTextChange:m=>zn(l,m),onDelete:()=>Ln(l)}})),[zn,Ln]),Zr=u.useCallback(n=>{if(!a)return;const l=`annotation-${Date.now().toString(36)}`,d=O({x:window.innerWidth/2,y:window.innerHeight/2}),m=n==="constraint"?"{constraint}":n==="note"?"Note":"Text",x=Z.getState().diagramLayouts[a]??{nodes:{},edges:{}},C={kind:n,x:d.x,y:d.y,width:180,height:n==="text"?56:92,text:m},y={...x,annotations:{...x.annotations,[l]:C}};F({[a]:y}),He(a,y),N(T=>[...T,...to(y).filter(j=>j.id===l)])},[a,O,F,N,to]),Nn=u.useCallback(()=>{if(!a)return;const n=Z.getState().diagramLayouts[a],l={nodes:{},edges:{},canvas:{...n==null?void 0:n.canvas,autoLayout:!0}};F({[a]:l}),He(a,l),Ut(d=>d+1)},[a,F]),Jr=u.useCallback(n=>{Gr(n),requestAnimationFrame(()=>e(oe.current.map(l=>l.id))),Nn()},[Nn,e]),xe=u.useCallback(()=>{var l;if(!a)return;const n=Z.getState().diagramLayouts[a]??{nodes:{},edges:{}};((l=n.canvas)==null?void 0:l.autoLayout)!==!1&&F({[a]:{...n,canvas:{...n.canvas,autoLayout:!1}}})},[a,F]);u.useEffect(()=>{if(!a||Rt||Ee||v.length===0||it===0)return;const n=window.setTimeout(()=>{const l=Z.getState().diagramLayouts[a]??{nodes:{},edges:{}},d=re(),m=rl({nodes:Object.fromEntries(v.filter(x=>x.type!=="annotationNode").map(x=>[x.id,{...l.nodes[x.id]??{},x:x.position.x,y:x.position.y,...x.width?{width:x.width}:{},...x.height?{height:x.height}:{},ports:Object.fromEntries((x.data.ports??[]).map(C=>[C.id,{x:C.x,y:C.y,side:C.side}]))}])),edges:Object.fromEntries($.map(x=>{var C,y,T,j,J,Y;return[x.id,{...(()=>{var se;const{points:ee,...ae}=((se=l.edges)==null?void 0:se[x.id])??{};return ae})(),...(C=x.data)!=null&&C.manualRoute&&((T=(y=x.data)==null?void 0:y.points)!=null&&T.length)?{points:(j=x.data)==null?void 0:j.points,source:x.source,target:x.target,sourcePortId:(J=x.data)==null?void 0:J.sourcePortId,targetPortId:(Y=x.data)==null?void 0:Y.targetPortId}:{}}]})),annotations:Object.fromEntries(v.filter(x=>x.type==="annotationNode").map(x=>{var C,y;return[x.id,{kind:x.data.kind,text:String(x.data.text??""),color:x.data.color,x:x.position.x,y:x.position.y,width:Number(x.width??((C=x.style)==null?void 0:C.width)??180),height:Number(x.height??((y=x.style)==null?void 0:y.height)??92)}]})),canvas:{...l.canvas,zoom:d.zoom,pan:{x:d.x,y:d.y},autoLayout:!1}});F({[a]:m}),He(a,m),Se(0)},350);return()=>window.clearTimeout(n)},[a,Rt,Ee,it,v,$,re,F]);const _=f?f.viewKind??(No==null?void 0:No.viewKind)??"general":void 0,Tn=u.useMemo(()=>Wc(_),[_]),de=u.useCallback(n=>Tn.has(n),[Tn]),oo=_==="interconnection"?.72:.8,_e=u.useCallback((n=0)=>{const l=ge.current,d=oe.current.filter(se=>!se.hidden);if(!l||d.length===0)return;const{width:m,height:x}=l.getBoundingClientRect(),C=_==="actionflow"&&qe&&Ze==="above"?112:0,y=m,T=x-C,j=Ki(d);if(y<=0||T<=0||j.width<=0||j.height<=0)return;if(_==="actionflow"&&Xe){if(Ye==="horizontal"){const se=Math.max(.1,Math.min(2,T*.72/j.height));Q({x:y*.05-j.x*se,y:(T-j.height*se)/2-j.y*se,zoom:se},{duration:n})}else{const se=Math.max(.1,Math.min(2,y*.78/j.width));Q({x:(y-j.width*se)/2-j.x*se,y:T*.06-j.y*se,zoom:se},{duration:n})}return}const J=.08,Y=.08;if(Math.min(y*(1-J*2)/j.width,T*(1-Y*2)/j.height,2)>=oo){I({padding:J,minZoom:oo,maxZoom:2,duration:n});return}const ae=Math.max(.1,Math.min(2,y*(1-J*2)/j.width));Q({x:y*J-j.x*ae,y:T*Y-j.y*ae,zoom:ae},{duration:n})},[Ye,qe,Ze,Le,oo,I,Mo,Q,Xe,Xt,_]),gt=_==="general"&&!eo&&!lt,Dn=(f==null?void 0:f.diagramType)==="ucd",[ut,Bn]=u.useState("graph"),[To,$n]=u.useState("all"),[Do,Pn]=u.useState("straight"),[Mt,On]=u.useState(new Set),Qr=u.useMemo(()=>t?ya(t):0,[t]),Wn=u.useMemo(()=>t?wa(t):[],[t]),Bo=(hs=f==null?void 0:f.properties)==null?void 0:hs.modes,ei=u.useMemo(()=>{if(!Bo)return Zo;const n=new Set(Bo.split(",").map(d=>d.trim())),l=Zo.filter(d=>n.has(d));return l.length?l:Zo},[Bo]),_n=u.useMemo(()=>{if(!t||!f)return[];const n=new Set(f.elementIds),l=Object.values(t.elements).filter(d=>n.has(d.id)&&d.allocatedTo).map(d=>d.allocatedTo);return Fa(l,t)},[t,f]),ti=u.useMemo(()=>{if(!t||!f)return!1;const n=new Set(f.elementIds);return Object.values(t.elements).some(l=>n.has(l.id)&&!!(l.attributes.stage||l.attributes.phase))},[t,f]),no=u.useMemo(()=>{if(!t||!f||_!=="actionflow")return[];const n=(f.elementIds??[]).map(l=>t.elements[l]).filter(l=>!!l&&l.construct==="action");return ka(n,t)},[t,f,_]),[zt,oi]=u.useState("containment"),[Lt,so]=u.useState(new Set),[Hn,Nt]=u.useState(new Set),[ro,$o]=u.useState(null),[Ne,Po]=u.useState("all"),[tt,Oo]=u.useState("summary"),[Vn,Gn]=u.useState(!1),[Un,Tt]=u.useState(new Set),[xt,Wo]=u.useState(null),[Dt,Kn]=u.useState("flat"),[Xn,Bt]=u.useState(new Set),[io,_o]=u.useState(null),[ao,ni]=u.useState(new Map),Te=u.useRef(new Map),si=u.useMemo(()=>tr(t,ro),[t,ro]),ri=u.useMemo(()=>tr(t,io),[t,io]),ii=u.useMemo(()=>{var m;if(!t||!xt)return[];const n=[xt],l=new Set(n);let d=xt;for(;d;){const x=(m=t.elements[d])==null?void 0:m.parentAction;if(!x||l.has(x)||!t.elements[x])break;n.unshift(x),l.add(x),d=x}return n},[t,xt]),lo=u.useMemo(()=>{if(!t||_!=="statetransition")return[];const n=new Set;for(const l of t.relationships){if(!So.has(l.type))continue;const d=t.elements[l.sourceId];!d||!t.elements[l.targetId]||!va(d)||d.kind.endsWith("Machine")||n.add(d.id)}return[...n]},[t,_]),ai=u.useMemo(()=>t?[...new Set(t.relationships.filter(n=>So.has(n.type)).map(n=>n.sourceId))]:[],[t]);u.useEffect(()=>{var l,d;Se(0),Bn(Sa(f==null?void 0:f.properties)),$n(Jo(f==null?void 0:f.properties).level??"all"),Pn(Jo(f==null?void 0:f.properties).edgeStyle??"straight"),On(new Set),vn(!0),Sn("allocation"),Cn("all");const n=(d=(l=f==null?void 0:f.properties)==null?void 0:l.styleHint)!=null&&d.startsWith("expanded:")?f.properties.styleHint.slice(9).split(",").map(m=>m.trim()).filter(Boolean):[];so(new Set(n)),$o(null),Po("all"),Oo("summary"),Gn(!1),Tt(new Set),Wo(null),Kn("flat"),_o(null),Te.current.clear()},[a,(ms=f==null?void 0:f.properties)==null?void 0:ms.layoutHint,(fs=f==null?void 0:f.properties)==null?void 0:fs.styleHint]);const li=u.useMemo(()=>({decompositionNode:ll,interconnectionNode:cc,actionFlowNode:Ea,actionFlowLane:ja,actionFlowLaneLabel:Ca,stateNode:gc,seqLifeline:bc,seqSection:wc,seqOccurrence:kc,useCase:vc,useCaseActor:Sc,useCaseBoundary:Cc,contextSystem:Ic,contextExternal:Ac,contextBoundary:Rc,diagramNode:Mc,annotationNode:Kd,decisionNode:Dc,forkNode:Bc,startEndNode:$c}),[]),ci=u.useMemo(()=>({interconnectionEdge:mc,useCaseEdge:Ec}),[]),di=u.useCallback(n=>{var l,d;return((l=n.data)==null?void 0:l.color)||((d=n.data)==null?void 0:d.layerColor)||"#ccc"},[]),me=u.useMemo(()=>{var T;const n=(f==null?void 0:f.viewpointId)==="__model"?null:(f==null?void 0:f.viewpointId)||c,l=n&&(t==null?void 0:t.viewpoints),d=p.size>0,m=(T=f==null?void 0:f.elementIds)!=null&&T.length?new Set(f.elementIds):void 0;if(!l&&!d&&!m)return;const x=l?t.viewpoints.find(j=>j.id===n):void 0,C=x?new Set(x.visibleKinds):void 0,y=x?new Set(x.visibleLayers):void 0;return j=>p.has(j.layer)?!1:m?m.has(j.id):((C==null?void 0:C.size)??0)>0||((y==null?void 0:y.size)??0)>0?!!(C!=null&&C.has(j.kind))||!!(y!=null&&y.has(j.layer)):!0},[c,f,t==null?void 0:t.viewpoints,p]),Yn=u.useMemo(()=>{if(!t||_!=="interconnection")return[];const n=Object.values(t.elements),l=me?n.filter(me):n;return Ia(Aa(l,t.relationships),Pd)},[t,_,me]),qn=u.useRef(null);u.useEffect(()=>{if(!t)return;const n=`${a??""}|${_??""}`;if(qn.current!==n){if(_==="statetransition"){if(lo.length===0)return;Bt(new Set(lo))}else _==="interconnection"&&Nt(new Set(Yn));qn.current=n}},[t,a,_,lo,Yn]);const co=u.useMemo(()=>{if(!t||!f||f.diagramType!=="bdd")return null;const n=f.relationshipTypes??[];return n.length===0||n.every(d=>So.has(d.charAt(0).toLowerCase()+d.slice(1)))?Ra(Es(t,me,f.relationshipTypes)):null},[t,f,me]),Zn=u.useCallback(()=>{if(t)return lt?Ma(t):gt?Es(t,me,f==null?void 0:f.relationshipTypes):za(t)},[t,lt,gt,me,f==null?void 0:f.relationshipTypes]),Ho=u.useCallback(n=>{so(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),Jn=u.useCallback(n=>{Nt(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),Qn=u.useCallback(n=>{Tt(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),uo=u.useCallback(n=>{_o(n),Bt(new Set),g(null)},[g]),po=u.useCallback(n=>{Wo(n),Tt(new Set),g(null)},[g]),ho=u.useCallback(n=>{$o(n),Nt(new Set),g(null)},[g]),es=u.useCallback(n=>{Bt(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),ts=u.useCallback(n=>{Te.current.clear(),ni(l=>{const d=new Map(l),m=d.get(n)||"vertical";return d.set(n,m==="vertical"?"horizontal":"vertical"),d})},[]),Vo=u.useCallback(()=>{const n=Zn();if(!n)return;const l=new Set,d=m=>{l.add(m);for(const x of n.childrenMap.get(m)||[])n.elements.has(x)&&d(x)};for(const m of n.roots)n.elements.has(m)&&d(m);so(l)},[Zn]),Go=u.useCallback(()=>so(new Set),[]),Uo=u.useCallback(()=>{Te.current.clear(),Ut(n=>n+1)},[]),ui=u.useCallback(()=>{if(!a)return;const n=Z.getState().diagramLayouts[a]??{},{pan:l,zoom:d,...m}=n.canvas??{},x={nodes:{},edges:{},canvas:{...m,autoLayout:!0}};Ge.current=null,F({[a]:x}),He(a,x),Te.current.clear(),Ut(C=>C+1),window.setTimeout(()=>_e(300),250)},[a,F,_e]),os=u.useCallback(n=>n.map(l=>{if(l.type!=="diagramNode")return l;const d=t==null?void 0:t.elements[l.id];return{...l,data:{...l.data,onContextMenu:(m,x)=>{Et({x:m.clientX,y:m.clientY,nodeId:x,nodeKind:l.data.kind??""})},onInlineEdit:(m,x)=>{if(!d)return;const C={...d,name:x};Ss(C)}}}}),[t]),ns=u.useCallback((n,l)=>{const d=!sl(l),m=new Map(n.map(B=>[B.id,B])),x=n.map(B=>{const q=l.nodes[B.id];if(!q)return B;const Fe=B.parentId?m.get(B.parentId):void 0,Ae=d&&B.type==="contextSystem"&&(Fe==null?void 0:Fe.type)==="contextBoundary"?il(q,Fe.position):{x:q.x,y:q.y};return{...B,position:Ae,...q.width?{width:q.width}:{},...q.height?{height:q.height}:{},...q.width||q.height?{style:{...B.style,...q.width?{width:q.width}:{},...q.height?{height:q.height}:{}}}:{},data:{...B.data,bgColor:q.color||void 0,...q.opacity!==void 0?{fillOpacity:q.opacity}:{},...q.ports?{ports:(B.data.ports??[]).map(X=>{var te;return{...X,...((te=q.ports)==null?void 0:te[X.id])??{}}})}:{}}}}),C=new Map(x.map(B=>[B.id,B])),y=x.filter(B=>B.type==="actionFlowLane"),T=B=>(B.data.memberIds??[]).map(q=>C.get(q)).filter(Boolean),j=B=>B.position.x,J=B=>B.position.y,Y=B=>{var q;return B.position.x+Number(B.width??((q=B.style)==null?void 0:q.width)??180)},ee=B=>{var q;return B.position.y+Number(B.height??((q=B.style)==null?void 0:q.height)??96)},ae=y.flatMap(T),se=ae.length>0?{x:Math.min(...ae.map(j)),y:Math.min(...ae.map(J))}:void 0,Me=ae.length>0?{x:Math.max(...ae.map(Y)),y:Math.max(...ae.map(ee))}:void 0,$t=new Map;return x.map(B=>{if(B.type!=="actionFlowLane")return B;const q=B.data,Fe=T(B);if(Fe.length===0||!se||!Me)return B;const Ae=q.orientation==="column",X=Ae?Math.min(...Fe.map(j)):se.x,te=Ae?Math.max(...Fe.map(Y)):Me.x,mo=Ae?se.y:Math.min(...Fe.map(J)),wt=Ae?Me.y:Math.max(...Fe.map(ee)),pt={position:{x:Ae?X-36:X-120,y:Ae?mo-32:mo-36},width:te-X+(Ae?72:156),height:wt-mo+(Ae?68:72)};return $t.set(B.id,pt),{...B,position:pt.position,style:{...B.style,width:pt.width,height:pt.height}}}).map(B=>{if(B.type!=="actionFlowLaneLabel")return B;const q=$t.get(B.id.replace("__lane_label_","__lane_"));return q?{...B,position:q.position,style:{...B.style,width:q.width,height:q.height}}:B})},[]),ss=u.useCallback((n,l,d)=>{Oe.current=Date.now()+250,xe(),Se(C=>C+1);const m=pe.current.map(C=>{var Y,ee;if(!(((Y=C.data)==null?void 0:Y.sourcePortId)===l||((ee=C.data)==null?void 0:ee.targetPortId)===l))return C;const{points:T,manualRoute:j,...J}=C.data??{};return{...C,data:J}});pe.current=m;const x=oe.current.map(C=>C.id!==n?C:{...C,data:{...C.data,ports:(C.data.ports??[]).map(y=>y.id===l?{...y,y:d}:y)}});ne(x)},[ne,xe]),rs=u.useCallback((n,l)=>{Oe.current=Date.now()+250,xe(),Se(d=>d+1),G(d=>{const m=d.map(x=>x.id===n?{...x,data:{...x.data,points:l,manualRoute:!0}}:x);return pe.current=m,m})},[xe,G]),pi=u.useCallback(async n=>{const l=ge.current;if(l){he(!1),je(null),Re(n);try{await $d(l,n,f==null?void 0:f.name)}catch(d){je(d instanceof Error?d.message:String(d))}finally{Re(null)}}},[f==null?void 0:f.name]),hi=u.useCallback(()=>{xe(),Se(d=>d+1);const n=pe.current.map(d=>{var y;if(!((y=d.data)!=null&&y.manualRoute))return d;const{points:m,manualRoute:x,...C}=d.data;return{...d,data:C}}),l=nn(oe.current,n,"tidy");pe.current=l,G(l)},[xe,G]);u.useEffect(()=>{if(!t)return;const n=ve.current!==t&&vt.current===a;if(Ge.current=n?re():null,ve.current=t,vt.current=a,_==="grid"||_==="browser"||_==="geometry")return;let l=!1;const d=({nodes:T,edges:j},J=!0)=>{if(l)return;const Y=Wa(T,j),ee=new Map(Y.nodes.map(X=>[X.id,X])),ae=new Map(Y.edges.map(X=>[X.id,X])),se=T.map(X=>{const te=ee.get(X.id);return te?{...X,position:{x:te.x,y:te.y},style:{...X.style,width:te.width,height:te.height},parentId:te.parentId,...te.parentId?{extent:"parent"}:{}}:X}),Me=j.filter(X=>ae.has(X.id)).map(X=>{const te=ae.get(X.id);return{...X,source:te.sourceId,target:te.targetId,label:te.label??X.label}}),$t=se,ys=Me,B=a?Z.getState().diagramLayouts[a]:void 0,Fe=[...B&&Object.keys(B.nodes).length>0?ns($t,B):$t,...to(B)],Ae=ys.map(X=>{var pt,ws,Fs;const te=(pt=B==null?void 0:B.edges)==null?void 0:pt[X.id],wt=!(te!=null&&te.source)||te.source===X.source&&te.target===X.target&&te.sourcePortId===((ws=X.data)==null?void 0:ws.sourcePortId)&&te.targetPortId===((Fs=X.data)==null?void 0:Fs.targetPortId)?te==null?void 0:te.points:void 0;return{...X,data:{...X.data,...wt!=null&&wt.length?{points:wt,manualRoute:!0}:{},flowAnimation:et,onRouteChange:Xo=>rs(X.id,Xo),onSelect:Xo=>{Xo.stopPropagation(),!(Date.now()<Oe.current)&&(G(Yo=>Yo.map(ks=>({...ks,selected:ks.id===X.id}))),t.relationships.some(Yo=>Yo.id===X.id)&&S(X.id))}}}});N(J?os(Fe):Fe),G(nn(Fe,Ae)),Ke(!1),Or(X=>X+1)},m=T=>j=>{l||(console.error(`${T} layout error:`,j),Ke(!1),Fn(`${T} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},x=(T,j,J=!0)=>{Ke(!0),Fn(null),Ud(j,T).then(Y=>d(Y,J)).catch(m(T))},C=()=>{const T=ar.select({viewKind:_,diagramType:f==null?void 0:f.diagramType,isFBSDiagram:lt,isDecompDiagram:eo,isGeneralTemplate:gt,generalMode:ut,layoutStyle:zt}),j={onToggleExpand:Ho,onToggleDirection:ts},J={fbs:{expandedNodes:Lt,nodeDirections:ao,callbacks:j,layoutProviderId:dt},decomposition:{expandedNodes:Lt,nodeDirections:ao,callbacks:j,positionCache:Te.current},containment:{expandedNodes:Lt,callbacks:{onToggleExpand:Ho}},useCase:{viewpointFilter:void 0,systemName:f==null?void 0:f.name,...f?Jo(f.properties):{},level:To,edgeStyle:Do,hiddenActorIds:Mt},context:{systemName:f==null?void 0:f.name,viewpointFilter:me,relationshipTypes:f==null?void 0:f.relationshipTypes},interconnection:{viewpointFilter:me,relationshipTypes:f==null?void 0:f.relationshipTypes,collapsedNodes:Hn,onDrillIn:ho,onToggleCollapse:Jn,focusId:ro??void 0,portDisplay:Ne,connectionDisplay:tt,onPortMove:ss,layoutProviderId:dt},actionflow:{viewpointFilter:me,swimlanes:Xe,laneGrouping:Yt,displayLevel:Ct,expandedActionIds:Un,onToggleAction:Qn,onDrillInAction:po,focusActionId:xt??void 0,visibleFlowKinds:Je,direction:Ye,nesting:Dt,layoutProviderId:dt},statetransition:{viewpointFilter:me,collapsedStateIds:Xn,onToggleCollapse:es,onDrillIn:uo,focusStateId:io??void 0,layoutProviderId:dt},sequence:{viewpointFilter:me},general:{mode:ut,viewpointFilter:me,expandedNodes:Lt,nodeDirections:ao,callbacks:j,positionCache:Te.current,hierarchyRelationshipTypes:f==null?void 0:f.relationshipTypes,layoutProviderId:dt},standard:{viewpointFilter:me,relationshipTypes:f==null?void 0:f.relationshipTypes,compartments:gt,layoutProviderId:dt}},Y=T.compute(t,J);Y instanceof Promise?x(T.descriptor.label,Y,T.descriptor.interactive):d(Y,T.descriptor.interactive)},y=window.setTimeout(C,Gd);return()=>{l=!0,window.clearTimeout(y)}},[t,me,eo,lt,zt,_,gt,ut,Xe,Wr,f==null?void 0:f.relationshipTypes,f==null?void 0:f.diagramType,f==null?void 0:f.name,To,Do,Mt,dt,Lt,Hn,ro,Ne,tt,Un,xt,Je,Ye,Yt,Ct,Dt,ao,Xn,io,es,uo,po,Ho,Jn,Qn,ts,a,ho,ns,os,to,ss,rs,S,re]),u.useEffect(()=>{if(Gt===0)return;const n=setTimeout(()=>{var m;const l=Ge.current;if(Ge.current=null,l){Q(l);return}const d=a?(m=Z.getState().diagramLayouts[a])==null?void 0:m.canvas:void 0;_!=="actionflow"&&(d==null?void 0:d.zoom)!==void 0&&d.pan?Q({x:d.pan.x,y:d.pan.y,zoom:d.zoom},{duration:300}):_e(500)},200);return()=>clearTimeout(n)},[Gt,a,_e,Q,_]),u.useEffect(()=>{if(_!=="actionflow"||Gt===0)return;const n=requestAnimationFrame(()=>_e(180));return()=>cancelAnimationFrame(n)},[qe,Ze,Le,_e,Mo,Gt,Xt,_]),u.useEffect(()=>{N(n=>n.map(l=>{const d=l.type==="actionFlowLane"?l.data.inspectElementId:void 0,m=!!i&&(l.id===i||d===i);return{...l,selected:m,style:{...l.style,boxShadow:m?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:i?m?1:.5:1}}}))},[i,N]),u.useEffect(()=>{if(!It||!t)return;const n=Ha(t,It,"both",Jt),l=new Set(n.nodes.map(d=>d.elementId));l.add(It),N(d=>d.map(m=>({...m,style:{...m.style,opacity:l.has(m.id)?1:.08,pointerEvents:l.has(m.id)?"all":"none"}}))),G(d=>d.map(m=>({...m,style:{...m.style,opacity:l.has(m.source)&&l.has(m.target)?1:.05}})))},[It,Jt,t,N,G]),u.useEffect(()=>{if(!Qt)return;const n=setTimeout(()=>Rn(null),2500);return()=>clearTimeout(n)},[Qt]),u.useEffect(()=>{const n=l=>{const d=l.target;if(!(d.tagName==="INPUT"||d.tagName==="TEXTAREA")){if((l.metaKey||l.ctrlKey)&&l.key==="z"&&!l.shiftKey){l.preventDefault();const m=At.current.pop();m&&(m.undo(),Lo.current.push(m))}if((l.metaKey||l.ctrlKey)&&(l.key==="Z"||l.key==="z"&&l.shiftKey)){l.preventDefault();const m=Lo.current.pop();m&&(m.do(),At.current.push(m))}l.key==="g"&&(l.metaKey||l.ctrlKey)&&l.shiftKey&&(l.preventDefault(),kn(m=>!m)),l.key==="0"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),_e(400))}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[_e]);const mi=u.useCallback(n=>{n.preventDefault(),n.dataTransfer.dropEffect="copy"},[]),fi=u.useCallback(n=>{n.preventDefault();const l=n.dataTransfer.getData(Ar);if(l)try{const d=JSON.parse(l),m=O({x:n.clientX,y:n.clientY});jt({x:n.clientX,y:n.clientY,flowX:m.x,flowY:m.y,kind:d.kind,layer:d.layer,construct:d.construct})}catch{}},[O]),gi=u.useCallback(n=>{const l=O({x:n.clientX,y:n.clientY});jt({x:n.clientX,y:n.clientY,flowX:l.x,flowY:l.y})},[O]),xi=u.useCallback(n=>{if(!Ie||!a){jt(null);return}const l=Ie.kind??"Part",d=Ie.layer??"logical",m=Ie.construct??"part",x=ln[d]??"#6B7280",C=Va(n,Object.keys((t==null?void 0:t.elements)??{})),y={id:C,type:"diagramNode",position:{x:Ie.flowX,y:Ie.flowY},data:{label:n,kind:l,layer:d,construct:m,color:x,isNew:!0,onContextMenu:(Y,ee)=>{Et({x:Y.clientX,y:Y.clientY,nodeId:ee,nodeKind:l})},onInlineEdit:(Y,ee)=>{Ss({id:C,name:ee,kind:l,construct:m,layer:d})}}};N(Y=>[...Y,y]),ra({id:C,name:n,kind:l,construct:m,layer:d,attributes:{_layer:d}});const T=(f==null?void 0:f.elementIds)??[];P(a,[...T,C]);const j=a,J={nodes:{...(h[j]??{}).nodes??{},[C]:{x:Ie.flowX,y:Ie.flowY}},edges:(h[j]??{}).edges??{}};F({[j]:J}),He(j,J),jt(null)},[Ie,a,f,h,F,P,N]),bi=u.useCallback(()=>{Et(null),Zt(null)},[]),yi=u.useCallback((n,l)=>{l!=null&&l.isValid},[]),Ko=u.useCallback((n,l)=>{const d=La(l);return(d?t==null?void 0:t.elements[d]:void 0)??(t==null?void 0:t.elements[n])},[t]),wi=u.useCallback(n=>{const{source:l,target:d,sourceHandle:m,targetHandle:x}=n;if(!l||!d)return;const C=Ko(l,m),y=Ko(d,x);!C||!y||C.id!==y.id&&qt({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:C,targetElement:y})},[Ko]),Fi=u.useCallback(async n=>{if(!Qe||!a){qt(null);return}const l=Qe.sourceElement.id;qt(null);const d=await s({type:n.type,sourceId:n.sourceId,targetId:n.targetId,direction:n.direction,flowItem:n.flowItem,selectedElementId:l,diagramId:a});if(!d.success){console.warn(`[MEMO] Relationship rejected: ${d.error}`);return}if(!(oe.current.some(y=>y.id===n.sourceId)&&oe.current.some(y=>y.id===n.targetId)))return;const x=Cs[n.type]??"#6B7280",C={id:d.relationshipId??`e_${n.sourceId}_${n.targetId}_${n.type}`,source:n.sourceId,target:n.targetId,label:n.type,type:"default",style:{stroke:x,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:x}};G(y=>Xi(C,y))},[Qe,a,G,s]),ki=u.useCallback((n,l)=>{Ue.current={id:l.id,x:l.position.x,y:l.position.y}},[]),vi=u.useCallback((n,l)=>{const d=Ue.current;if(Ue.current=null,!((d==null?void 0:d.id)===l.id&&Math.hypot(l.position.x-d.x,l.position.y-d.y)>2)||(Oe.current=Date.now()+250,Se(j=>j+1),!a))return;const{x,y:C}=l.position;if(l.type==="annotationNode")return;xe();const y=pe.current.map(j=>{var ae;if(!((ae=j.data)!=null&&ae.manualRoute)||j.source!==l.id&&j.target!==l.id)return j;const{points:J,manualRoute:Y,...ee}=j.data;return{...j,data:ee}});pe.current=y,ne(oe.current);const T=Te.current.get(l.id);if(Te.current.set(l.id,{x,y:C}),w(a,l.id,{x,y:C}),T){const j=l.id,J=a;Mn({do:()=>w(J,j,{x,y:C}),undo:()=>{w(J,j,T),N(Y=>Y.map(ee=>ee.id===j?{...ee,position:T}:ee))}})}},[a,w,Mn,N,xe,ne]),Si=u.useCallback(n=>{const l=y=>{var T;return"id"in y&&((T=oe.current.find(j=>j.id===y.id))==null?void 0:T.type)==="annotationNode"};n.some(y=>y.type==="position"&&y.dragging&&!l(y))&&xe();const d=n.some(y=>y.type==="dimensions"&&y.resizing),m=n.some(y=>y.type==="dimensions"&&y.setAttributes);d&&n.some(y=>y.type==="dimensions"&&y.resizing&&!l(y))&&xe(),m&&Se(y=>y+1);const x=new Map(n.flatMap(y=>y.type==="dimensions"&&y.dimensions?[[y.id,y.dimensions]]:[])),C=Yi(n,oe.current).map(y=>{var ae,se;const T=x.get(y.id);if(!T)return y;const j=Number(y.width??((ae=y.style)==null?void 0:ae.width)??T.width),J=Number(y.height??((se=y.style)==null?void 0:se.height)??T.height),Y=y.data.ports,ee=Y==null?void 0:Y.map(Me=>({...Me,...Me.side==="right"?{x:Me.x+T.width-j}:{},...Me.side==="bottom"?{y:Me.y+T.height-J}:{}}));return{...y,style:{...y.style,width:T.width,height:T.height},...ee?{data:{...y.data,ports:ee}}:{}}});ne(C,!d||m)},[ne,xe]),Ci=u.useCallback((n,l)=>{},[]),ji=u.useCallback((n,l)=>{n.preventDefault(),Zt({x:n.clientX,y:n.clientY,edgeId:l.id,relType:String(l.label??"edge")})},[]),Ei=u.useCallback((n,l)=>{var x,C,y,T,j,J;if(Date.now()<Oe.current)return;if((n==null?void 0:n.shiftKey)||(n==null?void 0:n.metaKey)||(n==null?void 0:n.ctrlKey)||((x=n==null?void 0:n.nativeEvent)==null?void 0:x.shiftKey)||((C=n==null?void 0:n.nativeEvent)==null?void 0:C.metaKey)||((y=n==null?void 0:n.nativeEvent)==null?void 0:y.ctrlKey)||((T=n==null?void 0:n.getModifierState)==null?void 0:T.call(n,"Shift"))||((j=n==null?void 0:n.getModifierState)==null?void 0:j.call(n,"Meta"))||((J=n==null?void 0:n.getModifierState)==null?void 0:J.call(n,"Control"))){window.setTimeout(()=>N(Y=>Y.map(ee=>({...ee,selected:ee.selected||ee.id===i||ee.id===l.id}))),0);return}if(l.type==="annotationNode")return;const m=l.type==="actionFlowLane"?l.data.inspectElementId:void 0;!m&&(l.id.startsWith("__")||l.id.includes("__start")||l.id.includes("__done"))||(g(m??l.id),a&&R({type:"diagram",diagramId:a}))},[g,a,R,i,N]),Ii=u.useCallback((n,l)=>{var d;if((d=n==null?void 0:n.stopPropagation)==null||d.call(n),_==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(x=>x.parentAction===l.id))return;po(l.id);return}if(_==="statetransition"){const m=l.data;if(!m.hasChildren||m.isMachine){g(l.id);return}uo(l.id);return}if(_==="interconnection"){const m=l.data;if(!m.isContainer&&!m.hasChildren){g(l.id);return}ho(l.id)}},[_,t==null?void 0:t.elements,g,po,uo,ho]),Ai=u.useCallback(()=>{b(null),S(null),Et(null),Zt(null),N(n=>n.map(l=>({...l,style:{...l.style,opacity:1,boxShadow:void 0}}))),G(n=>n.map(l=>l.selected?{...l,selected:!1}:l))},[b,S,N,G]),Ri=u.useCallback((n,l)=>{var d;(d=n==null?void 0:n.stopPropagation)==null||d.call(n),!(Date.now()<Oe.current)&&(G(m=>m.map(x=>({...x,selected:x.id===l.id}))),t!=null&&t.relationships.some(m=>m.id===l.id)?S(l.id):t!=null&&t.elements[l.id]&&g(l.id))},[t,g,S,G]),Mi=u.useCallback((n,l)=>{_t({endpointIds:[l.id]})},[]),zi=u.useCallback((n,l)=>{_t({edgeId:l.id,endpointIds:rr(l)})},[]),is=u.useCallback(()=>_t(null),[]),Li=u.useCallback((n,l)=>{var d;a&&(w(a,n,{...((d=h[a])==null?void 0:d.nodes[n])??{x:0,y:0},color:l||void 0}),N(m=>m.map(x=>x.id===n?{...x,data:{...x.data,bgColor:l||void 0}}:x)))},[a,h,w,N]),De=u.useMemo(()=>v.filter(n=>n.selected&&n.type!=="actionFlowLane"&&!n.id.startsWith("__")),[v]),bt=u.useCallback(()=>De.map(n=>{var l,d,m,x;return{id:n.id,x:n.position.x,y:n.position.y,width:Number(n.width??((l=n.measured)==null?void 0:l.width)??((d=n.style)==null?void 0:d.width)??180),height:Number(n.height??((m=n.measured)==null?void 0:m.height)??((x=n.style)==null?void 0:x.height)??96)}}),[De]),yt=u.useCallback(n=>{n.size!==0&&(xe(),N(l=>l.map(d=>{const m=n.get(d.id);return m?{...d,position:{x:m.x??d.position.x,y:m.y??d.position.y},...m.width!==void 0?{width:m.width}:{},...m.height!==void 0?{height:m.height}:{},...m.width!==void 0||m.height!==void 0?{style:{...d.style,...m.width!==void 0?{width:m.width}:{},...m.height!==void 0?{height:m.height}:{}}}:{}}:d})),Se(l=>l+1))},[xe,N]),Ni=u.useCallback(n=>{yt(Ya(bt(),n))},[yt,bt]),Ti=u.useCallback(n=>{yt(qa(bt(),n))},[yt,bt]),Di=u.useCallback(n=>{yt(Za(bt(),n))},[yt,bt]),as=u.useCallback(n=>{if(!a||De.length===0)return;xe();const l=Z.getState().diagramLayouts[a];for(const m of De){const x=(l==null?void 0:l.nodes[m.id])??{x:m.position.x,y:m.position.y};w(a,m.id,{...x,...n.color!==void 0?{color:n.color||void 0}:{},...n.opacity!==void 0?{opacity:n.opacity}:{}})}const d=new Set(De.map(m=>m.id));N(m=>m.map(x=>d.has(x.id)?{...x,data:{...x.data,...n.color!==void 0?{bgColor:n.color||void 0}:{},...n.opacity!==void 0?{fillOpacity:n.opacity}:{}}}:x)),Se(m=>m+1)},[a,De,xe,w,N]),Bi=u.useMemo(()=>{const n=De.map(l=>Number(l.data.fillOpacity??1));return n.length===0?1:n.every(l=>l===n[0])?n[0]:1},[De]),ls=u.useCallback(n=>{if(!a||!f)return;const l=(f.elementIds??[]).filter(d=>d!==n);P(a,l),N(d=>d.filter(m=>m.id!==n))},[a,f,P,N]),$i=u.useCallback((n,l)=>{const d=l==="dashed"?"6 3":l==="dotted"?"2 3":void 0;G(m=>m.map(x=>x.id===n?{...x,style:{...x.style,strokeDasharray:d}}:x))},[G]),Pi=u.useCallback((n,l)=>{G(d=>d.map(m=>m.id===n?{...m,style:{...m.style,stroke:l||(Cs[String(m.label??"")]??"#6B7280")}}:m))},[G]),Oi=u.useCallback(n=>{G(l=>l.map(d=>d.id===n?{...d,label:d.label?"":n.split("_")[3]??""}:d))},[G]);return f&&t&&_==="grid"?o.jsx(Na,{diagram:f,model:t,viewpointFilter:me}):f&&t&&_==="browser"?o.jsx(Ta,{diagram:f,model:t,viewpointFilter:me}):f&&t&&_==="geometry"?o.jsx(_a,{diagram:f,model:t,viewpointFilter:me}):!f&&v.length===0&&!Ee?o.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!St&&o.jsx(tn,{collapsed:St,onToggleCollapse:()=>Kt(!0)}),St&&o.jsx(tn,{collapsed:!0,onToggleCollapse:()=>Kt(!1)}),o.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:o.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[o.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"📊"}),o.jsx("h3",{style:{fontSize:W.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),o.jsx("p",{style:{fontSize:W.md,color:"#9CA3AF",lineHeight:1.6},children:"Choose a diagram from the sidebar or drag elements from the palette."})]})})]}):o.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[o.jsx(tn,{collapsed:St,onToggleCollapse:()=>Kt(!St),elementIds:f==null?void 0:f.elementIds,eligibleKinds:(gs=f==null?void 0:f.elementKinds)!=null&&gs.length?new Set(f.elementKinds):f!=null&&f.viewpointId&&(t!=null&&t.viewpoints)?new Set(((xs=t.viewpoints.find(n=>n.id===f.viewpointId))==null?void 0:xs.visibleKinds)??[]):void 0}),o.jsxs("div",{className:"flex-1 flex min-w-0",children:[!Xt&&o.jsxs("aside",{"aria-label":"Diagram tools",className:"flex shrink-0 flex-col border-r",style:{width:126,background:"#FAFAF8",borderColor:"#E5E5E0"},children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{background:"#F0F0ED",borderBottom:"1px solid #E5E5E0"},children:[o.jsx("span",{style:{fontSize:W.xs,fontWeight:600,color:"#374151"},children:"Toolbar"}),o.jsx("button",{type:"button",onClick:()=>Ro(!0),title:"Hide Toolbar","aria-label":"Hide Toolbar",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:5,cursor:"pointer",color:"#6B7280",fontSize:20,lineHeight:1},children:"×"})]}),f&&!Mo&&(Xt?o.jsx("button",{type:"button",className:"m-3 flex items-center justify-center rounded-lg",onClick:()=>Ro(!1),title:"Show diagram tools","aria-label":"Show diagram tools",style:{width:36,height:36,background:"#FFFFFF",color:"#1B3A4B",border:"1px solid #D8E0E4",boxShadow:"0 1px 4px rgba(0,0,0,0.10)"},children:o.jsx(H.lanes,{})}):o.jsxs("div",{className:"memo-diagram-tools memo-diagram-tools--left m-3 grid content-start items-stretch justify-items-stretch rounded-lg text-xs",style:{width:94,padding:6,gap:6,overflow:"visible",gridTemplateColumns:"repeat(2, 38px)",gridAutoRows:"38px",gridAutoFlow:"row dense",background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[de("grid")&&o.jsx(fe,{icon:zo?o.jsx(H.grid,{}):o.jsx(H.gridOff,{}),active:zo,onClick:()=>{Vr(n=>{const l=!n;return kn(l),l})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),de("route")&&o.jsx(fe,{icon:o.jsx(H.tidy,{}),active:!1,onClick:hi,title:"Re-route connectors around blocks and into separate lanes. Replaces any bends you drew by hand."}),a&&de("autoLayout")&&o.jsx(fe,{icon:o.jsx(H.arrange,{}),active:Rt,onClick:()=>{if(Rt)xe();else{const n=Z.getState().diagramLayouts[a],l={nodes:{},edges:{},canvas:{...n==null?void 0:n.canvas,autoLayout:!0}};F({[a]:l}),He(a,l),Ut(d=>d+1)}},title:Rt?"Auto layout is on. Drag an item to preserve a manual layout.":"Auto layout is off. Click to recalculate the diagram."}),de("export")&&o.jsxs("div",{style:{position:"relative"},children:[o.jsx(fe,{icon:o.jsx(H.download,{}),active:le,onClick:()=>{je(null),he(n=>!n)},title:"Download this diagram as an image"}),le&&o.jsx("div",{role:"menu","aria-label":"Export diagram",className:"absolute z-20 rounded-lg overflow-hidden",style:{top:"calc(100% + 6px)",left:0,minWidth:128,background:"#FFFFFF",border:"1px solid #E2E1DB",boxShadow:"0 4px 14px rgba(0,0,0,0.12)"},children:["png","svg","pdf"].map(n=>o.jsx("button",{role:"menuitem",onClick:()=>{pi(n)},disabled:ye!==null,className:"w-full text-left px-3 py-1.5 text-xs font-medium",style:{background:"#FFFFFF",color:"#374151",border:0,cursor:ye?"default":"pointer"},children:n.toUpperCase()},n))}),L&&o.jsxs("div",{role:"alert",className:"absolute z-20 rounded-lg px-3 py-1.5 text-xs",style:{top:"calc(100% + 6px)",left:0,minWidth:200,background:"#FEF2F2",color:"#B91C1C",border:"1px solid #FECACA"},children:["Export failed: ",L]})]}),lt&&de("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx(Pe,{hidden:Le==="left"}),o.jsx(Be,{icon:o.jsx(H.expand,{}),onClick:Vo,title:"Expand all nodes",ariaLabel:"Expand all"}),o.jsx(Be,{icon:o.jsx(H.collapse,{}),onClick:Go,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),_==="actionflow"&&de("flowSwimlanes")&&o.jsxs(o.Fragment,{children:[o.jsx(fe,{icon:Xe?o.jsx(H.lanes,{}):o.jsx(H.lanesOff,{}),active:Xe,onClick:()=>vn(n=>!n),title:"Toggle allocation swimlanes"}),de("flowSwimlanes")&&Xe&&ti&&o.jsx(fe,{icon:o.jsx(H.lanes,{}),label:void 0,active:Yt==="stage",onClick:()=>Sn(n=>n==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),de("flowHierarchy")&&Xe&&Yt==="allocation"&&_n.length>0&&o.jsxs("div",{style:{position:"relative"},children:[o.jsx(fe,{icon:o.jsx(H.library,{}),active:jn,onClick:()=>En(n=>!n),title:`Responsibility hierarchy level: ${Ct==="all"?"all levels":`level ${Ct}`}`}),jn&&o.jsx("div",{className:"absolute z-30 rounded-lg p-1",style:{top:"calc(100% + 5px)",left:0,width:112,background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 4px 14px rgba(0,0,0,0.12)"},children:["all",..._n].map(n=>{const l=Ct===n;return o.jsx("button",{type:"button",className:"w-full rounded px-2 py-1 text-left text-xs font-semibold",style:{background:l?"#E8FBF5":"transparent",color:l?"#0F766E":"#475569"},onClick:()=>{Cn(n),En(!1)},children:n==="all"?"All levels":`Level ${n}`},String(n))})})]}),o.jsx(Pe,{hidden:Le==="left"}),de("flowNesting")&&o.jsx(fe,{icon:Dt==="flat"?o.jsx(H.split,{}):o.jsx(H.rectangle,{}),active:Dt==="nested",onClick:()=>Kn(n=>n==="flat"?"nested":"flat"),title:Dt==="flat"?"Steps: inline. Click to show nested steps.":"Steps: nested. Click to show inline steps."}),o.jsx(Pe,{hidden:Le==="left"}),de("flowDirection")&&o.jsx(fe,{icon:Ye==="horizontal"?o.jsx(H.arrowRight,{}):o.jsx(H.arrowDown,{}),active:Ye==="vertical",onClick:()=>Jr(Ye==="horizontal"?"vertical":"horizontal"),title:Ye==="horizontal"?"Flow direction: left to right. Click for top to bottom.":"Flow direction: top to bottom. Click for left to right."}),o.jsx(Pe,{hidden:Le==="left"}),de("flowLegend")&&o.jsx(fe,{icon:o.jsx(H.lanes,{}),active:qe,onClick:()=>Ur(n=>!n),title:qe?"Hide flow legend":"Show flow legend"}),de("flowLegend")&&qe&&o.jsx(fe,{icon:Ze==="overlay"?o.jsx(H.overlay,{}):o.jsx(H.arrowUp,{}),active:Ze==="above",onClick:()=>Kr(n=>n==="overlay"?"above":"overlay"),title:Ze==="overlay"?"Legend over diagram. Click to place it above.":"Legend above diagram. Click to overlay it."}),o.jsx(Pe,{hidden:Le==="left"}),o.jsx(fe,{icon:o.jsx(H.expand,{}),title:"Expand all sub-actions",onClick:()=>Tt(new Set(Object.values((t==null?void 0:t.elements)??{}).map(n=>n.parentAction).filter(n=>!!n)))}),o.jsx(fe,{icon:o.jsx(H.collapse,{}),title:"Collapse all sub-actions",onClick:()=>Tt(new Set)}),o.jsx(Pe,{hidden:Le==="left"}),de("flowFilters")&&o.jsxs("div",{style:{position:"relative"},children:[o.jsx(fe,{icon:o.jsx(H.filter,{}),active:In,badge:`${Je.size}/4`,fullWidth:!1,onClick:()=>Xr(n=>!n),title:"Choose which modeled connection categories are visible"}),In&&o.jsxs("div",{className:"absolute p-3 rounded-lg",style:{width:264,top:0,left:"calc(100% + 8px)",background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:30},children:[o.jsx("div",{style:{color:"#1F2937",fontWeight:700,fontSize:W.xs},children:"Show connection categories"}),o.jsx("div",{style:{color:"#6B7280",fontSize:W.xs,lineHeight:1.4,marginTop:3,marginBottom:8},children:"Changes this diagram view only; the SysML model is not modified."}),["control","data","energy","material"].map(n=>{const l=Je.has(n),d=n==="control"?"#4B5563":n==="data"?"#3498DB":n==="energy"?"#D97706":"#16A34A";return o.jsxs("button",{role:"switch","aria-checked":l,onClick:()=>Yr(m=>{const x=new Set(m);return x.has(n)?x.delete(n):x.add(n),x}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${l?"Hide":"Show"} ${n} connections`,children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:d}}),n]}),o.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:l?"#2563EB":"#D1D5DB",padding:2,transition:"background 160ms ease"},children:o.jsx("span",{style:{display:"block",width:14,height:14,borderRadius:"50%",background:"#FFFFFF",boxShadow:"0 1px 2px rgba(0,0,0,0.22)",transform:l?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},n)})]})]}),o.jsx(rn,{path:ii,nameOf:n=>{var l;return((l=t==null?void 0:t.elements[n])==null?void 0:l.name)??n},onFocus:Wo,rootLabel:"Back to the whole action flow"})]}),_==="interconnection"&&de("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx(Pe,{hidden:Le==="left"}),o.jsx(Be,{icon:o.jsx(H.expand,{}),onClick:()=>Nt(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),o.jsx(Be,{icon:o.jsx(H.collapse,{}),onClick:()=>Nt(new Set(ai)),title:"Collapse all parts",ariaLabel:"Collapse all"}),de("interconnectionPorts")&&de("interconnectionConnections")&&Le==="left"?o.jsxs(o.Fragment,{children:[o.jsx(fe,{icon:Ne==="all"?o.jsx(H.library,{}):Ne==="ports"?o.jsx(H.rectangle,{}):o.jsx(H.minus,{}),active:Ne!=="none",onClick:()=>Po(n=>n==="all"?"ports":n==="ports"?"none":"all"),title:Ne==="all"?"Ports: nested. Click for top-level ports.":Ne==="ports"?"Ports: top-level only. Click to hide ports.":"Ports: hidden. Click to show nested ports."}),o.jsx(fe,{icon:tt==="summary"?o.jsx(H.tidy,{}):tt==="all"?o.jsx(H.lanes,{}):o.jsx(H.minus,{}),active:tt!=="none",onClick:()=>Oo(n=>n==="summary"?"all":n==="all"?"none":"summary"),title:tt==="summary"?"Connections: summary. Click to show all.":tt==="all"?"Connections: all. Click to hide them.":"Connections: hidden. Click for summary."})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#9CA3AF",fontSize:W.xs,fontWeight:600},children:"Ports"}),o.jsx(Is,{value:Ne,onChange:Po,options:[{value:"all",label:"Nested",title:"Show ports and their nested ports"},{value:"ports",label:"Top",title:"Show top-level ports only (nested connectors lift to the parent port)"},{value:"none",label:"Off",title:"Hide ports; connectors run part to part"}]}),o.jsx("span",{style:{color:"#9CA3AF",fontSize:W.xs,fontWeight:600},children:"Connections"}),o.jsx(Is,{value:tt,onChange:Oo,options:[{value:"summary",label:"Summary",title:"Show focused-subsystem boundary flows and bundle repeated rendered endpoint pairs"},{value:"all",label:"All",title:"Show every model connector"},{value:"none",label:"Off",title:"Hide connectors while inspecting block structure"}]})]}),o.jsx(rn,{path:si,nameOf:n=>{var l;return((l=t==null?void 0:t.elements[n])==null?void 0:l.name)??n},onFocus:$o,rootLabel:"Back to the whole diagram"})]}),_==="statetransition"&&de("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx(Pe,{}),o.jsx(Be,{icon:o.jsx(H.expand,{}),onClick:()=>Bt(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),o.jsx(Be,{icon:o.jsx(H.collapse,{}),onClick:()=>Bt(new Set(lo)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),o.jsx(rn,{path:ri,nameOf:n=>{var l;return((l=t==null?void 0:t.elements[n])==null?void 0:l.name)??n},onFocus:_o,rootLabel:"Back to the whole machine"})]}),Dn&&de("useCaseOptions")&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Level",o.jsxs("select",{"aria-label":"Use case hierarchy level",value:To,onChange:n=>$n(n.target.value==="all"?"all":Number(n.target.value)),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[o.jsx("option",{value:"all",children:"All levels"}),Array.from({length:Qr+1},(n,l)=>o.jsxs("option",{value:l,children:["L",l]},l))]})]}),o.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Routing",o.jsxs("select",{"aria-label":"Use case connector routing",value:Do,onChange:n=>Pn(n.target.value),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[o.jsx("option",{value:"straight",children:"Straight"}),o.jsx("option",{value:"elbow",children:"Elbow"}),o.jsx("option",{value:"rounded",children:"Rounded"}),o.jsx("option",{value:"curved",children:"Curved"}),o.jsx("option",{value:"arc",children:"Arc"})]})]}),o.jsx("button",{onClick:ui,className:"px-2 py-0.5 text-xs font-semibold rounded",style:{color:"#047857",background:"#ECFDF5",border:"1px solid #A7F3D0"},title:"Reapply the constrained hierarchy layout and obstacle-aware routes",children:"Auto arrange"}),Wn.length>0&&o.jsxs("details",{className:"relative",children:[o.jsxs("summary",{className:"px-2 py-0.5 text-xs font-semibold rounded cursor-pointer",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:["Actors",Mt.size?`: ${Mt.size} hidden`:""]}),o.jsxs("div",{className:"absolute top-7 left-0 z-30 min-w-48 p-2 rounded shadow-lg",style:{background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[o.jsx("div",{className:"mb-1 text-xs",style:{color:"#64748B"},children:"Hide related use cases"}),Wn.map(n=>o.jsxs("label",{className:"flex items-center gap-2 py-1 text-xs",style:{color:"#374151"},children:[o.jsx("input",{type:"checkbox",checked:Mt.has(n.id),onChange:()=>On(l=>{const d=new Set(l);return d.has(n.id)?d.delete(n.id):d.add(n.id),d})}),n.name]},n.id))]})]})]}),gt&&!Dn&&de("generalMode")&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:ei.map(n=>o.jsx("button",{onClick:()=>{Bn(n),Te.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:ut===n?"#1B3A4B":"#FFFFFF",color:ut===n?"#FFFFFF":"#6B7280"},title:n==="graph"?"Relationship graph with compartments":n==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:n==="graph"?o.jsx(H.tidy,{}):n==="tree"?o.jsx(H.library,{}):o.jsx(H.rectangle,{})},n))}),ut!=="graph"&&o.jsxs(o.Fragment,{children:[o.jsx(Be,{icon:o.jsx(H.expand,{}),onClick:Vo,title:"Expand all nodes",ariaLabel:"Expand all"}),o.jsx(Be,{icon:o.jsx(H.collapse,{}),onClick:Go,title:"Collapse all nodes",ariaLabel:"Collapse all"}),ut==="tree"&&o.jsx("button",{onClick:Uo,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]})]}),eo&&!lt&&de("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["containment","decomposition"].map(n=>o.jsx("button",{onClick:()=>{oi(n),Te.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:zt===n?"#1B3A4B":"#FFFFFF",color:zt===n?"#FFFFFF":"#6B7280"},children:n==="containment"?o.jsx(H.rectangle,{}):o.jsx(H.library,{})},n))}),o.jsx(Pe,{}),o.jsx(Be,{icon:o.jsx(H.expand,{}),onClick:Vo,title:"Expand all nodes",ariaLabel:"Expand all"}),o.jsx(Be,{icon:o.jsx(H.collapse,{}),onClick:Go,title:"Collapse all nodes",ariaLabel:"Collapse all"}),zt==="decomposition"&&o.jsx("button",{onClick:Uo,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]}),a&&o.jsxs(o.Fragment,{children:[_!=="actionflow"&&o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsx("div",{id:"memo-diagram-editor-controls","data-compact-diagram-tools":"true",style:{display:"contents"}})]}),a&&_==="interconnection"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #CBD5E1"},children:["note","text","constraint"].map(n=>o.jsxs("button",{onClick:()=>Zr(n),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:"#FFFFFF",color:"#475569",border:0},title:`Add an editable ${n} annotation to this IBD`,children:["+ ",n]},n))}),o.jsxs("button",{"aria-pressed":et,onClick:()=>{const n=Z.getState().diagramLayouts[a]??{nodes:{},edges:{}},l={...n,canvas:{...n.canvas,flowAnimation:!et}};F({[a]:l}),He(a,l),G(d=>d.map(m=>({...m,data:{...m.data,flowAnimation:!et}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:et?"#EFF6FF":"#F8FAFC",color:et?"#1D4ED8":"#64748B",border:`1px solid ${et?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",et?"On":"Off"]}),o.jsx("button",{"aria-pressed":Vn,onClick:()=>Gn(n=>!n),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F8FAFC",color:"#475569",border:"1px solid #CBD5E1"},title:"Show or hide the IBD notation legend",children:"Legend"})]})]}))]}),o.jsxs("div",{ref:ge,className:"flex-1 relative min-h-0",onDragOver:mi,onDrop:fi,onDoubleClick:gi,children:[It&&o.jsxs("div",{className:"absolute top-3 right-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs",style:{background:"#1B3A4B",color:"#FFFFFF",boxShadow:"0 2px 8px rgba(0,0,0,0.18)"},children:[o.jsx("span",{style:{color:"#2DD4A8",fontWeight:700},children:"◎ Focus"}),o.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Depth"}),[1,2,3].map(n=>o.jsx("button",{onClick:()=>qr(n),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:Jt===n?"#2DD4A8":"rgba(255,255,255,0.15)",color:Jt===n?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:n},n)),o.jsx("button",{onClick:()=>{An(null),N(n=>n.map(l=>({...l,style:{...l.style,opacity:1,pointerEvents:"all"}}))),G(n=>n.map(l=>({...l,style:{...l.style,opacity:1}})))},style:{marginLeft:4,padding:"2px 8px",borderRadius:4,cursor:"pointer",background:"rgba(255,255,255,0.15)",color:"#FFFFFF",fontSize:"11px",border:"none"},children:"Exit Focus"})]}),Qt&&o.jsxs("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-xs font-mono",style:{background:"#1B3A4B",color:"#2DD4A8",boxShadow:"0 4px 16px rgba(0,0,0,0.2)",whiteSpace:"nowrap"},children:["Copied: ",Qt]}),Ee&&o.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-10 px-4 py-1.5 rounded-full text-xs font-medium",style:{background:"#FFFFFF",color:"#6B7280",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:"Computing layout…"}),at&&!Ee&&o.jsxs("div",{role:"alert",className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 flex items-center gap-3 px-3 py-2",style:{maxWidth:620,background:"#FFFDF7",color:"#5F4300",border:"1px solid #E7C35A",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:W.xs},children:[o.jsx("span",{children:at}),o.jsx("button",{onClick:Uo,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),no.length>0&&!Ee&&o.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:W.xs},children:[o.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",no.length," floating ",no.length===1?"action has":"actions have"," no flow or succession connection:"," ",no.map((n,l)=>o.jsxs("span",{children:[l>0&&", ",o.jsx("button",{onClick:()=>g(n.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:n.name})]},n.id))]}),co&&!Ee&&o.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:W.xs},children:[o.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",co.rootIds.length," roots",co.disconnectedIds.length>0&&o.jsxs(o.Fragment,{children:[" and ",co.disconnectedIds.length," disconnected/floating elements"]}),"."]}),_==="actionflow"&&qe&&o.jsxs("div",{"aria-label":"Action flow legend",className:"absolute z-10 flex flex-col gap-2 px-3 py-2.5",style:{top:Ze==="above"?8:12,right:12,minWidth:154,background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:12,color:"#374151",fontSize:W.xs,boxShadow:"0 2px 8px rgba(31,41,55,0.10)"},children:[o.jsx("div",{className:"flex items-center gap-4",children:o.jsx("span",{style:{fontWeight:700},children:"Flow legend"})}),Je.has("control")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2px solid #4B5563"}}),"Control flow"]}),Je.has("data")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #3498DB"}}),"Object flow"]}),Je.has("energy")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #D97706"}}),"Energy flow"]}),Je.has("material")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #16A34A"}}),"Material flow"]})]}),_==="interconnection"&&v.length>0&&Vn&&o.jsxs("div",{"aria-label":"Interconnection legend",className:"absolute right-3 bottom-3 z-10 flex flex-col gap-1.5 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:4,color:"#374151",fontSize:W.xs},children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{style:{fontWeight:700},children:"Ports"}),Ne!=="none"?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(sn,{color:vo.in,glyph:"→"})," in"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(sn,{color:vo.out,glyph:"→"})," out"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(sn,{color:vo.inout,glyph:"⇄"})," inout"]}),Ne==="all"&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:"#6B728022",border:"1.5px solid #6B7280"}}),"nested"]})]}):o.jsx("span",{style:{color:"#9CA3AF"},children:"hidden"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{style:{fontWeight:700},children:"Flow"}),["data","energy","material"].map(n=>o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${Da[n]}`}}),n]},n))]})]}),!Ee&&v.length===0&&f&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:f.auto&&((bs=f.elementIds)==null?void 0:bs.length)===0?o.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🔍"}),o.jsx("div",{style:{fontSize:W.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),o.jsx("div",{style:{fontSize:W.xs,color:"#6B7280",lineHeight:1.6},children:"The view is auto-populated from its selectionQuery in the model. Add includeElementKinds / includeLayers to its SysML definition, or link elements to it with IncludedIn relationships."})]}):o.jsxs("div",{className:"text-center",style:{opacity:.4},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🖱️"}),o.jsx("div",{style:{fontSize:W.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),De.length>=2&&o.jsx(Ka,{count:De.length,opacity:Bi,onAlign:Ni,onMatchSize:Ti,onDistribute:Di,onFill:n=>as({color:n}),onOpacity:n=>as({opacity:n})}),Ee&&o.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${js.accent} 0%, ${js.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),o.jsxs(qi,{nodes:v,edges:$,nodeTypes:li,edgeTypes:ci,onNodesChange:Si,onEdgesChange:be,onNodeClick:Ei,onNodeDoubleClick:Ii,onEdgeClick:Ri,onPaneClick:Ai,onNodeDragStart:ki,onNodeDragStop:vi,onNodeContextMenu:Ci,onEdgeContextMenu:ji,onNodeMouseEnter:Mi,onNodeMouseLeave:is,onEdgeMouseEnter:zi,onEdgeMouseLeave:is,onConnect:wi,onConnectStart:bi,onConnectEnd:yi,connectionMode:Zi.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:Hr,snapGrid:Hd,fitView:_!=="actionflow",fitViewOptions:{...Od,minZoom:oo},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!0,panOnDrag:[1,2],multiSelectionKeyCode:["Shift","Meta","Control"],selectionKeyCode:null,proOptions:_d,style:_==="actionflow"?{...Qs,position:"absolute",left:0,top:qe&&Ze==="above"?112:0,right:0,bottom:0,width:"auto",height:"auto"}:Qs,children:[zo&&o.jsx(Ji,{color:"#C5C7C2",gap:20,size:1.5}),o.jsx(tl,{}),o.jsxs(Qi,{position:"bottom-right",showFitView:!1,style:{marginBottom:82},children:[o.jsx(vs,{title:"Fit diagram to view","aria-label":"Fit diagram to view",onClick:()=>_e(250),children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M8 3H3v5M16 3h5v5M21 16v5h-5M3 16v5h5"}),o.jsx("path",{d:"M3 8l5-5M21 8l-5-5M21 16l-5 5M3 16l5 5"})]})}),o.jsx(vs,{title:"Toggle fullscreen canvas","aria-label":"Toggle fullscreen canvas",onClick:n=>{var d;const l=n.currentTarget.closest(".react-flow");l&&(document.fullscreenElement?document.exitFullscreen():(d=l.requestFullscreen)==null||d.call(l))},children:"⛶"})]}),v.length>20&&o.jsx(ea,{style:Wd,nodeColor:di,maskColor:"rgba(247, 247, 245, 0.7)"})]})]})]}),Ie&&o.jsx(Xd,{x:Ie.x,y:Ie.y,onConfirm:xi,onCancel:()=>jt(null)}),Qe&&o.jsx(Ba,{x:Qe.x,y:Qe.y,sourceElement:Qe.sourceElement,targetElement:Qe.targetElement,registries:r,allowedTypes:f==null?void 0:f.relationshipTypes,onSelect:Fi,onCancel:()=>qt(null)}),we&&o.jsx(Lc,{x:we.x,y:we.y,nodeId:we.nodeId,nodeKind:we.nodeKind,onClose:()=>Et(null),onEditName:()=>{N(n=>n.map(l=>l.id===we.nodeId?{...l,data:{...l.data,_triggerEdit:!0}}:l))},onChangeColor:n=>Li(we.nodeId,n),onRemoveFromDiagram:()=>ls(we.nodeId),onDeleteFromModel:()=>{ls(we.nodeId)},onShowProperties:()=>{b(we.nodeId)},onShowInCatalog:()=>{b(we.nodeId),k("catalog")},onFocusElement:()=>{An(we.nodeId)},onShowRelMatrix:()=>{R({type:"traceability"})},onOpenSource:()=>{const n=t==null?void 0:t.elements[we.nodeId];n!=null&&n.file&&(navigator.clipboard.writeText(n.file).catch(()=>{}),Rn(n.file))},onViewKindInOntology:()=>{const n=we.nodeKind;let l=null,d=null;for(const m of z){for(const x of m.layers)if(x.kinds.some(C=>C.name===n)){l=m.name,d=x.id;break}if(l)break}l&&(D(n),M("ontologies"),k("ontology"),R({type:"ontology-detail",packageName:l,layerId:d??void 0}))}}),We&&o.jsx(Tc,{x:We.x,y:We.y,edgeId:We.edgeId,relType:We.relType,onClose:()=>Zt(null),onChangeStyle:n=>$i(We.edgeId,n),onChangeColor:n=>Pi(We.edgeId,n),onToggleLabel:()=>Oi(We.edgeId),onDelete:()=>G(n=>n.filter(l=>l.id!==We.edgeId))})]})}function iu(){return o.jsx(Hi,{children:o.jsx(Yd,{})})}export{iu as DiagramCanvas};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-CqGqDbgT.js","assets/reactflow-s7jmJtXx.js","assets/zustand-CrhqMOHB.js","assets/index-Bij8Q4Kg.js","assets/index-BWMNo4wW.css","assets/notation-scene-DT8LpWVK.js","assets/layout-providers-Dr743WlP.js","assets/elk-6l8mIQnQ.js","assets/ExplorerTreeRow-DqhF_qoO.js","assets/DiagramToolbarControls-B2gZFJlg.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-bo8oPBct.js","assets/SysmlCodeEditor-BBfup_Ni.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Fe=Object.defineProperty;var Se=(t,r,l)=>r in t?Fe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[r]=l;var U=(t,r,l)=>Se(t,typeof r!="symbol"?r+"":r,l);import{_ as G,u as _,g as Ee,a as je,l as we,s as Ce,b as Re,c as ke,F as u,C as n,d as De,e as Ae,L as _e,f as Te,h as Le}from"./index-Bij8Q4Kg.js";import{j as e,a as Me}from"./reactflow-s7jmJtXx.js";import{a as s}from"./zustand-CrhqMOHB.js";import{I as y}from"./DiagramToolbarControls-B2gZFJlg.js";const Y="memo.renderer.reactflow";class Ne{constructor(){U(this,"providers",new Map);U(this,"components",new Map)}register(r){const l=this.providers.get(r.descriptor.id);if(l&&l!==r)throw new Error(`Renderer provider already registered: ${r.descriptor.id}`);this.providers.set(r.descriptor.id,r)}unregister(r){return this.components.delete(r),this.providers.delete(r)}get(r){return this.providers.get(r)}has(r){return this.providers.has(r)}list(r=[]){return[...this.providers.values()].map(l=>l.descriptor).filter(l=>r.every(i=>l.capabilities.includes(i))).sort((l,i)=>l.name.localeCompare(i.name))}loadComponent(r){const l=this.providers.get(r)??this.providers.get(Y);if(!l)throw new Error(`Renderer provider not found: ${r} (no default registered)`);const i=l.descriptor.id;let a=this.components.get(i);return a||(a=l.loadComponent(),this.components.set(i,a)),a}}const $e={descriptor:{id:"memo.renderer.reactflow",name:"ReactFlow",engine:"ReactFlow (@xyflow/react 12)",version:"12",contractVersion:"1",license:"MIT",description:"Default authoring canvas — React node components, palette, full editing.",capabilities:["interactive-editing","all-view-kinds","manual-layout","undo-redo","minimap","orthogonal-routes"]},loadComponent:()=>G(()=>import("./DiagramCanvas-CqGqDbgT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(t=>t.DiagramCanvas)},ze={descriptor:{id:"memo.renderer.maxgraph",name:"maxGraph",engine:"maxGraph (@maxgraph/core — draw.io rendering engine lineage)",version:"0.x",contractVersion:"1",license:"Apache-2.0",description:"draw.io-style retained-mode canvas — SVG cells, rubberband selection, image export.",capabilities:["all-view-kinds","manual-layout","export-image"]},loadComponent:()=>G(()=>import("./MaxGraphCanvas-bo8oPBct.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>t.MaxGraphCanvas)},B=new Ne;B.register($e);B.register(ze);const Ie={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Be="memo.diagram.renderer.v3",Oe="renderer",Pe="memo.renderer.",ae=new Set;function q(t){const r=t==null?void 0:t.trim();if(r)return r.includes(".")?r:`${Pe}${r}`}function Ve(){if(!(typeof window>"u"))try{return q(new URLSearchParams(window.location.search).get(Oe))}catch{return}}function Ue(){if(!(typeof window>"u"))try{return q(window.localStorage.getItem(Be))}catch{return}}function Ge(){try{const t=Ie;return q(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function ce(){return Ve()??Ue()??Ge()??Y}function Ye(t){return ae.add(t),()=>ae.delete(t)}function qe(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function We(){const t=s.useSyncExternalStore(Ye,ce,ce),r=B.has(t)?t:Y,l=s.useMemo(()=>s.lazy(()=>B.loadComponent(r).then(i=>({default:i}))),[r]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(qe,{}),children:e.jsx(l,{})})})}const He=s.lazy(()=>G(()=>import("./SysmlCodeEditor-BBfup_Ni.js"),__vite__mapDeps([12,1,2,13])).then(t=>({default:t.SysmlCodeEditor})));function Ke(t,r){const l=(t.elementIds??[]).map(i=>r[i]).filter(Boolean).map(i=>` ${i.construct??"part"} ${i.id} : ${i.kind};`).join(`
|
|
3
|
+
`);return[`package '${t.name}' {`,` // Diagram: ${t.diagramType.toUpperCase()} | Viewpoint: ${t.viewpointId}`,l||" // No elements selected","}"].join(`
|
|
4
|
+
`)}function Qe({diagram:t}){const r=_(c=>c.model),l=_(c=>c.updateDiagramElementIds),[i,a]=s.useState(""),f=s.useMemo(()=>Ae(r),[r]),S=s.useCallback(c=>{const m=new Set(t.elementIds??[]);m.has(c)?m.delete(c):m.add(c),l(t.id,[...m])},[t.id,t.elementIds,l]),R=s.useMemo(()=>new Set(t.elementIds??[]),[t.elementIds]),E=_e.filter(c=>f.has(c));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${n.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${n.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:n.primary,fontSize:u.xs},children:["Elements (",R.size," selected)"]}),e.jsx("input",{value:i,onChange:c=>a(c.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${n.border}`,color:n.primary,fontSize:u.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:E.map(c=>{const m=(f.get(c)??[]).filter(p=>!i||p.name.toLowerCase().includes(i.toLowerCase())||p.id.toLowerCase().includes(i.toLowerCase()));if(m.length===0)return null;const O=Le[c]??n.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:O,fontSize:u.badge},children:Te[c]??c}),m.map(p=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:u.xs},onMouseEnter:x=>x.currentTarget.style.background="#F0F0ED",onMouseLeave:x=>x.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:R.has(p.id),onChange:()=>S(p.id),style:{accentColor:n.accent}}),e.jsx("span",{className:"truncate",style:{color:n.primary},title:p.id,children:p.name||p.id})]},p.id))]},c)})})]})}function de({tone:t,message:r,actions:l}){const i=t==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:i?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${i?"#FECACA":"#FDE68A"}`,color:i?"#B91C1C":"#92400E",fontSize:u.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:r}),l.map(a=>e.jsx("button",{onClick:a.onClick,title:a.hint,style:{fontSize:u.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${i?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:a.label},a.label))]})}const Xe=4e3;function Je({at:t}){const[r,l]=s.useState(!1);return s.useEffect(()=>{if(!t)return;l(!0);const i=setTimeout(()=>l(!1),Xe);return()=>clearTimeout(i)},[t]),r?e.jsx("span",{title:"A source file this view depends on changed; the view was rebuilt",style:{fontSize:u.badge,padding:"1px 6px",borderRadius:999,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0",whiteSpace:"nowrap"},children:"↻ Refreshed from source"}):null}const Ze=[];function nt({diagramId:t}){const r=_(o=>o.model),l=_(o=>o.diagramParseErrors[t]??Ze),i=_(o=>o.lastSourceChange),a=Ee(r,t),[f,S]=s.useState("visual"),[R,E]=s.useState(""),[c,m]=s.useState(!1),[O,p]=s.useState(!1),[x,W]=s.useState(!1),[h,T]=s.useState(!1),[k,F]=s.useState(null),[ue,H]=s.useState(null),[L,D]=s.useState(null),[M,N]=s.useState(null),[fe,he]=s.useState(null),[K,Q]=s.useState([]),[g,X]=s.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),[j,pe]=s.useState(null),w=s.useRef(),b=s.useRef(""),J=s.useRef(0),A=s.useRef(void 0),$=s.useRef(0),Z=s.useRef(!1);s.useEffect(()=>{Z.current=h},[h]),s.useEffect(()=>{const o=()=>pe(document.getElementById("memo-diagram-editor-controls"));o();const v=new MutationObserver(o);return v.observe(document.body,{childList:!0,subtree:!0}),()=>v.disconnect()},[]);const ee=s.useMemo(()=>je(r,t),[r,t]),z=s.useCallback(async()=>{const o=++$.current,v=t;m(!0);try{const d=await we(v);if($.current!==o)return!1;const le=d.text??"";return b.current=le,A.current=d.revision,E(le),p(!0),T(!1),F(null),N(null),D(null),!0}catch(d){return $.current===o&&F(d instanceof Error?d.message:String(d)),!1}finally{$.current===o&&m(!1)}},[t]);s.useEffect(()=>{if(clearTimeout(w.current),F(null),H(null),T(!1),D(null),N(null),Q([]),A.current=void 0,!(!a||!r)){if(!a.sourceFile||window.__MEMO_DATA__){const o=Ke(a,r.elements);b.current=o,E(o),m(!1),p(!1);return}E(""),b.current="",p(!1),z()}},[t,a==null?void 0:a.sourceFile]),s.useEffect(()=>{if(!i||!(a!=null&&a.sourceFile)||window.__MEMO_DATA__||!Ce(i,ee))return;he(i.at);const o=i.files.includes(a.sourceFile);if(o){if(Z.current){D({files:i.files.filter(v=>ee.includes(v)),at:i.at,touchesOwnSource:o});return}z()}},[i==null?void 0:i.seq]);const xe=o=>{b.current=o,E(o),T(!0),F(null)},I=s.useCallback(async o=>{if(!a)return;const v=++J.current;W(!0),F(null);try{if(a.sourceFile){if(!A.current)throw new Error("Reload the source before saving this edit.");const d=await Re(t,o,A.current);if(d.conflict){N({theirs:d.text??"",revision:d.revision,at:Date.now()}),F(d.error??"The file changed on disk since this edit began.");return}A.current=d.revision,N(null),D(null),Q(d.parseErrors??[])}else ke(t,o);b.current===o&&T(!1),H(Date.now())}catch(d){F(d instanceof Error?d.message:String(d))}finally{J.current===v&&W(!1)}},[a,t]),te=s.useCallback(()=>{clearTimeout(w.current),z()},[z]),me=s.useCallback(()=>{navigator.clipboard.writeText(b.current)},[]),ge=s.useCallback(()=>{const o=new Blob([b.current],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(o),d=document.createElement("a");d.href=v,d.download=`${t}-rejected.sysml`,d.click(),URL.revokeObjectURL(v)},[t]);s.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(g)),clearTimeout(w.current),g&&h&&!c&&!M&&(w.current=setTimeout(()=>void I(b.current),800)),()=>clearTimeout(w.current)),[g,h,c,R,I,M]);const P=s.useCallback(()=>{clearTimeout(w.current),I(b.current)},[I]),ve=s.useMemo(()=>Object.values((r==null?void 0:r.elements)??{}).map(o=>({id:o.id,name:o.name,kind:o.kind})),[r==null?void 0:r.elements]);if(!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:n.faint,fontSize:u.sm},children:"Diagram not found"});const re=a.auto,C=!re||!!a.sourceFile&&O,se=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[M&&e.jsx(de,{tone:"conflict",message:`${a.sourceFile} changed on disk. Your rejected edit remains in this buffer and was not written.`,actions:[{label:"Copy draft",onClick:me,hint:"Copy the rejected SysML edit"},{label:"Download rejected edit",onClick:ge,hint:"Export the rejected SysML edit"},{label:"Reveal file",onClick:()=>De(a.sourceFile),hint:"Open the changed source file"},{label:"Reload from disk",onClick:te,hint:"Discard the draft and load current disk content"}]}),!M&&L&&e.jsx(de,{tone:"notice",message:L.files.length>1?`${L.files.length} source files changed on disk. Your unsaved edits are untouched.`:`${L.files[0]} changed on disk. Your unsaved edits are untouched.`,actions:[{label:"Reload from disk",onClick:te,hint:"Discards your unsaved edits"},{label:"Keep editing",onClick:()=>D(null),hint:"Dismiss until the next change"}]}),e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:u.xs},children:"Loading SysML editor…"}),children:e.jsx(He,{value:R,sourceFile:a.sourceFile,readOnly:!C||c,symbols:ve,onChange:xe,onSave:()=>{C&&h&&P()}})})}),K.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C1407",color:"#FCD34D",borderTop:"1px solid #3B2A0A",fontFamily:"monospace"},title:"Saved, but the file does not parse — the model keeps its last good state for this file",children:K.join(" · ")}),l.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#F87171",borderTop:"1px solid #3B0A0A",fontFamily:"monospace"},children:l.join(" · ")}),k&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:k}),!C&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:n.faint,borderTop:`1px solid ${n.border}`},children:a.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":a.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),oe=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(We,{})}),!re&&e.jsx(Qe,{diagram:a})]}),ne=(j==null?void 0:j.dataset.compactDiagramTools)==="true",ie={visual:"split",split:"text",text:"visual"},V={visual:"Visual",split:"Both",text:"Text"},be=f==="visual"?e.jsx(y.eye,{}):f==="split"?e.jsx(y.split,{}):e.jsx(y.code,{}),ye=j?e.jsxs(e.Fragment,{children:[C&&e.jsx("button",{type:"button","aria-label":`Auto-save ${g?"on":"off"}`,"aria-pressed":g,onClick:()=>X(o=>!o),title:`Auto-save ${g?"on":"off"}. Click to turn it ${g?"off":"on"}.`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:0,borderRadius:5,border:`1px solid ${g?"#A7F3D0":n.border}`,cursor:"pointer",background:g?"#ECFDF5":"#FFFFFF",color:g?"#047857":n.secondary},children:e.jsx(y.clock,{})}),C&&e.jsx("button",{"aria-label":"Save SysML",onClick:P,disabled:!h||x||c,title:"Save SysML (Ctrl/Cmd+S)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:0,borderRadius:5,border:`1px solid ${n.border}`,cursor:!h||x||c?"default":"pointer",background:h?n.accent:"#F0F0ED",color:h?"#FFFFFF":n.faint},children:e.jsx(y.save,{})}),ne?e.jsx("button",{type:"button","aria-label":`Editor mode: ${V[f]}`,title:`Editor mode: ${V[f]}. Click to switch to ${V[ie[f]]}.`,onClick:()=>S(ie[f]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",borderRadius:5,border:"1px solid #1B3A4B",cursor:"pointer",background:"#1B3A4B",color:"#FFFFFF"},children:be}):e.jsxs("select",{"aria-label":"Diagram editor view",title:"Choose editor view",value:f,onChange:o=>S(o.target.value),style:{fontSize:u.xs,height:28,padding:"0 6px",borderRadius:5,border:`1px solid ${n.border}`,background:"#FFFFFF",color:n.primary},children:[e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"split",children:"Both"}),e.jsx("option",{value:"text",children:"Text"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{at:fe}),c&&e.jsx("span",{style:{color:n.faint,fontSize:u.xs},children:"Loading source…"}),x&&e.jsx("span",{style:{color:n.faint,fontSize:u.xs},children:"Saving…"}),!x&&k&&e.jsx("span",{title:k,style:{color:"#EF4444",fontSize:u.xs},children:"Save failed"}),!x&&!k&&h&&e.jsx("span",{style:{color:"#B45309",fontSize:u.xs},children:"Unsaved"}),!x&&!h&&ue&&e.jsx("span",{style:{color:"#15803D",fontSize:u.xs},children:"Saved"}),!x&&l.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:u.xs},children:[l.length," error",l.length>1?"s":""]}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:n.secondary,fontSize:u.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:o=>X(o.target.checked),style:{accentColor:n.accent}}),"Auto-save"]}),e.jsx("button",{onClick:P,disabled:!h||x||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:u.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${n.border}`,cursor:!h||x||c?"default":"pointer",background:h?n.accent:"#F0F0ED",color:h?"#FFFFFF":n.faint,fontWeight:600},children:"Save"})]}),e.jsxs("label",{className:"flex items-center gap-1",style:{color:n.secondary,fontSize:u.xs},children:["View",e.jsxs("select",{"aria-label":"Diagram editor view",value:f,onChange:o=>S(o.target.value),style:{fontSize:u.xs,padding:"3px 8px",borderRadius:"5px",border:`1px solid ${n.border}`,background:"#FFFFFF",color:n.primary},children:[e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"split",children:"Both"}),e.jsx("option",{value:"text",children:"Text"})]})]})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"relative flex items-center justify-center px-3 py-2",style:{borderBottom:`1px solid ${n.border}`,background:"#FAFAF8",flexShrink:0},children:[f!=="visual"&&e.jsxs("button",{type:"button",onClick:()=>S("visual"),title:"Return to the visual diagram",className:"absolute left-3 flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold",style:{border:`1px solid ${n.border}`,background:"#FFFFFF",color:n.primary},children:[e.jsx(y.eye,{}),"Return to diagram"]}),e.jsx("span",{className:"truncate",style:{color:n.primary,fontSize:u.md,fontWeight:700},children:a.name}),f==="visual"&&e.jsxs("div",{className:"absolute right-3 flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("memo:toggle-diagram-elements")),title:"Show or hide Diagram Elements","aria-label":"Show or hide Diagram Elements",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n.border}`,borderRadius:5,background:"#FFFFFF",color:n.secondary,cursor:"pointer"},children:e.jsx(y.elements,{size:18})}),e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("memo:toggle-diagram-toolbar")),title:"Show or hide Toolbar","aria-label":"Show or hide Toolbar",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n.border}`,borderRadius:5,background:"#FFFFFF",color:n.secondary,cursor:"pointer"},children:e.jsx(y.tools,{size:18})})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[f==="visual"&&oe,f==="text"&&se,f==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${n.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:se}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:oe})]})]}),j&&Me.createPortal(e.jsx("div",{className:ne?"contents":"flex flex-wrap items-center gap-2",children:ye}),j)]})}export{nt as DiagramEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as r}from"./reactflow-s7jmJtXx.js";import{W as c}from"./zustand-CrhqMOHB.js";const o="#ECEBE6",i="#1B3A4B",l="#5B6470",j="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",s=(e,x)=>r.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:x}),F={arrowRight:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 12h14"}),r.jsx("path",{d:"M13 6l6 6-6 6"})]})),arrowDown:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 4v14"}),r.jsx("path",{d:"M6 13l6 6 6-6"})]})),arrowUp:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 20V6"}),r.jsx("path",{d:"m6 11 6-6 6 6"})]})),elements:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"4",y:"4",width:"6",height:"6",rx:"1"}),r.jsx("circle",{cx:"17",cy:"7",r:"3"}),r.jsx("path",{d:"m7 14 4 6H3z"}),r.jsx("path",{d:"m17 14 3 3-3 3-3-3z"})]})),tools:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"}),r.jsx("circle",{cx:"9",cy:"6",r:"1.8",fill:"currentColor"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.8",fill:"currentColor"}),r.jsx("circle",{cx:"11",cy:"18",r:"1.8",fill:"currentColor"})]})),overlay:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"4",y:"7",width:"12",height:"12",rx:"1.5"}),r.jsx("rect",{x:"8",y:"3",width:"12",height:"12",rx:"1.5"})]})),eye:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M2.5 12s3.4-5 9.5-5 9.5 5 9.5 5-3.4 5-9.5 5-9.5-5-9.5-5Z"}),r.jsx("circle",{cx:"12",cy:"12",r:"2.2"})]})),split:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),r.jsx("path",{d:"M12 4v16"})]})),code:({size:e=16})=>s(e,r.jsx(r.Fragment,{children:r.jsx("path",{d:"m8 7-4 5 4 5M16 7l4 5-4 5M14 4l-4 16"})})),lanes:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"3.4",rx:"1.3"}),r.jsx("rect",{x:"3",y:"10.3",width:"18",height:"3.4",rx:"1.3"}),r.jsx("rect",{x:"3",y:"15.6",width:"18",height:"3.4",rx:"1.3"})]})),lanesOff:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"3.4",rx:"1.3"}),r.jsx("rect",{x:"3",y:"15.6",width:"18",height:"3.4",rx:"1.3"}),r.jsx("path",{d:"M4 20 20 4"})]})),grid:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),r.jsx("path",{d:"M9.2 3.5v17M14.8 3.5v17M3.5 9.2h17M3.5 14.8h17"})]})),gridOff:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),r.jsx("path",{d:"M4 20 20 4"})]})),expand:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M15 4h5v5"}),r.jsx("path",{d:"M9 20H4v-5"}),r.jsx("path",{d:"M20 4l-7 7"}),r.jsx("path",{d:"M4 20l7-7"})]})),collapse:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M14 10h5"}),r.jsx("path",{d:"M19 10V5"}),r.jsx("path",{d:"M10 14H5"}),r.jsx("path",{d:"M5 14v5"}),r.jsx("path",{d:"M20 4l-6 6"}),r.jsx("path",{d:"M4 20l6-6"})]})),filter:({size:e=16})=>s(e,r.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M11 5l-6 7 6 7"}),r.jsx("path",{d:"M5 12h14"})]})),rectangle:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"2"}),r.jsx("path",{d:"M8 5v14M16 5v14",strokeDasharray:"2 2"})]})),upload:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 16V4"}),r.jsx("path",{d:"M7.5 8.5 12 4l4.5 4.5"}),r.jsx("path",{d:"M4 15v4h16v-4"})]})),capture:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"6",width:"18",height:"13",rx:"2"}),r.jsx("path",{d:"M8 6l1.5-2h5L16 6"}),r.jsx("circle",{cx:"12",cy:"12.5",r:"3.2"})]})),info:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 10.5v6"}),r.jsx("path",{d:"M12 7.5h.01"})]})),plus:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 5v14"}),r.jsx("path",{d:"M5 12h14"})]})),minus:({size:e=16})=>s(e,r.jsx("path",{d:"M5 12h14"})),library:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"4",y:"4",width:"5",height:"16",rx:"1"}),r.jsx("rect",{x:"10",y:"4",width:"5",height:"16",rx:"1"}),r.jsx("path",{d:"M17 5l3 14"})]})),detect:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M8 4H4v4M16 4h4v4M8 20H4v-4M16 20h4v-4"}),r.jsx("rect",{x:"7",y:"8",width:"10",height:"8",rx:"1.5",strokeDasharray:"2 2"})]})),tidy:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 7h6l4-4h8"}),r.jsx("path",{d:"M3 17h6l4 4h8"}),r.jsx("circle",{cx:"3",cy:"7",r:"1.3"}),r.jsx("circle",{cx:"3",cy:"17",r:"1.3"})]})),arrange:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"4",y:"4",width:"5",height:"5",rx:"1"}),r.jsx("rect",{x:"15",y:"4",width:"5",height:"5",rx:"1"}),r.jsx("rect",{x:"4",y:"15",width:"5",height:"5",rx:"1"}),r.jsx("rect",{x:"15",y:"15",width:"5",height:"5",rx:"1"}),r.jsx("path",{d:"m10.5 7 3 0M12 10.5v3"})]})),download:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 4v11"}),r.jsx("path",{d:"M7.5 10.5 12 15l4.5-4.5"}),r.jsx("path",{d:"M4 16v3h16v-3"})]})),save:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 3h12l3 3v15H5z"}),r.jsx("path",{d:"M8 3v6h8V3M8 20v-7h8v7"})]})),clock:({size:e=16})=>s(e,r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"8"}),r.jsx("path",{d:"M12 7v5l3 2"})]}))};function m({hidden:e=!1}){return e?null:r.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function u({options:e,value:x,onChange:a}){return r.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:o,borderRadius:9},children:e.map(t=>{const n=t.value===x;return r.jsxs("button",{role:"tab","aria-selected":n,onClick:()=>a(t.value),title:t.title,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:t.label?"3px 9px":"4px 7px",borderRadius:7,border:"none",cursor:"pointer",color:n?i:l,background:n?"#FFFFFF":"transparent",boxShadow:n?j:"none",transition:"background 140ms ease, color 140ms ease, box-shadow 140ms ease"},children:[t.icon,t.label&&r.jsx("span",{children:t.label})]},t.value)})})}function M({children:e}){return r.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:c.Children.toArray(e).map((x,a)=>r.jsxs(c.Fragment,{children:[a>0&&r.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),x]},a))})}function y({icon:e,label:x,onClick:a,active:t=!1,title:n,ariaExpanded:h,ariaLabel:d}){return r.jsxs("button",{onClick:a,title:n,"aria-label":d,"aria-pressed":t,"aria-expanded":h,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:x?"5px 9px":"5px 7px",border:"none",cursor:"pointer",color:t?"#FFFFFF":l,background:t?i:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[e,x&&r.jsx("span",{children:x})]})}function b({icon:e,label:x,onClick:a,active:t=!1,title:n,badge:h,fullWidth:d=!1}){return r.jsxs("button",{onClick:a,title:n,"aria-pressed":t,className:"flex items-center gap-1.5 text-xs font-semibold",style:{width:d?"100%":void 0,justifyContent:d?"center":void 0,padding:h!=null||x!=null?"5px 9px":"5px 7px",borderRadius:9,border:`1px solid ${t?i:"#E2E1DB"}`,cursor:"pointer",color:t?"#FFFFFF":l,background:t?i:"#FFFFFF",transition:"background 140ms ease, color 140ms ease, border-color 140ms ease"},children:[e,x!=null&&r.jsx("span",{children:x}),h!=null&&r.jsx("span",{style:{fontSize:11,fontWeight:700,lineHeight:1,padding:"2px 5px",borderRadius:6,background:t?"rgba(255,255,255,0.22)":"#F0EFEA",color:t?"#FFFFFF":"#6B7280"},children:h})]})}export{F as I,u as S,M as T,y as a,m as b,b as c};
|