@memoarchitect/architect 0.8.26 → 0.10.5

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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{AiWorkspace-Z3BbnmaP.js → AiWorkspace-DABn1bcB.js} +2 -2
  3. package/dist/assets/{AnalysisWorkspace-DjaUOo7U.js → AnalysisWorkspace-B8CYPLNe.js} +1 -1
  4. package/dist/assets/{ComplianceWizard-DKxZ1z25.js → ComplianceWizard-DqeyOz4M.js} +1 -1
  5. package/dist/assets/DSMView-V3iNMXFW.js +5 -0
  6. package/dist/assets/{Dashboard-CYT7KjqU.js → Dashboard-BQj09cZH.js} +1 -1
  7. package/dist/assets/{DhfDashboard-DacdOtkU.js → DhfDashboard-K1p89I1a.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-CIhopT8J.js → DhfWorkbench-BqS0Z41-.js} +3 -3
  9. package/dist/assets/DiagramCanvas-BkKlNUeI.js +4 -0
  10. package/dist/assets/DiagramEditor-D6CT8dNm.js +4 -0
  11. package/dist/assets/{ElementDetailView-D5XvAL_i.js → ElementDetailView-D1ydy4ml.js} +2 -2
  12. package/dist/assets/{ExplorerTreeRow-DUmcEsqf.js → ExplorerTreeRow-DNlv-JxW.js} +1 -1
  13. package/dist/assets/{ImportView-9y1nhQS4.js → ImportView-RFKKNv71.js} +1 -1
  14. package/dist/assets/{LayerGrid-bhFpOIbe.js → LayerGrid-D0ulV2Rw.js} +1 -1
  15. package/dist/assets/{LayerTable-RuswZVUI.js → LayerTable-CZR1_QVc.js} +1 -1
  16. package/dist/assets/{MaxGraphCanvas-D3BXQK2y.js → MaxGraphCanvas-iQCvQs_L.js} +1 -1
  17. package/dist/assets/{ModelDiff-Cl2dhlk3.js → ModelDiff-CNpUtYV1.js} +1 -1
  18. package/dist/assets/OntologyDecompositionDiagram-DsCM8X-l.js +1 -0
  19. package/dist/assets/{OntologyViewer-VOrKTRuQ.js → OntologyViewer-Cx5WU_uI.js} +2 -2
  20. package/dist/assets/{ReviewDashboard--LMXZ3F4.js → ReviewDashboard-B6tw6wBJ.js} +1 -1
  21. package/dist/assets/{ScenarioEditor-bB4iBbgO.js → ScenarioEditor-B_M819qh.js} +1 -1
  22. package/dist/assets/{StatisticsDashboard-iXimfU20.js → StatisticsDashboard-DDsFeIAZ.js} +1 -1
  23. package/dist/assets/{TabularView-DnIfq-TB.js → TabularView-kcWhQVcI.js} +1 -1
  24. package/dist/assets/TraceabilityMatrix-DGny6KvJ.js +3 -0
  25. package/dist/assets/{UiScreensWorkspace-Cs1ivqzc.js → UiScreensWorkspace-BpIx67i-.js} +1 -1
  26. package/dist/assets/{WorkflowWizard-C7jI6C59.js → WorkflowWizard-D9NwvOlw.js} +1 -1
  27. package/dist/assets/index-BFvU1nLo.js +4067 -0
  28. package/dist/assets/index-BVySIRo1.css +1 -0
  29. package/dist/assets/{index.es-DABt8CUc.js → index.es-BxzJo0aw.js} +1 -1
  30. package/dist/assets/{jspdf.es.min-G-Vwo9yG.js → jspdf.es.min-B7Dh4CBm.js} +3 -3
  31. package/dist/assets/notation-scene-BB2meNb3.js +1 -0
  32. package/dist/index.html +2 -2
  33. package/dist-standalone/index.html +209 -209
  34. package/lib/bin/memo-architect.js +15 -6
  35. package/lib/bin/memo-architect.js.map +1 -1
  36. package/package.json +3 -3
  37. package/dist/assets/DSMView-DJhmrXYm.js +0 -5
  38. package/dist/assets/DiagramCanvas-CLE_nv7Y.js +0 -4
  39. package/dist/assets/DiagramEditor-puQuE8gB.js +0 -4
  40. package/dist/assets/OntologyDecompositionDiagram-aONGngg4.js +0 -1
  41. package/dist/assets/TraceabilityMatrix-eilGn6Sr.js +0 -3
  42. package/dist/assets/index-CG-gfw-s.js +0 -4067
  43. package/dist/assets/index-DXB4CKwW.css +0 -1
  44. package/dist/assets/notation-scene-DLZms6VR.js +0 -1
@@ -1 +0,0 @@
1
- import{j as e,H as C,P as k,R as D,c as S,k as O,l as R,m as T}from"./reactflow-C9OlmOYw.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as I}from"./layout-providers-BSDYNZu0.js";import{h as L,u as h,Z as P,$ as M,d as z}from"./index-CG-gfw-s.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,V=180;async function K(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:V})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await I(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function Z(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return K(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(T,{showInteractive:!1})]})}),t&&e.jsx(U,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const U=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(Z,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
@@ -1,3 +0,0 @@
1
- import{j as o}from"./reactflow-C9OlmOYw.js";import{a as i}from"./zustand-CrhqMOHB.js";import{u as k,i as Ne,j as _,r as ye,F as T,C as r,T as Ke}from"./index-CG-gfw-s.js";import{l as Be,e as be,c as qe,s as We,a as we,r as He,A as Se,T as ke,H as Pe}from"./DSMView-DJhmrXYm.js";import{a as Ge,I as ee}from"./DiagramToolbarControls-XMGLx08e.js";const Qe=[{id:"risk-control",label:"ISO 14971: Risk → Control",description:"Hazards and hazardous situations traced to risk controls",rowKinds:["Hazard","HazardousSituation"],columnKinds:["RiskControlMeasure","SafetyGoal"],linkTypes:["mitigates","tracesRisk","causes","leadsTo"]},{id:"req-test",label:"IEC 62304: Requirement → Test",description:"Software requirements traced to verification tests",rowKinds:["Requirement","SoftwareRequirement","SystemRequirement"],columnKinds:["Test","TestCase","VerificationCase","VerificationActivity"],linkTypes:["verifiedBy","satisfiedBy","validates"]},{id:"req-function",label:"Requirement → Function",description:"Requirements traced to the functions that satisfy them",rowKinds:["Requirement","SystemRequirement"],columnKinds:["Function","SystemFunction","ComponentFunction"],linkTypes:["satisfiedBy","derivesFrom"]},{id:"function-component",label:"Function → Component",description:"Functions allocated to logical and physical components",rowKinds:["Function","SystemFunction","ComponentFunction"],columnKinds:["LogicalComponent","SoftwareModule","MechanicalPart","Component"],linkTypes:["allocatedTo","realizes"]},{id:"everything",label:"Everything",description:"Every element against every element, every relationship",rowKinds:[],columnKinds:[],linkTypes:[]}];function _e(){var ge;const s=k(e=>e.model),f=k(e=>e.connected),C=k(e=>e.selectElement),ve=k(e=>e.selectedElementId),te=k(e=>e.selectedDiagramId),ne=k(e=>e.createRelationship),oe=k(e=>e.deleteRelationship),[g,M]=i.useState({}),[y,O]=i.useState({}),[R,B]=i.useState([]),[E,q]=i.useState([]),[x,W]=i.useState([]),[H,je]=i.useState("natural"),[P,Te]=i.useState("natural"),[se,ie]=i.useState(null),[Re,Ee]=i.useState("top"),[h,Fe]=i.useState(!1),[re,Ie]=i.useState(39),[Me,Ue]=i.useState(!0),[ae,G]=i.useState(new Set),[le,Q]=i.useState(new Set),[l,z]=i.useState(null),[$,v]=i.useState(null),[A,de]=i.useState(""),[L,D]=i.useState(!1),b=i.useMemo(()=>Ne(s),[s]),ce=i.useMemo(()=>s?Be(s):[],[s]),U=i.useMemo(()=>be(s,g),[s,g]),V=i.useMemo(()=>be(s,y),[s,y]),Y=i.useMemo(()=>{if(!s||!b)return[];const e=(a,u,w)=>(!u.layer||a.layer===u.layer)&&(!u.kind||a.kind===u.kind)&&(w.length===0||w.includes(a.id)),t=Object.values(s.elements).filter(a=>e(a,g,R)),n=Object.values(s.elements).filter(a=>e(a,y,E)),d=new Set;for(const a of t)for(const u of n)if(a.id!==u.id)for(const w of _(a,u,b))d.add(w.definition.name);const p=new Map;for(const a of s.relationships)p.set(a.type,(p.get(a.type)??0)+1);return[...d].sort().map(a=>({value:a,hint:String(p.get(a)??0),color:ye(a)}))},[s,b,g,y,R,E]);i.useEffect(()=>{const e=new Set(U.map(t=>t.value));B(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[U]),i.useEffect(()=>{const e=new Set(V.map(t=>t.value));q(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[V]),i.useEffect(()=>{const e=new Set(Y.map(t=>t.value));W(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[Y]);const c=i.useMemo(()=>s?qe(s,{rows:{layer:g.layer,kinds:g.kind?[g.kind]:[],elementIds:R,expanded:ae,ordering:H},columns:{layer:y.layer,kinds:y.kind?[y.kind]:[],elementIds:E,expanded:le,ordering:P},dependencyTypes:x,symmetric:!0}):null,[s,g,y,R,E,x,H,P,ae,le]),[N,Oe]=i.useState(!1);i.useEffect(()=>{if(N||!s)return;const e=We(s);e.rows&&(M({layer:e.rows}),O({layer:e.columns}),Oe(!0))},[s,N]);const[pe,ze]=i.useState(!1);i.useEffect(()=>{if(pe||!N||!c)return;const e=c.rowRoots.filter(n=>n.children.length>0).map(n=>n.id),t=c.columnRoots.filter(n=>n.children.length>0).map(n=>n.id);e.length===0&&t.length===0||(G(new Set(e)),Q(new Set(t)),ze(!0))},[c,N,pe]);const j=i.useCallback((e,t)=>{e==="rows"?G(t):Q(t)},[]),ue=i.useCallback(e=>{c&&j(e,new Set(we(e==="rows"?c.rowRoots:c.columnRoots)))},[c,j]),me=i.useCallback(e=>j(e,new Set),[j]),fe=i.useCallback((e,t)=>{c&&j(e,new Set(we(e==="rows"?c.rowRoots:c.columnRoots,t)))},[c,j]),Z=i.useCallback(e=>{if(!s)return null;for(const t of e){const n=Object.values(s.elements).find(d=>d.kind===t);if(n)return{layer:n.layer,kind:t}}return null},[s]),$e=i.useCallback(e=>{const t=new Set(s?He(s):[]),n=Z(e.rowKinds),d=Z(e.columnKinds);e.id==="everything"?(M({}),O({})):(n&&M(n),d&&O(d)),W(e.linkTypes.filter(p=>t.has(p))),B([]),q([]),z(null)},[s,Z]),xe=i.useMemo(()=>{var p;if(!s||!l)return[];const e=l.row.node.id,t=l.column.node.id;if(l.row.node.children.length===0&&l.column.node.children.length===0){const a=new Set(x);return s.relationships.filter(u=>(a.size===0||a.has(u.type))&&(u.sourceId===e&&u.targetId===t||u.sourceId===t&&u.targetId===e))}const d=new Set(((p=l.cell)==null?void 0:p.relationshipIds)??[]);return s.relationships.filter(a=>d.has(a.id))},[s,l,x]),F=i.useMemo(()=>{if(!s||!l||!b)return[];const e=s.elements[l.row.node.id],t=s.elements[l.column.node.id];return!e||!t||e.id===t.id?[]:_(e,t,b)},[s,l,b]),K=i.useMemo(()=>{const e=new Set;for(const t of x)e.add(t),e.add(t.charAt(0).toUpperCase()+t.slice(1));return e},[x]),he=i.useMemo(()=>{const e=A.trim().toLowerCase();return F.filter(t=>!e||t.definition.name.toLowerCase().includes(e)).sort((t,n)=>{const d=Number(K.has(n.definition.name))-Number(K.has(t.definition.name));return d!==0?d:t.definition.name.localeCompare(n.definition.name)})},[F,A,K]),Ae=!!(l&&l.row.node.isElement&&l.column.node.isElement&&!l.row.expanded&&!l.column.expanded&&l.row.node.children.length===0&&l.column.node.children.length===0),J=i.useCallback(async e=>{D(!0),v(null);const t=await ne({type:e.definition.name,sourceId:e.sourceId,targetId:e.targetId,direction:e.direction,diagramId:te??void 0});D(!1),v(t.success?{kind:"ok",message:`Trace written to ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be created."})},[ne,te]),X=i.useCallback(async e=>{D(!0),v(null);const t=await oe(e);D(!1),v(t.success?{kind:"ok",message:`Trace removed from ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be removed."})},[oe]),Le=i.useCallback(async(e,t,n)=>{if(!h||!f||!s||!b||!e.node.isElement||!t.node.isElement||e.node.children.length>0||t.node.children.length>0||e.node.id===t.node.id||x.length!==1)return;const d=x[0],p=s.relationships.find(S=>S.type===d&&(S.sourceId===e.node.id&&S.targetId===t.node.id||S.sourceId===t.node.id&&S.targetId===e.node.id));if(p){if(p.named===!1){v({kind:"error",message:"This trace has no declared name, so it cannot be removed until it is named in SysML."});return}await X(p.id);return}const a=s.elements[e.node.id],u=s.elements[t.node.id];if(!a||!u)return;const w=_(a,u,b).find(S=>S.definition.name===d);if(!w){v({kind:"error",message:`${d} is not legal between these element types.`});return}await J(w)},[h,f,s,b,x,J,X]),De=i.useCallback((e,t,n)=>{if(e!=null&&e.diagonal)return{};if(e){const p="#65A30D",a=Math.min(.14+e.strength*.13,.55);return{text:e.strength===1?"✓":String(e.strength),color:p,background:`${p}${Math.round(a*255).toString(16).padStart(2,"0")}`,title:`${t.node.name} ↔ ${n.node.name}
2
- ${e.types.join(", ")}${h?`
3
- Click to inspect or remove`:""}`}}return h?t.node.isElement&&n.node.isElement&&t.node.children.length===0&&n.node.children.length===0&&t.node.id!==n.node.id?{actionable:!0,title:`Click to trace ${t.node.name} → ${n.node.name}`}:{}:{}},[h]),I=i.useMemo(()=>{if(!c)return{traced:0,total:0};const e=c.rows.filter(n=>n.node.children.length===0);return{traced:e.filter(n=>{const d=c.rows.indexOf(n);return c.matrix[d].some(p=>p&&!p.diagonal)}).length,total:e.length}},[c]);if(!s||!c)return o.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:r.faint,fontSize:T.sm},children:"No model loaded"});const m=Re==="left";return o.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#FAFAF8",position:"relative"},children:[o.jsxs("div",{style:m?{position:"absolute",inset:"0 auto 0 0",width:"250px",zIndex:30,overflow:"auto",borderRight:`1px solid ${r.border}`,background:r.surface}:{borderBottom:`1px solid ${r.border}`,background:r.surface,position:"relative"},children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:m?{flexDirection:"column",alignItems:"stretch",position:"relative",paddingTop:"54px"}:{flexWrap:"wrap",position:"relative",paddingRight:"52px"},children:[o.jsx("span",{style:{position:"absolute",top:"9px",right:"12px"},children:o.jsx(Ge,{icon:m?o.jsx(ee.arrowUp,{}):o.jsx(ee.panelCollapse,{}),onClick:()=>Ee(e=>e==="top"?"left":"top"),title:m?"Move toolbar to top":"Move toolbar to left"})}),o.jsx(Se,{axis:"rows",layers:ce,scope:g,onScopeChange:M,elements:R,onElementsChange:B,elementOptions:U,ordering:H,onOrderingChange:je,onExpandAll:ue,onCollapseAll:me,onExpandToDepth:fe,leftDock:m,filterOpen:se==="rows",onFilterOpenChange:e=>ie(e?"rows":null),parentOf:new Map}),o.jsx(Se,{axis:"columns",layers:ce,scope:y,onScopeChange:O,elements:E,onElementsChange:q,elementOptions:V,ordering:P,onOrderingChange:Te,onExpandAll:ue,onCollapseAll:me,onExpandToDepth:fe,leftDock:m,filterOpen:se==="columns",onFilterOpenChange:e=>ie(e?"columns":null),parentOf:new Map}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:m?"1fr":"max-content max-content max-content",gridTemplateRows:"auto auto",alignItems:"center",columnGap:"10px",rowGap:"5px",padding:"6px 8px",border:`1px solid ${r.border}`,borderRadius:"9px",background:"#FAFBFC"},children:[o.jsx(ke,{label:o.jsxs(o.Fragment,{children:[o.jsx(ee.filter,{})," Relations"]}),ariaLabel:"Filter trace relationships",title:"Relationships counted as trace",width:m?210:260,fullWidth:m,children:o.jsx(Ke,{label:"Trace relationships",allLabel:"Any relationship",options:Y,selected:x,onChange:W,title:"Relationships counted as trace"})}),o.jsx(ke,{label:"Presets",ariaLabel:"Traceability presets",title:"Choose a traceability starting point",width:m?210:270,fullWidth:m,children:Qe.map(e=>o.jsx("button",{onClick:()=>$e(e),title:e.description,style:{padding:"6px 7px",border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",fontSize:T.xs,color:r.primary,textAlign:"left"},children:e.label},e.id))}),o.jsxs("label",{title:f?"Click cells to add or remove trace links. Only leaf-to-leaf cells can be edited.":"The dev server is unreachable, so nothing can be written to the model.",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:T.xs,width:m?"100%":void 0,boxSizing:"border-box",padding:"3px 9px",borderRadius:"5px",border:`1px solid ${h?r.accent:r.border}`,background:h?"#E8F8F3":r.surface,color:f?r.primary:r.faint,cursor:f?"pointer":"not-allowed",fontWeight:600},children:[o.jsx("input",{type:"checkbox",checked:h,disabled:!f,onChange:e=>{Fe(e.target.checked),z(null)},style:{accentColor:r.accent}}),"Edit trace"]}),o.jsxs("label",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"5px",fontSize:T.xs,color:r.muted,justifyContent:m?"center":void 0},title:"Cell size",children:["Zoom",o.jsx("input",{type:"range",min:14,max:44,step:2,value:re,onChange:e=>Ie(Number(e.target.value)),style:{width:"80px",accentColor:r.accent}})]})]})]}),$&&o.jsx("div",{style:{padding:"5px 16px",fontSize:"11px",color:$.kind==="ok"?"#0F766E":"#B91C1C",background:$.kind==="ok"?"#ECFDF5":"#FEF2F2",borderTop:`1px solid ${r.borderLight}`},children:$.message})]}),o.jsx("div",{style:{display:"flex",flex:1,minHeight:0,minWidth:0,marginLeft:m?"250px":0,width:m?"calc(100% - 250px)":void 0},children:o.jsx(Pe,{result:c,onToggleRow:e=>G(t=>Ce(t,e)),onToggleColumn:e=>Q(t=>Ce(t,e)),onSelectElement:C,selectedElementId:ve,renderCell:De,onCellClick:(e,t,n)=>{z({row:e,column:t,cell:n}),de("")},onCellDoubleClick:(e,t,n)=>{Le(e,t,n)},cellSize:re,showColumnNames:Me,cornerHeader:o.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",height:"100%"},children:[o.jsx("span",{style:{fontSize:T.sm,fontWeight:600,color:r.primary},children:"Traceability Matrix"}),o.jsxs("span",{style:{fontSize:"11px",color:r.faint,marginTop:"2px"},children:[c.totalDependencies," link",c.totalDependencies===1?"":"s"," shown",I.total>0&&` · ${I.traced}/${I.total} rows traced (${Math.round(I.traced/I.total*100)}%)`]})]})})}),l&&o.jsxs("div",{style:{position:"fixed",bottom:"76px",right:"20px",zIndex:100,width:"330px",maxHeight:"52vh",overflowY:"auto",padding:"12px 14px",borderRadius:"9px",background:r.surface,border:`1px solid ${r.border}`,boxShadow:"0 6px 22px rgba(0,0,0,0.14)",fontSize:T.xs},children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{style:{fontWeight:600,color:r.primary},children:[l.row.node.name," ","↔"," ",l.column.node.name]}),o.jsx("button",{onClick:()=>z(null),style:{color:r.faint,background:"none",border:"none",cursor:"pointer"},children:"✕"})]}),xe.length>0?o.jsx("div",{style:{marginTop:"9px",display:"flex",flexDirection:"column",gap:"5px"},children:xe.map(e=>{var t,n;return o.jsxs("div",{className:"flex items-center justify-between gap-2",style:{padding:"4px 6px",borderRadius:"5px",background:r.surfaceAlt},children:[o.jsx("span",{style:{color:ye(e.type),fontWeight:500},children:e.type}),o.jsxs("span",{style:{flex:1,color:r.faint,fontSize:"10px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[((t=s.elements[e.sourceId])==null?void 0:t.name)??e.sourceId," ","→"," ",((n=s.elements[e.targetId])==null?void 0:n.name)??e.targetId]}),h&&o.jsx("button",{disabled:L||e.named===!1,onClick:()=>void X(e.id),title:e.named===!1?"This connection has no declared name, so it cannot be addressed for deletion. Name it in the source first.":"Remove this trace link",style:{fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid #FCA5A5",background:"#FEF2F2",color:"#B91C1C",cursor:L||e.named===!1?"not-allowed":"pointer",opacity:e.named===!1?.5:1},children:"Remove"})]},e.id)})}):o.jsx("div",{style:{marginTop:"8px",color:r.muted},children:"No trace between these two."}),((ge=l.cell)==null?void 0:ge.aggregated)&&o.jsx("div",{style:{marginTop:"8px",fontSize:"11px",color:r.faint},children:"This mark sums a collapsed subsystem. Expand both sides to edit individual links."}),h&&o.jsxs("div",{style:{marginTop:"11px",borderTop:`1px solid ${r.borderLight}`,paddingTop:"9px"},children:[o.jsx("div",{style:{fontSize:"11px",color:r.muted,marginBottom:"6px"},children:"Add a trace link"}),Ae?F.length===0?o.jsxs("div",{style:{fontSize:"11px",color:r.faint},children:["The ontology allows no relationship between ",l.row.node.kind," and ",l.column.node.kind,"."]}):o.jsxs(o.Fragment,{children:[F.length>8&&o.jsx("input",{value:A,onChange:e=>de(e.target.value),placeholder:`Filter ${F.length} legal types…`,"aria-label":"Filter link types",style:{width:"100%",marginBottom:"7px",padding:"4px 7px",border:`1px solid ${r.border}`,borderRadius:"5px",fontSize:"11px",outline:"none",color:r.primary}}),o.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"5px"},children:[he.map(e=>{var n,d;const t=K.has(e.definition.name);return o.jsxs("button",{disabled:L,onClick:()=>void J(e),title:`${((n=s.elements[e.sourceId])==null?void 0:n.name)??e.sourceId} → ${((d=s.elements[e.targetId])==null?void 0:d.name)??e.targetId}`,style:{fontSize:"11px",padding:"3px 8px",borderRadius:"5px",border:`1px solid ${t?r.accent:r.border}`,background:t?"#E8F8F3":r.surface,color:r.primary,cursor:L?"wait":"pointer",fontWeight:t?600:400},children:[e.definition.name,o.jsx("span",{style:{color:r.faint,marginLeft:"4px"},children:e.direction==="outgoing"?"→":"←"})]},`${e.definition.name}-${e.direction}`)}),he.length===0&&o.jsxs("span",{style:{fontSize:"11px",color:r.faint},children:["No legal type matches ","“",A,"”","."]})]})]}):o.jsx("div",{style:{fontSize:"11px",color:r.faint},children:"Both sides must be individual elements. Expand the subsystems first."})]})]})]})}function Ce(s,f){const C=new Set(s);return C.has(f)?C.delete(f):C.add(f),C}export{_e as TraceabilityMatrix};