@memoarchitect/architect 0.11.2 → 0.11.3

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 (36) hide show
  1. package/dist/assets/{AiWorkspace-GFHs046m.js → AiWorkspace-DRN1NVMU.js} +1 -1
  2. package/dist/assets/{AnalysisWorkspace-BfZ4GYza.js → AnalysisWorkspace-BGdkl3PU.js} +1 -1
  3. package/dist/assets/{ComplianceWizard-CYBizPbC.js → ComplianceWizard-BktwMgJe.js} +1 -1
  4. package/dist/assets/{DSMView-BsjhUbpW.js → DSMView-Em0sO2Uj.js} +1 -1
  5. package/dist/assets/{Dashboard-rdbfFJYx.js → Dashboard-CXbU-BFU.js} +1 -1
  6. package/dist/assets/{DhfDashboard-BdhBA4OL.js → DhfDashboard-DcZw_zNy.js} +1 -1
  7. package/dist/assets/{DhfWorkbench-tnIpEFmu.js → DhfWorkbench-ClLIypQX.js} +3 -3
  8. package/dist/assets/DiagramCanvas-wDamEqea.js +4 -0
  9. package/dist/assets/{DiagramEditor-icnDwdxM.js → DiagramEditor-BSJuk0w6.js} +2 -2
  10. package/dist/assets/{ElementDetailView-Crpltlrz.js → ElementDetailView-BMgTV4b7.js} +1 -1
  11. package/dist/assets/{ExplorerTreeRow-DG8T31JS.js → ExplorerTreeRow-CX2kYnaJ.js} +1 -1
  12. package/dist/assets/{ImportView-1vrZ1CGB.js → ImportView-Dwl7KYVo.js} +1 -1
  13. package/dist/assets/{LayerGrid-DnP2smgG.js → LayerGrid-wfRIaj8M.js} +1 -1
  14. package/dist/assets/{LayerTable-97qPfMD3.js → LayerTable-DUhcLrAE.js} +1 -1
  15. package/dist/assets/{MaxGraphCanvas-BJss9LYp.js → MaxGraphCanvas-zFgc11zx.js} +1 -1
  16. package/dist/assets/{ModelDiff-H5nxOavB.js → ModelDiff-Br7XLC74.js} +1 -1
  17. package/dist/assets/{OntologyDecompositionDiagram-D0G3A7-R.js → OntologyDecompositionDiagram-BbpIVZLr.js} +1 -1
  18. package/dist/assets/{OntologyViewer-0BJ2jMZ8.js → OntologyViewer-610n8iwf.js} +2 -2
  19. package/dist/assets/{ReviewDashboard-Dl-YTC4_.js → ReviewDashboard-aDWpLpkb.js} +1 -1
  20. package/dist/assets/{ScenarioEditor-CiHaTvVY.js → ScenarioEditor-cLJenHgj.js} +1 -1
  21. package/dist/assets/{StatisticsDashboard-w2dtCD94.js → StatisticsDashboard-DOJHl1sB.js} +1 -1
  22. package/dist/assets/{TabularView-CFy0PK1L.js → TabularView-C-bodzPd.js} +1 -1
  23. package/dist/assets/{TraceabilityMatrix-DDoHYsCP.js → TraceabilityMatrix-Bp0KSjVP.js} +1 -1
  24. package/dist/assets/UiScreensWorkspace-CcV0r4cA.js +1 -0
  25. package/dist/assets/{WorkflowWizard-Br1zPSLC.js → WorkflowWizard-St0tA37H.js} +1 -1
  26. package/dist/assets/{index-DEVvBtNh.js → index-BYfHEpXT.js} +68 -68
  27. package/dist/assets/{index-BVySIRo1.css → index-X7EXuNCl.css} +1 -1
  28. package/dist/assets/{index.es-D0WykKwq.js → index.es-D_igLMWe.js} +1 -1
  29. package/dist/assets/{jspdf.es.min-DZ4wvU_9.js → jspdf.es.min-B7e0_lrE.js} +3 -3
  30. package/dist/assets/notation-scene-BLpi6R_E.js +1 -0
  31. package/dist/index.html +2 -2
  32. package/dist-standalone/index.html +184 -184
  33. package/package.json +1 -1
  34. package/dist/assets/DiagramCanvas-BmVByLcM.js +0 -4
  35. package/dist/assets/UiScreensWorkspace-DOxjCMG9.js +0 -1
  36. package/dist/assets/notation-scene-HbscVJH5.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./reactflow-C9OlmOYw.js";import{a as j}from"./zustand-CrhqMOHB.js";import{u as g,h as F}from"./index-DEVvBtNh.js";function z({model:n}){const i=g(t=>t.setActiveView),s=g(t=>t.setExplorerTab),l=j.useMemo(()=>Object.values(n.elements).filter(t=>["system","subsystem","logicalcomponent","softwarecomponent","physicalcomponent"].includes(t.kind.toLowerCase())).slice(0,8),[n]),a=j.useMemo(()=>{const t={};for(const o of Object.values(n.elements))t[o.layer]=(t[o.layer]||0)+1;return t},[n]),x=Object.entries(a).sort((t,o)=>o[1]-t[1]).slice(0,5),p=Object.keys(n.elements).length;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🏗️",title:"System Architecture",badge:`${p} elements`,onExpand:()=>{s("model")}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Layer distribution"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:x.map(([t,o])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:F[t]||"#95A5A6",flexShrink:0}}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",flex:1,textTransform:"capitalize"},children:t}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#6B7280"},children:o}),e.jsx("div",{style:{width:"60px",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:F[t]||"#95A5A6",width:`${Math.round(o/p*100)}%`}})})]},t))})]}),e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Key components"}),l.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:l.map(t=>e.jsxs("button",{onClick:()=>i({type:"element-detail",elementId:t.id}),style:{textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"3px 0",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:t.kind}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",fontWeight:500},children:t.name})]},t.id))}):e.jsx(C,{text:"No System or Subsystem elements yet"})]})]}),n.diagrams&&n.diagrams.length>0&&e.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[n.diagrams.slice(0,4).map(t=>e.jsxs("button",{onClick:()=>i({type:"diagram",diagramId:t.id}),style:q,onMouseEnter:o=>o.currentTarget.style.background="#E5E5E0",onMouseLeave:o=>o.currentTarget.style.background="#F3F4F6",children:["⊟ ",t.name]},t.id)),n.diagrams.length>4&&e.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF",alignSelf:"center"},children:["+",n.diagrams.length-4," more"]})]})]})}function R({model:n}){const i=g(t=>t.setActiveView),{reqs:s,withTestLink:l,withArchLink:a}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(d=>["systemrequirement","requirement","userneed"].includes(d.kind.toLowerCase())),f=new Set;for(const d of n.relationships)f.add(d.sourceId),f.add(d.targetId);const u=new Set(["test","verification","validationtest"]),y=new Set(["system","subsystem","logicalcomponent","softwarecomponent"]),c=new Set(t.filter(d=>u.has(d.kind.toLowerCase())).map(d=>d.id)),b=new Set(t.filter(d=>y.has(d.kind.toLowerCase())).map(d=>d.id));let r=0,S=0;for(const d of o){const A=n.relationships.filter(h=>h.sourceId===d.id||h.targetId===d.id).flatMap(h=>[h.sourceId,h.targetId]);A.some(h=>c.has(h))&&r++,A.some(h=>b.has(h))&&S++}return{reqs:o,withTestLink:r,withArchLink:S}},[n]),x=s.length>0?Math.round(l/s.length*100):0,p=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"📋",title:"Requirements",badge:`${s.length} total`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No requirements found. Add Requirement elements to your model."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Verified by tests",percent:x,count:l,total:s.length,color:"#2DD4A8"}),e.jsx(v,{label:"Linked to architecture",percent:p,count:a,total:s.length,color:"#4A90D9"})]})]})}function I({model:n}){const i=g(t=>t.setActiveView),{hazards:s,riskControls:l,mitigatesCount:a,residualRiskCount:x}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(r=>r.kind.toLowerCase()==="hazard"),f=t.filter(r=>r.kind.toLowerCase()==="riskcontrol"),u=n.relationships.filter(r=>r.type.toLowerCase()==="mitigates"),y=u.length,c=new Set(u.map(r=>r.targetId)),b=o.filter(r=>!c.has(r.id)).length;return{hazards:o,riskControls:f,mitigatesCount:y,residualRiskCount:b}},[n]),p=s.length>0?Math.round((s.length-x)/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"⚠️",title:"Risk Chain (ISO 14971)",badge:`${s.length} hazards`,onExpand:()=>i({type:"traceability"}),badgeColor:x>0?"#E74C3C":"#2ECC71"}),s.length===0?e.jsx(C,{text:"No hazards found. Add Hazard elements to start your ISO 14971 risk analysis."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Hazards mitigated",percent:p,count:s.length-x,total:s.length,color:"#2ECC71",warningThreshold:80}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Risk controls",value:l.length}),e.jsx(m,{label:"Mitigates links",value:a}),x>0&&e.jsx(m,{label:"Unmitigated hazards",value:x,alert:!0})]})]})]})}function L({model:n}){const i=g(p=>p.setActiveView),{tests:s,passing:l,withReqLink:a}=j.useMemo(()=>{const p=Object.values(n.elements),t=p.filter(c=>c.kind.toLowerCase()==="test"),o=p.filter(c=>["systemrequirement","requirement"].includes(c.kind.toLowerCase())),f=new Set(o.map(c=>c.id));let u=0;for(const c of t)n.relationships.filter(r=>r.sourceId===c.id||r.targetId===c.id).flatMap(r=>[r.sourceId,r.targetId]).some(r=>f.has(r))&&u++;const y=t.filter(c=>(c.attributes.status||"").toLowerCase()==="pass").length;return{tests:t,passing:y,withReqLink:u}},[n]),x=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🧪",title:"Verification",badge:`${s.length} tests`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No tests found. Add Test elements and link them to requirements."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Tests linked to requirements",percent:x,count:a,total:s.length,color:"#2DD4A8"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Tests",value:s.length}),l>0&&e.jsx(m,{label:"Passing",value:l}),s.length-l>0&&e.jsx(m,{label:"Unverified",value:s.length-l,alert:s.length-l>0&&l>0})]})]})]})}function k({icon:n,title:i,badge:s,onExpand:l,badgeColor:a}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:n}),e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:a?a+"20":"#F3F4F6",color:a||"#6B7280"},children:s})]}),e.jsx("button",{onClick:l,style:{fontSize:"11px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Expand →"})]})}function v({label:n,percent:i,count:s,total:l,color:a,warningThreshold:x=100}){const p=i>=x?a:i>=50?"#F39C12":"#E74C3C";return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"12px",color:"#374151"},children:n}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:600,color:i>=80?"#2ECC71":"#374151"},children:[s,"/",l," (",i,"%)"]})]}),e.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"3px",background:p,width:`${i}%`,transition:"width 0.4s ease"}})})]})}function m({label:n,value:i,alert:s}){return e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"baseline"},children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:700,color:s?"#E74C3C":"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function C({text:n}){return e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",fontStyle:"italic",padding:"8px 0"},children:n})}const w={background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px"},E={fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"#9CA3AF",marginBottom:"8px"},q={fontSize:"11px",color:"#374151",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 10px",cursor:"pointer",transition:"background 0.1s",fontWeight:500};function D(){const n=g(s=>s.model),i=g(s=>s.setActiveView);return n?e.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Design Review Dashboard"}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Architecture · Requirements · Risk · Verification — in one view"})]}),e.jsx("button",{onClick:()=>i({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsx(z,{model:n}),e.jsx(R,{model:n}),e.jsx(I,{model:n}),e.jsx(L,{model:n})]})]})}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})})}export{D as ReviewDashboard};
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as j}from"./zustand-CrhqMOHB.js";import{u as g,h as F}from"./index-BYfHEpXT.js";function z({model:n}){const i=g(t=>t.setActiveView),s=g(t=>t.setExplorerTab),l=j.useMemo(()=>Object.values(n.elements).filter(t=>["system","subsystem","logicalcomponent","softwarecomponent","physicalcomponent"].includes(t.kind.toLowerCase())).slice(0,8),[n]),a=j.useMemo(()=>{const t={};for(const o of Object.values(n.elements))t[o.layer]=(t[o.layer]||0)+1;return t},[n]),x=Object.entries(a).sort((t,o)=>o[1]-t[1]).slice(0,5),p=Object.keys(n.elements).length;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🏗️",title:"System Architecture",badge:`${p} elements`,onExpand:()=>{s("model")}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Layer distribution"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:x.map(([t,o])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:F[t]||"#95A5A6",flexShrink:0}}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",flex:1,textTransform:"capitalize"},children:t}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#6B7280"},children:o}),e.jsx("div",{style:{width:"60px",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:F[t]||"#95A5A6",width:`${Math.round(o/p*100)}%`}})})]},t))})]}),e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Key components"}),l.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:l.map(t=>e.jsxs("button",{onClick:()=>i({type:"element-detail",elementId:t.id}),style:{textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"3px 0",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:t.kind}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",fontWeight:500},children:t.name})]},t.id))}):e.jsx(C,{text:"No System or Subsystem elements yet"})]})]}),n.diagrams&&n.diagrams.length>0&&e.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[n.diagrams.slice(0,4).map(t=>e.jsxs("button",{onClick:()=>i({type:"diagram",diagramId:t.id}),style:q,onMouseEnter:o=>o.currentTarget.style.background="#E5E5E0",onMouseLeave:o=>o.currentTarget.style.background="#F3F4F6",children:["⊟ ",t.name]},t.id)),n.diagrams.length>4&&e.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF",alignSelf:"center"},children:["+",n.diagrams.length-4," more"]})]})]})}function R({model:n}){const i=g(t=>t.setActiveView),{reqs:s,withTestLink:l,withArchLink:a}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(d=>["systemrequirement","requirement","userneed"].includes(d.kind.toLowerCase())),f=new Set;for(const d of n.relationships)f.add(d.sourceId),f.add(d.targetId);const u=new Set(["test","verification","validationtest"]),y=new Set(["system","subsystem","logicalcomponent","softwarecomponent"]),c=new Set(t.filter(d=>u.has(d.kind.toLowerCase())).map(d=>d.id)),b=new Set(t.filter(d=>y.has(d.kind.toLowerCase())).map(d=>d.id));let r=0,S=0;for(const d of o){const A=n.relationships.filter(h=>h.sourceId===d.id||h.targetId===d.id).flatMap(h=>[h.sourceId,h.targetId]);A.some(h=>c.has(h))&&r++,A.some(h=>b.has(h))&&S++}return{reqs:o,withTestLink:r,withArchLink:S}},[n]),x=s.length>0?Math.round(l/s.length*100):0,p=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"📋",title:"Requirements",badge:`${s.length} total`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No requirements found. Add Requirement elements to your model."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Verified by tests",percent:x,count:l,total:s.length,color:"#2DD4A8"}),e.jsx(v,{label:"Linked to architecture",percent:p,count:a,total:s.length,color:"#4A90D9"})]})]})}function I({model:n}){const i=g(t=>t.setActiveView),{hazards:s,riskControls:l,mitigatesCount:a,residualRiskCount:x}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(r=>r.kind.toLowerCase()==="hazard"),f=t.filter(r=>r.kind.toLowerCase()==="riskcontrol"),u=n.relationships.filter(r=>r.type.toLowerCase()==="mitigates"),y=u.length,c=new Set(u.map(r=>r.targetId)),b=o.filter(r=>!c.has(r.id)).length;return{hazards:o,riskControls:f,mitigatesCount:y,residualRiskCount:b}},[n]),p=s.length>0?Math.round((s.length-x)/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"⚠️",title:"Risk Chain (ISO 14971)",badge:`${s.length} hazards`,onExpand:()=>i({type:"traceability"}),badgeColor:x>0?"#E74C3C":"#2ECC71"}),s.length===0?e.jsx(C,{text:"No hazards found. Add Hazard elements to start your ISO 14971 risk analysis."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Hazards mitigated",percent:p,count:s.length-x,total:s.length,color:"#2ECC71",warningThreshold:80}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Risk controls",value:l.length}),e.jsx(m,{label:"Mitigates links",value:a}),x>0&&e.jsx(m,{label:"Unmitigated hazards",value:x,alert:!0})]})]})]})}function L({model:n}){const i=g(p=>p.setActiveView),{tests:s,passing:l,withReqLink:a}=j.useMemo(()=>{const p=Object.values(n.elements),t=p.filter(c=>c.kind.toLowerCase()==="test"),o=p.filter(c=>["systemrequirement","requirement"].includes(c.kind.toLowerCase())),f=new Set(o.map(c=>c.id));let u=0;for(const c of t)n.relationships.filter(r=>r.sourceId===c.id||r.targetId===c.id).flatMap(r=>[r.sourceId,r.targetId]).some(r=>f.has(r))&&u++;const y=t.filter(c=>(c.attributes.status||"").toLowerCase()==="pass").length;return{tests:t,passing:y,withReqLink:u}},[n]),x=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🧪",title:"Verification",badge:`${s.length} tests`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No tests found. Add Test elements and link them to requirements."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Tests linked to requirements",percent:x,count:a,total:s.length,color:"#2DD4A8"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Tests",value:s.length}),l>0&&e.jsx(m,{label:"Passing",value:l}),s.length-l>0&&e.jsx(m,{label:"Unverified",value:s.length-l,alert:s.length-l>0&&l>0})]})]})]})}function k({icon:n,title:i,badge:s,onExpand:l,badgeColor:a}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:n}),e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:a?a+"20":"#F3F4F6",color:a||"#6B7280"},children:s})]}),e.jsx("button",{onClick:l,style:{fontSize:"11px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Expand →"})]})}function v({label:n,percent:i,count:s,total:l,color:a,warningThreshold:x=100}){const p=i>=x?a:i>=50?"#F39C12":"#E74C3C";return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"12px",color:"#374151"},children:n}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:600,color:i>=80?"#2ECC71":"#374151"},children:[s,"/",l," (",i,"%)"]})]}),e.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"3px",background:p,width:`${i}%`,transition:"width 0.4s ease"}})})]})}function m({label:n,value:i,alert:s}){return e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"baseline"},children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:700,color:s?"#E74C3C":"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function C({text:n}){return e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",fontStyle:"italic",padding:"8px 0"},children:n})}const w={background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px"},E={fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"#9CA3AF",marginBottom:"8px"},q={fontSize:"11px",color:"#374151",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 10px",cursor:"pointer",transition:"background 0.1s",fontWeight:500};function D(){const n=g(s=>s.model),i=g(s=>s.setActiveView);return n?e.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Design Review Dashboard"}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Architecture · Requirements · Risk · Verification — in one view"})]}),e.jsx("button",{onClick:()=>i({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsx(z,{model:n}),e.jsx(R,{model:n}),e.jsx(I,{model:n}),e.jsx(L,{model:n})]})]})}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})})}export{D as ReviewDashboard};
@@ -1,3 +1,3 @@
1
- import{j as e}from"./reactflow-C9OlmOYw.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as A,p as he,q as fe,C as f,F as C,h as E,E as O,t as Z,M as ge,v as ye,D as je}from"./index-DEVvBtNh.js";function ke(d){const r=d.diagramType.toLowerCase(),b=["afd","ofd","ffd"].includes(r)?ye(d):r;return je[b]}function ee({expanded:d,color:r=f.muted}){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{transform:d?"rotate(90deg)":void 0,transition:"transform 150ms ease",flexShrink:0},children:e.jsx("path",{d:"M6 4L10 8L6 12",stroke:r,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function te({open:d,color:r}){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M1.5 3.5h4.8l1.2 1.5H14.5v8H1.5z",fill:r,opacity:"0.15",stroke:r,strokeWidth:"1",strokeLinejoin:"round"}),d&&e.jsx("path",{d:"M1.5 5h13v8H1.5z",fill:r,opacity:"0.08"})]})}function be({color:d}){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[e.jsx("rect",{x:"2",y:"1.5",width:"12",height:"13",rx:"1.5",fill:d,opacity:"0.1",stroke:d,strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"5.5",x2:"11",y2:"5.5",stroke:d,strokeWidth:"0.8",opacity:"0.5"}),e.jsx("line",{x1:"5",y1:"8",x2:"11",y2:"8",stroke:d,strokeWidth:"0.8",opacity:"0.5"})]})}function se(d){return d?d.split(`
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as A,p as he,q as fe,C as f,F as C,h as E,E as O,t as Z,M as ge,v as ye,D as je}from"./index-BYfHEpXT.js";function ke(d){const r=d.diagramType.toLowerCase(),b=["afd","ofd","ffd"].includes(r)?ye(d):r;return je[b]}function ee({expanded:d,color:r=f.muted}){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{transform:d?"rotate(90deg)":void 0,transition:"transform 150ms ease",flexShrink:0},children:e.jsx("path",{d:"M6 4L10 8L6 12",stroke:r,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function te({open:d,color:r}){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M1.5 3.5h4.8l1.2 1.5H14.5v8H1.5z",fill:r,opacity:"0.15",stroke:r,strokeWidth:"1",strokeLinejoin:"round"}),d&&e.jsx("path",{d:"M1.5 5h13v8H1.5z",fill:r,opacity:"0.08"})]})}function be({color:d}){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[e.jsx("rect",{x:"2",y:"1.5",width:"12",height:"13",rx:"1.5",fill:d,opacity:"0.1",stroke:d,strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"5.5",x2:"11",y2:"5.5",stroke:d,strokeWidth:"0.8",opacity:"0.5"}),e.jsx("line",{x1:"5",y1:"8",x2:"11",y2:"8",stroke:d,strokeWidth:"0.8",opacity:"0.5"})]})}function se(d){return d?d.split(`
2
2
  `).filter(b=>b.trim()).map((b,W)=>{const I=b.match(/^\d+\.\s*(.*)/);return{index:W,text:I?I[1]:b}}):[]}function ve(d){return d.map((r,b)=>`${b+1}. ${r.text}`).join(`
3
3
  `)}function Ce({explorerOnly:d=!1}){const r=A(t=>t.model),b=A(t=>t.createRelationship),W=A(t=>t.inspectElement),I=A(t=>t.setActiveView),G=A(t=>t.setActiveMode),S=A(t=>t.selectedElementId),[D,ne]=x.useState(""),[i,F]=x.useState(null),[L,P]=x.useState(""),[z,_]=x.useState(null),[T,H]=x.useState(""),R=x.useMemo(()=>{if(!r)return[];const t=Object.values(r.elements),n=r.elements,o=(...s)=>{const y=new Set(s.map(j=>j.toLowerCase()));return r.relationships.filter(j=>y.has(j.type.toLowerCase()))},c=(s,y)=>{var j;return typeof s=="string"&&((j=s.split("::").at(-1))==null?void 0:j.trim())===y},h=t.filter(s=>s.kind.endsWith("UseCase")),w=new Set(h.map(s=>s.id)),u=new Map,a=new Set;for(const s of o("Includes")){if(!w.has(s.sourceId)||!w.has(s.targetId))continue;const y=u.get(s.sourceId)??[];y.push(s.targetId),u.set(s.sourceId,y),a.add(s.targetId)}const v=new Map,g=[],m=(s,y)=>{if(!v.has(s)){v.set(s,y),g.push(s);for(const j of u.get(s)??[])m(j,y+1)}};for(const s of h)a.has(s.id)||m(s.id,0);for(const s of h)m(s.id,0);const M=g.map(s=>n[s]).filter(s=>!!s),$=s=>!D||s.name.toLowerCase().includes(D.toLowerCase())||s.kind.toLowerCase().includes(D.toLowerCase());return M.map(s=>{var Q;const y=o("Supports","supportsUseCase").filter(l=>l.targetId===s.id).map(l=>n[l.sourceId]).filter(l=>!!l&&l.kind==="OperationalWorkflow"),j=t.filter(l=>l.kind.endsWith("Scenario")).filter(l=>c(l.attributes.parentUseCase,s.id)||o("Realizes","scenarioRealizesUseCase").some(N=>N.sourceId===l.id&&N.targetId===s.id)),U=j.map(l=>t.find(N=>c(l.attributes.parentWorkflow,N.id))).filter(l=>!!l),pe=[...new Map([...y,...U].map(l=>[l.id,l])).values()],ue=j.map(l=>{const N=(r.diagrams??[]).filter(me=>{var X;return(X=me.scenarioIds)==null?void 0:X.includes(l.id)});return{scenario:l,views:N}}),xe=pe.map(l=>({workflow:l,scenarios:ue.filter(({scenario:N})=>c(N.attributes.parentWorkflow,l.id))}));return{useCase:s,workflows:xe,depth:v.get(s.id)??0,hasChildren:(((Q=u.get(s.id))==null?void 0:Q.length)??0)>0}}).filter(s=>$(s.useCase)||s.workflows.some(({workflow:y,scenarios:j})=>$(y)||j.some(({scenario:U})=>$(U))))},[r,D]),p=S&&r?r.elements[S]:null,K=x.useMemo(()=>he(r,S||""),[r,S]),k=x.useMemo(()=>i||(p?se(p.doc||""):[]),[p,i]),oe=x.useCallback(()=>{p&&F(se(p.doc||""))},[p]),re=x.useCallback(()=>{if(!p||!i)return;const t=ve(i);fe({...p,doc:t}),F(null)},[p,i]),V=x.useCallback(()=>{if(!L.trim())return;const t=[...i||k,{index:k.length,text:L.trim()}];F(t),P("")},[L,i,k]),le=x.useCallback(t=>{const n=(i||k).filter((o,c)=>c!==t);F(n)},[i,k]),Y=x.useCallback((t,n)=>{const o=[...i||k],c=t+n;c<0||c>=o.length||([o[t],o[c]]=[o[c],o[t]],F(o))},[i,k]),ae=x.useCallback((t,n)=>{const o=[...i||k];o[t]={...o[t],text:n},F(o)},[i,k]),ce=x.useMemo(()=>{if(!r||!T)return[];const t=T.toLowerCase();return Object.values(r.elements).filter(n=>n.id!==S&&n.name.toLowerCase().includes(t)).slice(0,10)},[r,T,S]),[q,ie]=x.useState(new Set),J=t=>{ie(n=>{const o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o})},B=t=>{F(null),G("scenario"),W(t),I({type:"element-detail",elementId:t})},de=({workflow:t,scenarios:n})=>{const o=`workflow:${t.id}`,c=q.has(o),h=()=>J(o),w=a=>{G("scenario"),I({type:"diagram",diagramId:a.id})},u=(a,v)=>{const g=S===a.id;return e.jsxs("button",{type:"button",onClick:()=>B(a.id),className:"flex w-full items-center gap-1.5 px-2 py-1 text-left",style:{borderRadius:"4px",margin:"0 4px",marginLeft:`${v+4}px`,width:`calc(100% - ${v+8}px)`,background:g?`${f.accent}18`:"transparent"},onMouseEnter:m=>{g||(m.currentTarget.style.background="#F0F0ED")},onMouseLeave:m=>{m.currentTarget.style.background=g?`${f.accent}18`:"transparent"},children:[e.jsx(be,{color:E[a.layer]||f.muted}),e.jsx(O,{element:a,selected:g})]},a.id)};return e.jsxs("div",{className:"mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:a=>a.currentTarget.style.background="#F0F0ED",onMouseLeave:a=>a.currentTarget.style.background="transparent",onClick:()=>B(t.id),children:[e.jsx("button",{type:"button","aria-label":`${c?"Collapse":"Expand"} ${t.name}`,onClick:a=>{a.stopPropagation(),h()},children:e.jsx(ee,{expanded:c,color:f.muted})}),e.jsx(te,{open:c,color:E.operational}),e.jsx(O,{element:t,fontSize:C.explorer.kind,fontWeight:600}),e.jsx(Z,{count:n.length,color:E.operational,title:`${n.length} scenarios`})]}),c&&n.map(({scenario:a,views:v})=>e.jsxs("div",{style:{marginLeft:"16px"},children:[u(a,0),e.jsx("div",{style:{marginLeft:"20px"},children:v.length>0&&e.jsx("div",{className:"pt-1",children:v.map(g=>{const m=ke(g);return e.jsxs("button",{type:"button",onClick:()=>w(g),className:"flex w-full items-center gap-2 px-2 py-1 text-left",style:{borderRadius:"4px",margin:"0 4px",width:"calc(100% - 8px)"},onMouseEnter:M=>M.currentTarget.style.background="#F0F0ED",onMouseLeave:M=>M.currentTarget.style.background="transparent",title:m==null?void 0:m.fullName,children:[m&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:m.color+"20",color:m.color,fontSize:C.badge},children:m.code}),e.jsxs("span",{className:"flex-1",style:{minWidth:0},children:[e.jsx("span",{className:"truncate block",style:{color:f.primary,fontSize:C.explorer.item},children:g.name}),e.jsx("span",{className:"truncate block font-mono",style:{color:f.faint,fontSize:"9px",marginTop:1},children:g.id})]})]},g.id)})})})]},a.id)),c&&n.length===0&&e.jsx("div",{className:"px-2 py-1",style:{color:f.faint,fontSize:C.explorer.count,marginLeft:"20px"},children:"No scenarios"})]})};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d&&e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:f.surface},children:[e.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:e.jsx("input",{type:"text",placeholder:"Search "+R.length+" use cases...",value:D,onChange:t=>ne(t.target.value),className:"w-full px-3 py-2 rounded-lg focus:outline-none",style:{background:f.surfaceAlt,border:`1px solid ${f.border}`,color:f.primary,fontSize:C.explorer.search}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",style:{fontSize:C.explorer.item},children:[R.map(({useCase:t,workflows:n,depth:o})=>{const c="use-case:"+t.id,h=q.has(c),w=n.reduce((u,{scenarios:a})=>u+a.length,0);return e.jsxs("div",{className:"mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px",marginLeft:4+o*16},onMouseEnter:u=>u.currentTarget.style.background="#F0F0ED",onMouseLeave:u=>u.currentTarget.style.background="transparent",onClick:()=>B(t.id),children:[e.jsx("button",{type:"button","aria-label":`${h?"Collapse":"Expand"} ${t.name}`,onClick:u=>{u.stopPropagation(),J(c)},children:e.jsx(ee,{expanded:h,color:E.functional})}),e.jsx(te,{open:h,color:E.functional}),e.jsx(O,{element:t,fontSize:C.explorer.group,fontWeight:600}),e.jsx(Z,{count:w,color:E.functional,title:`${w} scenarios`})]}),h&&e.jsxs("div",{style:{marginLeft:16+o*16},children:[n.map(({workflow:u,scenarios:a})=>e.jsx(de,{workflow:u,scenarios:a},u.id)),n.length===0&&e.jsx("div",{className:"px-2 py-1",style:{color:f.faint,fontSize:C.explorer.kind},children:"No workflows"})]})]},t.id)}),R.length===0&&e.jsx("div",{className:"px-4 py-8 text-center",style:{color:f.faint},children:"No use-case scenario chains found."})]})]}),!d&&e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsxs(e.Fragment,{children:[!p&&e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:2},children:e.jsx(ge,{size:180})}),e.jsx("div",{className:"text-sm",children:"Select a scenario to edit steps and link elements"})]})}),p&&e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#1a1a1a"},children:p.name}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-md font-medium",style:{background:"#E67E2218",color:"#E67E22"},children:p.kind})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:"Steps"}),!i&&e.jsx("button",{onClick:oe,className:"px-2 py-0.5 text-xs rounded",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"Edit"}),i&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:re,className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Save"}),e.jsx("button",{onClick:()=>F(null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-1",children:k.map((t,n)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium",style:{background:"#2DD4A815",color:"#1B3A4B"},children:n+1}),i?e.jsx("input",{type:"text",value:t.text,onChange:o=>ae(n,o.target.value),className:"flex-1 text-sm px-2 py-1 rounded focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#374151"}}):e.jsx("span",{className:"flex-1 text-sm",style:{color:"#374151"},children:t.text}),i&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("button",{onClick:()=>Y(n,-1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move up",children:"▲"}),e.jsx("button",{onClick:()=>Y(n,1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move down",children:"▼"}),e.jsx("button",{onClick:()=>le(n),className:"px-1 text-xs",style:{color:"#E74C3C"},title:"Remove",children:"✕"})]})]},n))}),i&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{type:"text",value:L,onChange:t=>P(t.target.value),onKeyDown:t=>t.key==="Enter"&&V(),placeholder:"Add a step...",className:"flex-1 text-sm px-3 py-2 rounded-lg focus:outline-none",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",color:"#374151"}}),e.jsx("button",{onClick:V,className:"px-3 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"+ Add"})]}),k.length===0&&!i&&e.jsx("div",{className:"text-xs p-3 rounded-lg",style:{background:"#F3F4F6",color:"#9CA3AF"},children:"No steps defined. Click Edit to add scenario steps."})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:["Linked Elements (",K.length,")"]}),e.jsx("button",{onClick:()=>_(z===null?0:null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#4A90D915",color:"#4A90D9",border:"1px solid #4A90D940"},children:z!==null?"Done":"+ Link"})]}),z!==null&&e.jsxs("div",{className:"mb-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #4A90D940"},children:[e.jsx("input",{type:"text",value:T,onChange:t=>H(t.target.value),placeholder:"Search elements to link...",className:"w-full text-sm px-2 py-1 rounded focus:outline-none mb-1",style:{border:"1px solid #E5E5E0",color:"#374151"}}),ce.map(t=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs rounded cursor-pointer",onMouseEnter:n=>n.currentTarget.style.background="#F0F0ED",onMouseLeave:n=>n.currentTarget.style.background="transparent",onClick:()=>{b({type:"traceTo",sourceId:p.id,targetId:t.id,direction:"outgoing",selectedElementId:p.id}),H(""),_(null)},children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:E[t.layer]||"#95A5A6"}}),e.jsx("span",{style:{color:"#374151"},children:t.name}),e.jsx("span",{style:{color:"#9CA3AF"},children:t.kind})]},t.id))]}),e.jsx("div",{className:"space-y-1",children:K.map(t=>{const n=t.sourceId===p.id?t.targetId:t.sourceId,o=r.elements[n],c=t.sourceId===p.id?"→":"←";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:h=>h.currentTarget.style.background="#F0F0ED",onMouseLeave:h=>h.currentTarget.style.background="#FFFFFF",onClick:()=>B(n),children:[e.jsx("span",{style:{color:"#9CA3AF"},children:c}),e.jsx("span",{className:"font-medium",style:{color:"#2563EB"},children:t.type}),e.jsx("span",{style:{color:"#374151"},children:(o==null?void 0:o.name)||n}),o&&e.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded text-xs",style:{background:(E[o.layer]||"#95A5A6")+"18",color:E[o.layer]||"#95A5A6"},children:o.kind})]},t.id)})})]}),e.jsx("div",{className:"text-xs",style:{color:"#D1D5DB"},children:p.file})]})]})})]})}export{Ce as ScenarioEditor};
@@ -1 +1 @@
1
- import{j as e}from"./reactflow-C9OlmOYw.js";import{a as A}from"./zustand-CrhqMOHB.js";import{u as f,L as y,h as u,f as b}from"./index-DEVvBtNh.js";function w(a){var F;const c=Object.values(a.elements),n=c.length,t=a.relationships.length,i=((F=a.diagrams)==null?void 0:F.length)??0,d=new Map;for(const s of c){const o=d.get(s.layer)||{count:0,kinds:new Map};o.count++,o.kinds.set(s.kind,(o.kinds.get(s.kind)||0)+1),d.set(s.layer,o)}const m=y.filter(s=>d.has(s)).map(s=>({layer:s,label:b[s]||s,color:u[s]||"#95A5A6",count:d.get(s).count,kinds:d.get(s).kinds}));for(const[s,o]of d)y.includes(s)||m.push({layer:s,label:b[s]||s,color:u[s]||"#95A5A6",count:o.count,kinds:o.kinds});const l=new Map;for(const s of c){const o=l.get(s.kind)||{count:0,layer:s.layer};o.count++,l.set(s.kind,o)}const r=[...l.entries()].map(([s,{count:o,layer:C}])=>({kind:s,count:o,layer:C})).sort((s,o)=>o.count-s.count).slice(0,15),x=new Map;for(const s of a.relationships)x.set(s.type,(x.get(s.type)||0)+1);const j=[...x.entries()].map(([s,o])=>({type:s,count:o})).sort((s,o)=>o.count-s.count),p=new Set;for(const s of a.relationships)p.add(s.sourceId),p.add(s.targetId);const N=c.filter(s=>!p.has(s.id)).length;Math.max(...m.map(s=>s.count),1);const v=m.map(s=>({layer:s.layer,label:s.label,color:s.color,percent:Math.round(s.count/n*100)})),E=n>0?t/n:0,k=n>0?t/n:0;return{totalElements:n,totalRelationships:t,totalDiagrams:i,layers:m,topKinds:r,relTypes:j,avgRelsPerElement:Math.round(k*10)/10,orphanCount:N,coverage:v,density:Math.round(E*100)/100}}function B(){var d,m;const a=f(l=>l.model),c=f(l=>l.validation),n=f(l=>l.completeness),t=A.useMemo(()=>a?w(a):null,[a]);if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF"},children:e.jsx("div",{className:"text-sm",children:"No model data"})});const i=((d=c==null?void 0:c.violations)==null?void 0:d.length)??0;return e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Model Statistics"}),e.jsx("p",{className:"text-xs mb-6",style:{color:"#9CA3AF"},children:"Quick health check for your model"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(h,{label:"Elements",value:t.totalElements,color:"#1B3A4B"}),e.jsx(h,{label:"Relationships",value:t.totalRelationships,color:"#4A90D9"}),e.jsx(h,{label:"Diagrams",value:t.totalDiagrams,color:"#7B68EE"}),e.jsx(h,{label:"Violations",value:i,color:i>0?"#E74C3C":"#2ECC71"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(g,{label:"Rel. Density",value:`${t.avgRelsPerElement}`,unit:"per element",status:t.avgRelsPerElement>=1.5?"good":t.avgRelsPerElement>=.5?"ok":"low"}),e.jsx(g,{label:"Orphans",value:`${t.orphanCount}`,unit:"unlinked",status:t.orphanCount===0?"good":t.orphanCount<=5?"ok":"low"}),e.jsx(g,{label:"Layers Used",value:`${t.layers.length}`,unit:`of ${y.length}`,status:t.layers.length>=6?"good":t.layers.length>=3?"ok":"low"}),e.jsx(g,{label:"Kinds Used",value:`${t.topKinds.length}`,unit:"types",status:t.topKinds.length>=8?"good":t.topKinds.length>=4?"ok":"low"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Elements by Layer"}),e.jsx("div",{className:"space-y-2",children:t.layers.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-xs truncate",style:{color:"#374151"},children:l.label}),e.jsx("div",{className:"flex-1 h-4 rounded-full overflow-hidden",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.max(l.count/t.totalElements*100,2)}%`,background:l.color,opacity:.8}})}),e.jsx("span",{className:"w-8 text-right text-xs font-medium",style:{color:"#374151"},children:l.count})]},`${l.layer}-${r}`))})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Layer Coverage"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.map(l=>{const r=t.coverage.find(p=>p.layer===l),x=(r==null?void 0:r.percent)??0,j=x>0?Math.max(.15,x/100):.05;return e.jsxs("div",{className:"p-2 rounded-lg text-center",style:{background:`${u[l]||"#95A5A6"}${Math.round(j*255).toString(16).padStart(2,"0")}`,border:`1px solid ${u[l]||"#95A5A6"}30`},children:[e.jsx("div",{className:"text-xs font-medium truncate",style:{color:"#374151"},children:b[l]||l}),e.jsxs("div",{className:"text-lg font-bold",style:{color:u[l]||"#95A5A6"},children:[x,"%"]})]},l)})})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Top Element Types"}),e.jsx("div",{className:"space-y-1",children:t.topKinds.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:u[l.layer]||"#95A5A6"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.kind}),e.jsx("span",{className:"font-medium",style:{color:"#6B7280"},children:l.count})]},`${l.kind}-${r}`))})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Relationship Types"}),e.jsxs("div",{className:"space-y-1",children:[t.relTypes.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#4A90D9"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.type}),e.jsx("span",{className:"font-medium",style:{color:"#6B7280"},children:l.count})]},`${l.type}-${r}`)),t.relTypes.length===0&&e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:"No relationships"})]})]})]}),n&&e.jsxs("div",{className:"mt-4 p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Completeness by Layer"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:(m=n.layers)==null?void 0:m.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:u[l.layer]||"#95A5A6"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.layer}),e.jsxs("span",{className:"font-medium",style:{color:l.completeness>=80?"#2ECC71":l.completeness>=50?"#F39C12":"#E74C3C"},children:[Math.round(l.completeness),"%"]})]},`${l.layer}-${r}`))})]})]})})}function h({label:a,value:c,color:n}){return e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:n},children:c.toLocaleString()}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:a})]})}function g({label:a,value:c,unit:n,status:t}){const i=t==="good"?"#2ECC71":t==="ok"?"#F39C12":"#E74C3C";return e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${i}30`},children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold",style:{color:i},children:c}),e.jsx("span",{className:"text-xs",style:{color:"#9CA3AF"},children:n})]}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#6B7280"},children:a})]})}export{B as StatisticsDashboard};
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as A}from"./zustand-CrhqMOHB.js";import{u as f,L as y,h as u,f as b}from"./index-BYfHEpXT.js";function w(a){var F;const c=Object.values(a.elements),n=c.length,t=a.relationships.length,i=((F=a.diagrams)==null?void 0:F.length)??0,d=new Map;for(const s of c){const o=d.get(s.layer)||{count:0,kinds:new Map};o.count++,o.kinds.set(s.kind,(o.kinds.get(s.kind)||0)+1),d.set(s.layer,o)}const m=y.filter(s=>d.has(s)).map(s=>({layer:s,label:b[s]||s,color:u[s]||"#95A5A6",count:d.get(s).count,kinds:d.get(s).kinds}));for(const[s,o]of d)y.includes(s)||m.push({layer:s,label:b[s]||s,color:u[s]||"#95A5A6",count:o.count,kinds:o.kinds});const l=new Map;for(const s of c){const o=l.get(s.kind)||{count:0,layer:s.layer};o.count++,l.set(s.kind,o)}const r=[...l.entries()].map(([s,{count:o,layer:C}])=>({kind:s,count:o,layer:C})).sort((s,o)=>o.count-s.count).slice(0,15),x=new Map;for(const s of a.relationships)x.set(s.type,(x.get(s.type)||0)+1);const j=[...x.entries()].map(([s,o])=>({type:s,count:o})).sort((s,o)=>o.count-s.count),p=new Set;for(const s of a.relationships)p.add(s.sourceId),p.add(s.targetId);const N=c.filter(s=>!p.has(s.id)).length;Math.max(...m.map(s=>s.count),1);const v=m.map(s=>({layer:s.layer,label:s.label,color:s.color,percent:Math.round(s.count/n*100)})),E=n>0?t/n:0,k=n>0?t/n:0;return{totalElements:n,totalRelationships:t,totalDiagrams:i,layers:m,topKinds:r,relTypes:j,avgRelsPerElement:Math.round(k*10)/10,orphanCount:N,coverage:v,density:Math.round(E*100)/100}}function B(){var d,m;const a=f(l=>l.model),c=f(l=>l.validation),n=f(l=>l.completeness),t=A.useMemo(()=>a?w(a):null,[a]);if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF"},children:e.jsx("div",{className:"text-sm",children:"No model data"})});const i=((d=c==null?void 0:c.violations)==null?void 0:d.length)??0;return e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Model Statistics"}),e.jsx("p",{className:"text-xs mb-6",style:{color:"#9CA3AF"},children:"Quick health check for your model"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(h,{label:"Elements",value:t.totalElements,color:"#1B3A4B"}),e.jsx(h,{label:"Relationships",value:t.totalRelationships,color:"#4A90D9"}),e.jsx(h,{label:"Diagrams",value:t.totalDiagrams,color:"#7B68EE"}),e.jsx(h,{label:"Violations",value:i,color:i>0?"#E74C3C":"#2ECC71"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(g,{label:"Rel. Density",value:`${t.avgRelsPerElement}`,unit:"per element",status:t.avgRelsPerElement>=1.5?"good":t.avgRelsPerElement>=.5?"ok":"low"}),e.jsx(g,{label:"Orphans",value:`${t.orphanCount}`,unit:"unlinked",status:t.orphanCount===0?"good":t.orphanCount<=5?"ok":"low"}),e.jsx(g,{label:"Layers Used",value:`${t.layers.length}`,unit:`of ${y.length}`,status:t.layers.length>=6?"good":t.layers.length>=3?"ok":"low"}),e.jsx(g,{label:"Kinds Used",value:`${t.topKinds.length}`,unit:"types",status:t.topKinds.length>=8?"good":t.topKinds.length>=4?"ok":"low"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Elements by Layer"}),e.jsx("div",{className:"space-y-2",children:t.layers.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-xs truncate",style:{color:"#374151"},children:l.label}),e.jsx("div",{className:"flex-1 h-4 rounded-full overflow-hidden",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.max(l.count/t.totalElements*100,2)}%`,background:l.color,opacity:.8}})}),e.jsx("span",{className:"w-8 text-right text-xs font-medium",style:{color:"#374151"},children:l.count})]},`${l.layer}-${r}`))})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Layer Coverage"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.map(l=>{const r=t.coverage.find(p=>p.layer===l),x=(r==null?void 0:r.percent)??0,j=x>0?Math.max(.15,x/100):.05;return e.jsxs("div",{className:"p-2 rounded-lg text-center",style:{background:`${u[l]||"#95A5A6"}${Math.round(j*255).toString(16).padStart(2,"0")}`,border:`1px solid ${u[l]||"#95A5A6"}30`},children:[e.jsx("div",{className:"text-xs font-medium truncate",style:{color:"#374151"},children:b[l]||l}),e.jsxs("div",{className:"text-lg font-bold",style:{color:u[l]||"#95A5A6"},children:[x,"%"]})]},l)})})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Top Element Types"}),e.jsx("div",{className:"space-y-1",children:t.topKinds.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:u[l.layer]||"#95A5A6"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.kind}),e.jsx("span",{className:"font-medium",style:{color:"#6B7280"},children:l.count})]},`${l.kind}-${r}`))})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Relationship Types"}),e.jsxs("div",{className:"space-y-1",children:[t.relTypes.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#4A90D9"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.type}),e.jsx("span",{className:"font-medium",style:{color:"#6B7280"},children:l.count})]},`${l.type}-${r}`)),t.relTypes.length===0&&e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:"No relationships"})]})]})]}),n&&e.jsxs("div",{className:"mt-4 p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Completeness by Layer"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:(m=n.layers)==null?void 0:m.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:u[l.layer]||"#95A5A6"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.layer}),e.jsxs("span",{className:"font-medium",style:{color:l.completeness>=80?"#2ECC71":l.completeness>=50?"#F39C12":"#E74C3C"},children:[Math.round(l.completeness),"%"]})]},`${l.layer}-${r}`))})]})]})})}function h({label:a,value:c,color:n}){return e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:n},children:c.toLocaleString()}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:a})]})}function g({label:a,value:c,unit:n,status:t}){const i=t==="good"?"#2ECC71":t==="ok"?"#F39C12":"#E74C3C";return e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${i}30`},children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold",style:{color:i},children:c}),e.jsx("span",{className:"text-xs",style:{color:"#9CA3AF"},children:n})]}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#6B7280"},children:a})]})}export{B as StatisticsDashboard};
@@ -1 +1 @@
1
- import{j as t}from"./reactflow-C9OlmOYw.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as w,F as j,f as L,h as T}from"./index-DEVvBtNh.js";function R({element:l}){var f;const i=!!((f=l.attributes.description)!=null&&f.trim()),d=Object.keys(l.attributes).length,S=i&&d>=1,v=i||d>=1,p=S?"#2DD4A8":v?"#F39C12":"#E5E5E0",A=S?"Complete":v?"Partial":"Empty";return t.jsx("span",{className:"inline-block rounded-full flex-shrink-0",style:{width:8,height:8,backgroundColor:p,cursor:"default"},title:A})}function Y({col:l,sortKey:i,sortDir:d}){return l!==i?t.jsx("span",{style:{color:"#D1D5DB",fontSize:"10px",marginLeft:3},children:"⇅"}):t.jsx("span",{style:{color:"#1B3A4B",fontSize:"10px",marginLeft:3},children:d==="asc"?"↑":"↓"})}function P(){const l=w(e=>e.model),i=w(e=>e.activeView),d=w(e=>e.selectedViewpointId),S=w(e=>e.selectElement),v=w(e=>e.selectedElementId),[p,A]=x.useState("name"),[f,C]=x.useState("asc"),[E,B]=x.useState(""),[b,I]=x.useState(""),[g,M]=x.useState(""),h=x.useMemo(()=>{var n,s,o,c,r;if(!l)return[];const e=Object.values(l.elements);if(i.type==="tabular"&&i.diagramId){const a=(n=l.diagrams)==null?void 0:n.find(u=>u.id===i.diagramId);if((s=a==null?void 0:a.elementIds)!=null&&s.length){const u=new Set(a.elementIds);return e.filter(m=>u.has(m.id))}}if(d){const a=(o=l.viewpoints)==null?void 0:o.find(u=>u.id===d);if(a){const u=(c=a.visibleLayers)!=null&&c.length?new Set(a.visibleLayers):null,m=(r=a.visibleKinds)!=null&&r.length?new Set(a.visibleKinds):null;return e.filter(F=>(!u||u.has(F.layer))&&(!m||m.has(F.kind)))}}return e},[l,i,d]),k=x.useMemo(()=>{const e=new Map;for(const s of h)for(const o of Object.keys(s.attributes))o==="description"||o==="shortDescription"||e.set(o,(e.get(o)??0)+1);const n=Math.max(1,h.length*.1);return[...e.entries()].filter(([,s])=>s>=n).sort((s,o)=>o[1]-s[1]).slice(0,4).map(([s])=>s)},[h]),O=x.useMemo(()=>[...new Set(h.map(e=>e.layer))].sort(),[h]),V=x.useMemo(()=>[...new Set(h.map(e=>e.kind))].sort(),[h]),N=x.useMemo(()=>{const e=E.toLowerCase();let n=h.filter(s=>!(e&&!s.name.toLowerCase().includes(e)&&!s.kind.toLowerCase().includes(e)||b&&s.layer!==b||g&&s.kind!==g));return n.sort((s,o)=>{let c="",r="";if(p==="name")c=s.name,r=o.name;else if(p==="kind")c=s.kind,r=o.kind;else if(p==="layer")c=s.layer,r=o.layer;else if(p==="status"){const u=m=>{var z;const F=!!((z=m.attributes.description)!=null&&z.trim()),D=Object.keys(m.attributes).length>=1;return F&&D?2:F||D?1:0};c=String(u(s)),r=String(u(o))}else c=s.attributes[p]??"",r=o.attributes[p]??"";const a=c.localeCompare(r,void 0,{numeric:!0});return f==="asc"?a:-a}),n},[h,E,b,g,p,f]);function K(e){p===e?C(n=>n==="asc"?"desc":"asc"):(A(e),C("asc"))}const W=x.useMemo(()=>{var e,n;if(!l)return"";if(i.type==="tabular"&&i.diagramId){const s=(e=l.diagrams)==null?void 0:e.find(o=>o.id===i.diagramId);return s?`Diagram: ${s.name}`:"Diagram"}if(d){const s=(n=l.viewpoints)==null?void 0:n.find(o=>o.id===d);return s?`Viewpoint: ${s.label}`:"Viewpoint"}return"All Elements"},[l,i,d]),y=({col:e,label:n,width:s})=>t.jsxs("th",{onClick:()=>K(e),className:"px-3 py-2 text-left cursor-pointer select-none",style:{fontSize:"11px",fontWeight:600,color:"#374151",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",whiteSpace:"nowrap",width:s,position:"sticky",top:0,zIndex:1},children:[n,t.jsx(Y,{col:e,sortKey:p,sortDir:f})]});return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{background:"#FFFFFF"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 flex-shrink-0",style:{borderBottom:"1px solid #E5E5E0",background:"#FAFAF8"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Tabular View"}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:W})]}),t.jsx("div",{className:"flex-1"}),t.jsx("input",{type:"text",placeholder:"Search elements…",value:E,onChange:e=>B(e.target.value),className:"px-3 py-1.5 rounded-lg focus:outline-none",style:{width:220,fontSize:j.xs,color:"#1a1a1a",border:"1px solid #E5E5E0",background:"#FFFFFF"}}),t.jsxs("select",{value:b,onChange:e=>I(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All layers"}),O.map(e=>t.jsx("option",{value:e,children:L[e]??e},e))]}),t.jsxs("select",{value:g,onChange:e=>M(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All kinds"}),V.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",whiteSpace:"nowrap"},children:[N.length," / ",h.length," elements"]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse",style:{tableLayout:"fixed"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:28}}),t.jsx("col",{style:{width:"30%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"20%"}}),k.map(e=>t.jsx("col",{style:{width:"10%"}},e))]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:{background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",position:"sticky",top:0,zIndex:1}}),t.jsx(y,{col:"name",label:"Name"}),t.jsx(y,{col:"kind",label:"Kind"}),t.jsx(y,{col:"layer",label:"Layer"}),t.jsx(y,{col:"status",label:"",width:40}),t.jsx(y,{col:"shortDescription",label:"Short description"}),k.map(e=>t.jsx(y,{col:e,label:e},e))]})}),t.jsxs("tbody",{children:[N.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6+k.length,className:"py-16 text-center",style:{fontSize:"13px",color:"#9CA3AF"},children:E||b||g?"No elements match the current filters":"No elements in scope"})}),N.map(e=>{var c;const n=e.id===v,s=T[e.layer]??"#9CA3AF",o=((c=e.attributes.shortDescription)==null?void 0:c.trim())??"";return t.jsxs("tr",{onClick:()=>S(e.id),className:"cursor-pointer",style:{background:n?"#2DD4A812":"transparent",borderBottom:"1px solid #F0F0ED"},onMouseEnter:r=>{n||(r.currentTarget.style.background="#F7F7F5")},onMouseLeave:r=>{n||(r.currentTarget.style.background="transparent")},children:[t.jsx("td",{className:"px-2",children:n&&t.jsx("span",{style:{color:"#2DD4A8",fontSize:"10px"},children:"▶"})}),t.jsxs("td",{className:"px-3 py-2",children:[t.jsx("div",{style:{fontSize:j.xs,fontWeight:500,color:"#1B3A4B",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.shortId&&t.jsx("div",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:e.shortId})]}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:"#374151"},children:e.kind})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{fontSize:"10px",fontWeight:600,background:s+"1A",color:s,whiteSpace:"nowrap"},children:L[e.layer]??e.layer})}),t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx(R,{element:e})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#6B7280",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o})}),k.map(r=>t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:e.attributes[r]??""})},r))]},e.id)})]})]})})]})}export{P as TabularView};
1
+ import{j as t}from"./reactflow-C9OlmOYw.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as w,F as j,f as L,h as T}from"./index-BYfHEpXT.js";function R({element:l}){var f;const i=!!((f=l.attributes.description)!=null&&f.trim()),d=Object.keys(l.attributes).length,S=i&&d>=1,v=i||d>=1,p=S?"#2DD4A8":v?"#F39C12":"#E5E5E0",A=S?"Complete":v?"Partial":"Empty";return t.jsx("span",{className:"inline-block rounded-full flex-shrink-0",style:{width:8,height:8,backgroundColor:p,cursor:"default"},title:A})}function Y({col:l,sortKey:i,sortDir:d}){return l!==i?t.jsx("span",{style:{color:"#D1D5DB",fontSize:"10px",marginLeft:3},children:"⇅"}):t.jsx("span",{style:{color:"#1B3A4B",fontSize:"10px",marginLeft:3},children:d==="asc"?"↑":"↓"})}function P(){const l=w(e=>e.model),i=w(e=>e.activeView),d=w(e=>e.selectedViewpointId),S=w(e=>e.selectElement),v=w(e=>e.selectedElementId),[p,A]=x.useState("name"),[f,C]=x.useState("asc"),[E,B]=x.useState(""),[b,I]=x.useState(""),[g,M]=x.useState(""),h=x.useMemo(()=>{var n,s,o,c,r;if(!l)return[];const e=Object.values(l.elements);if(i.type==="tabular"&&i.diagramId){const a=(n=l.diagrams)==null?void 0:n.find(u=>u.id===i.diagramId);if((s=a==null?void 0:a.elementIds)!=null&&s.length){const u=new Set(a.elementIds);return e.filter(m=>u.has(m.id))}}if(d){const a=(o=l.viewpoints)==null?void 0:o.find(u=>u.id===d);if(a){const u=(c=a.visibleLayers)!=null&&c.length?new Set(a.visibleLayers):null,m=(r=a.visibleKinds)!=null&&r.length?new Set(a.visibleKinds):null;return e.filter(F=>(!u||u.has(F.layer))&&(!m||m.has(F.kind)))}}return e},[l,i,d]),k=x.useMemo(()=>{const e=new Map;for(const s of h)for(const o of Object.keys(s.attributes))o==="description"||o==="shortDescription"||e.set(o,(e.get(o)??0)+1);const n=Math.max(1,h.length*.1);return[...e.entries()].filter(([,s])=>s>=n).sort((s,o)=>o[1]-s[1]).slice(0,4).map(([s])=>s)},[h]),O=x.useMemo(()=>[...new Set(h.map(e=>e.layer))].sort(),[h]),V=x.useMemo(()=>[...new Set(h.map(e=>e.kind))].sort(),[h]),N=x.useMemo(()=>{const e=E.toLowerCase();let n=h.filter(s=>!(e&&!s.name.toLowerCase().includes(e)&&!s.kind.toLowerCase().includes(e)||b&&s.layer!==b||g&&s.kind!==g));return n.sort((s,o)=>{let c="",r="";if(p==="name")c=s.name,r=o.name;else if(p==="kind")c=s.kind,r=o.kind;else if(p==="layer")c=s.layer,r=o.layer;else if(p==="status"){const u=m=>{var z;const F=!!((z=m.attributes.description)!=null&&z.trim()),D=Object.keys(m.attributes).length>=1;return F&&D?2:F||D?1:0};c=String(u(s)),r=String(u(o))}else c=s.attributes[p]??"",r=o.attributes[p]??"";const a=c.localeCompare(r,void 0,{numeric:!0});return f==="asc"?a:-a}),n},[h,E,b,g,p,f]);function K(e){p===e?C(n=>n==="asc"?"desc":"asc"):(A(e),C("asc"))}const W=x.useMemo(()=>{var e,n;if(!l)return"";if(i.type==="tabular"&&i.diagramId){const s=(e=l.diagrams)==null?void 0:e.find(o=>o.id===i.diagramId);return s?`Diagram: ${s.name}`:"Diagram"}if(d){const s=(n=l.viewpoints)==null?void 0:n.find(o=>o.id===d);return s?`Viewpoint: ${s.label}`:"Viewpoint"}return"All Elements"},[l,i,d]),y=({col:e,label:n,width:s})=>t.jsxs("th",{onClick:()=>K(e),className:"px-3 py-2 text-left cursor-pointer select-none",style:{fontSize:"11px",fontWeight:600,color:"#374151",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",whiteSpace:"nowrap",width:s,position:"sticky",top:0,zIndex:1},children:[n,t.jsx(Y,{col:e,sortKey:p,sortDir:f})]});return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{background:"#FFFFFF"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 flex-shrink-0",style:{borderBottom:"1px solid #E5E5E0",background:"#FAFAF8"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Tabular View"}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:W})]}),t.jsx("div",{className:"flex-1"}),t.jsx("input",{type:"text",placeholder:"Search elements…",value:E,onChange:e=>B(e.target.value),className:"px-3 py-1.5 rounded-lg focus:outline-none",style:{width:220,fontSize:j.xs,color:"#1a1a1a",border:"1px solid #E5E5E0",background:"#FFFFFF"}}),t.jsxs("select",{value:b,onChange:e=>I(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All layers"}),O.map(e=>t.jsx("option",{value:e,children:L[e]??e},e))]}),t.jsxs("select",{value:g,onChange:e=>M(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All kinds"}),V.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",whiteSpace:"nowrap"},children:[N.length," / ",h.length," elements"]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse",style:{tableLayout:"fixed"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:28}}),t.jsx("col",{style:{width:"30%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"20%"}}),k.map(e=>t.jsx("col",{style:{width:"10%"}},e))]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:{background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",position:"sticky",top:0,zIndex:1}}),t.jsx(y,{col:"name",label:"Name"}),t.jsx(y,{col:"kind",label:"Kind"}),t.jsx(y,{col:"layer",label:"Layer"}),t.jsx(y,{col:"status",label:"",width:40}),t.jsx(y,{col:"shortDescription",label:"Short description"}),k.map(e=>t.jsx(y,{col:e,label:e},e))]})}),t.jsxs("tbody",{children:[N.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6+k.length,className:"py-16 text-center",style:{fontSize:"13px",color:"#9CA3AF"},children:E||b||g?"No elements match the current filters":"No elements in scope"})}),N.map(e=>{var c;const n=e.id===v,s=T[e.layer]??"#9CA3AF",o=((c=e.attributes.shortDescription)==null?void 0:c.trim())??"";return t.jsxs("tr",{onClick:()=>S(e.id),className:"cursor-pointer",style:{background:n?"#2DD4A812":"transparent",borderBottom:"1px solid #F0F0ED"},onMouseEnter:r=>{n||(r.currentTarget.style.background="#F7F7F5")},onMouseLeave:r=>{n||(r.currentTarget.style.background="transparent")},children:[t.jsx("td",{className:"px-2",children:n&&t.jsx("span",{style:{color:"#2DD4A8",fontSize:"10px"},children:"▶"})}),t.jsxs("td",{className:"px-3 py-2",children:[t.jsx("div",{style:{fontSize:j.xs,fontWeight:500,color:"#1B3A4B",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.shortId&&t.jsx("div",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:e.shortId})]}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:"#374151"},children:e.kind})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{fontSize:"10px",fontWeight:600,background:s+"1A",color:s,whiteSpace:"nowrap"},children:L[e.layer]??e.layer})}),t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx(R,{element:e})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#6B7280",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o})}),k.map(r=>t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:e.attributes[r]??""})},r))]},e.id)})]})]})})]})}export{P as TabularView};
@@ -1,3 +1,3 @@
1
- import{j as s}from"./reactflow-C9OlmOYw.js";import{a as i}from"./zustand-CrhqMOHB.js";import{u as k,i as We,k as He,j as ne,r as ke,F as R,C as r,T as Ge}from"./index-DEVvBtNh.js";import{l as Qe,e as Ce,s as ve,c as Ue,a as Ve,b as je,r as Ye,A as Te,T as Re,H as Ze}from"./DSMView-BsjhUbpW.js";import{a as Je,I as oe}from"./DiagramToolbarControls-XMGLx08e.js";const Xe=[{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 it(){var Se;const o=k(e=>e.model),f=k(e=>e.connected),v=k(e=>e.selectElement),Fe=k(e=>e.selectedElementId),se=k(e=>e.selectedDiagramId),ie=k(e=>e.createRelationship),re=k(e=>e.deleteRelationship),[b,O]=i.useState({}),[w,z]=i.useState({}),[E,W]=i.useState([]),[F,H]=i.useState([]),[x,G]=i.useState([]),[Q,Ie]=i.useState("natural"),[U,Me]=i.useState("natural"),[ae,le]=i.useState(null),[Oe,ze]=i.useState("top"),[h,$e]=i.useState(!1),[de,Ae]=i.useState(39),[Le,_e]=i.useState(!0),[ce,V]=i.useState(new Set),[pe,Y]=i.useState(new Set),[l,$]=i.useState(null),[A,j]=i.useState(null),[L,ue]=i.useState(""),[D,K]=i.useState(!1),S=i.useMemo(()=>We(o),[o]),me=i.useMemo(()=>o?Qe(o):[],[o]),fe=k(e=>e.availableOntologies),g=i.useMemo(()=>He(fe),[fe]),Z=i.useMemo(()=>Ce(o,b,g),[o,b,g]),J=i.useMemo(()=>Ce(o,w,g),[o,w,g]),N=i.useMemo(()=>ve(b,o,g),[b,o,g]),B=i.useMemo(()=>ve(w,o,g),[w,o,g]),X=i.useMemo(()=>{if(!o||!S)return[];const e=(a,m,C,y)=>(!m.layer||a.layer===m.layer)&&(C.length===0||C.includes(a.kind))&&(y.length===0||y.includes(a.id)),t=Object.values(o.elements).filter(a=>e(a,b,N,E)),n=Object.values(o.elements).filter(a=>e(a,w,B,F)),d=new Set;for(const a of t)for(const m of n)if(a.id!==m.id)for(const C of ne(a,m,S))d.add(C.definition.name);const p=new Map;for(const a of o.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:ke(a)}))},[o,S,b,w,N,B,E,F]);i.useEffect(()=>{const e=new Set(Z.map(t=>t.value));W(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[Z]),i.useEffect(()=>{const e=new Set(J.map(t=>t.value));H(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[J]),i.useEffect(()=>{const e=new Set(X.map(t=>t.value));G(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[X]);const c=i.useMemo(()=>o?Ue(o,{rows:{layer:b.layer,kinds:N,elementIds:E,expanded:ce,ordering:Q},columns:{layer:w.layer,kinds:B,elementIds:F,expanded:pe,ordering:U},dependencyTypes:x,symmetric:!0}):null,[o,b,w,N,B,E,F,x,Q,U,ce,pe]),[P,De]=i.useState(!1);i.useEffect(()=>{if(P||!o)return;const e=Ve(o);e.rows&&(O({layer:e.rows}),z({layer:e.columns}),De(!0))},[o,P]);const[xe,Ke]=i.useState(!1);i.useEffect(()=>{if(xe||!P||!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||(V(new Set(e)),Y(new Set(t)),Ke(!0))},[c,P,xe]);const T=i.useCallback((e,t)=>{e==="rows"?V(t):Y(t)},[]),he=i.useCallback(e=>{c&&T(e,new Set(je(e==="rows"?c.rowRoots:c.columnRoots)))},[c,T]),ge=i.useCallback(e=>T(e,new Set),[T]),ye=i.useCallback((e,t)=>{c&&T(e,new Set(je(e==="rows"?c.rowRoots:c.columnRoots,t)))},[c,T]),_=i.useCallback(e=>{if(!o)return null;for(const t of e){const n=Object.values(o.elements).find(d=>d.kind===t);if(n)return{layer:n.layer,kind:t}}return null},[o]),Ne=i.useCallback(e=>{const t=new Set(o?Ye(o):[]),n=_(e.rowKinds),d=_(e.columnKinds);e.id==="everything"?(O({}),z({})):(n&&O(n),d&&z(d)),G(e.linkTypes.filter(p=>t.has(p))),W([]),H([]),$(null)},[o,_]),be=i.useMemo(()=>{var p;if(!o||!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 o.relationships.filter(m=>(a.size===0||a.has(m.type))&&(m.sourceId===e&&m.targetId===t||m.sourceId===t&&m.targetId===e))}const d=new Set(((p=l.cell)==null?void 0:p.relationshipIds)??[]);return o.relationships.filter(a=>d.has(a.id))},[o,l,x]),I=i.useMemo(()=>{if(!o||!l||!S)return[];const e=o.elements[l.row.node.id],t=o.elements[l.column.node.id];return!e||!t||e.id===t.id?[]:ne(e,t,S)},[o,l,S]),q=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]),we=i.useMemo(()=>{const e=L.trim().toLowerCase();return I.filter(t=>!e||t.definition.name.toLowerCase().includes(e)).sort((t,n)=>{const d=Number(q.has(n.definition.name))-Number(q.has(t.definition.name));return d!==0?d:t.definition.name.localeCompare(n.definition.name)})},[I,L,q]),Be=!!(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),ee=i.useCallback(async e=>{K(!0),j(null);const t=await ie({type:e.definition.name,sourceId:e.sourceId,targetId:e.targetId,direction:e.direction,diagramId:se??void 0});K(!1),j(t.success?{kind:"ok",message:`Trace written to ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be created."})},[ie,se]),te=i.useCallback(async e=>{K(!0),j(null);const t=await re(e);K(!1),j(t.success?{kind:"ok",message:`Trace removed from ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be removed."})},[re]),Pe=i.useCallback(async(e,t,n)=>{if(!h||!f||!o||!S||!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=o.relationships.find(y=>y.type===d&&(y.sourceId===e.node.id&&y.targetId===t.node.id||y.sourceId===t.node.id&&y.targetId===e.node.id));if(p){if(p.named===!1){j({kind:"error",message:"This trace has no declared name, so it cannot be removed until it is named in SysML."});return}await te(p.id);return}const a=o.elements[e.node.id],m=o.elements[t.node.id];if(!a||!m)return;const C=ne(a,m,S).find(y=>y.definition.name===d);if(!C){j({kind:"error",message:`${d} is not legal between these element types.`});return}await ee(C)},[h,f,o,S,x,ee,te]),qe=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}
1
+ import{j as s}from"./reactflow-C9OlmOYw.js";import{a as i}from"./zustand-CrhqMOHB.js";import{u as k,i as We,k as He,j as ne,r as ke,F as R,C as r,T as Ge}from"./index-BYfHEpXT.js";import{l as Qe,e as Ce,s as ve,c as Ue,a as Ve,b as je,r as Ye,A as Te,T as Re,H as Ze}from"./DSMView-Em0sO2Uj.js";import{a as Je,I as oe}from"./DiagramToolbarControls-XMGLx08e.js";const Xe=[{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 it(){var Se;const o=k(e=>e.model),f=k(e=>e.connected),v=k(e=>e.selectElement),Fe=k(e=>e.selectedElementId),se=k(e=>e.selectedDiagramId),ie=k(e=>e.createRelationship),re=k(e=>e.deleteRelationship),[b,O]=i.useState({}),[w,z]=i.useState({}),[E,W]=i.useState([]),[F,H]=i.useState([]),[x,G]=i.useState([]),[Q,Ie]=i.useState("natural"),[U,Me]=i.useState("natural"),[ae,le]=i.useState(null),[Oe,ze]=i.useState("top"),[h,$e]=i.useState(!1),[de,Ae]=i.useState(39),[Le,_e]=i.useState(!0),[ce,V]=i.useState(new Set),[pe,Y]=i.useState(new Set),[l,$]=i.useState(null),[A,j]=i.useState(null),[L,ue]=i.useState(""),[D,K]=i.useState(!1),S=i.useMemo(()=>We(o),[o]),me=i.useMemo(()=>o?Qe(o):[],[o]),fe=k(e=>e.availableOntologies),g=i.useMemo(()=>He(fe),[fe]),Z=i.useMemo(()=>Ce(o,b,g),[o,b,g]),J=i.useMemo(()=>Ce(o,w,g),[o,w,g]),N=i.useMemo(()=>ve(b,o,g),[b,o,g]),B=i.useMemo(()=>ve(w,o,g),[w,o,g]),X=i.useMemo(()=>{if(!o||!S)return[];const e=(a,m,C,y)=>(!m.layer||a.layer===m.layer)&&(C.length===0||C.includes(a.kind))&&(y.length===0||y.includes(a.id)),t=Object.values(o.elements).filter(a=>e(a,b,N,E)),n=Object.values(o.elements).filter(a=>e(a,w,B,F)),d=new Set;for(const a of t)for(const m of n)if(a.id!==m.id)for(const C of ne(a,m,S))d.add(C.definition.name);const p=new Map;for(const a of o.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:ke(a)}))},[o,S,b,w,N,B,E,F]);i.useEffect(()=>{const e=new Set(Z.map(t=>t.value));W(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[Z]),i.useEffect(()=>{const e=new Set(J.map(t=>t.value));H(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[J]),i.useEffect(()=>{const e=new Set(X.map(t=>t.value));G(t=>t.every(n=>e.has(n))?t:t.filter(n=>e.has(n)))},[X]);const c=i.useMemo(()=>o?Ue(o,{rows:{layer:b.layer,kinds:N,elementIds:E,expanded:ce,ordering:Q},columns:{layer:w.layer,kinds:B,elementIds:F,expanded:pe,ordering:U},dependencyTypes:x,symmetric:!0}):null,[o,b,w,N,B,E,F,x,Q,U,ce,pe]),[P,De]=i.useState(!1);i.useEffect(()=>{if(P||!o)return;const e=Ve(o);e.rows&&(O({layer:e.rows}),z({layer:e.columns}),De(!0))},[o,P]);const[xe,Ke]=i.useState(!1);i.useEffect(()=>{if(xe||!P||!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||(V(new Set(e)),Y(new Set(t)),Ke(!0))},[c,P,xe]);const T=i.useCallback((e,t)=>{e==="rows"?V(t):Y(t)},[]),he=i.useCallback(e=>{c&&T(e,new Set(je(e==="rows"?c.rowRoots:c.columnRoots)))},[c,T]),ge=i.useCallback(e=>T(e,new Set),[T]),ye=i.useCallback((e,t)=>{c&&T(e,new Set(je(e==="rows"?c.rowRoots:c.columnRoots,t)))},[c,T]),_=i.useCallback(e=>{if(!o)return null;for(const t of e){const n=Object.values(o.elements).find(d=>d.kind===t);if(n)return{layer:n.layer,kind:t}}return null},[o]),Ne=i.useCallback(e=>{const t=new Set(o?Ye(o):[]),n=_(e.rowKinds),d=_(e.columnKinds);e.id==="everything"?(O({}),z({})):(n&&O(n),d&&z(d)),G(e.linkTypes.filter(p=>t.has(p))),W([]),H([]),$(null)},[o,_]),be=i.useMemo(()=>{var p;if(!o||!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 o.relationships.filter(m=>(a.size===0||a.has(m.type))&&(m.sourceId===e&&m.targetId===t||m.sourceId===t&&m.targetId===e))}const d=new Set(((p=l.cell)==null?void 0:p.relationshipIds)??[]);return o.relationships.filter(a=>d.has(a.id))},[o,l,x]),I=i.useMemo(()=>{if(!o||!l||!S)return[];const e=o.elements[l.row.node.id],t=o.elements[l.column.node.id];return!e||!t||e.id===t.id?[]:ne(e,t,S)},[o,l,S]),q=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]),we=i.useMemo(()=>{const e=L.trim().toLowerCase();return I.filter(t=>!e||t.definition.name.toLowerCase().includes(e)).sort((t,n)=>{const d=Number(q.has(n.definition.name))-Number(q.has(t.definition.name));return d!==0?d:t.definition.name.localeCompare(n.definition.name)})},[I,L,q]),Be=!!(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),ee=i.useCallback(async e=>{K(!0),j(null);const t=await ie({type:e.definition.name,sourceId:e.sourceId,targetId:e.targetId,direction:e.direction,diagramId:se??void 0});K(!1),j(t.success?{kind:"ok",message:`Trace written to ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be created."})},[ie,se]),te=i.useCallback(async e=>{K(!0),j(null);const t=await re(e);K(!1),j(t.success?{kind:"ok",message:`Trace removed from ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be removed."})},[re]),Pe=i.useCallback(async(e,t,n)=>{if(!h||!f||!o||!S||!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=o.relationships.find(y=>y.type===d&&(y.sourceId===e.node.id&&y.targetId===t.node.id||y.sourceId===t.node.id&&y.targetId===e.node.id));if(p){if(p.named===!1){j({kind:"error",message:"This trace has no declared name, so it cannot be removed until it is named in SysML."});return}await te(p.id);return}const a=o.elements[e.node.id],m=o.elements[t.node.id];if(!a||!m)return;const C=ne(a,m,S).find(y=>y.definition.name===d);if(!C){j({kind:"error",message:`${d} is not legal between these element types.`});return}await ee(C)},[h,f,o,S,x,ee,te]),qe=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
2
  ${e.types.join(", ")}${h?`
3
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]),M=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(!o||!c)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:r.faint,fontSize:R.sm},children:"No model loaded"});const u=Oe==="left";return s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#FAFAF8",position:"relative"},children:[s.jsxs("div",{style:u?{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:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:u?{flexDirection:"column",alignItems:"stretch",position:"relative",paddingTop:"54px"}:{flexWrap:"wrap",position:"relative",paddingRight:"52px"},children:[s.jsx("span",{style:{position:"absolute",top:"9px",right:"12px"},children:s.jsx(Je,{icon:u?s.jsx(oe.arrowUp,{}):s.jsx(oe.panelCollapse,{}),onClick:()=>ze(e=>e==="top"?"left":"top"),title:u?"Move toolbar to top":"Move toolbar to left"})}),s.jsx(Te,{axis:"rows",layers:me,scope:b,onScopeChange:O,elements:E,onElementsChange:W,elementOptions:Z,ordering:Q,onOrderingChange:Ie,onExpandAll:he,onCollapseAll:ge,onExpandToDepth:ye,leftDock:u,filterOpen:ae==="rows",onFilterOpenChange:e=>le(e?"rows":null),parentOf:new Map,kindParents:g}),s.jsx(Te,{axis:"columns",layers:me,scope:w,onScopeChange:z,elements:F,onElementsChange:H,elementOptions:J,ordering:U,onOrderingChange:Me,onExpandAll:he,onCollapseAll:ge,onExpandToDepth:ye,leftDock:u,filterOpen:ae==="columns",onFilterOpenChange:e=>le(e?"columns":null),parentOf:new Map,kindParents:g}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:u?"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:[s.jsx(Re,{label:s.jsxs(s.Fragment,{children:[s.jsx(oe.filter,{})," Relations"]}),ariaLabel:"Filter trace relationships",title:"Relationships counted as trace",width:u?210:260,fullWidth:u,children:s.jsx(Ge,{label:"Trace relationships",allLabel:"Any relationship",options:X,selected:x,onChange:G,title:"Relationships counted as trace"})}),s.jsx(Re,{label:"Presets",ariaLabel:"Traceability presets",title:"Choose a traceability starting point",width:u?210:270,fullWidth:u,children:Xe.map(e=>s.jsx("button",{onClick:()=>Ne(e),title:e.description,style:{padding:"6px 7px",border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",fontSize:R.xs,color:r.primary,textAlign:"left"},children:e.label},e.id))}),s.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:R.xs,width:u?"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:[s.jsx("input",{type:"checkbox",checked:h,disabled:!f,onChange:e=>{$e(e.target.checked),$(null)},style:{accentColor:r.accent}}),"Edit trace"]}),s.jsxs("label",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"5px",fontSize:R.xs,color:r.muted,justifyContent:u?"center":void 0},title:"Cell size",children:["Zoom",s.jsx("input",{type:"range",min:14,max:44,step:2,value:de,onChange:e=>Ae(Number(e.target.value)),style:{width:"80px",accentColor:r.accent}})]})]})]}),A&&s.jsx("div",{style:{padding:"5px 16px",fontSize:"11px",color:A.kind==="ok"?"#0F766E":"#B91C1C",background:A.kind==="ok"?"#ECFDF5":"#FEF2F2",borderTop:`1px solid ${r.borderLight}`},children:A.message})]}),s.jsx("div",{style:{display:"flex",flex:1,minHeight:0,minWidth:0,marginLeft:u?"250px":0,width:u?"calc(100% - 250px)":void 0},children:s.jsx(Ze,{result:c,onToggleRow:e=>V(t=>Ee(t,e)),onToggleColumn:e=>Y(t=>Ee(t,e)),onSelectElement:v,selectedElementId:Fe,renderCell:qe,onCellClick:(e,t,n)=>{$({row:e,column:t,cell:n}),ue("")},onCellDoubleClick:(e,t,n)=>{Pe(e,t,n)},cellSize:de,showColumnNames:Le,cornerHeader:s.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",height:"100%"},children:[s.jsx("span",{style:{fontSize:R.sm,fontWeight:600,color:r.primary},children:"Traceability Matrix"}),s.jsxs("span",{style:{fontSize:"11px",color:r.faint,marginTop:"2px"},children:[c.totalDependencies," link",c.totalDependencies===1?"":"s"," shown",M.total>0&&` · ${M.traced}/${M.total} rows traced (${Math.round(M.traced/M.total*100)}%)`]})]})})}),l&&s.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:R.xs},children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{style:{fontWeight:600,color:r.primary},children:[l.row.node.name," ","↔"," ",l.column.node.name]}),s.jsx("button",{onClick:()=>$(null),style:{color:r.faint,background:"none",border:"none",cursor:"pointer"},children:"✕"})]}),be.length>0?s.jsx("div",{style:{marginTop:"9px",display:"flex",flexDirection:"column",gap:"5px"},children:be.map(e=>{var t,n;return s.jsxs("div",{className:"flex items-center justify-between gap-2",style:{padding:"4px 6px",borderRadius:"5px",background:r.surfaceAlt},children:[s.jsx("span",{style:{color:ke(e.type),fontWeight:500},children:e.type}),s.jsxs("span",{style:{flex:1,color:r.faint,fontSize:"10px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[((t=o.elements[e.sourceId])==null?void 0:t.name)??e.sourceId," ","→"," ",((n=o.elements[e.targetId])==null?void 0:n.name)??e.targetId]}),h&&s.jsx("button",{disabled:D||e.named===!1,onClick:()=>void te(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:D||e.named===!1?"not-allowed":"pointer",opacity:e.named===!1?.5:1},children:"Remove"})]},e.id)})}):s.jsx("div",{style:{marginTop:"8px",color:r.muted},children:"No trace between these two."}),((Se=l.cell)==null?void 0:Se.aggregated)&&s.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&&s.jsxs("div",{style:{marginTop:"11px",borderTop:`1px solid ${r.borderLight}`,paddingTop:"9px"},children:[s.jsx("div",{style:{fontSize:"11px",color:r.muted,marginBottom:"6px"},children:"Add a trace link"}),Be?I.length===0?s.jsxs("div",{style:{fontSize:"11px",color:r.faint},children:["The ontology allows no relationship between ",l.row.node.kind," and ",l.column.node.kind,"."]}):s.jsxs(s.Fragment,{children:[I.length>8&&s.jsx("input",{value:L,onChange:e=>ue(e.target.value),placeholder:`Filter ${I.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}}),s.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"5px"},children:[we.map(e=>{var n,d;const t=q.has(e.definition.name);return s.jsxs("button",{disabled:D,onClick:()=>void ee(e),title:`${((n=o.elements[e.sourceId])==null?void 0:n.name)??e.sourceId} → ${((d=o.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:D?"wait":"pointer",fontWeight:t?600:400},children:[e.definition.name,s.jsx("span",{style:{color:r.faint,marginLeft:"4px"},children:e.direction==="outgoing"?"→":"←"})]},`${e.definition.name}-${e.direction}`)}),we.length===0&&s.jsxs("span",{style:{fontSize:"11px",color:r.faint},children:["No legal type matches ","“",L,"”","."]})]})]}):s.jsx("div",{style:{fontSize:"11px",color:r.faint},children:"Both sides must be individual elements. Expand the subsystems first."})]})]})]})}function Ee(o,f){const v=new Set(o);return v.has(f)?v.delete(f):v.add(f),v}export{it as TraceabilityMatrix};
@@ -0,0 +1 @@
1
+ import{j as n}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";import{u as v,E as Ee,F as We,M as Ke,O as He,Q as je,U as Ce,V as Oe}from"./index-BYfHEpXT.js";import{l as Ge,c as Xe,a as Ie,E as pe,S as Ye,b as qe}from"./ExplorerTreeRow-CX2kYnaJ.js";import{b as se,I as D,T as Ve,c as Je,a as ke}from"./DiagramToolbarControls-XMGLx08e.js";const Qe=(r,s,a=.006)=>s.x>=r.x-a&&s.y>=r.y-a&&s.x+s.width<=r.x+r.width+a&&s.y+s.height<=r.y+r.height+a;function Ze(r){const{data:s,width:a,height:d}=r;if(a<8||d<8||s.length<a*d*4)return[];const u=new Uint8Array(a*d);for(let h=0;h<u.length;h++){const p=h*4;u[h]=Math.round(s[p]*.299+s[p+1]*.587+s[p+2]*.114)}const c=new Uint8Array(a*d);for(let h=1;h<d-1;h++)for(let p=1;p<a-1;p++){const g=h*a+p,j=Math.abs(u[g+1]-u[g-1]),F=Math.abs(u[g+a]-u[g-a]);if(j+F>=42)for(let E=-1;E<=1;E++)for(let k=-1;k<=1;k++)c[g+E*a+k]=1}const m=new Uint8Array(a*d),C=[],$=[];for(let h=0;h<c.length;h++){if(!c[h]||m[h])continue;m[h]=1,$.push(h);let p=a,g=d,j=0,F=0,E=0;for(;$.length;){const V=$.pop(),W=V%a,B=Math.floor(V/a);p=Math.min(p,W),j=Math.max(j,W),g=Math.min(g,B),F=Math.max(F,B),E++;for(let A=-1;A<=1;A++)for(let R=-1;R<=1;R++){if(!R&&!A)continue;const U=W+R,J=B+A;if(U<0||J<0||U>=a||J>=d)continue;const I=J*a+U;c[I]&&!m[I]&&(m[I]=1,$.push(I))}}const k=j-p+1,G=F-g+1,w={x:p/a,y:g/d,width:k/a,height:G/d},X=w.width*w.height;if(w.width<.07||w.height<.035||X<.004||X>.93)continue;const Y=Math.max(1,2*k+2*G),q=Math.max(.45,Math.min(.96,E/Y));C.push({rect:w,confidence:q})}const T=[];for(const h of C.sort((p,g)=>g.confidence-p.confidence||g.rect.width*g.rect.height-p.rect.width*p.rect.height))if(T.some(g=>{const j=Math.abs(g.rect.x-h.rect.x),F=Math.abs(g.rect.y-h.rect.y),E=Math.abs(g.rect.width-h.rect.width),k=Math.abs(g.rect.height-h.rect.height);return j+F+E+k<.035})||T.push(h),T.length>=24)break;const N=T.sort((h,p)=>p.rect.width*p.rect.height-h.rect.width*h.rect.height);return N.map((h,p)=>{let g,j=1/0;for(let F=0;F<N.length;F++){if(F===p||!Qe(N[F].rect,h.rect))continue;const E=N[F].rect.width*N[F].rect.height,k=h.rect.width*h.rect.height;E>k*1.08&&E<j&&(g=F,j=E)}return{bounds:h.rect,confidence:h.confidence,parentIndex:g}})}async function et(r){const s=new Image;s.decoding="async",s.src=r,await s.decode();const a=Math.min(1,640/Math.max(s.naturalWidth,s.naturalHeight)),d=Math.max(1,Math.round(s.naturalWidth*a)),u=Math.max(1,Math.round(s.naturalHeight*a)),c=document.createElement("canvas");c.width=d,c.height=u;const m=c.getContext("2d",{willReadFrequently:!0});return m?(m.drawImage(s,0,0,d,u),Ze(m.getImageData(0,0,d,u))):[]}const De="memo-uiscreens-width",ae=250,ce=200,de=600;function tt(){if(typeof window>"u")return ae;try{const r=Number.parseInt(localStorage.getItem(De)??"",10);return Number.isFinite(r)?Math.min(de,Math.max(ce,r)):ae}catch{return ae}}function nt(r){var d;const s=[],a=[];for(const u of r){const c=(d=u.attributes)==null?void 0:d.elementPackage;if(!c){a.push(u);continue}const m=s.find(C=>C.name===c);m?m.members.push(u):s.push({name:c,members:[u]})}return{groups:s,ungrouped:a}}const Me=r=>({"bounds.x":String(Number(r.x.toFixed(5))),"bounds.y":String(Number(r.y.toFixed(5))),"bounds.width":String(Number(r.width.toFixed(5))),"bounds.height":String(Number(r.height.toFixed(5)))}),rt=(r,s)=>({x:(r.x-s.x)/s.width,y:(r.y-s.y)/s.height,width:r.width/s.width,height:r.height/s.height}),it=r=>r?r.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(r)?r:`/${r}`:"";function ot(r){return new Promise((s,a)=>{const d=new FileReader;d.onerror=()=>a(d.error??new Error("Could not read the image.")),d.onload=()=>{const u=String(d.result),c=new Image;c.onerror=()=>a(new Error("The selected file is not a readable image.")),c.onload=()=>s({base64:u.slice(u.indexOf(",")+1),width:c.naturalWidth,height:c.naturalHeight}),c.src=u},d.readAsDataURL(r)})}function me(r){const s=r.reduce((a,d)=>{const u=[d.id,d.shortId,d.attributes.id].map(c=>/^UIE-(\d+)$/i.exec(c??"")).filter(c=>!!c).map(c=>Number(c[1]));return Math.max(a,...u)},0);return`UIE-${String(s+1).padStart(3,"0")}`}function st(r){const s=r.reduce((a,d)=>{const u=[d.id,d.shortId,d.attributes.id].map(c=>/^UIA-(\d+)$/i.exec(c??"")).filter(c=>!!c).map(c=>Number(c[1]));return Math.max(a,...u)},0);return`UIA-${String(s+1).padStart(3,"0")}`}function ge(r,s,a){var C;const d=((C=r.match(/(\d+)$/))==null?void 0:C[1])??"1",u=`${s}${Number(d)}`,c=new Set(a.map($=>$.id));if(!c.has(u))return u;let m=2;for(;c.has(`${u}_${m}`);)m++;return`${u}_${m}`}function Ae(r,s){const a=s.find(c=>c.id===r.id);if(a)return a;const d=s.find(c=>{var m,C;return(((m=c.attributes)==null?void 0:m.providedId)??((C=c.attributes)==null?void 0:C.id)??c.shortId)===r.id});if(d)return d;const u=r.name.toLowerCase().replace(/region layout|screen layout|[^a-z0-9]/g,"");return s.find(c=>{const m=c.name.toLowerCase().replace(/[^a-z0-9]/g,"");return m.length>0&&(u.includes(m)||m.includes(u))})}async function fe(r,s){var d;const a=Date.now()+1e4;for(;Date.now()<a;){const u=(d=v.getState().model)==null?void 0:d.elements[r];if(u&&u!==s)return;await new Promise(c=>setTimeout(c,100))}throw new Error("The new element was saved, but the rebuilt model did not arrive.")}async function at(r,s,a){var u;const d=Date.now()+1e4;for(;Date.now()<d;){if((u=v.getState().model)==null?void 0:u.relationships.find(m=>m.type.toLowerCase()===r.toLowerCase()&&m.sourceId===s&&m.targetId===a))return!0;await new Promise(m=>setTimeout(m,100))}return!1}const ct=(r,s,a)=>{var d;return!!((d=v.getState().model)!=null&&d.relationships.some(u=>u.type.toLowerCase()===r.toLowerCase()&&u.sourceId===s&&u.targetId===a))};function mt(){const r=v(e=>e.model),s=v(e=>e.createModelElement),a=v(e=>e.persistElementAttributes),d=v(e=>e.createRelationship),u=v(e=>e.createDiagram),c=v(e=>e.inspectElement),m=v(e=>e.selectedElementId),C=v(e=>e.deleteModelElement),$=v(e=>e.createPackage),T=v(e=>e.moveElementToPackage),[N,h]=f.useState(),[p,g]=f.useState(),[j,F]=f.useState(!1),[E,k]=f.useState(""),[G,w]=f.useState(""),[X,Y]=f.useState(!1),[q,V]=f.useState("NewUIScreen"),[W,B]=f.useState(!1),[A,R]=f.useState([]),[U,J]=f.useState(new Set),[I,Ne]=f.useState(tt),K=f.useRef(null),_=f.useCallback(e=>{Ne(Math.max(ce,Math.min(de,e)))},[]),ee=f.useCallback(()=>{var e;(e=K.current)==null||e.call(K),K.current=null},[]),Ue=f.useCallback(e=>{if(e.button!==0)return;e.preventDefault(),ee();const t=e.clientX,i=I,o=document.body.style.cursor,l=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const x=y=>{_(i+y.clientX-t)},b=()=>{window.removeEventListener("pointermove",x),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),document.body.style.cursor=o,document.body.style.userSelect=l,K.current=null};K.current=b,window.addEventListener("pointermove",x),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",b)},[_,I,ee]);f.useEffect(()=>{try{localStorage.setItem(De,String(Math.round(I)))}catch{}},[I]),f.useEffect(()=>()=>ee(),[ee]);const te=f.useRef(new Map),le=f.useRef(null),H=f.useMemo(()=>((r==null?void 0:r.diagrams)??[]).filter(e=>e.viewKind==="geometry"),[r]),O=f.useMemo(()=>r?Ge(r):[],[r]),ne=f.useMemo(()=>r?Object.values(r.elements).filter(e=>{var t;return e.kind==="UIElement"&&((t=e.attributes.formKind)==null?void 0:t.endsWith("screen"))}):[],[r]),z=f.useMemo(()=>H.find(e=>e.id===N),[H,N]),re=f.useMemo(()=>z?Ae(z,ne):void 0,[z,ne]),ie=f.useMemo(()=>{const e=new Map;for(const t of(r==null?void 0:r.relationships)??[])t.type.toLowerCase()==="capturesscreen"&&e.set(t.sourceId,t.targetId);return e},[r]),Q=f.useMemo(()=>re?O.filter(e=>ie.get(e.id)===re.id):[],[ie,O,re]);if(f.useEffect(()=>{var e;H.some(t=>t.id===N)||h((e=H[0])==null?void 0:e.id)},[H,N]),f.useEffect(()=>{var e;Q.some(t=>t.id===p)||g(((e=Q[0])==null?void 0:e.id)??"__none__")},[p,Q]),f.useEffect(()=>{R([]),te.current.clear()},[p]),!r)return null;const Z=Xe(r,{captureId:p}),L=Object.values(r.elements).filter(e=>e.kind==="UIElement"),S=re??Z.screen,Be=new Map(L.map(e=>[e.id,e])),P=new Map;for(const e of r.relationships){if(e.type.toLowerCase()!=="composes")continue;const t=Be.get(e.targetId);t&&P.set(e.sourceId,[...P.get(e.sourceId)??[],t])}const xe=(e,t,i)=>{h(e);const o=t&&i?qe(r,t.id,i.id):t?Ie(r,t.id):void 0;o&&g(o.id),i&&c(i.id)},ue=e=>J(t=>{const i=new Set(t);return i.has(e)?i.delete(e):i.add(e),i}),be=async e=>{const t=await e;t.success||window.alert(t.error??"The package could not be written.")},Re=async e=>{const t=Ce(r,e),i=window.prompt(t?`Name the group inside ${t.split("::").pop()}`:"Name the group");if(!(i!=null&&i.trim()))return;const o=await $(i.trim(),t);if(!o.success){window.alert(o.error??"The package could not be created.");return}const l=`${t}::${i.trim()}`;await Oe(l),await be(T(e.id,l))},$e=async e=>{var l;const t=Ce(r,e),i=je(r,e),o=window.prompt(i.length?`Move into which group? (${i.join(", ")})`:"Move into which group?",((l=e.attributes)==null?void 0:l.elementPackage)??i[0]??"");o!=null&&o.trim()&&await be(T(e.id,`${t}::${o.trim()}`))},ze=e=>[{label:"Group in new package…",onSelect:()=>{Re(e)}},...je(r,e).length>0?[{label:"Move into group…",onSelect:()=>{$e(e)}}]:[]],we=(e,t,i,o)=>{const{groups:l,ungrouped:x}=nt(e),b=x.map(y=>ye(y,t,i,o));return n.jsxs(n.Fragment,{children:[l.map(y=>{const M=`group:${i.id}:${y.name}`;return n.jsxs("div",{role:"none",children:[n.jsx(pe,{id:M,label:y.name,depth:o,hasChildren:!0,expanded:U.has(M),selected:!1,badge:"PKG",badgeColor:"#6B7280",count:y.members.length,title:`Grouping package — ${y.members.length} UI elements. The package groups; the screen still owns them.`,onClick:()=>ue(M)}),U.has(M)&&n.jsx("div",{role:"group",children:y.members.map(oe=>ye(oe,t,i,o+1))})]},M)}),b]})},ye=(e,t,i,o)=>n.jsxs("div",{role:"none",children:[n.jsx(pe,{id:`element:${e.id}`,label:n.jsx(Ee,{element:e}),depth:o,hasChildren:(P.get(e.id)??[]).length>0,expanded:U.has(`element:${e.id}`),selected:e.id===m,badge:"UIE",badgeColor:"#0F766E",count:(P.get(e.id)??[]).length||void 0,title:`${e.name} · ${e.attributes.formKind??"UIElement"}`,onClick:()=>{(P.get(e.id)??[]).length&&ue(`element:${e.id}`),xe(t,i,e)},onDelete:()=>C(e.id),actions:ze(e)}),U.has(`element:${e.id}`)&&we(P.get(e.id)??[],t,i,o+1)]},e.id),he=async(e,t,i)=>{let o="";for(let l=0;l<3;l++){if(ct(e,t,i))return;const x=await d({type:e,sourceId:t,targetId:i,direction:"outgoing",selectedElementId:t});if(x.success&&await at(e,t,i))return;o=x.success?"The relationship was written but did not appear in the rebuilt model.":x.error??"The relationship could not be created.",await new Promise(b=>setTimeout(b,250*(l+1)))}throw new Error(o||`Could not connect ${i} beneath ${t}.`)},Fe=async()=>{var t,i,o;const e=q.trim();if(e){w("Creating UI screen…");try{const l=me(L),x=ge(l,"uiElement",L),b=s({id:x,name:e,kind:"UIElement",construct:"part",layer:"implementation",file:"model/generated.sysml",doc:"",attributes:{id:l,description:`Root user-interface screen ${e}.`,formKind:"UIElementFormKind::screen",disclosureKind:"UIDisclosureKind::inline",detectionMethod:"BoundsDetectionKind::manual","bounds.x":"0","bounds.y":"0","bounds.width":"1","bounds.height":"1"}});await fe(b,(t=v.getState().model)==null?void 0:t.elements[b]);const y=((o=(i=r.viewpoints)==null?void 0:i.find(M=>M.label.toLowerCase().includes("ui layout")))==null?void 0:o.id)??"__model";u({id:l,name:`${e} — Region Layout`,diagramType:"bdd",viewKind:"geometry",viewpointId:y,elementIds:[x],activate:!1}),h(l),g("__none__"),c(x),Y(!1),V("NewUIScreen"),w("UI screen created. Choose a capture asset or upload one.")}catch(l){w(l instanceof Error?l.message:String(l))}}},Te=async e=>{if(!S)return w("Create or select a UI screen first.");const t=ie.get(e.id);if(t&&t!==S.id){const i=Object.values(r.elements).find(o=>o.id===t);return w(`“${e.name}” already depicts ${(i==null?void 0:i.name)??t}; duplicate the asset before reassigning it.`)}try{t||await he("CapturesScreen",e.id,S.id),g(e.id),B(!1),w(`Using capture asset “${e.name}”.`)}catch(i){w(i instanceof Error?i.message:String(i))}},Se=async(e,t={})=>{var i,o;if(!S){w("Add or capture a screen before drawing regions.");return}w("Saving region…");try{const l=me(L),x=ge(l,"uiElement",L);return s({id:x,name:((i=t.name)==null?void 0:i.trim())||`Region ${l}`,kind:"UIElement",construct:"part",layer:S.layer,file:S.file||"model/generated.sysml",doc:"",attributes:{id:l,...Me(e),formKind:"UIElementFormKind::panel",disclosureKind:"UIDisclosureKind::inline",detectionMethod:t.automatic?"BoundsDetectionKind::automaticConfirmed":"BoundsDetectionKind::manual",...t.confidence!==void 0?{detectionConfidence:String(Number(t.confidence.toFixed(3)))}:{},...t.automatic?{confirmedBy:"currentReviewer",confirmedAt:new Date().toISOString()}:{},boundaryColor:"#14B8A6",boundaryOpacity:"0.12"}}),await fe(x,(o=v.getState().model)==null?void 0:o.elements[x]),await he("Composes",t.parentElementId??S.id,x),F(!1),w("Region saved."),x}catch(l){w(l instanceof Error?l.message:String(l));return}},_e=async e=>{var t,i;if(!z||!S)return w("Choose a geometry view with a screen before uploading.");w("Saving capture…");try{const o=await ot(e),l=e.name.toLowerCase().split(".").pop(),x=e.type||(l==="png"?"image/png":l==="webp"?"image/webp":l==="jpg"||l==="jpeg"?"image/jpeg":"");if(!x)throw new Error("Choose a PNG, JPEG, or WebP capture.");const b=await He({viewName:z.name,fileName:e.name,base64:o.base64,mediaType:x});if(!b.success||!b.imageUri||!b.imageHash)throw new Error(b.error||"Capture upload failed.");const y=st(O),M=s({id:ge(y,"uiAsset",O),name:`${S.name} capture`,kind:"ScreenCapture",construct:"part",layer:S.layer,file:S.file||"model/generated.sysml",doc:"",attributes:{id:y,imageUri:b.imageUri,imageHash:b.imageHash,pixelWidth:String(o.width),pixelHeight:String(o.height),capturedBuild:E.trim(),captureContext:z.name}});await fe(M,(t=v.getState().model)==null?void 0:t.elements[M]),await he("CapturesScreen",M,S.id);for(const oe of L)(i=oe.attributes.detectionMethod)!=null&&i.endsWith("automatic")&&a(oe.id,{confirmedBy:"",confirmedAt:""});g(M),w("Capture saved; automatic regions require confirmation.")}catch(o){w(o instanceof Error?o.message:String(o))}},Le=async()=>{if(!Z.imageUri)return w("Attach a screen-capture asset before detecting regions.");w("Detecting nested boundaries…");try{const t=(await et(Z.imageUri)).map((i,o)=>({id:`proposal-${o+1}`,bounds:i.bounds,confidence:i.confidence,parentId:i.parentIndex!==void 0?`proposal-${i.parentIndex+1}`:void 0,status:"pending"}));te.current.clear(),R(t),w(t.length?`${t.length} boundary proposal${t.length===1?"":"s"} found. Accept or reject each box.`:"No strong rectangular boundaries were detected; draw regions manually.")}catch(e){w(e instanceof Error?e.message:String(e))}},ve=async e=>{const t=te.current.get(e);if(t)return t;const i=A.find(b=>b.id===e);if(!i||i.status==="rejected")return;let o,l=i.bounds;if(i.parentId){const b=A.find(y=>y.id===i.parentId);b&&b.status!=="rejected"&&(o=await ve(b.id),o&&(l=rt(i.bounds,b.bounds)))}const x=await Se(l,{parentElementId:o,automatic:!0,confidence:i.confidence});return x&&(te.current.set(e,x),R(b=>b.map(y=>y.id===e?{...y,status:"accepted"}:y))),x},Pe=e=>{const t=new Set([e]);let i=!0;for(;i;){i=!1;for(const o of A)o.parentId&&t.has(o.parentId)&&!t.has(o.id)&&(t.add(o.id),i=!0)}R(o=>o.map(l=>t.has(l.id)?{...l,status:"rejected"}:l)),w(`Rejected ${t.size} proposal${t.size===1?"":"s"}.`)};return n.jsxs("div",{className:"flex flex-1 min-h-0 relative",style:{background:"#F7F7F5"},children:[n.jsxs("aside",{style:{width:I,position:"relative",flexShrink:0,borderRight:"1px solid #E5E5E0",background:"#FFFFFF",padding:"16px 12px",overflowY:"auto"},children:[n.jsxs("div",{className:"flex items-center",style:{margin:"0 8px 4px"},children:[n.jsx("h1",{style:{margin:0,flex:1,color:"#1B3A4B",fontSize:18,fontWeight:700},children:"UI Screens"}),n.jsx(se,{icon:n.jsx(D.plus,{}),ariaLabel:"Add UI element",title:"Create a root UIElement screen",onClick:()=>Y(e=>!e),active:X})]}),n.jsx("p",{style:{margin:"0 8px 16px",color:"#6B7280",fontSize:12},children:"Capture, mark up, and trace screen regions."}),X&&n.jsxs("div",{style:{margin:"0 4px 12px",padding:10,background:"#F7F7F5",border:"1px solid #E5E5E0",borderRadius:8},children:[n.jsx("label",{style:{display:"block",color:"#6B7280",fontSize:10,fontWeight:600,marginBottom:4},children:"UI ELEMENT NAME"}),n.jsx("input",{"aria-label":"New UI screen name",value:q,onChange:e=>V(e.target.value),onKeyDown:e=>{e.key==="Enter"&&Fe()},style:{width:"100%",border:"1px solid #D8D8D2",borderRadius:6,padding:"6px 8px",fontSize:12}}),n.jsxs("div",{className:"flex gap-2",style:{marginTop:8},children:[n.jsx("button",{onClick:()=>void Fe(),disabled:!q.trim(),style:{flex:1,border:0,borderRadius:6,padding:"5px 8px",background:"#1B3A4B",color:"#FFFFFF",fontSize:11,cursor:"pointer"},children:"Create screen"}),n.jsx("button",{onClick:()=>Y(!1),style:{border:"1px solid #D8D8D2",borderRadius:6,padding:"5px 8px",background:"#FFFFFF",color:"#4B5563",fontSize:11,cursor:"pointer"},children:"Cancel"})]})]}),n.jsx("div",{role:"tree","aria-label":"UI screen hierarchy",children:H.map(e=>{const t=Ae(e,ne)??ne.find(l=>{var x;return((x=Ie(r,l.id))==null?void 0:x.attributes.captureContext)===e.name});if(!t)return null;const i=`screen:${t.id}`,o=P.get(t.id)??[];return n.jsxs("div",{role:"none",style:{marginBottom:4},children:[n.jsx(pe,{id:i,label:n.jsx(Ee,{element:t}),depth:0,hasChildren:o.length>0,expanded:U.has(i),selected:t.id===m,badge:"UIE",badgeColor:"#0F766E",title:"Root UIElement screen",onClick:()=>{o.length&&ue(i),xe(e.id,t,t)},onDelete:()=>C(t.id)}),U.has(i)&&n.jsx("div",{role:"group",children:we(o,e.id,t,1)})]},i)})}),n.jsx("div",{className:"memo-explorer-resizer",role:"separator","aria-label":"Resize UI Screens Explorer","aria-orientation":"vertical","aria-valuemin":ce,"aria-valuemax":de,"aria-valuenow":Math.round(I),tabIndex:0,title:"Drag to resize · Double-click to reset",onPointerDown:Ue,onDoubleClick:()=>_(ae),onKeyDown:e=>{e.key==="ArrowLeft"?(e.preventDefault(),_(I-20)):e.key==="ArrowRight"?(e.preventDefault(),_(I+20)):e.key==="Home"?(e.preventDefault(),_(ce)):e.key==="End"&&(e.preventDefault(),_(de))}})]}),n.jsx("main",{className:"flex-1 flex flex-col min-w-0 relative",children:z?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex items-center px-3 py-2",style:{minHeight:48,background:"#F7F7F5",borderBottom:"1px solid #E5E5E0"},children:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg",style:{width:"fit-content",maxWidth:"100%",background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[n.jsx("span",{title:"Choose the independent capture asset used as the canvas backdrop",children:n.jsx(D.capture,{})}),n.jsxs("select",{"aria-label":"Attached screen capture",value:p??"__none__",onChange:e=>g(e.target.value),className:"text-xs font-semibold rounded-lg px-2 py-1",style:{color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB",maxWidth:220},children:[Q.length===0&&n.jsx("option",{value:"__none__",children:"No capture attached"}),Q.map(e=>n.jsx("option",{value:e.id,children:e.name},e.id))]}),n.jsx(se,{icon:n.jsx(D.info,{}),onClick:()=>Z.capture&&c(Z.capture.id),ariaLabel:"Inspect capture asset",title:"Open this ScreenCapture asset in Properties"}),n.jsx(se,{icon:n.jsx(D.library,{}),label:"Assets",active:W,onClick:()=>B(e=>!e),title:"Choose a ScreenCapture from the asset library"}),n.jsx("input",{"aria-label":"New capture asset build",value:E,onChange:e=>k(e.target.value),placeholder:"Asset build",title:"Software build that produced the new capture asset",className:"text-xs rounded-lg px-2 py-1",style:{width:112,color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB"}}),n.jsx(Ve,{children:n.jsx(se,{icon:n.jsx(D.upload,{}),label:"Add capture",onClick:()=>{var e;return(e=le.current)==null?void 0:e.click()},title:"Create a ScreenCapture asset from a PNG, JPEG, or WebP image"})}),n.jsx("input",{ref:le,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,onChange:e=>{var t;return((t=e.target.files)==null?void 0:t[0])&&_e(e.target.files[0])}}),n.jsx(Je,{}),n.jsx(ke,{icon:n.jsx(D.rectangle,{}),label:j?"Cancel drawing":"Add region",active:j,onClick:()=>F(e=>!e),title:"Drag a rectangle, then edit the region in Properties"}),n.jsx(ke,{icon:n.jsx(D.detect,{}),label:"Detect",active:A.some(e=>e.status==="pending"),badge:A.filter(e=>e.status==="pending").length||void 0,onClick:()=>void Le(),title:"Propose nested regions from detected image boundaries"}),G&&n.jsx("span",{role:"status",className:"truncate",style:{marginLeft:"auto",fontSize:We.xs,color:"#6B7280",maxWidth:180},children:G})]})}),p==="__none__"?n.jsx("div",{className:"flex-1 flex items-center justify-center p-8",style:{background:"#F7F7F5"},children:n.jsxs("div",{style:{width:"min(560px, 100%)",padding:28,textAlign:"center",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:14,boxShadow:"0 4px 18px rgba(15,23,42,0.06)"},children:[n.jsx("div",{style:{display:"inline-flex",padding:12,borderRadius:12,background:"#E1F5EE",color:"#0F766E"},children:n.jsx(D.capture,{size:28})}),n.jsxs("h2",{style:{margin:"14px 0 6px",color:"#1B3A4B",fontSize:18,fontWeight:700},children:["Add a visual asset to ",S==null?void 0:S.name]}),n.jsx("p",{style:{margin:"0 auto 18px",maxWidth:430,color:"#6B7280",fontSize:12,lineHeight:1.5},children:"Upload a new screen capture or link an existing ScreenCapture from the asset library. The asset remains independent and is connected through CapturesScreen."}),n.jsxs("div",{className:"flex justify-center gap-2",children:[n.jsxs("button",{onClick:()=>{var e;return(e=le.current)==null?void 0:e.click()},className:"flex items-center gap-2",style:{padding:"8px 13px",border:0,borderRadius:8,background:"#1B3A4B",color:"#FFFFFF",cursor:"pointer",fontSize:12,fontWeight:600},children:[n.jsx(D.upload,{})," Upload screen capture"]}),n.jsxs("button",{onClick:()=>B(!0),className:"flex items-center gap-2",style:{padding:"8px 13px",border:"1px solid #D8D8D2",borderRadius:8,background:"#FFFFFF",color:"#374151",cursor:"pointer",fontSize:12,fontWeight:600},children:[n.jsx(D.library,{})," Choose from asset library"]})]}),n.jsx("p",{style:{margin:"14px 0 0",color:"#9CA3AF",fontSize:10},children:"You can also create the CapturesScreen relationship later in Properties."})]})}):n.jsx(Ye,{diagram:z,model:r,captureId:p,editable:!0,drawMode:j,newElementDefaultName:`Region ${me(L)}`,proposals:A,onAcceptProposal:e=>void ve(e),onRejectProposal:Pe,onCreateBounds:(e,t)=>void Se(e,{name:t}),onBoundsChange:(e,t)=>a(e,Me(t))}),W&&n.jsx("div",{className:"absolute inset-0 flex items-start justify-center",onMouseDown:e=>{e.target===e.currentTarget&&B(!1)},style:{zIndex:50,paddingTop:70,background:"#0F172A33",backdropFilter:"blur(1px)"},children:n.jsxs("div",{role:"dialog","aria-label":"ScreenCapture asset library",style:{width:"min(720px, calc(100% - 40px))",maxHeight:"calc(100% - 100px)",overflowY:"auto",background:"#FFFFFF",border:"1px solid #D1D5DB",borderRadius:12,boxShadow:"0 18px 50px rgba(15,23,42,0.22)"},children:[n.jsxs("div",{className:"flex items-center",style:{position:"sticky",top:0,zIndex:2,padding:"12px 14px",background:"#FFFFFF",borderBottom:"1px solid #E5E5E0"},children:[n.jsxs("div",{style:{flex:1},children:[n.jsx("strong",{style:{color:"#1B3A4B",fontSize:14},children:"ScreenCapture asset library"}),n.jsx("div",{style:{color:"#6B7280",fontSize:10},children:"Choose an unassigned asset or one already linked to this screen."})]}),n.jsx("button",{"aria-label":"Close asset library",onClick:()=>B(!1),style:{width:28,height:28,border:0,borderRadius:6,background:"#F0F0ED",color:"#4B5563",cursor:"pointer"},children:"×"})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(205px, 1fr))",gap:10,padding:12},children:[O.length===0&&n.jsx("div",{style:{gridColumn:"1 / -1",padding:28,textAlign:"center",color:"#9CA3AF",fontSize:12},children:"No capture assets yet. Upload the first capture."}),O.map(e=>{const t=ie.get(e.id),i=t?Object.values(r.elements).find(l=>l.id===t):void 0,o=!t||t===(S==null?void 0:S.id);return n.jsxs("button",{disabled:!o,onClick:()=>void Te(e),style:{display:"block",minWidth:0,padding:0,overflow:"hidden",textAlign:"left",border:`1px solid ${e.id===p?"#2DD4A8":"#E5E5E0"}`,borderRadius:9,background:e.id===p?"#F0FDFA":"#FFFFFF",color:o?"#374151":"#9CA3AF",cursor:o?"pointer":"not-allowed",opacity:o?1:.58},children:[n.jsx("div",{style:{height:118,background:"#F3F4F6",borderBottom:"1px solid #E5E5E0"},children:e.attributes.imageUri?n.jsx("img",{src:it(e.attributes.imageUri),alt:"",style:{width:"100%",height:"100%",objectFit:"contain"}}):n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx(D.capture,{size:28})})}),n.jsxs("div",{style:{padding:"8px 9px"},children:[n.jsx("div",{className:"truncate",style:{fontSize:11,fontWeight:650},children:e.name}),n.jsx("div",{className:"truncate",style:{fontSize:10,marginTop:3},children:i?`Depicts ${i.name}`:"Unassigned asset"}),e.attributes.capturedBuild&&n.jsx("div",{className:"truncate",style:{fontSize:9,color:"#9CA3AF",marginTop:2},children:e.attributes.capturedBuild})]})]},e.id)})]})]})})]}):n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"#6B7280",textAlign:"center"},children:n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:4},children:n.jsx(Ke,{size:190})}),n.jsx("h2",{style:{color:"#374151",fontSize:18},children:"No screen-layout views"}),n.jsx("p",{children:"Add a MemoScreenLayoutView to begin."})]})})})]})}export{mt as UiScreensWorkspace,nt as groupUiChildren,st as nextUiAssetId,me as nextUiElementId,Ae as screenForLayout,ge as usageIdentifier};
@@ -1 +1 @@
1
- import{j as t}from"./reactflow-C9OlmOYw.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-DEVvBtNh.js";const l=[{id:"setup",icon:"🎯",title:"Set Up Your Device",description:"Define who your device is for, what it does, and who uses it. Start with actors and intended use.",standard:"IEC 62366 · ISO 14971 §4",getCount:e=>Object.values(e.elements).filter(s=>["actor","stakeholder","usecase","goal"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="actor").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="usecase").length;return`${s} actor(s) · ${i} use case(s)`}},{id:"requirements",icon:"📋",title:"Define Requirements",description:"Capture user needs and system requirements. These form the basis of your V&V plan.",standard:"IEC 62304 §5.2 · 21 CFR 820.30(c)",getCount:e=>Object.values(e.elements).filter(s=>["systemrequirement","requirement","userneed"].includes(s.kind.toLowerCase())).length,getTarget:()=>5,actionLabel:"View Catalog",actionView:"catalog",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="userneed").length,i=Object.values(e.elements).filter(n=>["systemrequirement","requirement"].includes(n.kind.toLowerCase())).length;return`${s} user need(s) · ${i} system requirement(s)`}},{id:"hazards",icon:"⚠️",title:"Identify Hazards",description:"List all hazards your device could cause. Add hazardous situations and potential harms.",standard:"ISO 14971 §5–6",getCount:e=>Object.values(e.elements).filter(s=>["hazard","hazardoussituation","harm"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Risk Layer",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="hazard").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="harm").length;return`${s} hazard(s) · ${i} harm(s)`}},{id:"risk-controls",icon:"🔗",title:"Connect Risk Chain",description:"Add risk controls and connect them to hazards with Mitigates relationships. Verify the ISO 14971 chain.",standard:"ISO 14971 §7–8",getCount:e=>e.relationships.filter(s=>s.type.toLowerCase()==="mitigates").length,getTarget:()=>2,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="riskcontrol").length,i=e.relationships.filter(n=>n.type.toLowerCase()==="mitigates").length;return`${s} risk control(s) · ${i} mitigates link(s)`}},{id:"architecture",icon:"🏗️",title:"Define Architecture",description:"Add system and subsystem elements. This grounds requirements to real components.",standard:"IEC 62304 §5.3 · ISO 14971 §9",getCount:e=>Object.values(e.elements).filter(s=>["system","subsystem","logicalcomponent","softwarecomponent"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>["system","subsystem"].includes(n.kind.toLowerCase())).length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="softwarecomponent").length;return`${s} system/subsystem · ${i} software component(s)`}},{id:"verification",icon:"🧪",title:"Link Verification",description:"Add tests and link them to requirements. This closes the V&V loop and prepares your design review package.",standard:"IEC 62304 §5.7–5.8 · 21 CFR 820.30(g)",getCount:e=>Object.values(e.elements).filter(s=>s.kind.toLowerCase()==="test").length,getTarget:()=>3,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="test").length,i=e.relationships.filter(n=>["satisfies","refines","traces","verifies"].includes(n.type.toLowerCase())).length;return`${s} test(s) · ${i} traceability link(s)`}}];function m({step:e,index:s,isActive:i,model:n,onSelect:d,onAction:c}){const r=e.getCount(n),o=e.getTarget(),a=r>=o,u=Math.min(100,Math.round(r/o*100)),h=e.getDetails(n),g=a?"#2ECC71":r>0?"#F39C12":"#E5E5E0";return t.jsxs("button",{onClick:d,style:{textAlign:"left",background:i?"#FFFFFF":"transparent",border:`1px solid ${i?"#1B3A4B20":"transparent"}`,borderRadius:"10px",padding:"14px 16px",cursor:"pointer",width:"100%",transition:"all 0.15s",boxShadow:i?"0 2px 8px rgba(0,0,0,0.06)":"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[t.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",flexShrink:0,background:a?"#2ECC71":i?"#1B3A4B":"#F3F4F6",color:a||i?"#FFFFFF":"#6B7280",display:"flex",alignItems:"center",justifyContent:"center",fontSize:a?"14px":"12px",fontWeight:700},children:a?"✓":s+1}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:i?"#1B3A4B":"#374151"},children:[e.icon," ",e.title]}),r>0&&t.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"999px",background:g+"20",color:g},children:r})]}),h&&t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"2px"},children:h})]}),t.jsxs("div",{style:{width:"40px",textAlign:"right",fontSize:"10px",color:"#9CA3AF",flexShrink:0},children:[u,"%"]})]}),t.jsx("div",{style:{marginTop:"8px",height:"3px",background:"#F3F4F6",borderRadius:"2px",marginLeft:"38px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"2px",background:g,width:`${u}%`,transition:"width 0.4s ease"}})})]})}function f({step:e,model:s,onAction:i}){const n=e.getCount(s),d=e.getTarget(),c=n>=d;return t.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"24px"},children:[t.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:e.icon}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:800,color:"#1B3A4B",margin:"0 0 6px 0"},children:e.title}),t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",marginBottom:"12px",fontFamily:"monospace"},children:e.standard}),t.jsx("p",{style:{fontSize:"13px",color:"#4B6E80",lineHeight:"1.7",margin:"0 0 20px 0"},children:e.description}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"8px",background:c?"#2ECC7110":n>0?"#F39C1210":"#F3F4F6",marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"24px",fontWeight:800,color:c?"#2ECC71":n>0?"#F39C12":"#9CA3AF"},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:c?`✓ Target reached (${d}+ recommended)`:`${d-n} more recommended`}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:e.getDetails(s)})]})]}),t.jsxs("button",{onClick:()=>i(e.actionView),style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#1B3A4B",color:"#FFFFFF",border:"none",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:r=>r.currentTarget.style.background="#244D63",onMouseLeave:r=>r.currentTarget.style.background="#1B3A4B",children:[e.actionLabel," →"]})]})}function y({model:e}){const s=l.filter(n=>n.getCount(e)>=n.getTarget()).length,i=Math.round(s/l.length*100);return t.jsxs("div",{style:{padding:"16px 20px",background:"#FFFFFF",borderRadius:"12px",border:"1px solid #E5E5E0",marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Golden Path Progress"}),t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:[s,"/",l.length," steps"]})]}),t.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"3px",background:i>=100?"#2ECC71":"#2DD4A8",width:`${i}%`,transition:"width 0.4s ease"}})})]})}function j(){const e=p(o=>o.model),s=p(o=>o.setActiveView),i=p(o=>o.setExplorerTab),n=x.useMemo(()=>{if(!e)return 0;for(let o=0;o<l.length;o++)if(l[o].getCount(e)<l[o].getTarget())return o;return l.length-1},[e]),[d,c]=x.useState(n);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})});function r(o){switch(o){case"model":i("model"),s({type:"dashboard"});break;case"traceability":s({type:"traceability"});break;case"statistics":s({type:"statistics"});break;case"catalog":i("model"),s({type:"dashboard"});break}}return t.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:t.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Workflow Wizard"}),t.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Follow the golden path to a complete, review-ready device model"})]}),t.jsx("button",{onClick:()=>s({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),t.jsx(y,{model:e}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"380px 1fr",gap:"16px"},children:[t.jsx("div",{style:{background:"#F9FAFB",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"8px",display:"flex",flexDirection:"column",gap:"2px"},children:l.map((o,a)=>t.jsx(m,{step:o,index:a,isActive:a===d,model:e,onSelect:()=>c(a),onAction:r},o.id))}),t.jsx(f,{step:l[d],model:e,onAction:r})]})]})})}export{j as WorkflowWizard};
1
+ import{j as t}from"./reactflow-C9OlmOYw.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-BYfHEpXT.js";const l=[{id:"setup",icon:"🎯",title:"Set Up Your Device",description:"Define who your device is for, what it does, and who uses it. Start with actors and intended use.",standard:"IEC 62366 · ISO 14971 §4",getCount:e=>Object.values(e.elements).filter(s=>["actor","stakeholder","usecase","goal"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="actor").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="usecase").length;return`${s} actor(s) · ${i} use case(s)`}},{id:"requirements",icon:"📋",title:"Define Requirements",description:"Capture user needs and system requirements. These form the basis of your V&V plan.",standard:"IEC 62304 §5.2 · 21 CFR 820.30(c)",getCount:e=>Object.values(e.elements).filter(s=>["systemrequirement","requirement","userneed"].includes(s.kind.toLowerCase())).length,getTarget:()=>5,actionLabel:"View Catalog",actionView:"catalog",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="userneed").length,i=Object.values(e.elements).filter(n=>["systemrequirement","requirement"].includes(n.kind.toLowerCase())).length;return`${s} user need(s) · ${i} system requirement(s)`}},{id:"hazards",icon:"⚠️",title:"Identify Hazards",description:"List all hazards your device could cause. Add hazardous situations and potential harms.",standard:"ISO 14971 §5–6",getCount:e=>Object.values(e.elements).filter(s=>["hazard","hazardoussituation","harm"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Risk Layer",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="hazard").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="harm").length;return`${s} hazard(s) · ${i} harm(s)`}},{id:"risk-controls",icon:"🔗",title:"Connect Risk Chain",description:"Add risk controls and connect them to hazards with Mitigates relationships. Verify the ISO 14971 chain.",standard:"ISO 14971 §7–8",getCount:e=>e.relationships.filter(s=>s.type.toLowerCase()==="mitigates").length,getTarget:()=>2,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="riskcontrol").length,i=e.relationships.filter(n=>n.type.toLowerCase()==="mitigates").length;return`${s} risk control(s) · ${i} mitigates link(s)`}},{id:"architecture",icon:"🏗️",title:"Define Architecture",description:"Add system and subsystem elements. This grounds requirements to real components.",standard:"IEC 62304 §5.3 · ISO 14971 §9",getCount:e=>Object.values(e.elements).filter(s=>["system","subsystem","logicalcomponent","softwarecomponent"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>["system","subsystem"].includes(n.kind.toLowerCase())).length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="softwarecomponent").length;return`${s} system/subsystem · ${i} software component(s)`}},{id:"verification",icon:"🧪",title:"Link Verification",description:"Add tests and link them to requirements. This closes the V&V loop and prepares your design review package.",standard:"IEC 62304 §5.7–5.8 · 21 CFR 820.30(g)",getCount:e=>Object.values(e.elements).filter(s=>s.kind.toLowerCase()==="test").length,getTarget:()=>3,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="test").length,i=e.relationships.filter(n=>["satisfies","refines","traces","verifies"].includes(n.type.toLowerCase())).length;return`${s} test(s) · ${i} traceability link(s)`}}];function m({step:e,index:s,isActive:i,model:n,onSelect:d,onAction:c}){const r=e.getCount(n),o=e.getTarget(),a=r>=o,u=Math.min(100,Math.round(r/o*100)),h=e.getDetails(n),g=a?"#2ECC71":r>0?"#F39C12":"#E5E5E0";return t.jsxs("button",{onClick:d,style:{textAlign:"left",background:i?"#FFFFFF":"transparent",border:`1px solid ${i?"#1B3A4B20":"transparent"}`,borderRadius:"10px",padding:"14px 16px",cursor:"pointer",width:"100%",transition:"all 0.15s",boxShadow:i?"0 2px 8px rgba(0,0,0,0.06)":"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[t.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",flexShrink:0,background:a?"#2ECC71":i?"#1B3A4B":"#F3F4F6",color:a||i?"#FFFFFF":"#6B7280",display:"flex",alignItems:"center",justifyContent:"center",fontSize:a?"14px":"12px",fontWeight:700},children:a?"✓":s+1}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:i?"#1B3A4B":"#374151"},children:[e.icon," ",e.title]}),r>0&&t.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"999px",background:g+"20",color:g},children:r})]}),h&&t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"2px"},children:h})]}),t.jsxs("div",{style:{width:"40px",textAlign:"right",fontSize:"10px",color:"#9CA3AF",flexShrink:0},children:[u,"%"]})]}),t.jsx("div",{style:{marginTop:"8px",height:"3px",background:"#F3F4F6",borderRadius:"2px",marginLeft:"38px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"2px",background:g,width:`${u}%`,transition:"width 0.4s ease"}})})]})}function f({step:e,model:s,onAction:i}){const n=e.getCount(s),d=e.getTarget(),c=n>=d;return t.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"24px"},children:[t.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:e.icon}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:800,color:"#1B3A4B",margin:"0 0 6px 0"},children:e.title}),t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",marginBottom:"12px",fontFamily:"monospace"},children:e.standard}),t.jsx("p",{style:{fontSize:"13px",color:"#4B6E80",lineHeight:"1.7",margin:"0 0 20px 0"},children:e.description}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"8px",background:c?"#2ECC7110":n>0?"#F39C1210":"#F3F4F6",marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"24px",fontWeight:800,color:c?"#2ECC71":n>0?"#F39C12":"#9CA3AF"},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:c?`✓ Target reached (${d}+ recommended)`:`${d-n} more recommended`}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:e.getDetails(s)})]})]}),t.jsxs("button",{onClick:()=>i(e.actionView),style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#1B3A4B",color:"#FFFFFF",border:"none",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:r=>r.currentTarget.style.background="#244D63",onMouseLeave:r=>r.currentTarget.style.background="#1B3A4B",children:[e.actionLabel," →"]})]})}function y({model:e}){const s=l.filter(n=>n.getCount(e)>=n.getTarget()).length,i=Math.round(s/l.length*100);return t.jsxs("div",{style:{padding:"16px 20px",background:"#FFFFFF",borderRadius:"12px",border:"1px solid #E5E5E0",marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Golden Path Progress"}),t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:[s,"/",l.length," steps"]})]}),t.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"3px",background:i>=100?"#2ECC71":"#2DD4A8",width:`${i}%`,transition:"width 0.4s ease"}})})]})}function j(){const e=p(o=>o.model),s=p(o=>o.setActiveView),i=p(o=>o.setExplorerTab),n=x.useMemo(()=>{if(!e)return 0;for(let o=0;o<l.length;o++)if(l[o].getCount(e)<l[o].getTarget())return o;return l.length-1},[e]),[d,c]=x.useState(n);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})});function r(o){switch(o){case"model":i("model"),s({type:"dashboard"});break;case"traceability":s({type:"traceability"});break;case"statistics":s({type:"statistics"});break;case"catalog":i("model"),s({type:"dashboard"});break}}return t.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:t.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Workflow Wizard"}),t.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Follow the golden path to a complete, review-ready device model"})]}),t.jsx("button",{onClick:()=>s({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),t.jsx(y,{model:e}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"380px 1fr",gap:"16px"},children:[t.jsx("div",{style:{background:"#F9FAFB",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"8px",display:"flex",flexDirection:"column",gap:"2px"},children:l.map((o,a)=>t.jsx(m,{step:o,index:a,isActive:a===d,model:e,onSelect:()=>c(a),onAction:r},o.id))}),t.jsx(f,{step:l[d],model:e,onAction:r})]})]})})}export{j as WorkflowWizard};