@memoarchitect/architect 0.6.6 → 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 +26 -4
- package/dist/assets/AiWorkspace-Bu9TlIWg.js +7 -0
- package/dist/assets/AnalysisWorkspace-CodmoI-v.js +39 -0
- package/dist/assets/{ComplianceWizard-k98NZ2ec.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-B9V_n7kg.js → DhfDashboard-w-dJoJHU.js} +1 -1
- package/dist/assets/{DhfWorkbench-TOnZkdUU.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-CyMm-tSP.js → ImportView-D8svP04Q.js} +1 -1
- package/dist/assets/{LayerGrid-DNPZYTsD.js → LayerGrid-DEe0Ryz-.js} +1 -1
- package/dist/assets/{LayerTable-DhOq1DHo.js → LayerTable-CN_b2rDr.js} +2 -2
- package/dist/assets/{MaxGraphCanvas-DqKU1PTY.js → MaxGraphCanvas-bo8oPBct.js} +6 -6
- package/dist/assets/{ModelDiff-BbqIoesG.js → ModelDiff-xe95oVua.js} +1 -1
- package/dist/assets/OntologyDecompositionDiagram-BL9R8bdB.js +1 -0
- package/dist/assets/{OntologyViewer-BIpJC66j.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-DKoExM8K.js → ReviewDashboard-DeTge2oC.js} +1 -1
- package/dist/assets/ScenarioEditor-FAEYTHgP.js +3 -0
- package/dist/assets/{StatisticsDashboard-B8BduIDz.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-7--f9OH2.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/package.json +11 -5
- package/dist/assets/AiWorkspace-DS79vBOT.js +0 -3
- package/dist/assets/AnalysisWorkspace-D_u4shRY.js +0 -39
- package/dist/assets/DSMView-DGheBwZ0.js +0 -1
- package/dist/assets/Dashboard-BRUQvUFK.js +0 -1
- package/dist/assets/DhfSettingsPanel-B8aLsWn6.js +0 -1
- package/dist/assets/DiagramCanvas-B9d4aLKt.js +0 -1
- package/dist/assets/DiagramEditor-CJ7OG2IC.js +0 -4
- package/dist/assets/ElementDetailView-CDcm1rvf.js +0 -2
- package/dist/assets/OntologyDecompositionDiagram-DkxTe2C_.js +0 -1
- package/dist/assets/ScenarioEditor-JQ3huCnz.js +0 -3
- package/dist/assets/TabularView-BXfFSluC.js +0 -1
- package/dist/assets/TraceabilityMatrix-CHZHFucA.js +0 -1
- package/dist/assets/index-CVW92JY7.js +0 -3280
- package/dist/assets/index-Y1UZTZg-.css +0 -1
- package/dist/assets/layout-selection-ClQ295Xc.js +0 -1
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as s}from"./zustand-CrhqMOHB.js";import{u as B}from"./index-CVW92JY7.js";const I="memo.analysis.notebooks.v1",L="root",k={folders:[{id:L,name:"Notebooks"}],notebooks:[]};function R(){try{const n=localStorage.getItem(I);if(!n)return k;const o=JSON.parse(n);return!Array.isArray(o.folders)||!Array.isArray(o.notebooks)?k:o}catch{return k}}const _=[{template:"part-inventory",title:"Part inventory",description:"List part usages and their owners.",icon:"▦"},{template:"requirements-review",title:"Requirements review",description:"List requirements and their declared text.",icon:"☑"},{template:"ownership-tree",title:"Ownership tree",description:"Print the model hierarchy for review.",icon:"⌘"},{template:"syside-part-api",title:"Syside live model API",description:"Query typed PartUsage elements directly from SysML v2 files.",icon:"⌁"}];function O(n){switch(n){case"part-inventory":return[`# Part inventory from the current MEMO model snapshot
|
|
2
|
-
`,`parts = [element for element in elements if 'part' in (element.get('kind', '') + ' ' + element.get('construct', '')).lower()]
|
|
3
|
-
`,`[(part.get('shortId'), part.get('name'), part.get('kind')) for part in parts[:100]]
|
|
4
|
-
`];case"requirements-review":return[`# Requirements review from the current MEMO model snapshot
|
|
5
|
-
`,`requirements = [element for element in elements if 'requirement' in element.get('kind', '').lower()]
|
|
6
|
-
`,`[(requirement.get('shortId'), requirement.get('name'), requirement.get('documentation', ''))
|
|
7
|
-
`,` for requirement in requirements[:100]]
|
|
8
|
-
`];case"ownership-tree":return[`# Ownership/containment relationships in the current model
|
|
9
|
-
`,`ownership = [relationship for relationship in relationships
|
|
10
|
-
`,` if any(term in relationship.get('type', '').lower() for term in ('contain', 'own', 'compose'))]
|
|
11
|
-
`,`[(relationship.get('sourceId'), relationship.get('targetId'), relationship.get('type'))
|
|
12
|
-
`,` for relationship in ownership[:100]]
|
|
13
|
-
`];case"syside-part-api":return[`# Licensed Syside Automator: query the textual SysML v2 model directly
|
|
14
|
-
`,`from pathlib import Path
|
|
15
|
-
`,`import syside
|
|
16
|
-
`,`
|
|
17
|
-
`,`MODEL_ROOT = Path('../model')
|
|
18
|
-
`,`sysml_paths = [str(path) for path in MODEL_ROOT.rglob('*.sysml')]
|
|
19
|
-
`,`# GPCA currently has semantic diagnostics, so use Syside’s tolerant loader.
|
|
20
|
-
`,`sysml_model, diagnostics = syside.try_load_model(sysml_paths)
|
|
21
|
-
`,`part_usages = list(sysml_model.elements(syside.PartUsage))
|
|
22
|
-
`,`print(f'Loaded {len(sysml_model.user_docs)} documents and {len(part_usages)} PartUsage elements')
|
|
23
|
-
`,`[(part.name, part.owner.name if part.owner else None) for part in part_usages[:100]]
|
|
24
|
-
`];default:return[`# Query the current MEMO model snapshot
|
|
25
|
-
`,`[(element.get('shortId'), element.get('name'), element.get('kind')) for element in elements[:100]]
|
|
26
|
-
`]}}function N(n,o,d){const i=new TextEncoder().encode(JSON.stringify(d));let c="";for(let l=0;l<i.length;l+=32768)c+=String.fromCharCode(...i.subarray(l,l+32768));const m=btoa(c);return{nbformat:4,nbformat_minor:5,metadata:{kernelspec:{display_name:"Python 3",language:"python",name:"python3"},language_info:{name:"python",version:"3.12"}},cells:[{cell_type:"markdown",metadata:{},source:[`# ${n}
|
|
27
|
-
`,`
|
|
28
|
-
`,`This live notebook was generated by MEMO Architect with a snapshot of the currently loaded model. The starter cells require only Python and run without a commercial license.
|
|
29
|
-
`,`
|
|
30
|
-
`,"> For direct textual SysML v2 access, add the optional licensed Syside Automator adapter after configuring `SYSIDE_LICENSE_KEY`.\n"]},{cell_type:"code",execution_count:null,metadata:{},outputs:[],source:[`import base64
|
|
31
|
-
`,`import json
|
|
32
|
-
`,`
|
|
33
|
-
`,`model = json.loads(base64.b64decode('${m}').decode('utf-8'))
|
|
34
|
-
`,`elements = list(model.get('elements', {}).values())
|
|
35
|
-
`,`relationships = list(model.get('relationships', []))
|
|
36
|
-
`,`print(f'Loaded {len(elements)} elements and {len(relationships)} relationships')
|
|
37
|
-
`]},{cell_type:"code",execution_count:null,metadata:{},outputs:[],source:O(o)}]}}function S(n){return`${n.title.replace(/[^a-z0-9_-]+/gi,"-")||"memo-analysis"}.ipynb`}async function C(n,o){const d=S(n),i=N(n.title,n.template??"custom",o);if(!(await fetch(`http://127.0.0.1:8888/api/contents/${encodeURIComponent(d)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"notebook",format:"json",content:i})})).ok)throw new Error("JupyterLab is not available at 127.0.0.1:8888.")}async function M(n){const o=await fetch(`http://127.0.0.1:8888/api/contents/${encodeURIComponent(S(n))}?content=0`);if(o.status===404)return!1;if(!o.ok)throw new Error("JupyterLab is not available at 127.0.0.1:8888.");return!0}function W(){var F;const n=B(t=>t.model),[o,d]=s.useState(R),[i,c]=s.useState(L),[m,l]=s.useState(()=>{var t;return((t=R().notebooks.at(-1))==null?void 0:t.id)??null}),[j,y]=s.useState(null),[w,u]=s.useState(null);s.useEffect(()=>{localStorage.setItem(I,JSON.stringify(o))},[o]);const E=s.useMemo(()=>o.notebooks.filter(t=>t.folderId===i),[o.notebooks,i]),r=o.notebooks.find(t=>t.id===m)??null;s.useEffect(()=>{r&&(u(null),y(null),M(r).then(t=>t?u(r.id):C(r,n).then(()=>u(r.id))).catch(t=>y(t.message)))},[m]);function D(){const t=window.prompt("Folder name");if(!(t!=null&&t.trim()))return;const a={id:`folder-${crypto.randomUUID()}`,name:t.trim()};d(f=>({...f,folders:[...f.folders,a]})),c(a.id)}function g(t="custom",a="Model analysis",f=!0){const x=f?window.prompt("Notebook title",a):a;if(!(x!=null&&x.trim()))return;const v=x.trim(),A=o.notebooks.filter(p=>p.title===v).length,T=A?`${v} ${A+1}`:v,b={id:`notebook-${crypto.randomUUID()}`,title:T,folderId:i,createdAt:Date.now(),template:t};d(p=>({...p,notebooks:[...p.notebooks,b]})),l(b.id),u(null),y(null),C(b,n).then(()=>u(b.id)).catch(p=>y(p.message))}const h={border:"1px solid #BFE6D9",background:"#F2FCF8",color:"#176B55",borderRadius:6,padding:"7px 10px",cursor:"pointer",fontSize:12,fontWeight:600};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",style:{background:"#F7F7F5"},children:[e.jsxs("aside",{style:{width:280,flexShrink:0,borderRight:"1px solid #D9E2E7",background:"#FFF",padding:16,overflow:"auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,color:"#173B4E"},children:"Jupyter notebooks"}),e.jsx("div",{style:{fontSize:12,color:"#71889A",marginTop:3},children:"Python analysis workspace"})]}),e.jsx("button",{title:"New folder",onClick:D,style:h,children:"+ Folder"})]}),e.jsx("div",{style:{marginBottom:14},children:o.folders.map(t=>e.jsxs("button",{onClick:()=>c(t.id),style:{display:"block",width:"100%",textAlign:"left",border:"none",borderRadius:6,padding:"8px 10px",cursor:"pointer",background:i===t.id?"#E2F7F0":"transparent",color:"#1B3A4B",fontWeight:i===t.id?700:500},children:["▾ ",t.name]},t.id))}),e.jsx("button",{onClick:()=>g(),style:{...h,width:"100%",marginBottom:12},children:"+ New notebook"}),e.jsxs("div",{style:{borderTop:"1px solid #E3ECEF",margin:"4px 0 10px",paddingTop:12},children:[e.jsx("div",{style:{color:"#71889A",fontSize:10,fontWeight:700,letterSpacing:".07em",textTransform:"uppercase",margin:"0 0 7px 10px"},children:"Starter examples"}),_.map(t=>e.jsxs("button",{onClick:()=>g(t.template,t.title,!1),title:t.description,style:{display:"block",width:"100%",textAlign:"left",border:"none",borderRadius:6,padding:"8px 10px",cursor:"pointer",background:"transparent",color:"#244D63",fontSize:12},children:[e.jsx("span",{style:{color:"#2D8D70",marginRight:7},children:t.icon}),t.title]},t.template))]}),E.map(t=>e.jsxs("button",{onClick:()=>l(t.id),style:{display:"block",width:"100%",textAlign:"left",border:"none",borderRadius:6,padding:"9px 10px",cursor:"pointer",background:m===t.id?"#EEF7FB":"transparent",color:"#244D63",fontSize:13},children:["◫ ",t.title]},t.id)),E.length===0&&e.jsx("div",{style:{color:"#8AA0AE",fontSize:12,lineHeight:1.5,padding:"8px 10px"},children:"No notebooks in this folder yet."})]}),e.jsx("main",{style:{flex:1,minWidth:0,overflow:"auto",padding:"32px clamp(24px, 5vw, 72px)"},children:e.jsxs("div",{style:{maxWidth:960},children:[e.jsxs("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:20,marginBottom:26},children:[e.jsxs("div",{children:[e.jsx("div",{style:{color:"#2D8D70",fontSize:12,fontWeight:700,letterSpacing:".08em",textTransform:"uppercase"},children:"Model analysis"}),e.jsx("h1",{style:{color:"#173B4E",fontSize:28,margin:"6px 0 8px"},children:"Analysis"}),e.jsx("p",{style:{color:"#587487",margin:0,lineHeight:1.55,maxWidth:620},children:"Create live Jupyter notebooks that query the currently loaded MEMO model with Python. A licensed Syside adapter can be added for direct textual SysML v2 access."})]}),e.jsx("button",{onClick:()=>g(),style:{...h,whiteSpace:"nowrap"},children:"+ New notebook"})]}),e.jsx("section",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:12,marginBottom:24},children:[["Elements",Object.keys((n==null?void 0:n.elements)??{}).length],["Relationships",((F=n==null?void 0:n.relationships)==null?void 0:F.length)??0],["Kernel","Python 3.12"]].map(([t,a])=>e.jsxs("div",{style:{background:"#FFF",border:"1px solid #D9E6E9",borderRadius:10,padding:"15px 17px"},children:[e.jsx("div",{style:{color:"#7892A1",fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:".06em"},children:t}),e.jsx("div",{style:{color:"#173B4E",fontSize:20,fontWeight:700,marginTop:5},children:a})]},String(t)))}),e.jsxs("section",{style:{marginBottom:24},children:[e.jsx("div",{style:{color:"#587487",fontSize:12,fontWeight:700,textTransform:"uppercase",letterSpacing:".06em",marginBottom:9},children:"Starter notebooks"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:12},children:_.map(t=>e.jsxs("button",{onClick:()=>g(t.template,t.title,!1),style:{textAlign:"left",background:"#FFF",border:"1px solid #D9E6E9",borderRadius:10,padding:16,cursor:"pointer",color:"#173B4E"},children:[e.jsx("div",{style:{fontSize:20,color:"#2D8D70",marginBottom:8},children:t.icon}),e.jsx("div",{style:{fontWeight:700,fontSize:14},children:t.title}),e.jsx("div",{style:{color:"#7892A1",fontSize:12,lineHeight:1.45,marginTop:4},children:t.description})]},t.template))})]}),e.jsx("section",{style:{background:"#FFF",border:"1px solid #D9E6E9",borderRadius:10,padding:20},children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,color:"#173B4E",fontSize:18},children:r.title}),e.jsx("div",{style:{color:"#7892A1",fontSize:12,marginTop:5},children:w===r.id?"Saved and ready in local JupyterLab":"Preparing live notebook…"})]}),w===r.id?e.jsx("a",{href:`http://127.0.0.1:8888/lab/tree/${encodeURIComponent(S(r))}`,target:"_blank",rel:"noopener noreferrer",style:{...h,textDecoration:"none"},children:"▶ Open live JupyterLab"}):e.jsx("button",{disabled:!0,style:{...h,opacity:.55,cursor:"wait"},children:"Preparing…"})]}),j&&e.jsx("div",{style:{color:"#B45309",fontSize:12,marginTop:10},children:j}),e.jsx("pre",{style:{whiteSpace:"pre-wrap",margin:"18px 0 0",padding:14,borderRadius:7,background:"#102A3A",color:"#BDEFE1",fontSize:12,lineHeight:1.55},children:`elements = list(model.get('elements', {}).values())
|
|
38
|
-
parts = [e for e in elements if 'part' in (e.get('kind', '') + ' ' + e.get('construct', '')).lower()]
|
|
39
|
-
[(p.get('shortId'), p.get('name'), p.get('kind')) for p in parts[:100]]`})]}):e.jsxs("div",{style:{color:"#587487",lineHeight:1.6},children:[e.jsx("strong",{style:{color:"#173B4E"},children:"Start an analysis notebook."}),e.jsx("br",{}),"Choose a starter to create it instantly, then open it in live JupyterLab."]})})]})})]})}export{W as AnalysisWorkspace};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./reactflow-CsCqNKB-.js";import{a as b}from"./zustand-CrhqMOHB.js";import{u as C,f as _,R as v}from"./index-CVW92JY7.js";const U=["Function","Function","ActionDefinition","ActionUsage"],H=["flow","decomposedBy","composedOf","allocateTo","succession"];function K(o,c){const m=new Set((c==null?void 0:c.kinds)??U),u=new Set((c==null?void 0:c.relationshipTypes)??H),p=(c==null?void 0:c.cluster)??!0,d=[];for(const e of Object.values(o.elements))m.has(e.kind)&&d.push(e);d.sort((e,h)=>{const g=e.kind.localeCompare(h.kind);return g!==0?g:e.name.localeCompare(h.name)});const a=d.map(e=>e.id),f=new Map;for(let e=0;e<a.length;e++)f.set(a[e],e);const r=a.length,y={};for(const e of d)y[e.id]={name:e.name,kind:e.kind,layer:e.layer,allocatedTo:e.allocatedTo};const l=Array.from({length:r},()=>Array.from({length:r},()=>null));let t=0;for(const e of o.relationships){if(!u.has(e.type))continue;const h=f.get(e.sourceId),g=f.get(e.targetId);if(h===void 0||g===void 0||h===g)continue;let F=l[h][g];F||(F={count:0,types:[],flowItems:[]},l[h][g]=F),F.count++,F.types.includes(e.type)||F.types.push(e.type),e.flowItem&&!F.flowItems.includes(e.flowItem)&&F.flowItems.push(e.flowItem),t++}const i=p?Y(a,l):new Map;return{elementIds:a,elements:y,matrix:l,clusters:i,totalDependencies:t}}function Y(o,c){const m=o.length,u=Array.from({length:m},(l,t)=>t),p=new Array(m).fill(0);function d(l){return u[l]!==l&&(u[l]=d(u[l])),u[l]}function a(l,t){const i=d(l),e=d(t);i!==e&&(p[i]<p[e]?u[i]=e:p[i]>p[e]?u[e]=i:(u[e]=i,p[i]++))}for(let l=0;l<m;l++)for(let t=0;t<m;t++)l!==t&&(c[l][t]||c[t][l])&&a(l,t);const f=new Map;for(let l=0;l<m;l++){const t=d(l);f.has(t)||f.set(t,[]),f.get(t).push(o[l])}const r=new Map;let y=0;for(const l of f.values())r.set(y++,l);return r}function P(o){const c=[],m=new Set;for(const[,a]of o.clusters)for(const f of a)m.has(f)||(c.push(f),m.add(f));for(const a of o.elementIds)m.has(a)||c.push(a);const u=c.length,p=new Map;for(let a=0;a<o.elementIds.length;a++)p.set(o.elementIds[a],a);const d=Array.from({length:u},()=>Array.from({length:u},()=>null));for(let a=0;a<u;a++)for(let f=0;f<u;f++)d[a][f]=o.matrix[p.get(c[a])][p.get(c[f])];return{...o,elementIds:c,matrix:d}}const R=new Set(["Function","Function","UserActivity"]),z=new Set(["System","Subsystem","Component","LogicalComponent","SoftwareComponent","SoftwareModule","Software"]);function V(o){var y,l;const c=[],m=[];for(const t of Object.values(o.elements))R.has(t.kind)&&c.push(t),z.has(t.kind)&&m.push(t);const u=[],p=new Set,d=new Map;for(const t of m)d.set(t.id,[]);for(const t of o.relationships){if(t.type!=="allocateTo")continue;const i=o.elements[t.sourceId],e=o.elements[t.targetId];!i||!e||R.has(i.kind)&&z.has(e.kind)&&(u.push({functionId:i.id,functionName:i.name,targetId:e.id,targetName:e.name}),p.add(i.id),d.has(e.id)||d.set(e.id,[]),d.get(e.id).push(i.id))}for(const t of c)if(t.allocatedTo&&!p.has(t.id)){const i=m.find(e=>e.name===t.allocatedTo||e.id===t.allocatedTo);i&&(u.push({functionId:t.id,functionName:t.name,targetId:i.id,targetName:i.name}),p.add(t.id),d.has(i.id)||d.set(i.id,[]),d.get(i.id).push(t.id))}const a=[];let f=0;for(const t of c)p.has(t.id)||a.push({id:`ci-${f++}`,type:"unallocated-function",severity:"warning",elementId:t.id,elementName:t.name,message:`Function "${t.name}" is not allocated to any component`});for(const t of m){const i=d.get(t.id);(!i||i.length===0)&&a.push({id:`ci-${f++}`,type:"no-functions-allocated",severity:"info",elementId:t.id,elementName:t.name,message:`Component "${t.name}" has no functions allocated to it`})}const r=new Map;for(const t of u)r.set(t.functionId,t.targetId);for(const t of o.relationships){if(t.type!=="flow")continue;const i=r.get(t.sourceId),e=r.get(t.targetId);if(i&&e&&i!==e){const h=o.elements[t.sourceId],g=o.elements[t.targetId];h&&g&&a.push({id:`ci-${f++}`,type:"cross-component-flow",severity:"info",elementId:t.sourceId,elementName:h.name,message:`Flow from "${h.name}" to "${g.name}" crosses component boundary (${(y=o.elements[i])==null?void 0:y.name} → ${(l=o.elements[e])==null?void 0:l.name})`,relatedIds:[t.targetId,i,e]})}}return{allocations:u,componentFunctions:d,issues:a,functions:c,structures:m}}function N(o){for(const c of o.types)if(v[c])return v[c];return"#6B7280"}function Z(o){const c=N(o),m=Math.min(.15+o.count*.15,.6);return`${c}${Math.round(m*255).toString(16).padStart(2,"0")}`}const E=36,D=160;function Q(){const o=C(n=>n.model),c=C(n=>n.selectElement),m=C(n=>n.selectedElementId),u=C(n=>n.setAnalysisIssues),[p,d]=b.useState(!0),[a,f]=b.useState(!1),[r,y]=b.useState(null),[l,t]=b.useState("functional"),i=b.useMemo(()=>{switch(l){case"functional":return["Function","Function"];case"behavior":return["ActionDefinition","ActionUsage"];case"all":return["Function","Function","ActionDefinition","ActionUsage"]}},[l]),e=b.useMemo(()=>{if(!o)return null;const n=K(o,{kinds:i});return p?P(n):n},[o,p,i]),h=b.useMemo(()=>o?V(o):null,[o]);b.useEffect(()=>{if(h)return u(h.issues.map(n=>({id:n.id,source:"DSM",severity:n.severity,elementId:n.elementId,elementName:n.elementName,message:n.message,tag:n.type==="unallocated-function"?"unallocated":n.type==="cross-component-flow"?"cross-boundary":"no functions"}))),()=>u([])},[h,u]);const g=b.useCallback((n,x)=>{y({row:n,col:x})},[]),F=b.useCallback(()=>{y(null)},[]);if(!o||!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"#9CA3AF"},children:s.jsx("p",{children:"No model loaded"})});if(e.elementIds.length===0)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:s.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[s.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"▤"}),s.jsx("h3",{style:{fontSize:"15px",fontWeight:600,color:"#374151",marginBottom:"8px"},children:"No Functional Elements"}),s.jsx("p",{style:{fontSize:"13px",color:"#9CA3AF",lineHeight:1.6},children:"Add Function or Function elements to your model to see the DSM."})]})});const B=e.elementIds.length,k=new Set;if(p&&e.clusters.size>1){let n=0;for(const[,x]of e.clusters)n+=x.length,n<B&&k.add(n)}const j=r?(()=>{const n=e.matrix[r.row][r.col],x=e.elements[e.elementIds[r.row]],w=e.elements[e.elementIds[r.col]];return{cell:n,rowEl:x,colEl:w}})():null;return s.jsxs("div",{className:"flex-1 flex flex-col",style:{background:"#F7F7F5"},children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0",background:"#FFFFFF"},children:[s.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:"Design Structure Matrix"}),s.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:[B," elements, ",e.totalDependencies," dependencies"]}),s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["functional","behavior","all"].map(n=>s.jsx("button",{onClick:()=>t(n),className:"px-2 py-0.5 text-xs font-medium",style:{background:l===n?"#1B3A4B":"#FFFFFF",color:l===n?"#FFFFFF":"#6B7280"},children:n==="functional"?"Functions":n==="behavior"?"Behavior":"All"},n))}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"#6B7280"},children:[s.jsx("input",{type:"checkbox",checked:p,onChange:n=>d(n.target.checked),style:{accentColor:"#2DD4A8"}}),"Cluster"]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"#6B7280"},children:[s.jsx("input",{type:"checkbox",checked:a,onChange:n=>f(n.target.checked),style:{accentColor:"#E67E22"}}),"Allocation"]})]}),s.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[s.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[s.jsx("div",{style:{display:"flex",marginLeft:D,marginBottom:"4px"},children:e.elementIds.map((n,x)=>{const w=e.elements[n],A=(r==null?void 0:r.col)===x;return s.jsx("div",{style:{width:E,height:D-20,position:"relative",borderRight:k.has(x+1)?"2px solid #2DD4A8":void 0},children:s.jsx("div",{style:{position:"absolute",bottom:0,left:E/2,transformOrigin:"bottom left",transform:"rotate(-60deg)",whiteSpace:"nowrap",fontSize:"11px",fontWeight:A?600:400,color:A?"#1a1a1a":"#6B7280",cursor:"pointer"},onClick:()=>c(n),children:w.name})},n)})}),e.elementIds.map((n,x)=>{const w=e.elements[n],A=(r==null?void 0:r.row)===x,M=m===n,L=k.has(x);return s.jsxs("div",{style:{display:"flex",alignItems:"center",borderTop:L?"2px solid #2DD4A8":void 0},children:[s.jsxs("div",{style:{width:D,paddingRight:"8px",fontSize:"11px",fontWeight:A||M?600:400,color:A||M?"#1a1a1a":"#6B7280",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:"right",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"6px",height:E},onClick:()=>c(n),title:`${w.name} (${w.kind})`,children:[a&&w.allocatedTo&&s.jsx("span",{style:{fontSize:"9px",padding:"1px 4px",borderRadius:"3px",background:"#E67E2220",color:"#E67E22",fontWeight:500},children:w.allocatedTo}),s.jsx("span",{style:{width:"3px",height:"14px",borderRadius:"2px",background:_[w.layer]||"#9CA3AF",flexShrink:0}}),w.name]}),e.elementIds.map(($,I)=>{const S=e.matrix[x][I],T=x===I,W=(r==null?void 0:r.row)===x&&(r==null?void 0:r.col)===I,O=(r==null?void 0:r.row)===x||(r==null?void 0:r.col)===I;return s.jsx("div",{onMouseEnter:()=>g(x,I),onMouseLeave:F,onClick:()=>{S&&c(n)},style:{width:E,height:E,border:"1px solid #E5E5E0",borderRight:k.has(I+1)?"2px solid #2DD4A8":"1px solid #E5E5E0",background:T?"#F3F4F6":S?Z(S):O?"#FAFAFA":"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:S?"pointer":"default",transition:"background 100ms ease",outline:W&&S?`2px solid ${N(S)}`:void 0,outlineOffset:"-2px"},children:S&&!T&&s.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:N(S)},children:S.count>1?S.count:"●"})},$)})]},n)})]}),(j==null?void 0:j.cell)&&s.jsxs("div",{style:{position:"fixed",bottom:"80px",right:"20px",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontSize:"12px",zIndex:100,maxWidth:"280px"},children:[s.jsx("div",{style:{fontWeight:600,color:"#1a1a1a",marginBottom:"6px"},children:j.rowEl.name}),s.jsxs("div",{style:{color:"#6B7280",marginBottom:"4px"},children:["→"," ",j.colEl.name]}),s.jsx("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap"},children:j.cell.types.map(n=>s.jsx("span",{style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",background:(v[n]||"#6B7280")+"20",color:v[n]||"#6B7280",fontWeight:500},children:n},n))}),j.cell.flowItems.length>0&&s.jsxs("div",{style:{marginTop:"4px",color:"#9CA3AF",fontSize:"11px"},children:["Items: ",j.cell.flowItems.join(", ")]})]}),s.jsxs("div",{style:{marginTop:"20px",display:"flex",gap:"16px",flexWrap:"wrap",fontSize:"11px",color:"#6B7280"},children:[["flow","decomposedBy","composedOf","allocateTo","succession"].map(n=>s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[s.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"2px",background:v[n]||"#6B7280"}}),n]},n)),p&&e.clusters.size>1&&s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[s.jsx("span",{style:{width:"10px",height:"2px",background:"#2DD4A8"}}),"cluster boundary"]})]})]})]})}export{Q as DSMView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as f}from"./zustand-CrhqMOHB.js";import{u as x,f as m}from"./index-CVW92JY7.js";function j(i,d,s){var u,l;const n=Object.values(i.elements),o={},t={};for(const r of n)o[r.layer]=(o[r.layer]||0)+1,t[r.kind.toLowerCase()]=(t[r.kind.toLowerCase()]||0)+1;const a={};for(const r of i.relationships)a[r.type.toLowerCase()]=(a[r.type.toLowerCase()]||0)+1;return{totalElements:n.length,totalRelationships:i.relationships.length,violations:d,completenessPercent:s,riskCount:(o.risk||0)+(o.analysis||0),requirementsCount:o.requirements||0,architectureCount:["logical","physical","functional","logical_structure","software_structure","hardware_structure","functions","interfaces","system","context","operational","behavior"].reduce((r,p)=>r+(o[p]||0),0),verificationCount:(o.verification||0)+(o.assurance||0),hazardCount:t.hazard||0,requirementCount:Object.entries(t).filter(([r])=>r.endsWith("requirement")).reduce((r,[,p])=>r+p,0),riskControlCount:t.riskcontrol||0,systemCount:(t.system||0)+(t.subsystem||0)+(t.softwaresystem||0)+(t.logicalcomponent||0)+(t.hardwareassembly||0)+(t.softwarecomponent||0)+(t.processingnode||0),testCount:(t.verificationcase||0)+(t.validationcase||0)+(t.testartifact||0)+(t.test||0),mitigatesCount:Object.entries(a).filter(([r])=>r.startsWith("mitigat")).reduce((r,[,p])=>r+p,0),verificationLinkCount:Object.entries(a).filter(([r])=>r.startsWith("verif")||r.startsWith("validate")||r==="testedbyusability").reduce((r,[,p])=>r+p,0),diagramCount:((u=i.diagrams)==null?void 0:u.length)??0,projectName:((l=i.metadata)==null?void 0:l.projectName)||i.projectName||i.name||"My Device Project"}}function k(i){return i.totalElements===0?{icon:"🚀",title:"Add your first model elements",description:"Start with intended use, actors, and a system requirement. Or use the Workflow Wizard to guide you step by step.",urgency:"high"}:i.requirementCount===0?{icon:"📋",title:"Define your first requirement",description:"Your model has elements but no system requirements yet. Add a Requirement in the Model Explorer.",urgency:"high"}:i.hazardCount===0?{icon:"⚠️",title:"Add your first hazard",description:`You have ${i.requirementCount} requirement(s) but no hazard analysis yet. ISO 14971 requires hazard identification early.`,urgency:"high"}:i.hazardCount>0&&i.mitigatesCount===0?{icon:"🔗",title:"Connect hazards to risk controls",description:`You have ${i.hazardCount} hazard(s) but no MitigatesHazard relationships. Connect hazards to risk controls to complete the ISO 14971 chain.`,urgency:"high"}:i.systemCount===0?{icon:"🏗️",title:"Define your system architecture",description:"No architecture components found (SoftwareSystem, LogicalComponent, HardwareAssembly, …). Add an architecture layer to ground your requirements and risk analysis.",urgency:"medium"}:i.testCount===0?{icon:"🧪",title:"Add verification tests",description:`${i.requirementCount} requirement(s) have no verification tests yet. Add VerificationCases and link them to requirements with VerifiedBy.`,urgency:"medium"}:i.verificationLinkCount===0&&i.testCount>0?{icon:"↔️",title:"Link tests to requirements",description:"Verification cases exist but no VerifiedBy links found. Open the Traceability Matrix to connect tests to their requirements.",urgency:"medium"}:{icon:"✅",title:"Good coverage so far",description:"Requirements, hazards, and risk controls are in place. Check the GapBar (⌘⇧P) for completeness gaps before your review.",urgency:"low"}}function h({label:i,value:d,color:s,subtitle:n}){return e.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px 24px",display:"flex",flexDirection:"column",gap:"4px"},children:[e.jsx("div",{style:{fontSize:"28px",fontWeight:800,color:s,lineHeight:1},children:d}),e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"#374151"},children:i}),n&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function y({layer:i,label:d,count:s,color:n,onClick:o}){const t=s>0;return e.jsxs("button",{onClick:o,style:{background:t?`${n}12`:"#F9FAFB",border:`1px solid ${t?n+"30":"#E5E5E0"}`,borderRadius:"12px",padding:"16px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},onMouseEnter:a=>{a.currentTarget.style.background=t?`${n}20`:"#F3F4F6",a.currentTarget.style.transform="translateY(-1px)",a.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)"},onMouseLeave:a=>{a.currentTarget.style.background=t?`${n}12`:"#F9FAFB",a.currentTarget.style.transform="none",a.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:t?n:"#9CA3AF"},children:d}),e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:t?n+"20":"#F3F4F6",color:t?n:"#9CA3AF"},children:[s," elements"]})]}),e.jsx("div",{style:{width:"100%",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:t?n:"transparent",width:t?`${Math.min(100,s/10*100)}%`:"0",transition:"width 0.4s ease"}})}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"8px"},children:t?"Click to explore →":"Not started"})]})}function g({icon:i,label:d,onClick:s,variant:n="secondary"}){const o=n==="primary";return e.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:600,border:"none",background:o?"#1B3A4B":"rgba(255,255,255,0.7)",color:o?"#FFFFFF":"#374151",backdropFilter:"blur(4px)",transition:"all 0.15s"},onMouseEnter:t=>{t.currentTarget.style.background=o?"#244D63":"rgba(255,255,255,0.95)",t.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.1)"},onMouseLeave:t=>{t.currentTarget.style.background=o?"#1B3A4B":"rgba(255,255,255,0.7)",t.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:d})]})}function S(){var b;const i=x(c=>c.model),d=x(c=>c.validation),s=x(c=>c.completeness),n=x(c=>c.setActiveView),o=x(c=>c.setExplorerTab),t=x(c=>c.toggleGapBar),a=((b=d==null?void 0:d.violations)==null?void 0:b.length)??0,u=f.useMemo(()=>{if(typeof(s==null?void 0:s.overall)=="number")return Math.round(s.overall);if(!(s!=null&&s.layers)||s.layers.length===0)return 0;const c=s.layers.reduce((C,v)=>C+(v.completeness||0),0)/s.layers.length;return Math.round(c)},[s]),l=f.useMemo(()=>i?j(i,a,u):null,[i,a,u]),r=f.useMemo(()=>l?k(l):null,[l]);return!l||!i?e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"Loading dashboard…"})}):e.jsx("div",{style:{flex:1,overflowY:"auto",background:"linear-gradient(135deg, #EEF7F3 0%, #EAF2F8 55%, #F2EEF8 100%)",padding:"32px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{marginBottom:"28px"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:l.projectName}),e.jsxs("p",{style:{fontSize:"13px",color:"#4B6E80",margin:0},children:["Model dashboard · ",new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px",marginBottom:"24px"},children:[e.jsx(h,{label:"Elements",value:l.totalElements,color:"#1B3A4B"}),e.jsx(h,{label:"Relationships",value:l.totalRelationships,color:"#4A90D9"}),e.jsx(h,{label:"Completeness",value:`${u}%`,color:u>=70?"#2ECC71":u>=40?"#F39C12":"#E74C3C"}),e.jsx(h,{label:"Violations",value:a,color:a===0?"#2ECC71":"#E74C3C",subtitle:a===0?"All rules passing":"Open the GapBar"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",margin:"0 0 12px 0"},children:"Layer Coverage"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[e.jsx(y,{layer:"requirements",label:"Requirements",count:l.requirementsCount,color:m.requirements,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"risk",label:"Risk",count:l.riskCount,color:m.risk,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"logical",label:"Architecture",count:l.architectureCount,color:m.logical,onClick:()=>{o("views"),n({type:"welcome"})}}),e.jsx(y,{layer:"verification",label:"Verification",count:l.verificationCount,color:m.verification,onClick:()=>n({type:"traceability"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"24px"},children:[r&&e.jsxs("div",{style:{background:r.urgency==="high"?"rgba(231,76,60,0.06)":r.urgency==="medium"?"rgba(243,156,18,0.06)":"rgba(46,204,113,0.06)",border:`1px solid ${r.urgency==="high"?"#E74C3C30":r.urgency==="medium"?"#F39C1230":"#2ECC7130"}`,borderRadius:"12px",padding:"20px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"10px"},children:"💡 Suggested Next Step"}),e.jsx("div",{style:{fontSize:"16px",marginBottom:"6px"},children:r.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px"},children:r.title}),e.jsx("div",{style:{fontSize:"12px",color:"#4B6E80",lineHeight:"1.6"},children:r.description}),r.urgency!=="low"&&e.jsx("button",{onClick:()=>n({type:"workflow-wizard"}),style:{marginTop:"14px",padding:"8px 14px",fontSize:"12px",fontWeight:600,background:"#1B3A4B",color:"#FFFFFF",border:"none",borderRadius:"6px",cursor:"pointer"},onMouseEnter:c=>c.currentTarget.style.background="#244D63",onMouseLeave:c=>c.currentTarget.style.background="#1B3A4B",children:"Open Workflow Wizard →"})]}),e.jsxs("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"20px",backdropFilter:"blur(4px)"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"14px"},children:"Quick Actions"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(g,{icon:"🗂️",label:"Browse Model",onClick:()=>{o("model")}}),e.jsx(g,{icon:"📊",label:"Open Viewpoints",onClick:()=>o("views")}),e.jsx(g,{icon:"↔️",label:"Traceability Matrix",onClick:()=>n({type:"traceability"})}),e.jsx(g,{icon:"📋",label:"First Review Dashboard",onClick:()=>n({type:"review-dashboard"})}),e.jsx(g,{icon:"✅",label:"Check Completeness",onClick:()=>t()}),e.jsx(g,{icon:"📈",label:"Full Statistics",onClick:()=>n({type:"statistics"})})]})]})]}),l.diagramCount>0&&e.jsx("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"16px 20px",backdropFilter:"blur(4px)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:[l.diagramCount," model view",l.diagramCount!==1?"s":""," in this project"]}),e.jsx("button",{onClick:()=>o("views"),style:{fontSize:"12px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Browse viewpoints →"})]})})]})})}export{S as Dashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as d}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-CVW92JY7.js";const y=[{value:"",label:"— Select phase —"},{value:"concept",label:"Concept"},{value:"design",label:"Design & Development"},{value:"verification",label:"Verification & Validation"},{value:"production",label:"Production"}],i={width:"100%",padding:"7px 10px",border:"1px solid #D1D5DB",borderRadius:"6px",fontSize:"13px",color:"#1B3A4B",background:"#fff",boxSizing:"border-box",outline:"none",fontFamily:"inherit"},n={fontSize:"11px",fontWeight:600,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.04em",display:"block",marginBottom:"4px"},s={fontSize:"12px",fontWeight:700,color:"#1B3A4B",paddingBottom:"6px",borderBottom:"1px solid #E5E7EB",marginBottom:"12px",marginTop:"4px"},j={display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"};function C({onClose:a}){const c=p(o=>o.dhfSettings),x=p(o=>o.updateDhfSettings),[l,g]=d.useState({...c}),[r,h]=d.useState("identity");function t(o,m){g(f=>({...f,[o]:m}))}function u(){x(l),a()}return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onClick:o=>{o.target===o.currentTarget&&a()},children:e.jsxs("div",{style:{background:"#fff",borderRadius:"12px",width:"560px",maxHeight:"86vh",display:"flex",flexDirection:"column",boxShadow:"0 24px 60px rgba(0,0,0,0.22)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px 20px",borderBottom:"1px solid #E5E7EB",flexShrink:0},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#6B7280",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{style:{fontSize:"15px",fontWeight:700,color:"#1B3A4B",flex:1},children:"DHF Global Settings"}),e.jsx("button",{onClick:a,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",fontSize:"20px",lineHeight:1,padding:"0 2px"},children:"×"})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid #E5E7EB",flexShrink:0,padding:"0 20px"},children:["identity","branding","layout"].map(o=>e.jsx("button",{onClick:()=>h(o),style:{padding:"10px 14px",border:"none",background:"none",fontSize:"12px",fontWeight:600,cursor:"pointer",color:r===o?"#1B3A4B":"#9CA3AF",borderBottom:`2px solid ${r===o?"#2DD4A8":"transparent"}`,marginBottom:"-1px",textTransform:"capitalize"},children:o==="identity"?"Project":o==="branding"?"Branding":"Layout"},o))}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:[r==="identity"&&e.jsxs("div",{children:[e.jsx("p",{style:s,children:"Project Identity"}),e.jsxs("p",{style:{fontSize:"12px",color:"#6B7280",marginBottom:"16px",lineHeight:"1.5"},children:["These values resolve ",e.jsx("code",{style:{background:"#F3F4F6",padding:"1px 4px",borderRadius:"3px"},children:"{{project.*}}"})," directives in all templates and the AI drafting context."]}),e.jsxs("div",{style:j,children:[e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Company / Manufacturer"}),e.jsx("input",{style:i,value:l.company,onChange:o=>t("company",o.target.value),placeholder:"Acme Medical Devices Inc."})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Product / Device Name"}),e.jsx("input",{style:i,value:l.product,onChange:o=>t("product",o.target.value),placeholder:"InfuSafe IV Pump"})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Device Type"}),e.jsx("input",{style:i,value:l.deviceType,onChange:o=>t("deviceType",o.target.value),placeholder:"Class II active implantable"})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Document Version"}),e.jsx("input",{style:i,value:l.version,onChange:o=>t("version",o.target.value),placeholder:"1.0.0"})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:n,children:"Development Phase"}),e.jsx("select",{style:i,value:l.phase,onChange:o=>t("phase",o.target.value),children:y.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:n,children:"Document ID Prefix"}),e.jsx("input",{style:{...i,fontFamily:"monospace"},value:l.documentNumberingPrefix,onChange:o=>t("documentNumberingPrefix",o.target.value),placeholder:"DOC"}),e.jsxs("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:["Used in document IDs, e.g. ",e.jsxs("code",{children:[l.documentNumberingPrefix||"DOC","-RMP-001"]})]})]})]})]}),r==="branding"&&e.jsxs("div",{children:[e.jsx("p",{style:s,children:"Branding"}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",marginBottom:"16px",lineHeight:"1.5"},children:"Branding applied to exported HTML and DOCX documents. Per-document overrides can be set in the document's frontmatter."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"14px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Full Logo URL"}),e.jsx("input",{style:i,value:l.logoUrl,onChange:o=>t("logoUrl",o.target.value),placeholder:"https://... or data:image/png;base64,..."}),e.jsx("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:"Shown in document cover pages and report headers."}),l.logoUrl&&e.jsx("img",{src:l.logoUrl,alt:"Logo preview",style:{maxHeight:"48px",maxWidth:"200px",marginTop:"8px",border:"1px solid #E5E7EB",borderRadius:"4px",padding:"4px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Compact Logo URL"}),e.jsx("input",{style:i,value:l.compactLogoUrl,onChange:o=>t("compactLogoUrl",o.target.value),placeholder:"https://... or data:image/png;base64,..."}),e.jsx("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:"Shown in page headers (small). Falls back to Full Logo if empty."}),l.compactLogoUrl&&e.jsx("img",{src:l.compactLogoUrl,alt:"Compact logo preview",style:{maxHeight:"28px",maxWidth:"120px",marginTop:"8px",border:"1px solid #E5E7EB",borderRadius:"4px",padding:"4px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Primary Color"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("input",{type:"color",value:l.primaryColor,onChange:o=>t("primaryColor",o.target.value),style:{width:"40px",height:"32px",padding:"2px",border:"1px solid #D1D5DB",borderRadius:"6px",cursor:"pointer"}}),e.jsx("input",{style:{...i,flex:1,fontFamily:"monospace"},value:l.primaryColor,onChange:o=>t("primaryColor",o.target.value),placeholder:"#1B3A4B"})]}),e.jsx("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:"Used for headings, table headers, and badges in exported documents."})]})]})]}),r==="layout"&&e.jsxs("div",{children:[e.jsx("p",{style:s,children:"Document Layout"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{children:[e.jsxs("label",{style:{...n,display:"flex",alignItems:"center",gap:"8px",textTransform:"none",fontSize:"13px",fontWeight:600,color:"#1B3A4B",marginBottom:0},children:[e.jsx("input",{type:"checkbox",checked:l.compactMode,onChange:o=>t("compactMode",o.target.checked),style:{accentColor:"#2DD4A8"}}),"Compact mode"]}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",marginTop:"4px",marginLeft:"20px"},children:"Tighter line spacing and smaller heading sizes. Useful for regulatory submissions."})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Page Header Template"}),e.jsx("input",{style:{...i,fontFamily:"monospace",fontSize:"12px"},value:l.headerTemplate,onChange:o=>t("headerTemplate",o.target.value)}),e.jsxs("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:["Tokens: ",e.jsx("code",{children:"{{id}}"}),", ",e.jsx("code",{children:"{{title}}"}),", ",e.jsx("code",{children:"{{project.product}}"}),", ",e.jsx("code",{children:"{{project.version}}"}),", ",e.jsx("code",{children:"{{date}}"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Page Footer Template"}),e.jsx("input",{style:{...i,fontFamily:"monospace",fontSize:"12px"},value:l.footerTemplate,onChange:o=>t("footerTemplate",o.target.value)}),e.jsxs("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:["Tokens: same as header, plus ",e.jsx("code",{children:"{{page}}"})," and ",e.jsx("code",{children:"{{pages}}"})]})]})]})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",padding:"14px 20px",borderTop:"1px solid #E5E7EB",flexShrink:0,background:"#FAFAFA"},children:[e.jsx("button",{onClick:a,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #D1D5DB",background:"#fff",fontSize:"13px",cursor:"pointer",color:"#374151"},children:"Cancel"}),e.jsx("button",{onClick:u,style:{padding:"8px 20px",borderRadius:"6px",border:"none",background:"#2DD4A8",fontSize:"13px",fontWeight:600,cursor:"pointer",color:"#065F46"},children:"Save Settings"})]})]})})}export{C as DhfSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var qs=Object.defineProperty;var Zs=(t,i,n)=>i in t?qs(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n;var no=(t,i,n)=>Zs(t,typeof i!="symbol"?i+"":i,n);import{j as e,u as Hn,H as N,P as k,N as tt,a as xo,B as _n,E as po,R as Qs,b as Js,c as ei,d as ti,e as oi,i as ni,C as si,f as ii,g as ri,M as ai}from"./reactflow-CsCqNKB-.js";import{b as li,a as d,W as Sn}from"./zustand-CrhqMOHB.js";/* empty css */import{F as D,S as ce,z as ci,u as O,A as Kn,f as uo,g as di,D as vn,B as je,r as pi,i as kn,G as ui,R as Cn,V as En,C as In}from"./index-CVW92JY7.js";import{c as hi,a as xi,b as gi,d as fi,e as mi,f as yi,g as bi,h as Fi,i as wi,j as ji,k as Si,I as go,l as vi,P as At,s as ki,u as Ci,m as Ei,G as so,n as Ii,o as Di,C as Mt,p as Ni,r as Ai,q as io,t as Mi,v as Bi,w as zi,x as Dn,y as Ti,z as Ri,A as Li,B as $i,D as Wi,E as Oi,R as Pi,F as Hi}from"./layout-selection-ClQ295Xc.js";import"./layout-providers-Dr743WlP.js";import"./elk-6l8mIQnQ.js";function _i(t,i,n="both",a=10){const r=t.elements[i];if(!r)return{rootId:i,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const l=new Map,p=new Map;for(const h of t.relationships)l.has(h.sourceId)||l.set(h.sourceId,[]),l.get(h.sourceId).push(h),p.has(h.targetId)||p.set(h.targetId,[]),p.get(h.targetId).push(h);const f=new Set;f.add(i);const w=[],F=[],I=[[i,0]];for(;I.length>0;){const[h,C]=I.shift();if(C>=a)continue;const j=C+1;if(n==="downstream"||n==="both")for(const m of l.get(h)||[]){const A=m.targetId;if(F.push({fromId:h,toId:A,relType:m.type,relId:m.id}),!f.has(A)){f.add(A);const b=t.elements[A];b&&(w.push({elementId:A,name:b.name,kind:b.kind,layer:b.layer,depth:j,viaRelType:m.type,direction:"downstream"}),I.push([A,j]))}}if(n==="upstream"||n==="both")for(const m of p.get(h)||[]){const A=m.sourceId;if(F.push({fromId:A,toId:h,relType:m.type,relId:m.id}),!f.has(A)){f.add(A);const b=t.elements[A];b&&(w.push({elementId:A,name:b.name,kind:b.kind,layer:b.layer,depth:j,viaRelType:m.type,direction:"upstream"}),I.push([A,j]))}}}return w.sort((h,C)=>h.depth-C.depth||h.name.localeCompare(C.name)),{rootId:i,rootName:r.name,rootKind:r.kind,nodes:w,edges:F}}function Ki(t,i=[]){let a=t.replace(/[^A-Za-z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map((p,f)=>f===0?p.charAt(0).toLowerCase()+p.slice(1):p.charAt(0).toUpperCase()+p.slice(1)).join("");a||(a="element"),/^[0-9]/.test(a)&&(a=`n${a}`);const r=new Set(i);if(!r.has(a))return a;let l=2;for(;r.has(`${a}${l}`);)l++;return`${a}${l}`}function Vi(t){return t&&t.replace(/\s+(def|usage)$/,"").trim()||"part"}const Yi=[{value:"",label:"Default"},{value:"#FEF3C7",label:"Amber"},{value:"#DCFCE7",label:"Green"},{value:"#DBEAFE",label:"Blue"},{value:"#FCE7F3",label:"Pink"},{value:"#E5E7EB",label:"Grey"}],Ze={display:"flex",alignItems:"center",gap:2},Qe={width:1,height:18,background:"#E2E8F0",margin:"0 4px",flexShrink:0};function le({title:t,label:i,onClick:n}){return e.jsx("button",{title:t,"aria-label":t,onClick:n,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:i})}function Xi({count:t,onAlign:i,onMatchSize:n,onDistribute:a,onFill:r,onOpacity:l,opacity:p}){return e.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:[e.jsxs("span",{style:{fontSize:D.xs,color:"#6B7280",fontWeight:700,paddingRight:2},children:[t," selected"]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:"Align left edges",label:"⇤",onClick:()=>i("left")}),e.jsx(le,{title:"Align horizontal centres",label:"⇹",onClick:()=>i("centerX")}),e.jsx(le,{title:"Align right edges",label:"⇥",onClick:()=>i("right")}),e.jsx(le,{title:"Align top edges",label:"⤒",onClick:()=>i("top")}),e.jsx(le,{title:"Align vertical centres",label:"⇳",onClick:()=>i("centerY")}),e.jsx(le,{title:"Align bottom edges",label:"⤓",onClick:()=>i("bottom")})]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:"Match width to the widest",label:"↔",onClick:()=>n("width")}),e.jsx(le,{title:"Match height to the tallest",label:"↕",onClick:()=>n("height")}),e.jsx(le,{title:"Match width and height",label:"⤢",onClick:()=>n("both")})]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:t>=3?"Even horizontal gaps":"Even horizontal gaps (needs 3 blocks)",label:"⇿",onClick:()=>a("horizontal")}),e.jsx(le,{title:t>=3?"Even vertical gaps":"Even vertical gaps (needs 3 blocks)",label:"⇕",onClick:()=>a("vertical")})]}),e.jsx("span",{style:Qe}),e.jsx("div",{style:Ze,children:Yi.map(f=>e.jsx("button",{title:`Fill: ${f.label}`,"aria-label":`Fill ${f.label}`,onClick:()=>r(f.value),style:{width:20,height:20,padding:0,borderRadius:4,cursor:"pointer",border:"1px solid #CBD5E1",background:f.value||"#FFFFFF",color:"#94A3B8",fontSize:11,lineHeight:1,fontWeight:700},children:f.value?"":"⌫"},f.label))}),e.jsx("span",{style:Qe}),e.jsxs("label",{title:"Fill opacity",style:{display:"flex",alignItems:"center",gap:5,fontSize:D.xs,color:"#6B7280"},children:[e.jsx("span",{style:{fontWeight:700},children:"Opacity"}),e.jsx("input",{type:"range",min:20,max:100,step:5,value:Math.round(p*100),onChange:f=>l(Number(f.target.value)/100),style:{width:72,accentColor:"#2DD4A8"}}),e.jsxs("span",{style:{width:30,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[Math.round(p*100),"%"]})]}),e.jsx("div",{style:Ze,"aria-label":"Opacity presets",children:[1,.75,.5].map(f=>e.jsx("button",{"aria-label":`Set opacity to ${Math.round(f*100)}%`,title:`Set opacity to ${Math.round(f*100)}%`,onClick:()=>l(f),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(f*100)},f))})]})}function Gi(t,i){if(t.length===0)return;const n=a=>t.reduce((r,l)=>a(l,r)?l:r);switch(i){case"left":return n((a,r)=>a.x<r.x);case"right":return n((a,r)=>a.x+a.width>r.x+r.width);case"top":return n((a,r)=>a.y<r.y);case"bottom":return n((a,r)=>a.y+a.height>r.y+r.height);case"centerX":return n((a,r)=>a.width>r.width);case"centerY":return n((a,r)=>a.height>r.height)}}function Ui(t,i){const n=new Map,a=Gi(t,i);if(!a||t.length<2)return n;for(const r of t){let l;switch(i){case"left":l=a.x;break;case"right":l=a.x+a.width-r.width;break;case"centerX":l=a.x+a.width/2-r.width/2;break;case"top":l=a.y;break;case"bottom":l=a.y+a.height-r.height;break;case"centerY":l=a.y+a.height/2-r.height/2;break}const p=i==="left"||i==="right"||i==="centerX",f=p?r.x:r.y;Math.abs(f-l)<.5||n.set(r.id,p?{x:l}:{y:l})}return n}function qi(t,i){const n=new Map;if(t.length<2)return n;const a=Math.max(...t.map(l=>l.width)),r=Math.max(...t.map(l=>l.height));for(const l of t){const p={};i!=="height"&&Math.abs(l.width-a)>=.5&&(p.width=a),i!=="width"&&Math.abs(l.height-r)>=.5&&(p.height=r),Object.keys(p).length>0&&n.set(l.id,p)}return n}function Zi(t,i){const n=new Map;if(t.length<3)return n;const a=i==="horizontal",r=j=>a?j.x:j.y,l=j=>a?j.width:j.height,p=[...t].sort((j,m)=>r(j)-r(m)),f=p[0],w=p[p.length-1],F=r(w)+l(w)-r(f),I=p.reduce((j,m)=>j+l(m),0),h=(F-I)/(p.length-1);if(!Number.isFinite(h)||h<0)return n;let C=r(f)+l(f)+h;for(const j of p.slice(1,-1))Math.abs(r(j)-C)>=.5&&n.set(j.id,a?{x:C}:{y:C}),C+=l(j)+h;return n}const ot=li(t=>({subject:null,publish:i=>t({subject:i})})),et=t=>ot.getState().publish(t),Vn=t=>{var i,n;return[t.source,t.target,(i=t.data)==null?void 0:i.sourcePortId,(n=t.data)==null?void 0:n.targetPortId].filter(a=>!!a)},Qi=(t,i)=>t.edgeId===i.id||Vn(i).some(n=>t.endpointIds.includes(n)),fo=()=>ot(t=>t.subject!==null),Ji=t=>ot(i=>{var n;return((n=i.subject)==null?void 0:n.endpointIds.includes(t))??!1}),Yn=(t,i)=>ot(n=>{const a=n.subject;return a?a.edgeId===t||i.some(r=>r!==void 0&&a.endpointIds.includes(r)):!1}),er=t=>`.react-flow__edge[data-id="${CSS.escape(t)}"]`;function tr(){const t=ot(a=>a.subject),i=Hn(a=>t?a.edges.filter(r=>Qi(t,r)).map(r=>r.id).join("\0"):"");if(!t)return null;const n=i?i.split("\0").map(er).join(","):"";return e.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",n?`${n}{opacity:1}`:""]})}class or{constructor(){no(this,"providers",[]);no(this,"byId",new Map)}register(i,n){const a=this.byId.get(i.descriptor.id);if(a&&a!==i)throw new Error(`Template provider already registered: ${i.descriptor.id}`);if(a)return;this.byId.set(i.descriptor.id,i);const r=n?this.providers.findIndex(l=>l.descriptor.id===n):-1;r>=0?this.providers.splice(r,0,i):this.providers.push(i)}unregister(i){const n=this.byId.get(i);return n?(this.byId.delete(i),this.providers.splice(this.providers.indexOf(n),1),!0):!1}get(i){return this.byId.get(i)}has(i){return this.byId.has(i)}list(){return this.providers.map(i=>i.descriptor)}select(i){const n=this.providers.find(a=>a.matches(i));if(!n)throw new Error("No diagram template matches this view — register a catch-all provider");return n}}const Xn=new or,nr=[{descriptor:{id:"memo.template.fbs",name:"Functional Breakdown",label:"FBS",contractVersion:"1",interactive:!0,description:"Functional breakdown structure — functions per realising component."},matches:t=>t.isFBSDiagram,compute:(t,i)=>hi(t,i.fbs)},{descriptor:{id:"memo.template.decomposition",name:"Decomposition Tree",label:"Decomposition",contractVersion:"1",interactive:!0,description:"Expandable decomposition tree over composition relationships."},matches:t=>t.isDecompDiagram&&t.layoutStyle==="decomposition",compute:(t,i)=>xi(t,i.decomposition)},{descriptor:{id:"memo.template.containment",name:"Containment Blocks",label:"Containment",contractVersion:"1",interactive:!0,description:"Nested containment blocks over composition relationships."},matches:t=>t.isDecompDiagram,compute:(t,i)=>gi(t,i.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:t=>t.diagramType==="ucd",compute:(t,i)=>fi(t,i.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:t=>t.diagramType==="context",compute:(t,i)=>mi(t,i.context.systemName,i.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:t=>t.viewKind==="interconnection",compute:(t,i)=>yi(t,i.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:t=>t.viewKind==="actionflow",compute:(t,i)=>bi(t,i.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:t=>t.viewKind==="statetransition",compute:(t,i)=>Fi(t,i.statetransition)},{descriptor:{id:"memo.template.sequence",name:"Sequence",label:"Sequence",contractVersion:"1",interactive:!1,description:"Lifelines with chronological messages (KK-6)."},matches:t=>t.viewKind==="sequence",compute:(t,i)=>wi(t,i.sequence)},{descriptor:{id:"memo.template.general",name:"General (structured)",label:"General",contractVersion:"1",interactive:!0,description:"General template tree/containment modes (KK-2)."},matches:t=>t.isGeneralTemplate&&t.generalMode!=="graph",compute:(t,i)=>ji(t,i.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:(t,i)=>Si(t,i.standard)}];for(const t of nr)Xn.register(t);function nt({color:t="#334155",size:i=38}){const n=Math.round(i*1.42);return e.jsxs("svg",{width:i,height:n,viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:t,strokeWidth:"2",children:[e.jsx("circle",{cx:"19",cy:"8",r:"6",fill:"#FFFFFF"}),e.jsx("path",{d:"M19 14v18M6 23h26M19 32L8 49M19 32l11 17",strokeLinecap:"round"})]})}const mo=t=>t==="Actor"||t==="User";function sr({data:t}){const i=t,{element:n,layerColor:a,isExpanded:r,hasChildren:l,childCount:p,direction:f,onToggleExpand:w,onToggleDirection:F,showDirectionButton:I,depthBgColor:h,isContainer:C}=i,j=f==="vertical"?"V":"H",m=C&&r;return e.jsxs("div",{style:{background:m?h||"#FAFAF9":"#FFFFFF",borderLeft:m?`2px solid ${a}40`:`3px solid ${a}`,borderTop:`1px solid ${m?a+"30":"#E5E5E0"}`,borderRight:`1px solid ${m?a+"30":"#E5E5E0"}`,borderBottom:`1px solid ${m?a+"30":"#E5E5E0"}`,borderRadius:3,padding:m?"0":"8px 12px",minWidth:m?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[e.jsx(N,{type:"target",position:k.Top,id:"top",style:vt}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:vt}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:vt}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:vt}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:m?"8px 12px":"0"},children:[mo(n.kind)&&e.jsx(nt,{size:24,color:a}),l&&e.jsx("button",{onClick:A=>{A.stopPropagation(),w()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${a}`,background:r?a+"12":"#FFFFFF",color:a,fontSize:D.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:r?"Collapse":"Expand",children:r?"−":"+"}),l&&I&&e.jsx("button",{onClick:A=>{A.stopPropagation(),F()},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: ${f}. Click to toggle`,children:j}),e.jsx("span",{style:{fontSize:D.md,fontWeight:600,color:m?a:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.name})]}),!m&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:l?"26px":"14px"},children:[e.jsx("span",{style:{fontSize:D.badge,color:"#9CA3AF"},children:n.kind}),l&&e.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[p," parts",r?"":" (collapsed)"]})]})]})}const vt={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},ir=d.memo(sr),Nn={top:k.Top,bottom:k.Bottom,left:k.Left,right:k.Right},rr={top:"bottom",bottom:"top",left:"right",right:"left"},ar="#6B7280",Gn=t=>t?At[t]:ar;function Un(t,i){if(t==="inout")return"⇄";if(!t)return"";const n=t==="in";switch(i){case"left":return n?"→":"←";case"right":return n?"←":"→";case"top":return n?"↓":"↑";default:return n?"↑":"↓"}}const lr=104,An=40,qn=t=>({opacity:0,width:t,height:t,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"}),cr=t=>({...qn(t),pointerEvents:"auto",cursor:"crosshair",zIndex:12});function dr({port:t,onMove:i}){const{getZoom:n}=xo(),a=Hn(h=>h.transform[2]),r=Ji(t.id),l=fo()&&!r,p=t.size??go,f=p+5,w=Gn(t.direction),F=t.side==="left"||t.side==="right",I={position:"absolute",fontSize:t.nested?"9.5px":"10.5px",fontWeight:r?750:t.nested?600:650,color:r?"#0F172A":t.nested?"#6B7280":"#374151",opacity:l?.45:1,transition:"color 120ms ease, opacity 120ms ease",whiteSpace:"normal",pointerEvents:"none",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,width:F?lr:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...t.side==="left"?{left:f,bottom:"50%",marginBottom:2}:t.side==="right"?{right:f,bottom:"50%",marginBottom:2,textAlign:"right"}:t.side==="top"?{top:f,left:"50%",transform:"translateX(-50%)"}:{bottom:f,left:"50%",transform:"translateX(-50%)"}};return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:t.x,top:t.y,width:p,height:p,zIndex:t.nested?11:10},children:[e.jsx("div",{onPointerEnter:()=>et({endpointIds:[t.id]}),onPointerLeave:()=>et(null),onPointerDown:i?h=>{h.preventDefault(),h.stopPropagation();const C=h.clientY,j=t.y,m=b=>i(j+(b.clientY-C)/n()),A=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",A)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",A,{once:!0})}:void 0,title:`${t.name}${t.direction?` (${t.direction})`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:An,height:An,transform:`translate(-50%, -50%) scale(${1/Math.max(a,.1)})`,cursor:i?"grab":"default",touchAction:"none"}}),e.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${w}`,borderRadius:5,boxShadow:r?`0 0 0 4px ${w}33, 0 2px 8px rgba(15,23,42,0.24)`:"0 1px 3px rgba(15,23,42,0.18)",opacity:l?.5:1,display:"flex",alignItems:"center",justifyContent:"center",color:w,fontSize:t.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[Un(t.direction,t.side),e.jsx("span",{style:I,children:t.name.replace(/([a-z0-9])([A-Z])/g,"$1$2")}),[{suffix:"",pos:Nn[t.side],connectable:!0},{suffix:vi,pos:Nn[rr[t.side]],connectable:!1}].flatMap(h=>{const C=h.connectable?"ibd-port-connect":"ibd-port-anchor",j=h.connectable?cr(p):qn(p);return[e.jsx(N,{className:C,type:"source",id:`${t.id}${h.suffix}`,position:h.pos,style:j,isConnectable:h.connectable},`s${h.suffix}`),e.jsx(N,{className:C,type:"target",id:`${t.id}${h.suffix}`,position:h.pos,style:j,isConnectable:h.connectable},`t${h.suffix}`)]})]})]})}function Mn({side:t,direction:i}){const n=Gn(i),a=go;return e.jsx("div",{"aria-label":`implicit ${i} port`,title:`Implicit ${i} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:t==="left"?-a/2:void 0,right:t==="right"?-a/2:void 0,transform:"translateY(-50%)",width:a,height:a,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${n}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:n,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:Un(i,t)})}const kt={width:8,height:8,background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0};function Bn({name:t,kind:i,nameColor:n,typeColor:a,frame:r=!1}){return e.jsxs("span",{title:`${t} : ${i}`,style:{display:"flex",flexDirection:r?"row":"column",alignItems:r?"baseline":"flex-start",gap:r?6:1,minWidth:0,overflow:"hidden",flex:1},children:[e.jsx("span",{style:{display:r?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:r?D.md:D.sm,lineHeight:1.2,fontWeight:700,color:n,whiteSpace:r?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:r?void 0:2,overflowWrap:"anywhere"},children:t}),e.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r?`: ${i}`:`«${i}»`})]})}function pr({label:t,onDrillIn:i,color:n,onColor:a}){return e.jsx("button",{"aria-label":`Drill into ${t}`,title:`Open ${t} as its own internal block diagram`,className:"nodrag",onClick:r=>{r.stopPropagation(),i()},onDoubleClick:r=>r.stopPropagation(),style:{width:18,height:18,padding:0,borderRadius:3,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:a?"1px solid rgba(255,255,255,0.7)":`1px solid ${n}88`,background:a?"rgba(255,255,255,0.18)":"#FFFFFF",color:a?"#FFFFFF":n,fontSize:11,lineHeight:1,cursor:"pointer",fontWeight:700},children:"↳"})}function zn({label:t,isCollapsed:i,onToggle:n,color:a,onColor:r}){return e.jsx("button",{"aria-label":i?`Expand ${t}`:`Collapse ${t}`,onClick:l=>{l.stopPropagation(),n()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:r?"1px solid rgba(255,255,255,0.7)":`1px solid ${a}88`,background:r?"rgba(255,255,255,0.18)":"#FFFFFF",color:r?"#FFFFFF":a,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:i?"+":"−"})}function ur({id:t,data:i,selected:n,height:a}){const r=i,{label:l,kind:p,color:f,isContainer:w,isFrame:F,ports:I,implicitIn:h,implicitOut:C,onPortMove:j,hasChildren:m,isCollapsed:A,onToggleCollapse:b,onDrillIn:v,minWidth:T,minHeight:W,bgColor:E,fillOpacity:R}=r,[Q,H]=d.useState(!1),z=n?ce.selected:F?"none":Q?"0 8px 20px rgba(15,23,42,0.12)":w?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)";return e.jsxs("div",{onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:E||"#FFFFFF",opacity:R??1,border:F?"1.5px solid #94A3B8":`1px solid ${Q?f+"9A":"#CBD5E1"}`,...F?{}:{borderTop:`3px solid ${f}`},borderRadius:F?10:8,boxShadow:z,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[!F&&e.jsx(tt,{nodeId:t,isVisible:n,minWidth:T??180,minHeight:W??100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),e.jsx(N,{type:"target",position:k.Top,id:"top",style:kt}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:kt}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:kt}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:kt}),F?e.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:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:f,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),e.jsx(Bn,{name:l,kind:p,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),m&&b&&e.jsx(zn,{label:l,isCollapsed:A,onToggle:b,color:f})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:m?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[mo(p)&&e.jsx(nt,{size:24,color:f}),e.jsx(Bn,{name:l,kind:p,nameColor:"#0F172A",typeColor:w?f:"#64748B"}),m&&v&&e.jsx(pr,{label:l,onDrillIn:v,color:f}),m&&b&&e.jsx(zn,{label:l,isCollapsed:A,onToggle:b,color:f})]}),I.map(q=>e.jsx(dr,{port:q,onMove:j?S=>{const te=q.size??go,K=(F||w?70:62)-te/2,X=Math.max(K,(a??K+te+18)-te-18);j(q.id,Math.min(Math.max(S,K),X))}:void 0},q.id)),h&&e.jsx(Mn,{side:"left",direction:"in"}),C&&e.jsx(Mn,{side:"right",direction:"out"})]})}const hr=d.memo(ur);function Tn(t,i){const n=t.map(r=>({...r}));let a=i;for(;n.length>=2&&a>0;){const r=n[0],l=n[1],p=Math.hypot(l.x-r.x,l.y-r.y);if(p<=a)a-=p,n.shift();else{const f=a/p;n[0]={x:r.x+(l.x-r.x)*f,y:r.y+(l.y-r.y)*f},a=0}}return n}function xr(t,i){const n=Tn(t,i);return Tn([...n].reverse(),i).reverse()}const gr=t=>t.slice(1).reduce((i,n,a)=>i+Math.hypot(n.x-t[a].x,n.y-t[a].y),0);function Ct(t,i=7){if(t.length<2)return"";let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],p=t[r],f=t[r+1],w=Math.hypot(p.x-l.x,p.y-l.y),F=Math.hypot(f.x-p.x,f.y-p.y),I=Math.min(i,w/2,F/2),h=p.x-Math.sign(p.x-l.x)*I,C=p.y-Math.sign(p.y-l.y)*I,j=p.x+Math.sign(f.x-p.x)*I,m=p.y+Math.sign(f.y-p.y)*I;n+=` L ${h},${C} Q ${p.x},${p.y} ${j},${m}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}function fr(t){let i=0,n=-1;for(let p=1;p<t.length;p++){const f=Math.abs(t[p].x-t[p-1].x)+Math.abs(t[p].y-t[p-1].y);f>n&&(n=f,i=p)}const a=t[i-1],r=t[i],l=Math.abs(r.x-a.x)>=Math.abs(r.y-a.y)?{x:0,y:-14}:{x:14,y:0};return{x:(a.x+r.x)/2+l.x,y:(a.y+r.y)/2+l.y}}function mr(t){var A,b,v,T,W,E,R,Q,H,z,q;const{getZoom:i}=xo(),n=Yn(t.id,[t.source,t.target,(A=t.data)==null?void 0:A.sourcePortId,(b=t.data)==null?void 0:b.targetPortId]),a=fo()&&!n,r=((v=t.data)==null?void 0:v.points)??[];if(r.length<2)return null;const l=String(((T=t.style)==null?void 0:T.stroke)??"#2563EB"),p=Number(((W=t.style)==null?void 0:W.strokeWidth)??2),f=n?{...t.style,strokeWidth:p+1.4}:t.style,w=((E=t.data)==null?void 0:E.labelPoint)??fr(r),F=Math.min(28/Math.max(i(),.1),gr(r)*.3),I=xr(r,F),h=(R=t.data)==null?void 0:R.onRouteChange,C=(Q=t.data)==null?void 0:Q.onSelect,j=!!((H=t.data)!=null&&H.flowAnimation),m=r.length===2?[{index:1,a:r[0],b:r[1],straight:!0}]:r.slice(1).map((S,te)=>({index:te+1,a:r[te],b:S,straight:!1})).filter(S=>S.index>=2&&S.index<=r.length-2);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:Ct(r),fill:"none",stroke:l,strokeOpacity:.22,strokeWidth:p+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(_n,{id:t.id,path:Ct(r),style:f,markerEnd:t.markerEnd}),j&&e.jsx("path",{d:Ct(r),fill:"none",stroke:String(((z=t.style)==null?void 0:z.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((q=t.style)==null?void 0:q.strokeWidth)??2)),className:"memo-ibd-flow"}),I.length>=2&&e.jsx("path",{d:Ct(I),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(i(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:S=>C==null?void 0:C(S)}),t.label?e.jsx(po,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w.x}px, ${w.y}px)`,fontSize:D.badge,fontWeight:n?700:600,color:n?"#0F172A":"#475569",background:"rgba(255,255,255,0.96)",border:`1px solid ${n?l:"#E2E8F0"}`,opacity:a?.25:1,padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:t.label})}):null,t.selected&&h?m.map(S=>{const te=(S.a.x+S.b.x)/2,K=(S.a.y+S.b.y)/2;return e.jsx(po,{children:e.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:X=>{X.preventDefault(),X.stopPropagation();const st=X.clientX,it=X.clientY,ve=Ae=>{const re=(Ae.clientX-st)/i(),ge=(Ae.clientY-it)/i();if(S.straight){if(Math.abs(ge)>=Math.abs(re)){const ae=S.a.y+ge;h([S.a,{x:S.a.x,y:ae},{x:S.b.x,y:ae},S.b])}else{const ae=(S.a.x+S.b.x)/2+re;h([S.a,{x:ae,y:S.a.y},{x:ae,y:S.b.y},S.b])}return}const Z=r.map(ae=>({...ae}));S.a.y===S.b.y?(Z[S.index-1].y=S.a.y+ge,Z[S.index].y=S.b.y+ge):(Z[S.index-1].x=S.a.x+re,Z[S.index].x=S.b.x+re),h(Z)},Ne=()=>{window.removeEventListener("pointermove",ve),window.removeEventListener("pointerup",Ne)};window.addEventListener("pointermove",ve),window.addEventListener("pointerup",Ne,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${te}px, ${K}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:S.a.y===S.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${S.index}`)}):null]})}const yr=d.memo(mr);function br({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Fr({data:t,selected:i}){const n=t,{nodeType:a,label:r,laneColor:l,layerColor:p,inPorts:f,outPorts:w}=n,[F,I]=d.useState(!1);if(a==="start")return e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:ce.sm},children:e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:"#374151",width:6,height:6}})});if(a==="done")return e.jsxs("div",{style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"3px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:ce.sm},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:"#374151",width:6,height:6}})]});if(a==="fork"||a==="join"){const m=n.flowDirection==="vertical";return e.jsxs("div",{title:a==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:ce.sm},children:[e.jsx(N,{type:"target",position:m?k.Top:k.Left,style:{background:"#374151",width:6,height:6,border:"none"}}),e.jsx(N,{type:"source",position:m?k.Bottom:k.Right,style:{background:"#374151",width:6,height:6,border:"none"}})]})}const h=l||p||"#9CA3AF";if(n.isFrame)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${h}08`,border:`1.5px solid ${h}66`,borderRadius:10,boxShadow:i?"0 0 0 3px #2DD4A8":"none",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleExpand&&e.jsx("button",{"aria-label":`Collapse ${r}`,className:"nodrag",onClick:m=>{m.stopPropagation(),n.onToggleExpand()},onDoubleClick:m=>m.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${h}66`,borderRadius:4,background:"#FFFFFF",color:h,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&e.jsx(br,{onDrillIn:n.onDrillIn,color:h,label:r}),e.jsx("span",{style:{fontSize:D.md,fontWeight:700,color:h,whiteSpace:"nowrap"},children:r}),n.allocatedTo&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}})]});const C=18,j=Math.max(f.length*C,w.length*C,0);return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{background:"#FFFFFF",border:`1.5px solid ${h}`,borderRadius:3,minWidth:"140px",boxShadow:i?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":F?`0 0 0 2px ${h}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 14px",fontSize:D.md,fontWeight:600,color:"#1a1a1a",background:`${h}0D`,borderBottom:j>0?"1px solid #E5E5E0":"none",textAlign:"center",whiteSpace:"nowrap"},children:[r,n.hasChildren&&n.onDrillIn&&e.jsx("button",{"aria-label":`Drill into ${r}`,title:`Open ${r} as its own diagram`,className:"nodrag",onClick:m=>{m.stopPropagation(),n.onDrillIn()},onDoubleClick:m=>m.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${h}`,borderRadius:2,background:"#FFFFFF",color:h,fontSize:11,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:"↳"}),n.hasChildren&&n.onToggleExpand&&e.jsx("button",{"aria-label":n.isExpanded?`Collapse ${r}`:`Expand ${r}`,onClick:m=>{m.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${h}`,borderRadius:2,background:"#FFFFFF",color:h,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),j>0&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:f.map(m=>e.jsxs("div",{style:{fontSize:D.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${C}px`,gap:"4px"},children:[e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#3498DB",flexShrink:0}}),m]},`in-${m}`))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:w.map(m=>e.jsxs("div",{style:{fontSize:D.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${C}px`,gap:"4px"},children:[m,e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#E67E22",flexShrink:0}})]},`out-${m}`))})]}),n.allocatedTo&&e.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",n.allocatedTo]}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}})]})}const wr=d.memo(Fr);function jr({data:t,selected:i}){const n=t,a=n.orientation==="column";return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${n.color}08`,border:i?"3px solid #2DD4A8":`1px solid ${n.color}30`,borderLeft:i?"3px solid #2DD4A8":a?`1px solid ${n.color}30`:`3px solid ${n.color}`,borderTop:i?"3px solid #2DD4A8":a?`3px solid ${n.color}`:`1px solid ${n.color}30`,borderRadius:ci.md,pointerEvents:"auto",cursor:n.inspectElementId?"pointer":"default",display:"flex"},children:e.jsx("div",{style:{writingMode:a?"horizontal-tb":"vertical-rl",transform:a?void 0:"rotate(180deg)",padding:a?"7px 10px":"10px 6px",fontSize:D.xs,fontWeight:700,color:n.color,letterSpacing:"0.04em",textTransform:"uppercase",alignSelf:a?"flex-start":"center",width:a?"100%":void 0,textAlign:a?"center":void 0,whiteSpace:"nowrap"},children:n.label})})}const Sr=d.memo(jr);function Rn({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Ln({collapsed:t,onToggle:i,color:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),i()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:t?"Show substates":"Hide substates","aria-label":t?"Show substates":"Hide substates",style:{width:16,height:16,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n}66`,borderRadius:4,background:"#FFFFFF",color:n,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:t?"+":"−"})}const Et={width:8,height:8,border:"none",background:"transparent",opacity:0};function ro(){return e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Top,id:"top",style:Et}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:Et}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:Et}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:Et})]})}function vr({data:t,selected:i}){const n=t,[a,r]=d.useState(!1);if(n.isNote)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${n.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:ce.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:n.kind,children:[e.jsx(ro,{}),e.jsx("span",{style:{fontSize:D.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:n.kind})]});if(n.isContainer)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:n.isMachine?"transparent":`${n.color}06`,borderTop:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRight:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderBottom:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderLeft:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRadius:14,boxShadow:i?ce.selected:"none",position:"relative"},children:[e.jsx(ro,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleCollapse&&!n.isMachine&&e.jsx(Ln,{collapsed:!1,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&!n.isMachine&&e.jsx(Rn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsx("span",{style:{fontSize:D.md,fontWeight:700,color:n.isMachine?"#334155":n.color,whiteSpace:"nowrap"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.isMachine?"#94A3B8":`${n.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:n.kind})]})]});const l=!!n.hasChildren;return e.jsxs("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),title:l?`${n.hiddenCount??0} substate${n.hiddenCount===1?"":"s"} hidden — double-click to drill in`:void 0,style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",borderTop:`3px solid ${n.color}`,borderRight:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderBottom:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderLeft:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderRadius:12,boxShadow:i?ce.selected:a?"0 8px 20px rgba(15,23,42,0.12)":ce.md,transition:"box-shadow 150ms ease, border-color 150ms ease",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[e.jsx(ro,{}),e.jsx("span",{style:{fontSize:D.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.label}),n.subtitle&&e.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.subtitle}),l&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[n.onToggleCollapse&&e.jsx(Ln,{collapsed:!0,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&e.jsx(Rn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsxs("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,letterSpacing:"0.05em"},children:["⊞ ",n.hiddenCount??0]})]})]})}const kr=d.memo(vr),ho="#3498DB";function Cr({data:t}){const i=t;return e.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[e.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 ${ho}`,borderRadius:8,boxShadow:ce.md,textAlign:"center",fontSize:D.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.label}),e.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${ho}66`}})]})}const Er=d.memo(Cr);function Ir({data:t}){const i=t;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#1B3A4B06",border:"1px solid #1B3A4B22",borderRadius:10,pointerEvents:"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 14px"},children:[e.jsx("span",{style:{fontSize:D.sm,fontWeight:700,color:"#1B3A4B"},children:i.label}),i.scenario&&e.jsxs("span",{style:{fontSize:D.xs,color:"#6B7280"},children:["realizes ",i.scenario]})]})})}const Dr=d.memo(Ir),It={width:6,height:6,border:"none",background:"transparent",opacity:0};function Nr({data:t,selected:i}){const n=t;return e.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${ho}`,boxShadow:i?ce.selected:ce.sm,position:"relative"},title:n.kind,children:[e.jsx(N,{type:"source",id:"right",position:k.Right,style:It}),e.jsx(N,{type:"target",id:"right",position:k.Right,style:It}),e.jsx(N,{type:"source",id:"left",position:k.Left,style:It}),e.jsx(N,{type:"target",id:"left",position:k.Left,style:It}),e.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:n.label})]})}const Ar=d.memo(Nr),zt={opacity:0,width:1,height:1},Mr=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"grid",placeItems:"center",textAlign:"center",padding:"12px 22px",border:`2px solid ${n.color??"#E67E22"}`,borderRadius:"50%",background:"#FFF9F2",color:"#2D3748",fontSize:13,fontWeight:600,lineHeight:1.25},children:[n.label,e.jsx(N,{type:"target",position:k.Left,style:zt}),e.jsx(N,{type:"source",position:k.Right,style:zt})]})}),Br=d.memo(function({data:i}){const n=i,a=n.side==="right"?k.Left:k.Right;return e.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:[e.jsx(nt,{color:n.color??"#334155"}),e.jsx("span",{children:n.label}),e.jsx(N,{type:"source",position:a,style:zt}),e.jsx(N,{type:"target",position:a,style:zt})]})}),zr=d.memo(function({data:i}){const n=i;return e.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:n.label})});d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",textAlign:"center",color:"#64748B",fontSize:11,fontWeight:700,letterSpacing:".03em"},children:n.label})});function Tr(t,i=0){if(t.length<2)return"";if(i===0||t.length===2)return`M ${t.map(r=>`${r.x},${r.y}`).join(" L ")}`;let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],p=t[r],f=t[r+1],w=Math.min(i,Math.abs(p.x-l.x)/2+Math.abs(p.y-l.y)/2),F=Math.min(i,Math.abs(f.x-p.x)/2+Math.abs(f.y-p.y)/2),I={x:p.x+Math.sign(l.x-p.x)*w,y:p.y+Math.sign(l.y-p.y)*w},h={x:p.x+Math.sign(f.x-p.x)*F,y:p.y+Math.sign(f.y-p.y)*F};n+=` L ${I.x},${I.y} Q ${p.x},${p.y} ${h.x},${h.y}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}const Rr=d.memo(function(i){var C,j,m,A,b;const n=Yn(i.id,[i.source,i.target]),a=fo()&&!n,r=((C=i.data)==null?void 0:C.routing)??"rounded",l=Array.isArray((j=i.data)==null?void 0:j.points)?i.data.points:[],p=l.length>=2?l:[{x:i.sourceX,y:i.sourceY},{x:i.targetX,y:i.targetY}],w=r==="straight"?`M ${i.sourceX},${i.sourceY} L ${i.targetX},${i.targetY}`:Tr(p,r==="elbow"?0:r==="rounded"?16:r==="curved"?30:42),F=((m=i.data)==null?void 0:m.labelPoint)??p[Math.floor(p.length/2)]??{x:(i.sourceX+i.targetX)/2,y:(i.sourceY+i.targetY)/2},I=String(((A=i.style)==null?void 0:A.stroke)??"#64748B"),h=Number(((b=i.style)==null?void 0:b.strokeWidth)??1.5);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:w,fill:"none",stroke:I,strokeOpacity:.22,strokeWidth:h+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(_n,{path:w,style:n?{...i.style,strokeWidth:h+1.4}:i.style}),i.label&&e.jsx(po,{children:e.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F.x}px,${F.y}px)`,background:"#FFFFFF",padding:"2px 5px",borderRadius:3,color:n?"#0F172A":"#334155",fontSize:12,pointerEvents:"all",fontWeight:n?700:void 0,opacity:a?.25:1},children:i.label})})]})}),Dt={opacity:0,width:1,height:1};function Zn(){return e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Left,style:Dt}),e.jsx(N,{type:"source",position:k.Right,style:Dt}),e.jsx(N,{type:"target",position:k.Top,style:Dt}),e.jsx(N,{type:"source",position:k.Bottom,style:Dt})]})}const Lr=d.memo(function({data:i}){const n=i;return e.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:[e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:5,color:"#0F766E",fontSize:10,letterSpacing:".08em"},children:"SYSTEM OF INTEREST"}),n.label]}),e.jsx(Zn,{})]})}),$r=d.memo(function({data:i}){const n=i,a=n.category==="environment"?{border:"#7C3AED",fill:"#F5F3FF",text:"#4C1D95",tag:"ENVIRONMENT"}:n.category==="person"?{border:"#2563EB",fill:"#EFF6FF",text:"#1E3A8A",tag:"ACTOR"}:{border:"#64748B",fill:"#F8FAFC",text:"#334155",tag:"EXTERNAL SYSTEM"};return e.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 ${a.border}`,borderRadius:7,background:a.fill,color:a.text,fontSize:13,fontWeight:650,lineHeight:1.25},children:[n.category==="person"&&e.jsx(nt,{size:26,color:a.border}),e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:4,color:a.border,fontSize:9,letterSpacing:".07em"},children:a.tag}),n.label]}),e.jsx(Zn,{})]})}),Wr=d.memo(function({data:i}){const n=i;return e.jsx("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:n.label})}),Or=d.memo(function({id:i,data:n,selected:a}){var W;const r=n,[l,p]=d.useState(!1),[f,w]=d.useState(""),[F,I]=d.useState(!1),h=d.useRef(null),C=d.useCallback(()=>{w(r.label),p(!0),setTimeout(()=>{var E;(E=h.current)==null||E.select()},10)},[r.label]),j=d.useCallback(()=>{var R;p(!1);const E=f.trim();E&&E!==r.label&&((R=r.onInlineEdit)==null||R.call(r,i,E))},[f,r,i]),m=d.useCallback(E=>{E.key==="Enter"&&(E.preventDefault(),j()),E.key==="Escape"&&p(!1)},[j]),A=d.useCallback(E=>{var R;E.preventDefault(),(R=r.onContextMenu)==null||R.call(r,E,i)},[r,i]),b=r.bgColor??"#FFFFFF",v=r.color,T={background:v,border:"2px solid #FFFFFF",width:10,height:10,opacity:F||a?1:0,transition:"opacity 0.15s"};return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onContextMenu:A,onDoubleClick:C,style:{minWidth:120,minHeight:40,background:b,borderLeft:`3px solid ${v}`,borderRadius:8,boxShadow:a?`0 0 0 2px ${v}, 0 4px 12px ${v}44`:F?"0 4px 16px rgba(0,0,0,0.14)":"0 1px 4px rgba(0,0,0,0.08)",cursor:l?"text":"grab",position:"relative",transition:"box-shadow 0.15s",opacity:r.isNew?.7:1},children:[a&&e.jsx(tt,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:v,lineStyle:{borderColor:v},handleStyle:{background:v,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),e.jsxs("div",{style:{padding:"8px 12px",userSelect:"none",display:"flex",gap:8,alignItems:"center"},children:[mo(r.kind)&&e.jsx(nt,{size:26,color:v}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:v,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:r.kind}),l?e.jsx("input",{ref:h,value:f,onChange:E=>w(E.target.value),onBlur:j,onKeyDown:m,onClick:E=>E.stopPropagation(),autoFocus:!0,style:{fontSize:D.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):e.jsx("div",{style:{fontSize:D.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:r.label||r.kind}),r.isNew&&e.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]})]}),!!((W=r.compartments)!=null&&W.length)&&e.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:r.compartments.map(E=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline",fontSize:"10px",lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.jsx("span",{style:{color:"#9CA3AF"},children:E.key}),e.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:E.value})]},E.key))}),e.jsx(N,{type:"target",position:k.Top,style:{...T,top:-5}}),e.jsx(N,{type:"source",position:k.Bottom,style:{...T,bottom:-5},id:"bottom"}),e.jsx(N,{type:"source",position:k.Right,style:{...T,right:-5},id:"right"}),e.jsx(N,{type:"target",position:k.Left,style:{...T,left:-5}})]})}),Qn="application/memo-kind";function ao({collapsed:t,onToggleCollapse:i,elementIds:n=[],eligibleKinds:a}){const r=O(b=>b.model),l=O(b=>b.selectedElementId),p=O(b=>b.inspectElement),[f,w]=d.useState(""),[F,I]=d.useState(new Set),[h,C]=d.useState(!0),j=d.useMemo(()=>{if(!(a!=null&&a.size))return[];const b=f.trim().toLowerCase();return Kn(r).kinds.filter(v=>a.has(v.name)&&!v.isAbstract).filter(v=>!b||v.name.toLowerCase().includes(b)||(v.label??"").toLowerCase().includes(b)).map(v=>({name:v.name,label:v.label||v.name,layer:v.layer??"",construct:Vi(v.construct)})).sort((v,T)=>v.label.localeCompare(T.label))},[r,a,f]),m=d.useMemo(()=>{var W;if(!r)return[];const b=f.trim().toLowerCase(),v=new Map,T=new Set(n);for(const E of n){const R=(W=r.elements[E])==null?void 0:W.allocatedTo;R&&T.add(R)}for(const E of T){const R=r.elements[E];R&&(b&&!R.name.toLowerCase().includes(b)&&!R.kind.toLowerCase().includes(b)||(v.has(R.kind)||v.set(R.kind,[]),v.get(R.kind).push(R)))}return[...v.entries()].map(([E,R])=>({kind:E,elements:R.sort((Q,H)=>Q.name.localeCompare(H.name))})).sort((E,R)=>E.kind.localeCompare(R.kind))},[r,n,f]),A=b=>I(v=>{const T=new Set(v);return T.has(b)?T.delete(b):T.add(b),T});return t?e.jsxs("button",{className:"flex flex-col items-center py-2 gap-1 cursor-pointer",style:{width:36,border:0,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},onClick:i,title:"Expand diagram elements","aria-label":"Expand diagram elements",children:[e.jsx("span",{style:{color:"#6B7280",fontSize:18},children:"›"}),e.jsx("span",{style:{fontSize:10,color:"#6B7280",writingMode:"vertical-rl"},children:"Diagram Elements"})]}):e.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:240,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[e.jsx("span",{style:{fontSize:D.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),e.jsx("button",{onClick:i,title:"Collapse diagram elements","aria-label":"Collapse diagram elements",style:{background:"none",border:"none",cursor:"pointer",color:"#6B7280",fontSize:18,lineHeight:1},children:"‹"})]}),e.jsx("div",{className:"px-2 pt-2 pb-1",style:{flexShrink:0},children:e.jsx("input",{value:f,onChange:b=>w(b.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:D.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[j.length>0&&e.jsxs("div",{style:{borderBottom:"1px solid #E5E5E0",paddingBottom:4,marginBottom:4},children:[e.jsxs("button",{onClick:()=>C(b=>!b),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:"#6B7280"},children:h?"▼":"▶"}),e.jsx("span",{style:{fontSize:10,color:"#374151",fontWeight:700,letterSpacing:"0.04em"},children:"SHAPES"}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:j.length})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pb-1",style:{fontSize:9,color:"#9CA3AF"},children:"Drag onto the canvas to create"}),j.map(b=>{const v=uo[b.layer]??"#6B7280";return e.jsxs("div",{draggable:!0,onDragStart:T=>{T.dataTransfer.setData(Qn,JSON.stringify({kind:b.name,layer:b.layer,construct:b.construct})),T.dataTransfer.effectAllowed="copy"},title:`Drag to create a ${b.label} (${b.construct})`,className:"flex items-center gap-2 px-3 py-1.5",style:{cursor:"grab",fontSize:D.xs,color:"#374151"},children:[e.jsx("span",{style:{width:12,height:12,flexShrink:0,borderRadius:b.construct==="port"?2:3,border:`2px solid ${v}`,background:b.construct==="port"?"#FFFFFF":`${v}22`}}),e.jsx("span",{className:"truncate flex-1",children:b.label})]},b.name)})]})]}),m.map(b=>{var W;const v=F.has(b.kind),T=uo[(W=b.elements[0])==null?void 0:W.layer]??"#6B7280";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>A(b.kind),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:T},children:v?"▶":"▼"}),e.jsx("span",{className:"truncate",style:{fontSize:10,color:T,fontWeight:700},children:b.kind}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:b.elements.length})]}),!v&&b.elements.map(E=>{const R=l===E.id;return e.jsxs("button",{onClick:()=>p(E.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:D.xs,background:R?"#DDF7EF":"transparent",color:R?"#116149":"#374151",fontWeight:R?600:400},title:`Highlight ${E.name} in diagram`,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:T,flexShrink:0}}),e.jsx("span",{className:"truncate flex-1",children:E.name})]},E.id)})]},b.kind)}),m.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:D.xs},children:f?"No matching elements":"No elements in this diagram"})]})]})}function ne({label:t,icon:i,danger:n,onClick:a}){return e.jsxs("button",{onClick:a,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:D.xs},onMouseEnter:r=>{r.currentTarget.style.background=n?"#FEF2F2":"#F7F7F5"},onMouseLeave:r=>{r.currentTarget.style.background="none"},children:[i&&e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:i}),e.jsx("span",{style:{color:n?"#DC2626":"#1a1a1a"},children:t})]})}function Bt(){return e.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Jn({x:t,y:i,onClose:n,children:a}){const r=d.useRef(null);d.useEffect(()=>{const w=I=>{r.current&&!r.current.contains(I.target)&&n()},F=I=>{I.key==="Escape"&&n()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",F)}},[n]);const l=210,p=Math.min(t,window.innerWidth-l-8),f=Math.min(i,window.innerHeight-200);return e.jsx("div",{ref:r,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:p,top:f,minWidth:l,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:a})}const Pr=[{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 Hr({x:t,y:i,nodeId:n,nodeKind:a,onClose:r,onEditName:l,onChangeColor:p,onRemoveFromDiagram:f,onDeleteFromModel:w,onLinkRisk:F,onLinkRequirement:I,onShowProperties:h,onFocusElement:C,onShowInCatalog:j,onShowRelMatrix:m,onOpenSource:A,onViewKindInOntology:b}){const[v,T]=d.useState(!1);return e.jsxs(Jn,{x:t,y:i,onClose:r,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),h&&e.jsx(ne,{label:"Show Properties",icon:"ℹ",onClick:()=>{r(),h()}}),j&&e.jsx(ne,{label:"Show in Catalog",icon:"☰",onClick:()=>{r(),j()}}),C&&e.jsx(ne,{label:"Focus on Element",icon:"◎",onClick:()=>{r(),C()}}),m&&e.jsx(ne,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{r(),m()}}),b&&e.jsx(ne,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{r(),b()}}),A&&e.jsx(ne,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{r(),A()}}),(h||j||C||m||b||A)&&e.jsx(Bt,{}),e.jsx(ne,{label:"Edit name",icon:"✏️",onClick:()=>{r(),l()}}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer",fontSize:D.xs},onMouseEnter:W=>{T(!0),W.currentTarget.style.background="#F7F7F5"},onMouseLeave:W=>{W.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:"🎨"}),e.jsx("span",{style:{flex:1,textAlign:"left",color:"#1a1a1a"},children:"Change color"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:"10px"},children:"▶"})]}),v&&e.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:()=>T(!0),onMouseLeave:()=>T(!1),children:Pr.map(W=>e.jsxs("button",{onClick:()=>{r(),p(W.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:E=>{E.currentTarget.style.background="#F7F7F5"},onMouseLeave:E=>{E.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:W.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),e.jsx("span",{style:{fontSize:D.xs,color:"#374151"},children:W.label})]},W.value))})]}),e.jsx(Bt,{}),F&&e.jsx(ne,{label:"Link Risk",icon:"⚠️",onClick:()=>{r(),F()}}),I&&e.jsx(ne,{label:"Link Requirement",icon:"📋",onClick:()=>{r(),I()}}),(F||I)&&e.jsx(Bt,{}),e.jsx(ne,{label:"Remove from diagram",icon:"↩️",onClick:()=>{r(),f()}}),e.jsx(ne,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${n} from the model? This cannot be undone.`)&&(r(),w())}})]})}const _r=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function Kr({x:t,y:i,edgeId:n,relType:a,onClose:r,onChangeStyle:l,onChangeColor:p,onToggleLabel:f,onDelete:w}){return e.jsxs(Jn,{x:t,y:i,onClose:r,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40},children:"Style"}),["solid","dashed","dotted"].map(F=>e.jsx("button",{onClick:()=>{r(),l(F)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:F},F))]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40,flexShrink:0},children:"Color"}),_r.map(F=>e.jsx("button",{onClick:()=>{r(),p(F.value)},title:F.label,style:{width:16,height:16,borderRadius:"50%",background:F.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},F.value))]}),e.jsx(Bt,{}),e.jsx(ne,{label:"Toggle label",icon:"🏷️",onClick:()=>{r(),f()}}),e.jsx(ne,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{r(),w()}})]})}const Vr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=r.color??r.layerColor??"#E67E22",p=80,f=d.useCallback(w=>{var F;w.preventDefault(),(F=r.onContextMenu)==null||F.call(r,w,i)},[r,i]);return e.jsxs("div",{style:{width:p,height:p,position:"relative"},onContextMenu:f,children:[a&&e.jsx(tt,{minWidth:60,minHeight:60}),e.jsx("svg",{width:p,height:p,style:{position:"absolute",top:0,left:0},children:e.jsx("polygon",{points:`${p/2},4 ${p-4},${p/2} ${p/2},${p-4} 4,${p/2}`,fill:r.color?r.color+"44":"#FFF8E1",stroke:l,strokeWidth:a?2.5:1.5})}),e.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:r.condition||r.label||"?"}),e.jsx(N,{type:"target",position:k.Top,style:{background:l,border:"2px solid #fff"}}),e.jsx(N,{type:"source",position:k.Right,style:{background:l,border:"2px solid #fff"},id:"right"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:l,border:"2px solid #fff"},id:"bottom"}),e.jsx(N,{type:"target",position:k.Left,style:{background:l,border:"2px solid #fff"}})]})}),Yr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=(r.orientation??"horizontal")==="horizontal",p=l?120:8,f=l?8:60,w=d.useCallback(F=>{var I;F.preventDefault(),(I=r.onContextMenu)==null||I.call(r,F,i)},[r,i]);return e.jsxs("div",{style:{width:p,height:f,background:"#1a1a1a",borderRadius:4,position:"relative"},title:r.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:w,children:[a&&e.jsx(tt,{minWidth:40,minHeight:6}),l?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),e.jsx(N,{type:"source",position:k.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),e.jsx(N,{type:"source",position:k.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),e.jsx(N,{type:"source",position:k.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),e.jsx(N,{type:"source",position:k.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),Xr=d.memo(function({id:i,data:n}){const a=n,r=a.nodeType==="start",l=32,p=d.useCallback(f=>{var w;f.preventDefault(),(w=a.onContextMenu)==null||w.call(a,f,i)},[a,i]);return e.jsxs("div",{style:{width:l,height:l,position:"relative"},onContextMenu:p,children:[e.jsx("svg",{width:l,height:l,children:r?e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-6,fill:"#FFFFFF"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-10,fill:"#1a1a1a"})]})}),r?e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):e.jsx(N,{type:"target",position:k.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),Gr="#ECEBE6",Tt="#1B3A4B",yo="#5B6470",Ur="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",Se=(t,i)=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:i}),Y={arrowRight:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 12h14"}),e.jsx("path",{d:"M13 6l6 6-6 6"})]})),arrowDown:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 4v14"}),e.jsx("path",{d:"M6 13l6 6 6-6"})]})),lanes:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"10.3",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"15.6",width:"18",height:"3.4",rx:"1.3"})]})),grid:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),e.jsx("path",{d:"M9.2 3.5v17M14.8 3.5v17M3.5 9.2h17M3.5 14.8h17"})]})),expand:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15 4h5v5"}),e.jsx("path",{d:"M9 20H4v-5"}),e.jsx("path",{d:"M20 4l-7 7"}),e.jsx("path",{d:"M4 20l7-7"})]})),collapse:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 10h5"}),e.jsx("path",{d:"M19 10V5"}),e.jsx("path",{d:"M10 14H5"}),e.jsx("path",{d:"M5 14v5"}),e.jsx("path",{d:"M20 4l-6 6"}),e.jsx("path",{d:"M4 20l6-6"})]})),filter:({size:t=16})=>Se(t,e.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5l-6 7 6 7"}),e.jsx("path",{d:"M5 12h14"})]}))};function xe(){return e.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function Nt({options:t,value:i,onChange:n}){return e.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:Gr,borderRadius:9},children:t.map(a=>{const r=a.value===i;return e.jsxs("button",{role:"tab","aria-selected":r,onClick:()=>n(a.value),title:a.title,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:a.label?"3px 9px":"4px 7px",borderRadius:7,border:"none",cursor:"pointer",color:r?Tt:yo,background:r?"#FFFFFF":"transparent",boxShadow:r?Ur:"none",transition:"background 140ms ease, color 140ms ease, box-shadow 140ms ease"},children:[a.icon,a.label&&e.jsx("span",{children:a.label})]},a.value)})})}function qr({children:t}){return e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:Sn.Children.toArray(t).map((i,n)=>e.jsxs(Sn.Fragment,{children:[n>0&&e.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),i]},n))})}function ie({icon:t,label:i,onClick:n,active:a=!1,title:r,ariaExpanded:l,ariaLabel:p}){return e.jsxs("button",{onClick:n,title:r,"aria-label":p,"aria-pressed":a,"aria-expanded":l,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:i?"5px 9px":"5px 7px",border:"none",cursor:"pointer",color:a?"#FFFFFF":yo,background:a?Tt:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[t,i&&e.jsx("span",{children:i})]})}function Je({icon:t,label:i,onClick:n,active:a=!1,title:r,badge:l}){return e.jsxs("button",{onClick:n,title:r,"aria-pressed":a,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:l!=null||i!=null?"5px 9px":"5px 7px",borderRadius:9,border:`1px solid ${a?Tt:"#E2E1DB"}`,cursor:"pointer",color:a?"#FFFFFF":yo,background:a?Tt:"#FFFFFF",transition:"background 140ms ease, color 140ms ease, border-color 140ms ease"},children:[t,i!=null&&e.jsx("span",{children:i}),l!=null&&e.jsx("span",{style:{fontSize:11,fontWeight:700,lineHeight:1,padding:"2px 5px",borderRadius:6,background:a?"rgba(255,255,255,0.22)":"#F0EFEA",color:a?"#FFFFFF":"#6B7280"},children:l})]})}const Zr=1,$n="memo-layout-progress";if(typeof document<"u"&&!document.getElementById($n)){const t=document.createElement("style");t.id=$n,t.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(t)}const Qr={background:"#F7F7F5"},Jr={padding:.08,maxZoom:2},ea={background:"#FFFFFF"},ta={hideAttribution:!0},oa=[20,20],na=50,Wn=8e3,sa=90;function ia(t,i){return new Promise((n,a)=>{const r=window.setTimeout(()=>a(new Error(`${i} layout exceeded ${Wn/1e3}s`)),Wn);t.then(l=>{window.clearTimeout(r),n(l)},l=>{window.clearTimeout(r),a(l)})})}function ra({data:t,selected:i}){const n=t.kind,a=n==="note",r=n==="constraint";return e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",padding:a?"12px 14px":r?"10px 12px":"4px",background:a?String(t.color??"#FEF3C7"):r?"#FFFFFF":"transparent",border:r?"1.5px dashed #7C3AED":a?"1px solid #F59E0B":"1px solid transparent",borderRadius:a?3:r?5:0,boxShadow:a?"0 2px 6px rgba(0,0,0,.12)":"none",color:"#292524",fontSize:12,lineHeight:1.4},children:[e.jsx(tt,{isVisible:i,minWidth:100,minHeight:48,color:"#2563EB"}),e.jsx("button",{className:"nodrag","aria-label":"Delete annotation",title:"Delete annotation",onPointerDown:l=>{var p;l.preventDefault(),l.stopPropagation(),(p=t.onDelete)==null||p.call(t)},onClick:l=>{var p;l.stopPropagation(),(p=t.onDelete)==null||p.call(t)},style:{position:"absolute",top:3,right:5,border:0,background:"transparent",color:"#64748B",cursor:"pointer",fontSize:14,lineHeight:1,pointerEvents:"all",zIndex:30},children:"×"}),r&&e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#7C3AED",marginBottom:4},children:"constraint"}),e.jsx("div",{contentEditable:!0,suppressContentEditableWarning:!0,className:"nodrag",style:{outline:"none",whiteSpace:"pre-wrap",minHeight:20},onBlur:l=>{var p;return(p=t.onTextChange)==null?void 0:p.call(t,l.currentTarget.textContent??"")},children:String(t.text??"")})]})}function On(t,i){const n=new Map(t.map(h=>[h.id,h])),a=new Map,r=h=>{const C=a.get(h);if(C)return C;const j=n.get(h),m=j.parentId?r(j.parentId):{x:0,y:0},A={x:m.x+j.position.x,y:m.y+j.position.y};return a.set(h,A),A},l=h=>{var C,j;return{width:Number(h.width??((C=h.style)==null?void 0:C.width)??0),height:Number(h.height??((j=h.style)==null?void 0:j.height)??0)}},p=i.flatMap(h=>{var v,T,W,E,R,Q;const C=(H,z,q)=>{var S,te;if(typeof z=="string"){const K=(((te=(S=n.get(H))==null?void 0:S.data)==null?void 0:te.ports)??[]).find(X=>X.id===z);if(K){const X=K.size??20;return{x:K.x+X/2,y:K.y+X/2}}}return q},j=C(h.source,(v=h.data)==null?void 0:v.sourcePortId,(T=h.data)==null?void 0:T.sourceOffset),m=C(h.target,(W=h.data)==null?void 0:W.targetPortId,(E=h.data)==null?void 0:E.targetOffset);if(!j||!m||!n.has(h.source)||!n.has(h.target))return[];const A=r(h.source),b=r(h.target);return[{id:h.id,source:{x:A.x+j.x,y:A.y+j.y},target:{x:b.x+m.x,y:b.y+m.y},sourceNodeId:h.source,targetNodeId:h.target,sourceSide:(R=h.data)==null?void 0:R.sourceSide,targetSide:(Q=h.data)==null?void 0:Q.targetSide}]});if(p.length===0)return i;const f=t.filter(h=>!h.data.isFrame).map(h=>({id:h.id,...r(h.id),...l(h)})),w=new Map(p.map(h=>[h.id,h])),F=p.filter(h=>{var C,j;return!((j=(C=i.find(m=>m.id===h.id))==null?void 0:C.data)!=null&&j.manualRoute)}),I=Hi(F,f);return i.map(h=>{var j;const C=w.get(h.id);if(!C)return h;if((j=h.data)!=null&&j.manualRoute){const m=[...h.data.points??[]];if(m.length>=2)return m[0]=C.source,m[m.length-1]=C.target,{...h,data:{...h.data,points:m}}}return I.has(h.id)?{...h,data:{...h.data,points:I.get(h.id)}}:h})}function aa({x:t,y:i,onConfirm:n,onCancel:a}){const[r,l]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{var F;(F=p.current)==null||F.focus()},[]),d.useEffect(()=>{const F=I=>{const h=document.getElementById("quick-create-popup");h&&!h.contains(I.target)&&a()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[a]);const f=Math.min(t,window.innerWidth-220),w=Math.min(i,window.innerHeight-80);return e.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:f,top:w,width:200,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:[e.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",fontSize:D.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("input",{ref:p,value:r,onChange:F=>l(F.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:D.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:F=>{F.key==="Enter"&&r.trim()&&(F.preventDefault(),n(r.trim())),F.key==="Escape"&&a()}}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:()=>r.trim()&&n(r.trim()),style:{flex:1,fontSize:D.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),e.jsx("button",{onClick:a,style:{fontSize:D.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function lo({color:t,glyph:i}){return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:t+"22",border:`1.5px solid ${t}`,color:t,fontSize:9,fontWeight:800,lineHeight:1},children:i})}function Pn(t,i){if(!t||!i)return[];const n=new Map;for(const p of t.relationships)Mt.has(p.type)&&!n.has(p.targetId)&&n.set(p.targetId,p.sourceId);const a=[i],r=new Set(a);let l=i;for(;n.has(l);){const p=n.get(l);if(r.has(p))break;a.unshift(p),r.add(p),l=p}return a}function co({path:t,nameOf:i,onFocus:n,rootLabel:a}){if(t.length===0)return null;const r=t.length>1?t[t.length-2]:null;return e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(Je,{icon:e.jsx(Y.back,{}),label:"Parent",onClick:()=>n(r),title:r?`Back to ${i(r)}`:a}),e.jsx("button",{onClick:()=>n(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:a,children:"⌂ All"}),t.map((l,p)=>{const f=p===t.length-1;return e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[e.jsx("span",{children:"›"}),e.jsx("button",{onClick:()=>n(l),disabled:f,className:"text-xs font-medium",style:{color:f?"#1a1a1a":"#2563EB",fontWeight:f?700:500,cursor:f?"default":"pointer"},title:f?void 0:`Focus ${i(l)}`,children:i(l)})]},l)})]})}function la(){var cn,dn,pn,un,hn,xn,gn,fn,mn,yn;const t=O(o=>o.model),i=O(o=>o.createRelationship),n=d.useMemo(()=>Kn(t),[t]),a=O(o=>o.selectedElementId),r=O(o=>o.selectedViewpointId),l=O(o=>o.selectedDiagramId),p=O(o=>o.hiddenLayers),f=O(o=>o.selectElement),w=O(o=>o.inspectElement),F=O(o=>o.inspectRelationship),I=O(o=>o.setActiveMode),h=O(o=>o.setActiveView),C=O(o=>o.setExplorerTab),j=O(o=>o.availableOntologies),m=O(o=>o.setSelectedOntologyKind),A=O(o=>o.diagramLayouts),b=O(o=>o.setNodeLayout),v=O(o=>o.mergeDiagramLayouts),T=O(o=>o.updateDiagramElementIds),{fitView:W,screenToFlowPosition:E,getViewport:R,setViewport:Q}=xo(),[H,z]=Js([]),[q,S,te]=ei([]),K=d.useRef([]),X=d.useRef([]),st=d.useRef(t),it=d.useRef(l),ve=d.useRef(null),Ne=d.useRef(null),Ae=d.useRef(null),re=d.useRef(0);d.useEffect(()=>{K.current=H},[H]),d.useEffect(()=>{X.current=q},[q]);const ge=d.useCallback(o=>{K.current=o,Ne.current===null&&(Ne.current=requestAnimationFrame(()=>{Ne.current=null;const s=K.current,c=On(s,X.current);X.current=c,z(s),S(c)}))},[z,S]),[Z,ae]=d.useState(!1),[bo,ye]=d.useState(0),[Fo,wo]=d.useState(null),[jo,es]=d.useState(0),[ts,Rt]=d.useState(0),[Re,Lt]=d.useState(!0),[os,So]=d.useState(!0),[vo,ns]=d.useState(!0),[$t,ss]=d.useState("horizontal"),[rt,ko]=d.useState("allocation"),[Wt,Co]=d.useState("all"),[Eo,is]=d.useState(!1),[be,rs]=d.useState(new Set(["control","data","energy","material"])),[se,Le]=d.useState(null),[Fe,at]=d.useState(null),[J,$e]=d.useState(null),[fe,lt]=d.useState(null),[We,Io]=d.useState(null),[ct,as]=d.useState(2),[dt,Do]=d.useState(null),Oe=d.useRef([]),Ot=d.useRef([]),No=d.useCallback(o=>{Oe.current.push(o),Oe.current.length>na&&Oe.current.shift(),Ot.current=[]},[]),g=di(t,l),Pe=g?vn[g.diagramType]:null,pt=!!((cn=g==null?void 0:g.properties)!=null&&cn.layoutStyle),ke=((dn=g==null?void 0:g.properties)==null?void 0:dn.layoutStyle)==="fbs",Ce=l?A[l]:void 0,Ee=ki(Ce),me=((pn=Ce==null?void 0:Ce.canvas)==null?void 0:pn.autoLayout)!==!1,we=((un=Ce==null?void 0:Ce.canvas)==null?void 0:un.flowAnimation)===!0,Ao=d.useCallback((o,s)=>{var y;if(!l)return;const c=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},u=(y=c.annotations)==null?void 0:y[o];if(!u)return;const x={...c,annotations:{...c.annotations,[o]:{...u,text:s}}};v({[l]:x}),je(l,x),z(M=>M.map(B=>B.id===o?{...B,data:{...B.data,text:s}}:B))},[l,v,z]),Mo=d.useCallback(o=>{if(!l)return;const s=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},c={...s.annotations};delete c[o];const u={...s,annotations:c};v({[l]:u}),je(l,u),z(x=>x.filter(y=>y.id!==o))},[l,v,z]),ut=d.useCallback(o=>Object.entries((o==null?void 0:o.annotations)??{}).map(([s,c])=>({id:s,type:"annotationNode",zIndex:1e3,position:{x:c.x,y:c.y},style:{width:c.width??180,height:c.height??92},data:{kind:c.kind,text:c.text,color:c.color,onTextChange:u=>Ao(s,u),onDelete:()=>Mo(s)}})),[Ao,Mo]),ls=d.useCallback(o=>{if(!l)return;const s=`annotation-${Date.now().toString(36)}`,c=E({x:window.innerWidth/2,y:window.innerHeight/2}),u=o==="constraint"?"{constraint}":o==="note"?"Note":"Text",x=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},y={kind:o,x:c.x,y:c.y,width:180,height:o==="text"?56:92,text:u},M={...x,annotations:{...x.annotations,[s]:y}};v({[l]:M}),je(l,M),z(B=>[...B,...ut(M).filter(P=>P.id===s)])},[l,E,v,z,ut]),ee=d.useCallback(()=>{var s;if(!l)return;const o=O.getState().diagramLayouts[l]??{nodes:{},edges:{}};((s=o.canvas)==null?void 0:s.autoLayout)!==!1&&v({[l]:{...o,canvas:{...o.canvas,autoLayout:!1}}})},[l,v]);d.useEffect(()=>{if(!l||me||Z||H.length===0||bo===0)return;const o=window.setTimeout(()=>{const s=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},c=R(),u={nodes:Object.fromEntries(H.filter(x=>x.type!=="annotationNode").map(x=>[x.id,{...s.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(y=>[y.id,{x:y.x,y:y.y,side:y.side}]))}])),edges:Object.fromEntries(q.map(x=>{var y,M,B,P,_,$;return[x.id,{...(()=>{var ue;const{points:G,...V}=((ue=s.edges)==null?void 0:ue[x.id])??{};return V})(),...(y=x.data)!=null&&y.manualRoute&&((B=(M=x.data)==null?void 0:M.points)!=null&&B.length)?{points:(P=x.data)==null?void 0:P.points,source:x.source,target:x.target,sourcePortId:(_=x.data)==null?void 0:_.sourcePortId,targetPortId:($=x.data)==null?void 0:$.targetPortId}:{}}]})),annotations:Object.fromEntries(H.filter(x=>x.type==="annotationNode").map(x=>{var y,M;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??((y=x.style)==null?void 0:y.width)??180),height:Number(x.height??((M=x.style)==null?void 0:M.height)??92)}]})),canvas:{...s.canvas,zoom:c.zoom,pan:{x:c.x,y:c.y},autoLayout:!1}};v({[l]:u}),je(l,u),ye(0)},350);return()=>window.clearTimeout(o)},[l,me,Z,bo,H,q,R,v]);const L=g?g.viewKind??(Pe==null?void 0:Pe.viewKind)??"general":void 0,Ie=L==="interconnection"?.72:.1,He=L?En[L]:null,Me=L==="general"&&!pt&&!ke,Pt=(g==null?void 0:g.diagramType)==="ucd",[De,Bo]=d.useState("graph"),[Ht,zo]=d.useState("all"),[_t,To]=d.useState("straight"),[_e,Ro]=d.useState(new Set),cs=d.useMemo(()=>t?Ci(t):0,[t]),Lo=d.useMemo(()=>t?Ei(t):[],[t]),Kt=(hn=g==null?void 0:g.properties)==null?void 0:hn.modes,ds=d.useMemo(()=>{if(!Kt)return so;const o=new Set(Kt.split(",").map(c=>c.trim())),s=so.filter(c=>o.has(c));return s.length?s:so},[Kt]),[Ke,$o]=d.useState(!0),Wo=d.useMemo(()=>{if(!t||!g)return[];const o=new Set(g.elementIds),s=Object.values(t.elements).filter(c=>o.has(c.id)&&c.allocatedTo).map(c=>c.allocatedTo);return Ii(s,t)},[t,g]),ps=d.useMemo(()=>{if(!t||!g)return"Activity Diagram";const o=pi(g);return vn[o].fullName},[t,g]),us=d.useMemo(()=>{if(!t||!g)return!1;const o=new Set(g.elementIds);return Object.values(t.elements).some(s=>o.has(s.id)&&!!(s.attributes.stage||s.attributes.phase))},[t,g]),ht=d.useMemo(()=>{if(!t||!g||L!=="actionflow")return[];const o=(g.elementIds??[]).map(s=>t.elements[s]).filter(s=>!!s&&s.construct==="action");return Di(o,t)},[t,g,L]),[Ve,hs]=d.useState("containment"),[Ye,xt]=d.useState(new Set),[Oo,Xe]=d.useState(new Set),[gt,Vt]=d.useState(null),[Ge,Po]=d.useState("all"),[Yt,Ho]=d.useState("summary"),[_o,Ko]=d.useState(!1),[Vo,Ue]=d.useState(new Set),[Be,Xt]=d.useState(null),[Gt,Yo]=d.useState("flat"),[Xo,qe]=d.useState(new Set),[ft,Ut]=d.useState(null),[mt,xs]=d.useState(new Map),de=d.useRef(new Map),gs=d.useMemo(()=>Pn(t,gt),[t,gt]),fs=d.useMemo(()=>Pn(t,ft),[t,ft]),ms=d.useMemo(()=>{var u;if(!t||!Be)return[];const o=[Be],s=new Set(o);let c=Be;for(;c;){const x=(u=t.elements[c])==null?void 0:u.parentAction;if(!x||s.has(x)||!t.elements[x])break;o.unshift(x),s.add(x),c=x}return o},[t,Be]),yt=d.useMemo(()=>{if(!t||L!=="statetransition")return[];const o=new Set;for(const s of t.relationships){if(!Mt.has(s.type))continue;const c=t.elements[s.sourceId];!c||!t.elements[s.targetId]||!Ni(c)||c.kind.endsWith("Machine")||o.add(c.id)}return[...o]},[t,L]),ys=d.useMemo(()=>t?[...new Set(t.relationships.filter(o=>Mt.has(o.type)).map(o=>o.sourceId))]:[],[t]);d.useEffect(()=>{var s,c;ye(0),Bo(Ai(g==null?void 0:g.properties)),zo(io(g==null?void 0:g.properties).level??"all"),To(io(g==null?void 0:g.properties).edgeStyle??"straight"),Ro(new Set),$o(!0),ko("allocation"),Co("all");const o=(c=(s=g==null?void 0:g.properties)==null?void 0:s.styleHint)!=null&&c.startsWith("expanded:")?g.properties.styleHint.slice(9).split(",").map(u=>u.trim()).filter(Boolean):[];xt(new Set(o)),Vt(null),Po("all"),Ho("summary"),Ko(!1),Ue(new Set),Xt(null),Yo("flat"),Ut(null),de.current.clear()},[l,(xn=g==null?void 0:g.properties)==null?void 0:xn.layoutHint,(gn=g==null?void 0:g.properties)==null?void 0:gn.styleHint]);const bs=d.useMemo(()=>({decompositionNode:ir,interconnectionNode:hr,actionFlowNode:wr,actionFlowLane:Sr,stateNode:kr,seqLifeline:Er,seqSection:Dr,seqOccurrence:Ar,useCase:Mr,useCaseActor:Br,useCaseBoundary:zr,contextSystem:Lr,contextExternal:$r,contextBoundary:Wr,diagramNode:Or,annotationNode:ra,decisionNode:Vr,forkNode:Yr,startEndNode:Xr}),[]),Fs=d.useMemo(()=>({interconnectionEdge:yr,useCaseEdge:Rr}),[]),ws=d.useCallback(o=>{var s,c;return((s=o.data)==null?void 0:s.color)||((c=o.data)==null?void 0:c.layerColor)||"#ccc"},[]),U=d.useMemo(()=>{const o=(g==null?void 0:g.viewpointId)==="__model"?null:(g==null?void 0:g.viewpointId)||r,s=o&&(t==null?void 0:t.viewpoints),c=p.size>0,u=g!=null&&g.elementIds?new Set(g.elementIds):void 0;if(!s&&!c&&!u)return;const x=s?t.viewpoints.find(B=>B.id===o):void 0,y=x?new Set(x.visibleKinds):void 0,M=x?new Set(x.visibleLayers):void 0;return B=>p.has(B.layer)?!1:u?u.has(B.id):y&&M?y.has(B.kind)||M.has(B.layer):!0},[r,g,t==null?void 0:t.viewpoints,p]),Go=d.useMemo(()=>{if(!t||L!=="interconnection")return[];const o=Object.values(t.elements),s=U?o.filter(U):o;return Mi(Bi(s,t.relationships),Zr)},[t,L,U]),Uo=d.useRef(null);d.useEffect(()=>{if(!t)return;const o=`${l??""}|${L??""}`;if(Uo.current!==o){if(L==="statetransition"){if(yt.length===0)return;qe(new Set(yt))}else L==="interconnection"&&Xe(new Set(Go));Uo.current=o}},[t,l,L,yt,Go]);const bt=d.useMemo(()=>{if(!t||!g||g.diagramType!=="bdd")return null;const o=g.relationshipTypes??[];return o.length===0||o.every(c=>Mt.has(c.charAt(0).toLowerCase()+c.slice(1)))?zi(Dn(t,U,g.relationshipTypes)):null},[t,g,U]),qo=d.useCallback(()=>{if(t)return ke?Ti(t):Me?Dn(t,U,g==null?void 0:g.relationshipTypes):Ri(t)},[t,ke,Me,U,g==null?void 0:g.relationshipTypes]),qt=d.useCallback(o=>{xt(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Zo=d.useCallback(o=>{Xe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Qo=d.useCallback(o=>{Ue(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Ft=d.useCallback(o=>{Ut(o),qe(new Set),w(null)},[w]),wt=d.useCallback(o=>{Xt(o),Ue(new Set),w(null)},[w]),jt=d.useCallback(o=>{Vt(o),Xe(new Set),w(null)},[w]),Jo=d.useCallback(o=>{qe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),en=d.useCallback(o=>{de.current.clear(),xs(s=>{const c=new Map(s),u=c.get(o)||"vertical";return c.set(o,u==="vertical"?"horizontal":"vertical"),c})},[]),Zt=d.useCallback(()=>{const o=qo();if(!o)return;const s=new Set,c=u=>{s.add(u);for(const x of o.childrenMap.get(u)||[])o.elements.has(x)&&c(x)};for(const u of o.roots)o.elements.has(u)&&c(u);xt(s)},[qo]),Qt=d.useCallback(()=>xt(new Set),[]),Jt=d.useCallback(()=>{de.current.clear(),Rt(o=>o+1)},[]),js=d.useCallback(()=>{if(!l)return;const o=O.getState().diagramLayouts[l]??{},{pan:s,zoom:c,...u}=o.canvas??{},x={nodes:{},edges:{},canvas:{...u,autoLayout:!0}};ve.current=null,v({[l]:x}),je(l,x),de.current.clear(),Rt(y=>y+1),window.setTimeout(()=>W({padding:.08,minZoom:Ie,maxZoom:2,duration:300}),250)},[l,v,W,Ie]),tn=d.useCallback(o=>o.map(s=>{if(s.type!=="diagramNode")return s;const c=t==null?void 0:t.elements[s.id];return{...s,data:{...s.data,onContextMenu:(u,x)=>{$e({x:u.clientX,y:u.clientY,nodeId:x,nodeKind:s.data.kind??""})},onInlineEdit:(u,x)=>{if(!c)return;const y={...c,name:x};kn(y)}}}}),[t]),on=d.useCallback((o,s)=>{const c=o.map(x=>{const y=s.nodes[x.id];return y?{...x,position:{x:y.x,y:y.y},...y.width?{width:y.width}:{},...y.height?{height:y.height}:{},...y.width||y.height?{style:{...x.style,...y.width?{width:y.width}:{},...y.height?{height:y.height}:{}}}:{},data:{...x.data,bgColor:y.color||void 0,...y.opacity!==void 0?{fillOpacity:y.opacity}:{},...y.ports?{ports:(x.data.ports??[]).map(M=>{var B;return{...M,...((B=y.ports)==null?void 0:B[M.id])??{}}})}:{}}}:x}),u=new Map(c.map(x=>[x.id,x]));return c.map(x=>{if(x.type!=="actionFlowLane")return x;const y=x.data,M=(y.memberIds??[]).map(V=>u.get(V)).filter(Boolean);if(M.length===0)return x;const B=Math.min(...M.map(V=>V.position.x)),P=Math.min(...M.map(V=>V.position.y)),_=Math.max(...M.map(V=>{var ue;return V.position.x+Number(V.width??((ue=V.style)==null?void 0:ue.width)??180)})),$=Math.max(...M.map(V=>{var ue;return V.position.y+Number(V.height??((ue=V.style)==null?void 0:ue.height)??96)})),G=y.orientation==="column";return{...x,position:{x:G?B-36:B-120,y:G?P-32:P-36},style:{...x.style,width:_-B+(G?72:156),height:$-P+(G?68:72)}}})},[]),nn=d.useCallback((o,s,c)=>{re.current=Date.now()+250,ee(),ye(y=>y+1);const u=X.current.map(y=>{var $,G;if(!((($=y.data)==null?void 0:$.sourcePortId)===s||((G=y.data)==null?void 0:G.targetPortId)===s))return y;const{points:B,manualRoute:P,..._}=y.data??{};return{...y,data:_}});X.current=u;const x=K.current.map(y=>y.id!==o?y:{...y,data:{...y.data,ports:(y.data.ports??[]).map(M=>M.id===s?{...M,y:c}:M)}});ge(x)},[ge,ee]),sn=d.useCallback((o,s)=>{re.current=Date.now()+250,ee(),ye(c=>c+1),S(c=>{const u=c.map(x=>x.id===o?{...x,data:{...x.data,points:s,manualRoute:!0}}:x);return X.current=u,u})},[ee,S]);d.useEffect(()=>{if(!t)return;const o=st.current!==t&&it.current===l;if(ve.current=o?R():null,st.current=t,it.current=l,L==="grid"||L==="browser"||L==="geometry")return;let s=!1;const c=({nodes:B,edges:P},_=!0)=>{if(s)return;const $=l?O.getState().diagramLayouts[l]:void 0,V=[...$&&Object.keys($.nodes).length>0?on(B,$):B,...ut($)],ue=P.map(oe=>{var bn,Fn,wn;const he=(bn=$==null?void 0:$.edges)==null?void 0:bn[oe.id],St=!(he!=null&&he.source)||he.source===oe.source&&he.target===oe.target&&he.sourcePortId===((Fn=oe.data)==null?void 0:Fn.sourcePortId)&&he.targetPortId===((wn=oe.data)==null?void 0:wn.targetPortId)?he==null?void 0:he.points:void 0;return{...oe,data:{...oe.data,...St!=null&&St.length?{points:St,manualRoute:!0}:{},flowAnimation:we,onRouteChange:to=>sn(oe.id,to),onSelect:to=>{to.stopPropagation(),!(Date.now()<re.current)&&(S(oo=>oo.map(jn=>({...jn,selected:jn.id===oe.id}))),t.relationships.some(oo=>oo.id===oe.id)&&F(oe.id))}}}});z(_?tn(V):V),S(On(V,ue)),ae(!1),es(oe=>oe+1)},u=B=>P=>{s||(console.error(`${B} layout error:`,P),ae(!1),wo(`${B} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},x=(B,P,_=!0)=>{ae(!0),wo(null),ia(P,B).then($=>c($,_)).catch(u(B))},y=()=>{const B=Xn.select({viewKind:L,diagramType:g==null?void 0:g.diagramType,isFBSDiagram:ke,isDecompDiagram:pt,isGeneralTemplate:Me,generalMode:De,layoutStyle:Ve}),P={onToggleExpand:qt,onToggleDirection:en},_={fbs:{expandedNodes:Ye,nodeDirections:mt,callbacks:P,layoutProviderId:Ee},decomposition:{expandedNodes:Ye,nodeDirections:mt,callbacks:P,positionCache:de.current},containment:{expandedNodes:Ye,callbacks:{onToggleExpand:qt}},useCase:{viewpointFilter:void 0,systemName:g==null?void 0:g.name,...g?io(g.properties):{},level:Ht,edgeStyle:_t,hiddenActorIds:_e},context:{systemName:g==null?void 0:g.name,viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes},interconnection:{viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes,collapsedNodes:Oo,onDrillIn:jt,onToggleCollapse:Zo,focusId:gt??void 0,portDisplay:Ge,connectionDisplay:Yt,onPortMove:nn,layoutProviderId:Ee},actionflow:{viewpointFilter:U,swimlanes:Ke,laneGrouping:rt,displayLevel:Wt,expandedActionIds:Vo,onToggleAction:Qo,onDrillInAction:wt,focusActionId:Be??void 0,visibleFlowKinds:be,direction:$t,nesting:Gt,layoutProviderId:Ee},statetransition:{viewpointFilter:U,collapsedStateIds:Xo,onToggleCollapse:Jo,onDrillIn:Ft,focusStateId:ft??void 0,layoutProviderId:Ee},sequence:{viewpointFilter:U},general:{mode:De,viewpointFilter:U,expandedNodes:Ye,nodeDirections:mt,callbacks:P,positionCache:de.current,hierarchyRelationshipTypes:g==null?void 0:g.relationshipTypes,layoutProviderId:Ee},standard:{viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes,compartments:Me,layoutProviderId:Ee}},$=B.compute(t,_);$ instanceof Promise?x(B.descriptor.label,$,B.descriptor.interactive):c($,B.descriptor.interactive)},M=window.setTimeout(y,sa);return()=>{s=!0,window.clearTimeout(M)}},[t,U,pt,ke,Ve,L,Me,De,Ke,ts,g==null?void 0:g.relationshipTypes,g==null?void 0:g.diagramType,g==null?void 0:g.name,Ht,_t,_e,Ee,Ye,Oo,gt,Ge,Yt,Vo,Be,be,$t,rt,Wt,Gt,mt,Xo,ft,Jo,Ft,wt,qt,Zo,Qo,en,l,jt,on,tn,ut,nn,sn,F,R]),d.useEffect(()=>{if(jo===0)return;const o=setTimeout(()=>{var u;const s=ve.current;if(ve.current=null,s){Q(s);return}const c=l?(u=O.getState().diagramLayouts[l])==null?void 0:u.canvas:void 0;(c==null?void 0:c.zoom)!==void 0&&c.pan?Q({x:c.pan.x,y:c.pan.y,zoom:c.zoom},{duration:300}):W({padding:.08,minZoom:Ie,maxZoom:2,duration:500})},200);return()=>clearTimeout(o)},[jo,l,W,Ie,Q]),d.useEffect(()=>{z(o=>o.map(s=>{const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0,u=!!a&&(s.id===a||c===a);return{...s,selected:u,style:{...s.style,boxShadow:u?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:a?u?1:.5:1}}}))},[a,z]),d.useEffect(()=>{if(!We||!t)return;const o=_i(t,We,"both",ct),s=new Set(o.nodes.map(c=>c.elementId));s.add(We),z(c=>c.map(u=>({...u,style:{...u.style,opacity:s.has(u.id)?1:.08,pointerEvents:s.has(u.id)?"all":"none"}}))),S(c=>c.map(u=>({...u,style:{...u.style,opacity:s.has(u.source)&&s.has(u.target)?1:.05}})))},[We,ct,t,z,S]),d.useEffect(()=>{if(!dt)return;const o=setTimeout(()=>Do(null),2500);return()=>clearTimeout(o)},[dt]),d.useEffect(()=>{const o=s=>{const c=s.target;if(!(c.tagName==="INPUT"||c.tagName==="TEXTAREA")){if((s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey){s.preventDefault();const u=Oe.current.pop();u&&(u.undo(),Ot.current.push(u))}if((s.metaKey||s.ctrlKey)&&(s.key==="Z"||s.key==="z"&&s.shiftKey)){s.preventDefault();const u=Ot.current.pop();u&&(u.do(),Oe.current.push(u))}s.key==="g"&&(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.preventDefault(),So(u=>!u)),s.key==="0"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),W({padding:.08,minZoom:Ie,maxZoom:2,duration:400}))}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[W,Ie]);const Ss=d.useCallback(o=>{o.preventDefault(),o.dataTransfer.dropEffect="copy"},[]),vs=d.useCallback(o=>{o.preventDefault();const s=o.dataTransfer.getData(Qn);if(s)try{const c=JSON.parse(s),u=E({x:o.clientX,y:o.clientY});Le({x:o.clientX,y:o.clientY,flowX:u.x,flowY:u.y,kind:c.kind,layer:c.layer,construct:c.construct})}catch{}},[E]),ks=d.useCallback(o=>{const s=E({x:o.clientX,y:o.clientY});Le({x:o.clientX,y:o.clientY,flowX:s.x,flowY:s.y})},[E]),Cs=d.useCallback(o=>{if(!se||!l){Le(null);return}const s=se.kind??"Part",c=se.layer??"logical",u=se.construct??"part",x=uo[c]??"#6B7280",y=Ki(o,Object.keys((t==null?void 0:t.elements)??{})),M={id:y,type:"diagramNode",position:{x:se.flowX,y:se.flowY},data:{label:o,kind:s,layer:c,construct:u,color:x,isNew:!0,onContextMenu:($,G)=>{$e({x:$.clientX,y:$.clientY,nodeId:G,nodeKind:s})},onInlineEdit:($,G)=>{kn({id:y,name:G,kind:s,construct:u,layer:c})}}};z($=>[...$,M]),ui({id:y,name:o,kind:s,construct:u,layer:c,attributes:{_layer:c}});const B=(g==null?void 0:g.elementIds)??[];T(l,[...B,y]);const P=l,_={nodes:{...(A[P]??{}).nodes??{},[y]:{x:se.flowX,y:se.flowY}},edges:(A[P]??{}).edges??{}};v({[P]:_}),je(P,_),Le(null)},[se,l,g,A,v,T,z]),Es=d.useCallback(()=>{$e(null),lt(null)},[]),Is=d.useCallback((o,s)=>{s!=null&&s.isValid},[]),eo=d.useCallback((o,s)=>{const c=Li(s);return(c?t==null?void 0:t.elements[c]:void 0)??(t==null?void 0:t.elements[o])},[t]),Ds=d.useCallback(o=>{const{source:s,target:c,sourceHandle:u,targetHandle:x}=o;if(!s||!c)return;const y=eo(s,u),M=eo(c,x);!y||!M||y.id!==M.id&&at({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:y,targetElement:M})},[eo]),Ns=d.useCallback(async o=>{if(!Fe||!l){at(null);return}const s=Fe.sourceElement.id;at(null);const c=await i({type:o.type,sourceId:o.sourceId,targetId:o.targetId,direction:o.direction,flowItem:o.flowItem,selectedElementId:s,diagramId:l});if(!c.success){console.warn(`[MEMO] Relationship rejected: ${c.error}`);return}if(!(K.current.some(M=>M.id===o.sourceId)&&K.current.some(M=>M.id===o.targetId)))return;const x=Cn[o.type]??"#6B7280",y={id:c.relationshipId??`e_${o.sourceId}_${o.targetId}_${o.type}`,source:o.sourceId,target:o.targetId,label:o.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}};S(M=>ti(y,M))},[Fe,l,S,i]),As=d.useCallback((o,s)=>{Ae.current={id:s.id,x:s.position.x,y:s.position.y}},[]),Ms=d.useCallback((o,s)=>{const c=Ae.current;if(Ae.current=null,!((c==null?void 0:c.id)===s.id&&Math.hypot(s.position.x-c.x,s.position.y-c.y)>2)||(re.current=Date.now()+250,ye(B=>B+1),!l))return;const{x,y}=s.position;if(s.type==="annotationNode")return;ee();const M=de.current.get(s.id);if(de.current.set(s.id,{x,y}),b(l,s.id,{x,y}),M){const B=s.id,P=l;No({do:()=>b(P,B,{x,y}),undo:()=>{b(P,B,M),z(_=>_.map($=>$.id===B?{...$,position:M}:$))}})}},[l,b,No,z,ee]),Bs=d.useCallback(o=>{const s=c=>{var u;return"id"in c&&((u=K.current.find(x=>x.id===c.id))==null?void 0:u.type)==="annotationNode"};o.some(c=>c.type==="position"&&c.dragging&&!s(c))&&ee(),o.some(c=>c.type==="dimensions"&&c.resizing)&&(o.some(c=>c.type==="dimensions"&&c.resizing&&!s(c))&&ee(),ye(c=>c+1)),ge(oi(o,K.current))},[ge,ee]),zs=d.useCallback((o,s)=>{},[]),Ts=d.useCallback((o,s)=>{o.preventDefault(),lt({x:o.clientX,y:o.clientY,edgeId:s.id,relType:String(s.label??"edge")})},[]),Rs=d.useCallback((o,s)=>{var x,y,M,B,P,_;if(Date.now()<re.current)return;if((o==null?void 0:o.shiftKey)||(o==null?void 0:o.metaKey)||(o==null?void 0:o.ctrlKey)||((x=o==null?void 0:o.nativeEvent)==null?void 0:x.shiftKey)||((y=o==null?void 0:o.nativeEvent)==null?void 0:y.metaKey)||((M=o==null?void 0:o.nativeEvent)==null?void 0:M.ctrlKey)||((B=o==null?void 0:o.getModifierState)==null?void 0:B.call(o,"Shift"))||((P=o==null?void 0:o.getModifierState)==null?void 0:P.call(o,"Meta"))||((_=o==null?void 0:o.getModifierState)==null?void 0:_.call(o,"Control"))){window.setTimeout(()=>z($=>$.map(G=>({...G,selected:G.selected||G.id===a||G.id===s.id}))),0);return}if(s.type==="annotationNode")return;const u=s.type==="actionFlowLane"?s.data.inspectElementId:void 0;!u&&(s.id.startsWith("__")||s.id.includes("__start")||s.id.includes("__done"))||(w(u??s.id),l&&h({type:"diagram",diagramId:l}))},[w,l,h,a,z]),Ls=d.useCallback((o,s)=>{var c;if((c=o==null?void 0:o.stopPropagation)==null||c.call(o),L==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(x=>x.parentAction===s.id))return;wt(s.id);return}if(L==="statetransition"){const u=s.data;if(!u.hasChildren||u.isMachine){w(s.id);return}Ft(s.id);return}if(L==="interconnection"){const u=s.data;if(!u.isContainer&&!u.hasChildren){w(s.id);return}jt(s.id)}},[L,t==null?void 0:t.elements,w,wt,Ft,jt]),$s=d.useCallback(()=>{f(null),F(null),$e(null),lt(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,boxShadow:void 0}}))),S(o=>o.map(s=>s.selected?{...s,selected:!1}:s))},[f,F,z,S]),Ws=d.useCallback((o,s)=>{var c;(c=o==null?void 0:o.stopPropagation)==null||c.call(o),!(Date.now()<re.current)&&(S(u=>u.map(x=>({...x,selected:x.id===s.id}))),t!=null&&t.relationships.some(u=>u.id===s.id)?F(s.id):t!=null&&t.elements[s.id]&&w(s.id))},[t,w,F,S]),Os=d.useCallback((o,s)=>{et({endpointIds:[s.id]})},[]),Ps=d.useCallback((o,s)=>{et({edgeId:s.id,endpointIds:Vn(s)})},[]),rn=d.useCallback(()=>et(null),[]),Hs=d.useCallback((o,s)=>{var c;l&&(b(l,o,{...((c=A[l])==null?void 0:c.nodes[o])??{x:0,y:0},color:s||void 0}),z(u=>u.map(x=>x.id===o?{...x,data:{...x.data,bgColor:s||void 0}}:x)))},[l,A,b,z]),pe=d.useMemo(()=>H.filter(o=>o.selected&&o.type!=="actionFlowLane"&&!o.id.startsWith("__")),[H]),ze=d.useCallback(()=>pe.map(o=>{var s,c,u,x;return{id:o.id,x:o.position.x,y:o.position.y,width:Number(o.width??((s=o.measured)==null?void 0:s.width)??((c=o.style)==null?void 0:c.width)??180),height:Number(o.height??((u=o.measured)==null?void 0:u.height)??((x=o.style)==null?void 0:x.height)??96)}}),[pe]),Te=d.useCallback(o=>{o.size!==0&&(ee(),z(s=>s.map(c=>{const u=o.get(c.id);return u?{...c,position:{x:u.x??c.position.x,y:u.y??c.position.y},...u.width!==void 0?{width:u.width}:{},...u.height!==void 0?{height:u.height}:{},...u.width!==void 0||u.height!==void 0?{style:{...c.style,...u.width!==void 0?{width:u.width}:{},...u.height!==void 0?{height:u.height}:{}}}:{}}:c})),ye(s=>s+1))},[ee,z]),_s=d.useCallback(o=>{Te(Ui(ze(),o))},[Te,ze]),Ks=d.useCallback(o=>{Te(qi(ze(),o))},[Te,ze]),Vs=d.useCallback(o=>{Te(Zi(ze(),o))},[Te,ze]),an=d.useCallback(o=>{if(!l||pe.length===0)return;ee();const s=O.getState().diagramLayouts[l];for(const u of pe){const x=(s==null?void 0:s.nodes[u.id])??{x:u.position.x,y:u.position.y};b(l,u.id,{...x,...o.color!==void 0?{color:o.color||void 0}:{},...o.opacity!==void 0?{opacity:o.opacity}:{}})}const c=new Set(pe.map(u=>u.id));z(u=>u.map(x=>c.has(x.id)?{...x,data:{...x.data,...o.color!==void 0?{bgColor:o.color||void 0}:{},...o.opacity!==void 0?{fillOpacity:o.opacity}:{}}}:x)),ye(u=>u+1)},[l,pe,ee,b,z]),Ys=d.useMemo(()=>{const o=pe.map(s=>Number(s.data.fillOpacity??1));return o.length===0?1:o.every(s=>s===o[0])?o[0]:1},[pe]),ln=d.useCallback(o=>{if(!l||!g)return;const s=(g.elementIds??[]).filter(c=>c!==o);T(l,s),z(c=>c.filter(u=>u.id!==o))},[l,g,T,z]),Xs=d.useCallback((o,s)=>{const c=s==="dashed"?"6 3":s==="dotted"?"2 3":void 0;S(u=>u.map(x=>x.id===o?{...x,style:{...x.style,strokeDasharray:c}}:x))},[S]),Gs=d.useCallback((o,s)=>{S(c=>c.map(u=>u.id===o?{...u,style:{...u.style,stroke:s||(Cn[String(u.label??"")]??"#6B7280")}}:u))},[S]),Us=d.useCallback(o=>{S(s=>s.map(c=>c.id===o?{...c,label:c.label?"":o.split("_")[3]??""}:c))},[S]);if(g&&t&&L==="grid")return e.jsx($i,{diagram:g,model:t,viewpointFilter:U});if(g&&t&&L==="browser")return e.jsx(Wi,{diagram:g,model:t,viewpointFilter:U});if(g&&L==="geometry"){const o=En.geometry;return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"380px"},children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded font-semibold",style:{background:o.color+"20",color:o.color,fontSize:D.badge,marginBottom:"12px"},children:o.label}),e.jsx("h3",{style:{fontSize:D.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:g.name}),e.jsx("p",{style:{fontSize:D.md,color:"#9CA3AF",lineHeight:1.6},children:"Geometry View rendering is deferred (ADR-1-19): the ontology carries no spatial data to draw. This view is recognized and validated, but has no renderer yet."})]})})}return!g&&H.length===0&&!Z?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!Re&&e.jsx(ao,{collapsed:Re,onToggleCollapse:()=>Lt(!0)}),Re&&e.jsx(ao,{collapsed:!0,onToggleCollapse:()=>Lt(!1)}),e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"📊"}),e.jsx("h3",{style:{fontSize:D.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),e.jsx("p",{style:{fontSize:D.md,color:"#9CA3AF",lineHeight:1.6},children:"Choose a diagram from the sidebar or drag elements from the palette."})]})})]}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx(ao,{collapsed:Re,onToggleCollapse:()=>Lt(!Re),elementIds:g==null?void 0:g.elementIds,eligibleKinds:(fn=g==null?void 0:g.elementKinds)!=null&&fn.length?new Set(g.elementKinds):g!=null&&g.viewpointId&&(t!=null&&t.viewpoints)?new Set(((mn=t.viewpoints.find(o=>o.id===g.viewpointId))==null?void 0:mn.visibleKinds)??[]):void 0}),e.jsxs("div",{className:"flex-1 relative",onDragOver:Ss,onDrop:vs,onDoubleClick:ks,children:[g&&e.jsxs("div",{className:"absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs relative",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[He&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:He.color+"20",color:He.color,fontSize:D.badge},title:`${He.fullName}${Pe?` · ${Pe.fullName}`:""}`,children:L==="actionflow"?ps:He.label}),e.jsx("span",{className:"font-medium",style:{color:"#1a1a1a"},children:g.name}),g.auto&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"auto"}),e.jsx(xe,{}),e.jsx(Je,{icon:e.jsx(Y.grid,{}),label:"Grid",active:vo,onClick:()=>{ns(o=>{const s=!o;return So(s),s})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),ke&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),L==="actionflow"&&e.jsxs(e.Fragment,{children:[e.jsx(Je,{icon:e.jsx(Y.lanes,{}),active:Ke,onClick:()=>$o(o=>!o),title:"Toggle allocation swimlanes"}),Ke&&us&&e.jsx(Je,{icon:e.jsx(Y.lanes,{}),label:"Stage",active:rt==="stage",onClick:()=>ko(o=>o==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),Ke&&rt==="allocation"&&Wo.length>0&&e.jsxs("select",{"aria-label":"Display hierarchy level",title:"Display responsibility lanes at a hierarchy level; the SysML allocation is unchanged",value:Wt,onChange:o=>Co(o.target.value==="all"?"all":Number(o.target.value)),className:"text-xs font-semibold rounded-lg px-2 py-1",style:{color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Wo.map(o=>e.jsxs("option",{value:o,children:["L",o]},o))]}),e.jsx(xe,{}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Steps"}),e.jsx(Nt,{value:Gt,onChange:Yo,options:[{value:"flat",label:"Inline",title:"Expanded steps join the parent flow in place"},{value:"nested",label:"Nested",title:"Expanded steps are drawn inside their composite action (swimlanes off)"}]}),e.jsx(xe,{}),e.jsx(Nt,{value:$t,onChange:ss,options:[{value:"horizontal",icon:e.jsx(Y.arrowRight,{}),title:"Left-to-right flow"},{value:"vertical",icon:e.jsx(Y.arrowDown,{}),title:"Top-to-bottom flow"}]}),e.jsx(xe,{}),e.jsxs(qr,{children:[e.jsx(ie,{icon:e.jsx(Y.expand,{}),title:"Expand all sub-actions",onClick:()=>Ue(new Set(Object.values((t==null?void 0:t.elements)??{}).map(o=>o.parentAction).filter(o=>!!o)))}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),title:"Collapse all sub-actions",onClick:()=>Ue(new Set)})]}),e.jsx(xe,{}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Je,{icon:e.jsx(Y.filter,{}),active:Eo,badge:`${be.size}/4`,onClick:()=>is(o=>!o),title:"Choose which modeled connection categories are visible"}),Eo&&e.jsxs("div",{className:"absolute top-full right-0 mt-2 p-3 rounded-lg",style:{width:264,background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:30},children:[e.jsx("div",{style:{color:"#1F2937",fontWeight:700,fontSize:D.xs},children:"Show connection categories"}),e.jsx("div",{style:{color:"#6B7280",fontSize:D.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(o=>{const s=be.has(o),c=o==="control"?"#4B5563":o==="data"?"#3498DB":o==="energy"?"#D97706":"#16A34A";return e.jsxs("button",{role:"switch","aria-checked":s,onClick:()=>rs(u=>{const x=new Set(u);return x.has(o)?x.delete(o):x.add(o),x}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${s?"Hide":"Show"} ${o} connections`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:c}}),o]}),e.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:s?"#2563EB":"#D1D5DB",padding:2,transition:"background 160ms ease"},children:e.jsx("span",{style:{display:"block",width:14,height:14,borderRadius:"50%",background:"#FFFFFF",boxShadow:"0 1px 2px rgba(0,0,0,0.22)",transform:s?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},o)})]})]}),e.jsx(co,{path:ms,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Xt,rootLabel:"Back to the whole action flow"})]}),L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:()=>Xe(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:()=>Xe(new Set(ys)),title:"Collapse all parts",ariaLabel:"Collapse all"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Ports"}),e.jsx(Nt,{value:Ge,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"}]}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Connections"}),e.jsx(Nt,{value:Yt,onChange:Ho,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"}]}),e.jsx(co,{path:gs,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Vt,rootLabel:"Back to the whole diagram"})]}),L==="statetransition"&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:()=>qe(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:()=>qe(new Set(yt)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),e.jsx(co,{path:fs,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Ut,rootLabel:"Back to the whole machine"})]}),Pt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Level",e.jsxs("select",{"aria-label":"Use case hierarchy level",value:Ht,onChange:o=>zo(o.target.value==="all"?"all":Number(o.target.value)),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Array.from({length:cs+1},(o,s)=>e.jsxs("option",{value:s,children:["L",s]},s))]})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Routing",e.jsxs("select",{"aria-label":"Use case connector routing",value:_t,onChange:o=>To(o.target.value),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"straight",children:"Straight"}),e.jsx("option",{value:"elbow",children:"Elbow"}),e.jsx("option",{value:"rounded",children:"Rounded"}),e.jsx("option",{value:"curved",children:"Curved"}),e.jsx("option",{value:"arc",children:"Arc"})]})]}),e.jsx("button",{onClick:js,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"}),Lo.length>0&&e.jsxs("details",{className:"relative",children:[e.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",_e.size?`: ${_e.size} hidden`:""]}),e.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:[e.jsx("div",{className:"mb-1 text-xs",style:{color:"#64748B"},children:"Hide related use cases"}),Lo.map(o=>e.jsxs("label",{className:"flex items-center gap-2 py-1 text-xs",style:{color:"#374151"},children:[e.jsx("input",{type:"checkbox",checked:_e.has(o.id),onChange:()=>Ro(s=>{const c=new Set(s);return c.has(o.id)?c.delete(o.id):c.add(o.id),c})}),o.name]},o.id))]})]})]}),Me&&!Pt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:ds.map(o=>e.jsx("button",{onClick:()=>{Bo(o),de.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:De===o?"#1B3A4B":"#FFFFFF",color:De===o?"#FFFFFF":"#6B7280"},title:o==="graph"?"Relationship graph with compartments":o==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:o},o))}),De!=="graph"&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"}),De==="tree"&&e.jsx("button",{onClick:Jt,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"})]})]}),pt&&!ke&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["containment","decomposition"].map(o=>e.jsx("button",{onClick:()=>{hs(o),de.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:Ve===o?"#1B3A4B":"#FFFFFF",color:Ve===o?"#FFFFFF":"#6B7280"},children:o==="containment"?"Containment":"Decomposition"},o))}),e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"}),Ve==="decomposition"&&e.jsx("button",{onClick:Jt,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"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),!Pt&&e.jsxs("button",{"aria-pressed":me,onClick:()=>{if(me)ee();else{const o=O.getState().diagramLayouts[l],s={nodes:{},edges:{},canvas:{...o==null?void 0:o.canvas,autoLayout:!0}};v({[l]:s}),je(l,s),Rt(c=>c+1)}},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:me?"#ECFDF5":"#FFF7ED",color:me?"#047857":"#C2410C",border:`1px solid ${me?"#A7F3D0":"#FED7AA"}`},title:me?"Auto layout is on. Drag any item to switch it off and preserve your changes automatically.":"Auto layout is off. Your changes are saved automatically; click to discard overrides and recalculate.",children:["Auto layout: ",me?"On":"Off"]})]}),l&&L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #CBD5E1"},children:["note","text","constraint"].map(o=>e.jsxs("button",{onClick:()=>ls(o),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:"#FFFFFF",color:"#475569",border:0},title:`Add an editable ${o} annotation to this IBD`,children:["+ ",o]},o))}),e.jsxs("button",{"aria-pressed":we,onClick:()=>{const o=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},s={...o,canvas:{...o.canvas,flowAnimation:!we}};v({[l]:s}),je(l,s),S(c=>c.map(u=>({...u,data:{...u.data,flowAnimation:!we}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:we?"#EFF6FF":"#F8FAFC",color:we?"#1D4ED8":"#64748B",border:`1px solid ${we?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",we?"On":"Off"]}),e.jsx("button",{"aria-pressed":_o,onClick:()=>Ko(o=>!o),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"})]})]}),We&&e.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:[e.jsx("span",{style:{color:"#2DD4A8",fontWeight:700},children:"◎ Focus"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Depth"}),[1,2,3].map(o=>e.jsx("button",{onClick:()=>as(o),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:ct===o?"#2DD4A8":"rgba(255,255,255,0.15)",color:ct===o?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:o},o)),e.jsx("button",{onClick:()=>{Io(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,pointerEvents:"all"}}))),S(o=>o.map(s=>({...s,style:{...s.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"})]}),dt&&e.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: ",dt]}),Z&&e.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…"}),Fo&&!Z&&e.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:D.xs},children:[e.jsx("span",{children:Fo}),e.jsx("button",{onClick:Jt,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),ht.length>0&&!Z&&e.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:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",ht.length," floating ",ht.length===1?"action has":"actions have"," no flow or succession connection:"," ",ht.map((o,s)=>e.jsxs("span",{children:[s>0&&", ",e.jsx("button",{onClick:()=>w(o.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:o.name})]},o.id))]}),bt&&!Z&&e.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:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",bt.rootIds.length," roots",bt.disconnectedIds.length>0&&e.jsxs(e.Fragment,{children:[" and ",bt.disconnectedIds.length," disconnected/floating elements"]}),"."]}),L==="actionflow"&&e.jsxs("div",{"aria-label":"Action flow legend",className:"absolute right-3 bottom-3 z-10 flex items-center gap-4 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:3,color:"#374151",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Legend"}),be.has("control")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2px solid #4B5563"}}),"Control flow"]}),be.has("data")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #3498DB"}}),"Object flow"]}),be.has("energy")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #D97706"}}),"Energy flow"]}),be.has("material")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #16A34A"}}),"Material flow"]})]}),L==="interconnection"&&H.length>0&&_o&&e.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:D.xs},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Ports"}),Ge!=="none"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.in,glyph:"→"})," in"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.out,glyph:"→"})," out"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.inout,glyph:"⇄"})," inout"]}),Ge==="all"&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:"#6B728022",border:"1.5px solid #6B7280"}}),"nested"]})]}):e.jsx("span",{style:{color:"#9CA3AF"},children:"hidden"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Flow"}),["data","energy","material"].map(o=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${Oi[o]}`}}),o]},o))]})]}),!Z&&H.length===0&&g&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:g.auto&&((yn=g.elementIds)==null?void 0:yn.length)===0?e.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🔍"}),e.jsx("div",{style:{fontSize:D.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),e.jsx("div",{style:{fontSize:D.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."})]}):e.jsxs("div",{className:"text-center",style:{opacity:.4},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🖱️"}),e.jsx("div",{style:{fontSize:D.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),pe.length>=2&&e.jsx(Xi,{count:pe.length,opacity:Ys,onAlign:_s,onMatchSize:Ks,onDistribute:Vs,onFill:o=>an({color:o}),onOpacity:o=>an({opacity:o})}),Z&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${In.accent} 0%, ${In.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),e.jsxs(ni,{nodes:H,edges:q,nodeTypes:bs,edgeTypes:Fs,onNodesChange:Bs,onEdgesChange:te,onNodeClick:Rs,onNodeDoubleClick:Ls,onEdgeClick:Ws,onPaneClick:$s,onNodeDragStart:As,onNodeDragStop:Ms,onNodeContextMenu:zs,onEdgeContextMenu:Ts,onNodeMouseEnter:Os,onNodeMouseLeave:rn,onEdgeMouseEnter:Ps,onEdgeMouseLeave:rn,onConnect:Ds,onConnectStart:Es,onConnectEnd:Is,connectionMode:si.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:os,snapGrid:oa,fitView:!0,fitViewOptions:{...Jr,minZoom:Ie},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!0,panOnDrag:[1,2],multiSelectionKeyCode:["Shift","Meta","Control"],selectionKeyCode:null,proOptions:ta,style:Qr,children:[vo&&e.jsx(ii,{color:"#C5C7C2",gap:20,size:1.5}),e.jsx(tr,{}),e.jsx(ri,{}),H.length>20&&e.jsx(ai,{style:ea,nodeColor:ws,maskColor:"rgba(247, 247, 245, 0.7)"})]})]}),se&&e.jsx(aa,{x:se.x,y:se.y,onConfirm:Cs,onCancel:()=>Le(null)}),Fe&&e.jsx(Pi,{x:Fe.x,y:Fe.y,sourceElement:Fe.sourceElement,targetElement:Fe.targetElement,registries:n,allowedTypes:g==null?void 0:g.relationshipTypes,onSelect:Ns,onCancel:()=>at(null)}),J&&e.jsx(Hr,{x:J.x,y:J.y,nodeId:J.nodeId,nodeKind:J.nodeKind,onClose:()=>$e(null),onEditName:()=>{z(o=>o.map(s=>s.id===J.nodeId?{...s,data:{...s.data,_triggerEdit:!0}}:s))},onChangeColor:o=>Hs(J.nodeId,o),onRemoveFromDiagram:()=>ln(J.nodeId),onDeleteFromModel:()=>{ln(J.nodeId)},onShowProperties:()=>{f(J.nodeId)},onShowInCatalog:()=>{f(J.nodeId),I("catalog")},onFocusElement:()=>{Io(J.nodeId)},onShowRelMatrix:()=>{h({type:"traceability"})},onOpenSource:()=>{const o=t==null?void 0:t.elements[J.nodeId];o!=null&&o.file&&(navigator.clipboard.writeText(o.file).catch(()=>{}),Do(o.file))},onViewKindInOntology:()=>{const o=J.nodeKind;let s=null,c=null;for(const u of j){for(const x of u.layers)if(x.kinds.some(y=>y.name===o)){s=u.name,c=x.id;break}if(s)break}s&&(m(o),C("ontologies"),I("ontology"),h({type:"ontology-detail",packageName:s,layerId:c??void 0}))}}),fe&&e.jsx(Kr,{x:fe.x,y:fe.y,edgeId:fe.edgeId,relType:fe.relType,onClose:()=>lt(null),onChangeStyle:o=>Xs(fe.edgeId,o),onChangeColor:o=>Gs(fe.edgeId,o),onToggleLabel:()=>Us(fe.edgeId),onDelete:()=>S(o=>o.filter(s=>s.id!==fe.edgeId))})]})}function ya(){return e.jsx(Qs,{children:e.jsx(la,{})})}export{ya as DiagramCanvas};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-B9d4aLKt.js","assets/reactflow-CsCqNKB-.js","assets/zustand-CrhqMOHB.js","assets/index-CVW92JY7.js","assets/index-Y1UZTZg-.css","assets/layout-selection-ClQ295Xc.js","assets/layout-providers-Dr743WlP.js","assets/elk-6l8mIQnQ.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-DqKU1PTY.js","assets/SysmlCodeEditor-Die2RUsz.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
var fe=Object.defineProperty;var me=(t,s,i)=>s in t?fe(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;var B=(t,s,i)=>me(t,typeof s!="symbol"?s+"":s,i);import{_ as P,u as C,g as xe,a as he,l as pe,s as ge,b as ve,c as Se,F as d,C as a,d as ye,L as be,e as Ee,f as Fe}from"./index-CVW92JY7.js";import{j as e}from"./reactflow-CsCqNKB-.js";import{a as r}from"./zustand-CrhqMOHB.js";const V="memo.renderer.reactflow";class we{constructor(){B(this,"providers",new Map);B(this,"components",new Map)}register(s){const i=this.providers.get(s.descriptor.id);if(i&&i!==s)throw new Error(`Renderer provider already registered: ${s.descriptor.id}`);this.providers.set(s.descriptor.id,s)}unregister(s){return this.components.delete(s),this.providers.delete(s)}get(s){return this.providers.get(s)}has(s){return this.providers.has(s)}list(s=[]){return[...this.providers.values()].map(i=>i.descriptor).filter(i=>s.every(o=>i.capabilities.includes(o))).sort((i,o)=>i.name.localeCompare(o.name))}loadComponent(s){const i=this.providers.get(s)??this.providers.get(V);if(!i)throw new Error(`Renderer provider not found: ${s} (no default registered)`);const o=i.descriptor.id;let n=this.components.get(o);return n||(n=i.loadComponent(),this.components.set(o,n)),n}}const Re={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:()=>P(()=>import("./DiagramCanvas-B9d4aLKt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>t.DiagramCanvas)},je={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:()=>P(()=>import("./MaxGraphCanvas-DqKU1PTY.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(t=>t.MaxGraphCanvas)},$=new we;$.register(Re);$.register(je);const Ce={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Ae="memo.diagram.renderer.v3",_e="renderer",ke="memo.renderer.",se=new Set;function G(t){const s=t==null?void 0:t.trim();if(s)return s.includes(".")?s:`${ke}${s}`}function De(){if(!(typeof window>"u"))try{return G(new URLSearchParams(window.location.search).get(_e))}catch{return}}function Te(){if(!(typeof window>"u"))try{return G(window.localStorage.getItem(Ae))}catch{return}}function Le(){try{const t=Ce;return G(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function re(){return De()??Te()??Le()??V}function Me(t){return se.add(t),()=>se.delete(t)}function Ne(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function ze(){const t=r.useSyncExternalStore(Me,re,re),s=$.has(t)?t:V,i=r.useMemo(()=>r.lazy(()=>$.loadComponent(s).then(o=>({default:o}))),[s]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(r.Suspense,{fallback:e.jsx(Ne,{}),children:e.jsx(i,{})})})}const $e=r.lazy(()=>P(()=>import("./SysmlCodeEditor-Die2RUsz.js"),__vite__mapDeps([10,1,2,11])).then(t=>({default:t.SysmlCodeEditor})));function Oe(t,s){const i=(t.elementIds??[]).map(o=>s[o]).filter(Boolean).map(o=>` ${o.construct??"part"} ${o.id} : ${o.kind};`).join(`
|
|
3
|
-
`);return[`package '${t.name}' {`,` // Diagram: ${t.diagramType.toUpperCase()} | Viewpoint: ${t.viewpointId}`,i||" // No elements selected","}"].join(`
|
|
4
|
-
`)}function Ie({diagram:t}){const s=C(c=>c.model),i=C(c=>c.updateDiagramElementIds),[o,n]=r.useState(""),m=r.useMemo(()=>ye(s),[s]),O=r.useCallback(c=>{const x=new Set(t.elementIds??[]);x.has(c)?x.delete(c):x.add(c),i(t.id,[...x])},[t.id,t.elementIds,i]),w=r.useMemo(()=>new Set(t.elementIds??[]),[t.elementIds]),E=be.filter(c=>m.has(c));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${a.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${a.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:a.primary,fontSize:d.xs},children:["Elements (",w.size," selected)"]}),e.jsx("input",{value:o,onChange:c=>n(c.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${a.border}`,color:a.primary,fontSize:d.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:E.map(c=>{const x=(m.get(c)??[]).filter(u=>!o||u.name.toLowerCase().includes(o.toLowerCase())||u.id.toLowerCase().includes(o.toLowerCase()));if(x.length===0)return null;const I=Fe[c]??a.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:I,fontSize:d.badge},children:Ee[c]??c}),x.map(u=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:d.xs},onMouseEnter:h=>h.currentTarget.style.background="#F0F0ED",onMouseLeave:h=>h.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:w.has(u.id),onChange:()=>O(u.id),style:{accentColor:a.accent}}),e.jsx("span",{className:"truncate",style:{color:a.primary},title:u.id,children:u.name||u.id})]},u.id))]},c)})})]})}function ne({tone:t,message:s,actions:i}){const o=t==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:o?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${o?"#FECACA":"#FDE68A"}`,color:o?"#B91C1C":"#92400E",fontSize:d.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:s}),i.map(n=>e.jsx("button",{onClick:n.onClick,title:n.hint,style:{fontSize:d.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${o?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:n.label},n.label))]})}const Be=4e3;function Pe({at:t}){const[s,i]=r.useState(!1);return r.useEffect(()=>{if(!t)return;i(!0);const o=setTimeout(()=>i(!1),Be);return()=>clearTimeout(o)},[t]),s?e.jsx("span",{title:"A source file this view depends on changed; the view was rebuilt",style:{fontSize:d.badge,padding:"1px 6px",borderRadius:999,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0",whiteSpace:"nowrap"},children:"↻ Refreshed from source"}):null}const Ve=[];function We({diagramId:t}){const s=C(l=>l.model),i=C(l=>l.diagramParseErrors[t]??Ve),o=C(l=>l.lastSourceChange),n=xe(s,t),[m,O]=r.useState("visual"),[w,E]=r.useState(""),[c,x]=r.useState(!1),[I,u]=r.useState(!1),[h,Y]=r.useState(!1),[p,A]=r.useState(!1),[R,y]=r.useState(null),[oe,q]=r.useState(null),[_,j]=r.useState(null),[k,D]=r.useState(null),[ie,le]=r.useState(null),[U,W]=r.useState([]),[T,ae]=r.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),b=r.useRef(),v=r.useRef(""),K=r.useRef(0),L=r.useRef(void 0),M=r.useRef(0),H=r.useRef(!1);r.useEffect(()=>{H.current=p},[p]);const Q=r.useMemo(()=>he(s,t),[s,t]),N=r.useCallback(async()=>{const l=++M.current,g=t;x(!0);try{const S=await pe(g);if(M.current!==l)return!1;const f=S.text??"";return v.current=f,L.current=S.revision,E(f),u(!0),A(!1),y(null),D(null),j(null),!0}catch(S){return M.current===l&&y(S instanceof Error?S.message:String(S)),!1}finally{M.current===l&&x(!1)}},[t]);r.useEffect(()=>{if(clearTimeout(b.current),y(null),q(null),A(!1),j(null),D(null),W([]),L.current=void 0,!(!n||!s)){if(!n.sourceFile||window.__MEMO_DATA__){const l=Oe(n,s.elements);v.current=l,E(l),x(!1),u(!1);return}E(""),v.current="",u(!1),N()}},[t,n==null?void 0:n.sourceFile]),r.useEffect(()=>{if(!o||!(n!=null&&n.sourceFile)||window.__MEMO_DATA__||!ge(o,Q))return;le(o.at);const l=o.files.includes(n.sourceFile);if(l){if(H.current){j({files:o.files.filter(g=>Q.includes(g)),at:o.at,touchesOwnSource:l});return}N()}},[o==null?void 0:o.seq]);const ce=l=>{v.current=l,E(l),A(!0),y(null)},F=r.useCallback(async(l,g)=>{if(!n)return;const S=++K.current;Y(!0),y(null);try{if(n.sourceFile){const f=await ve(t,l,g!=null&&g.force?void 0:L.current);if(f.conflict){D({theirs:f.text??"",revision:f.revision,at:Date.now()}),y(f.error??"The file changed on disk since this edit began.");return}L.current=f.revision,D(null),j(null),W(f.parseErrors??[])}else Se(t,l);v.current===l&&A(!1),q(Date.now())}catch(f){y(f instanceof Error?f.message:String(f))}finally{K.current===S&&Y(!1)}},[n,t]),X=r.useCallback(()=>{clearTimeout(b.current),N()},[N]),de=r.useCallback(()=>{clearTimeout(b.current),F(v.current,{force:!0})},[F]);r.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(T)),clearTimeout(b.current),T&&p&&!c&&!k&&(b.current=setTimeout(()=>void F(v.current),800)),()=>clearTimeout(b.current)),[T,p,c,w,F,k]);const J=r.useCallback(()=>{clearTimeout(b.current),F(v.current)},[F]),ue=r.useMemo(()=>Object.values((s==null?void 0:s.elements)??{}).map(l=>({id:l.id,name:l.name,kind:l.kind})),[s==null?void 0:s.elements]);if(!n)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:a.faint,fontSize:d.sm},children:"Diagram not found"});const Z=n.auto,z=!Z||!!n.sourceFile&&I,ee=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[k&&e.jsx(ne,{tone:"conflict",message:`${n.sourceFile} changed on disk while you were editing. Saving now would discard those changes.`,actions:[{label:"Reload from disk",onClick:X,hint:"Discards your unsaved edits"},{label:"Overwrite with mine",onClick:de,hint:"Discards the changes on disk"}]}),!k&&_&&e.jsx(ne,{tone:"notice",message:_.files.length>1?`${_.files.length} source files changed on disk. Your unsaved edits are untouched.`:`${_.files[0]} changed on disk. Your unsaved edits are untouched.`,actions:[{label:"Reload from disk",onClick:X,hint:"Discards your unsaved edits"},{label:"Keep editing",onClick:()=>j(null),hint:"Dismiss until the next change"}]}),e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:d.xs},children:"Loading SysML editor…"}),children:e.jsx($e,{value:w,sourceFile:n.sourceFile,readOnly:!z||c,symbols:ue,onChange:ce,onSave:()=>{z&&p&&J()}})})}),U.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:U.join(" · ")}),i.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:i.join(" · ")}),R&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:R}),!z&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:a.faint,borderTop:`1px solid ${a.border}`},children:n.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":n.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),te=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(ze,{})}),!Z&&e.jsx(Ie,{diagram:n})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderBottom:`1px solid ${a.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsx("span",{className:"font-semibold truncate flex-1",style:{color:a.primary,fontSize:d.sm},children:n.name}),n.sourceFile&&e.jsx("span",{className:"truncate",title:n.sourceFile,style:{maxWidth:"220px",color:a.faint,fontSize:d.xs},children:n.sourceFile}),(m==="text"||m==="split")&&e.jsx("span",{title:"Local, public Monaco editor with SysML highlighting and model-aware completion",style:{color:"#4B6E80",fontSize:d.badge},children:"Monaco · SysML"}),e.jsx(Pe,{at:ie}),c&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Loading source…"}),h&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Saving…"}),!h&&R&&e.jsx("span",{title:R,style:{color:"#EF4444",fontSize:d.xs},children:"Save failed"}),!h&&!R&&p&&e.jsx("span",{style:{color:"#B45309",fontSize:d.xs},children:"Unsaved"}),!h&&!p&&oe&&e.jsx("span",{style:{color:"#15803D",fontSize:d.xs},children:"Saved"}),!h&&i.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:d.xs},children:[i.length," error",i.length>1?"s":""]}),z&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:a.secondary,fontSize:d.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:T,onChange:l=>ae(l.target.checked),style:{accentColor:a.accent}}),"Auto-save"]}),e.jsx("button",{onClick:J,disabled:!p||h||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:d.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${a.border}`,cursor:!p||h||c?"default":"pointer",background:p?a.accent:"#F0F0ED",color:p?"#FFFFFF":a.faint,fontWeight:600},children:"Save"})]}),e.jsx("div",{className:"flex overflow-hidden",style:{border:`1px solid ${a.border}`,borderRadius:"6px"},children:[["visual","⬜ Visual"],["split","⧉ Split"],["text","</> Text"]].map(([l,g])=>e.jsx("button",{onClick:()=>O(l),style:{fontSize:d.xs,padding:"3px 10px",border:"none",cursor:"pointer",background:m===l?a.accent:"transparent",color:m===l?"#FFFFFF":a.secondary,fontWeight:m===l?600:400},children:g},l))})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m==="visual"&&te,m==="text"&&ee,m==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${a.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:ee}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:te})]})]})]})}export{We as DiagramEditor};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as b}from"./zustand-CrhqMOHB.js";import{u,h as W,C as i,F as o,f as B,q as C,P as v,t as S,v as M,w as O,x as $,y as k}from"./index-CVW92JY7.js";const p="page",D=new Set(["Scenario","UseCase","UserActivity"]);function V(d){return d?d.split(`
|
|
2
|
-
`).filter(n=>n.trim()).map((n,l)=>{const x=n.match(/^\d+\.\s*(.*)/);return{index:l,text:x?x[1].trim():n.trim()}}):[]}function U({element:d,layerColor:n,onSave:l}){const x=b.useMemo(()=>V(d.doc||""),[d.doc]),[j,h]=b.useState(!1);return j||x.length===0?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:o.xs,color:i.faint,marginBottom:6,marginTop:0},children:["One step per line, numbered: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx(S,{value:d.doc||"",onSave:c=>{l(c),h(!1)},density:p,multiline:!0,placeholder:"Click to add scenario steps…"})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>h(!0),style:{position:"absolute",top:0,right:0,fontSize:o.xs,color:i.muted,padding:"2px 9px",border:`1px solid ${i.border}`,borderRadius:"6px",background:i.surface,cursor:"pointer"},onMouseEnter:c=>{c.currentTarget.style.borderColor=i.accent},onMouseLeave:c=>{c.currentTarget.style.borderColor=i.border},children:"✎ Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:o.xs,fontWeight:700,background:n,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),x.map((c,s)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx(N,{color:n}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:i.surface,border:`1px solid ${n}30`,borderRadius:"8px",padding:"10px 14px",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("span",{style:{flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:n+"18",color:n,fontSize:o.xs,fontWeight:700},children:s+1}),e.jsx("span",{style:{fontSize:o.sm,color:i.primary,lineHeight:1.5,paddingTop:"3px"},children:c.text})]})]},s)),e.jsx(N,{color:n}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:o.xs,fontWeight:700,background:n+"20",color:n,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${n}40`},children:"End"})]})]})}function N({color:d}){return e.jsx("div",{style:{width:"2px",height:"20px",background:d+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${d}80`}})})}function Y({elementId:d}={}){var I,R,T;const n=u(t=>t.activeView),l=u(t=>t.model),x=u(t=>t.validation),j=u(t=>t.updateElementField),h=u(t=>t.updateElementAttribute),c=u(t=>t.applyEdit),s=d??(n.type==="element-detail"?n.elementId:null),r=s&&l?l.elements[s]:null,E=b.useMemo(()=>{if(!l||!s)return{incoming:[],outgoing:[]};const t=W(l,s);return{incoming:t.filter(a=>a.targetId===s),outgoing:t.filter(a=>a.sourceId===s)}},[l,s]),g=b.useMemo(()=>!x||!s?[]:x.violations.filter(t=>t.elementId===s),[x,s]);if(!r||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:i.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:i.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:o.md},children:"Select an element to view details"})]})});const f=B[r.layer]||i.muted,m=(I=l==null?void 0:l.registries)==null?void 0:I.kinds.find(t=>t.name===r.kind),w=((R=m==null?void 0:m.namespace)==null?void 0:R[1])??((T=m==null?void 0:m.namespace)==null?void 0:T[0]),z=(t,a)=>{j(s,t,a),c(s)},L=(t,a)=>{h(s,t,a),c(s)},y=Object.entries(r.attributes).filter(([t])=>t!=="id"&&t!=="name"),F=D.has(r.kind);return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"#EEF4F7"},children:e.jsxs("div",{style:{maxWidth:"1040px",margin:"0 auto",padding:"20px 28px 48px"},children:[e.jsxs("header",{style:{background:i.surface,border:"1px solid rgba(60,60,67,0.12)",borderLeft:`4px solid ${f}`,borderRadius:"16px",padding:"14px 18px",marginBottom:16,boxShadow:"0 1px 3px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",style:{marginBottom:8},children:[e.jsx("span",{className:"px-2 py-0.5 rounded-md font-semibold",style:{background:f+"18",color:f,fontSize:o.xs},children:r.kind}),e.jsx("span",{className:"px-2 py-0.5 rounded-md",style:{background:i.surfaceAlt,color:i.muted,fontSize:o.xs},children:r.layer}),w&&e.jsx("span",{style:{color:i.faint,fontSize:o.xs},children:w.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}),r.shortId&&e.jsx("span",{style:{marginLeft:"auto",color:i.faint,fontSize:o.xs,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:r.shortId})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:i.primary,lineHeight:1.2,margin:0},children:r.name}),e.jsx("div",{style:{marginTop:9,paddingTop:8,borderTop:`1px solid ${i.borderLight}`},children:e.jsx(C,{density:p})})]}),g.length>0&&e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2",marginBottom:20},children:[e.jsxs("div",{className:"px-4 py-2 font-semibold",style:{color:"#DC2626",fontSize:o.sm,borderBottom:"1px solid #FEE2E2"},children:[g.length," violation",g.length!==1?"s":""]}),g.map((t,a)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:o.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:i.faint},children:["[",t.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:t.description})]},a))]}),e.jsx(v,{title:F?"Flow":"Description",density:p,collapsible:!1,children:F?e.jsx(U,{element:r,layerColor:f,onSave:t=>z("doc",t)}):e.jsx(S,{value:r.doc||"",onSave:t=>z("doc",t),density:p,multiline:!0,placeholder:"Click to add a description…"})}),e.jsxs(v,{title:"Attributes",count:y.length,density:p,collapsible:!1,children:[y.length===0&&e.jsx("p",{style:{fontSize:o.sm,color:i.faint,margin:0},children:"This element defines no attributes."}),y.length>0&&e.jsx("div",{style:{borderTop:`1px solid ${i.border}`,maxWidth:900},children:y.map(([t,a])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 24%) minmax(0, 1fr)",gap:16,alignItems:"center",padding:"7px 0",borderBottom:`1px solid ${i.borderLight}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{color:i.secondary,fontSize:o.sm,fontWeight:600},children:t}),e.jsx("div",{style:{color:i.faint,fontSize:"10px"},children:"Editable"})]}),e.jsx(S,{value:String(a??""),onSave:A=>L(t,A),density:p,placeholder:"Add value…",compact:!0})]},t))})]}),e.jsx(M,{element:r,outgoing:E.outgoing,incoming:E.incoming,density:p}),e.jsx(v,{title:"Source",density:p,collapsible:!1,children:e.jsx("div",{style:{maxWidth:720},children:e.jsx(O,{label:"SysML source file",editability:k("file"),density:p,children:e.jsx($,{value:r.file??"—",editability:k("file"),density:p,mono:!0})})})})]})})}export{Y as ElementDetailView};
|