@memoarchitect/architect 0.8.26 → 0.8.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/{AiWorkspace-Z3BbnmaP.js → AiWorkspace-Dp5oBDww.js} +1 -1
- package/dist/assets/{AnalysisWorkspace-DjaUOo7U.js → AnalysisWorkspace-CNHTkSRD.js} +1 -1
- package/dist/assets/{ComplianceWizard-DKxZ1z25.js → ComplianceWizard-CAJDtLdv.js} +1 -1
- package/dist/assets/{DSMView-DJhmrXYm.js → DSMView-Bv9j1Vk_.js} +1 -1
- package/dist/assets/{Dashboard-CYT7KjqU.js → Dashboard-BnOwnA1R.js} +1 -1
- package/dist/assets/{DhfDashboard-DacdOtkU.js → DhfDashboard-CQpiYHtW.js} +1 -1
- package/dist/assets/{DhfWorkbench-CIhopT8J.js → DhfWorkbench-DHxWuiiL.js} +3 -3
- package/dist/assets/{DiagramCanvas-CLE_nv7Y.js → DiagramCanvas-DtLlTvJf.js} +3 -3
- package/dist/assets/{DiagramEditor-puQuE8gB.js → DiagramEditor-DP_PiI7K.js} +2 -2
- package/dist/assets/{ElementDetailView-D5XvAL_i.js → ElementDetailView-BQsWfbPD.js} +1 -1
- package/dist/assets/{ExplorerTreeRow-DUmcEsqf.js → ExplorerTreeRow-CmGPHRI8.js} +1 -1
- package/dist/assets/{ImportView-9y1nhQS4.js → ImportView-YFBlvgF_.js} +1 -1
- package/dist/assets/{LayerGrid-bhFpOIbe.js → LayerGrid-KXyuibWY.js} +1 -1
- package/dist/assets/{LayerTable-RuswZVUI.js → LayerTable-CGsFJsKs.js} +1 -1
- package/dist/assets/{MaxGraphCanvas-D3BXQK2y.js → MaxGraphCanvas-BNn0Jxr6.js} +1 -1
- package/dist/assets/{ModelDiff-Cl2dhlk3.js → ModelDiff-CJCXuz_h.js} +1 -1
- package/dist/assets/{OntologyDecompositionDiagram-aONGngg4.js → OntologyDecompositionDiagram-5JWUI_PB.js} +1 -1
- package/dist/assets/{OntologyViewer-VOrKTRuQ.js → OntologyViewer-DxIWCcJM.js} +2 -2
- package/dist/assets/{ReviewDashboard--LMXZ3F4.js → ReviewDashboard-Qyj8RRFp.js} +1 -1
- package/dist/assets/{ScenarioEditor-bB4iBbgO.js → ScenarioEditor-BIAh6tLX.js} +1 -1
- package/dist/assets/{StatisticsDashboard-iXimfU20.js → StatisticsDashboard-CtI1hlfO.js} +1 -1
- package/dist/assets/{TabularView-DnIfq-TB.js → TabularView-DXxpRshk.js} +1 -1
- package/dist/assets/{TraceabilityMatrix-eilGn6Sr.js → TraceabilityMatrix-qEKmDy8z.js} +1 -1
- package/dist/assets/{UiScreensWorkspace-Cs1ivqzc.js → UiScreensWorkspace-BHhs5tcY.js} +1 -1
- package/dist/assets/{WorkflowWizard-C7jI6C59.js → WorkflowWizard-BjtGPRsS.js} +1 -1
- package/dist/assets/index-Cdkjp-H4.css +1 -0
- package/dist/assets/{index-CG-gfw-s.js → index-a2rpMs5Y.js} +70 -70
- package/dist/assets/{index.es-DABt8CUc.js → index.es-BwDQ0kmQ.js} +1 -1
- package/dist/assets/{jspdf.es.min-G-Vwo9yG.js → jspdf.es.min-KfOikWO5.js} +3 -3
- package/dist/assets/{notation-scene-DLZms6VR.js → notation-scene-CxT28i2i.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-standalone/index.html +183 -183
- package/lib/bin/memo-architect.js +15 -6
- package/lib/bin/memo-architect.js.map +1 -1
- package/package.json +3 -3
- package/dist/assets/index-DXB4CKwW.css +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{u as v,q as L,t as _,v as G,w as U}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{u as v,q as L,t as _,v as G,w as U}from"./index-a2rpMs5Y.js";import{a}from"./zustand-CrhqMOHB.js";const V={env:"an environment variable","env-file":"the project .env file","project-settings":"project settings","user-credentials":"your saved credentials",default:"the default"},Y={anthropic:"claude-opus-5",openai:"gpt-4o"};function Q({onClose:t}){const r=v(n=>n.llmSettings),f=v(n=>n.registerLlmRequest),[s,p]=a.useState((r==null?void 0:r.provider)??"anthropic"),[u,d]=a.useState((r==null?void 0:r.model)??""),[x,l]=a.useState(""),[y,S]=a.useState(!1),[b,j]=a.useState(null),k=a.useCallback(async()=>{S(!0),j(null);const n=`llmset-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((c,m)=>{f(n,c,m),L(n,{provider:s,model:u.trim()||void 0,...x?{apiKey:x}:{}}),setTimeout(()=>m(new Error("The save timed out.")),2e4)}),l(""),j("Saved.")}catch(c){j((c==null?void 0:c.message)??"The settings could not be saved.")}finally{S(!1)}},[s,u,x,f]),C=a.useCallback(async()=>{S(!0),j(null);const n=`llmclear-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((c,m)=>{f(n,c,m),L(n,{provider:s,apiKey:""}),setTimeout(()=>m(new Error("The request timed out.")),2e4)}),j("Key removed.")}catch(c){j((c==null?void 0:c.message)??"The key could not be removed.")}finally{S(!1)}},[s,f]),w={fontSize:"11px",fontWeight:600,color:"#374151",display:"block",marginBottom:"4px"},E={width:"100%",padding:"6px 10px",border:"1px solid #E5E5E0",borderRadius:"6px",fontSize:"12px",outline:"none",background:"#fff",color:"#1B3A4B",fontFamily:"inherit"};return e.jsxs("div",{style:{padding:"14px 20px",background:"#fff",borderBottom:"1px solid #E5E5E0",display:"flex",flexDirection:"column",gap:"12px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{flex:1,fontSize:"12px",fontWeight:700,color:"#1B3A4B"},children:"LLM settings"}),e.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"#9CA3AF",fontSize:"14px",cursor:"pointer"},children:"✕"})]}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsxs("div",{style:{flex:"0 0 130px"},children:[e.jsx("label",{style:w,children:"Provider"}),e.jsxs("select",{value:s,onChange:n=>p(n.target.value),style:{...E,cursor:"pointer"},children:[e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:w,children:"Model"}),e.jsx("input",{value:u,onChange:n=>d(n.target.value),placeholder:Y[s]??"",style:E})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:w,children:"API key"}),r&&!r.keyEditable&&r.configured?e.jsxs("div",{style:{fontSize:"11px",color:"#6B7280",lineHeight:1.6},children:["A key is already supplied by ",V[r.keyOrigin??"default"],", which takes precedence over anything saved here. Remove it there to set a key from this screen."]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:x,onChange:n=>l(n.target.value),placeholder:r!=null&&r.configured?"Saved — type a new key to replace it":"sk-…",autoComplete:"off",style:E}),e.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginTop:"4px",lineHeight:1.5},children:["Stored in ",e.jsx("code",{children:"~/.memo/credentials.json"})," with owner-only permissions — outside this project, so it is never committed. You can also set"," ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the environment or a project ",e.jsx("code",{children:".env"}),"."]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:k,disabled:y,style:{padding:"6px 14px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:y?"default":"pointer",opacity:y?.5:1},children:y?"Saving…":"Save"}),(r==null?void 0:r.configured)&&r.keyEditable&&e.jsx("button",{onClick:C,disabled:y,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #E5E5E0",background:"transparent",color:"#dc2626",fontSize:"11px",cursor:"pointer"},children:"Remove saved key"}),b&&e.jsx("span",{style:{fontSize:"11px",color:"#6B7280"},children:b})]})]})}const X=["What hazards have no risk controls?","Show trace from requirements to verification.","Which layers have the most gaps?","How many unmitigated hazards are there?","List all SOUP components."],J=12e4;function Z(){const t=v(o=>o.llmAvailable),r=v(o=>o.llmProvider),f=v(o=>o.llmModel),s=v(o=>o.model),p=v(o=>o.registerLlmRequest),[u,d]=a.useState([]),[x,l]=a.useState([]),[y,S]=a.useState(""),[b,j]=a.useState(!1),[k,C]=a.useState(!1),[w,E]=a.useState(!1),[n,c]=a.useState(!1),[m,B]=a.useState(new Set),[D,F]=a.useState(null),M=a.useRef(null),W=a.useRef(null);a.useEffect(()=>{var o;(o=M.current)==null||o.scrollIntoView({behavior:"smooth"})},[u,b]);const I=a.useCallback((o,h)=>new Promise((g,i)=>{p(o,g,i),h(),setTimeout(()=>i(new Error("The request timed out after 2 minutes.")),J)}),[p]),T=a.useCallback(async o=>{if(!o.trim()||b)return;const h=o.trim();S(""),d(i=>[...i,{role:"user",content:h}]),j(!0),F(null);const g=`chat-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const i=await I(g,()=>_(g,h,x,k));l(i.messages),d(A=>[...A,{role:"assistant",content:i.truncated?`${i.answer}
|
|
2
2
|
|
|
3
3
|
_(Stopped at the tool-call limit for one turn — ask again to continue.)_`:i.answer,changes:i.proposedChanges.length?i.proposedChanges:void 0}]),i.proposedChanges.length&&B(A=>{const z=new Set(A);for(const R of i.proposedChanges)z.add(R.id);return z})}catch(i){d(A=>[...A,{role:"assistant",content:(i==null?void 0:i.message)??"Unknown error",error:!0}])}finally{j(!1)}},[b,x,k,I]),P=o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),T(y))},q=o=>{B(h=>{const g=new Set(h);return g.has(o)?g.delete(o):g.add(o),g})},O=a.useCallback(async o=>{const h=o.filter(i=>m.has(i.id));if(h.length===0||n)return;c(!0),F(null);const g=`apply-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const i=await I(g,()=>G(g,h)),A=new Set(i.applied);d(z=>z.map(R=>R.changes?{...R,changes:R.changes.filter(N=>!A.has(N.id))}:R)),F(i.failed.length?`Applied ${i.applied.length}. Failed: ${i.failed.map(z=>z.error).join("; ")}`:`Applied ${i.applied.length} change${i.applied.length===1?"":"s"} to the model source.`)}catch(i){F((i==null?void 0:i.message)??"The changes could not be applied.")}finally{c(!1)}},[m,n,I]),K=o=>{const h=new Set(o.map(g=>g.id));d(g=>g.map(i=>i.changes?{...i,changes:i.changes.filter(A=>!h.has(A.id))}:i))},H=()=>{d([]),l([]),B(new Set),F(null)};return s?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"14px 20px 10px",borderBottom:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:"✦"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"Model Assistant"}),e.jsx("div",{style:{fontSize:"11px",color:t?"#059669":"#dc2626",marginTop:"1px"},children:t?`${r??"LLM"} · ${f??"unknown model"}`:"No API key configured"})]}),e.jsx("button",{onClick:()=>E(o=>!o),title:"LLM settings",style:{background:w?"#F3F4F6":"none",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",color:"#374151",cursor:"pointer"},children:"⚙ Settings"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px",fontSize:"11px",color:"#6B7280",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:k,onChange:o=>C(o.target.checked),style:{cursor:"pointer"}}),"Suggest edits — the assistant may propose model changes for your approval"]})]}),w&&e.jsx(Q,{onClose:()=>E(!1)}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:"12px"},children:[u.length===0&&e.jsxs("div",{style:{paddingTop:"8px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",marginBottom:"12px"},children:"Ask about your model in plain English. The assistant can look up any element, follow traceability chains, and read validation gaps."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:X.map(o=>e.jsx("button",{onClick:()=>T(o),disabled:!t||b,style:{textAlign:"left",padding:"8px 12px",borderRadius:"8px",background:"#fff",border:"1px solid #E5E5E0",fontSize:"12px",color:"#374151",cursor:"pointer",transition:"border-color 0.1s",opacity:t?1:.5},onMouseEnter:h=>{t&&(h.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:h=>{h.currentTarget.style.borderColor="#E5E5E0"},children:o},o))})]}),u.map((o,h)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:o.role==="user"?"row-reverse":"row",gap:"8px",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:o.role==="user"?"#1B3A4B":"#2DD4A815",fontSize:"10px",fontWeight:700,color:o.role==="user"?"#fff":"#2DD4A8",marginTop:"2px"},children:o.role==="user"?"U":"✦"}),e.jsx("div",{style:{maxWidth:"85%",padding:"10px 12px",borderRadius:"10px",background:o.role==="user"?"#1B3A4B":o.error?"#fef2f2":"#fff",color:o.role==="user"?"#fff":o.error?"#dc2626":"#1B3A4B",fontSize:"13px",lineHeight:"1.6",border:o.role==="assistant"?`1px solid ${o.error?"#fecaca":"#E5E5E0"}`:"none",whiteSpace:"pre-wrap"},children:o.content})]}),o.changes&&o.changes.length>0&&e.jsx(ee,{changes:o.changes,approved:m,onToggle:q,onApply:()=>O(o.changes),onDiscard:()=>K(o.changes),applying:n})]},h)),D&&e.jsx("div",{style:{fontSize:"11px",color:"#374151",background:"#fff",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"8px 12px"},children:D}),b&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",background:"#2DD4A815",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#2DD4A8",fontWeight:700},children:"✦"}),e.jsx("div",{style:{padding:"10px 14px",borderRadius:"10px",background:"#fff",border:"1px solid #E5E5E0",display:"flex",gap:"4px",alignItems:"center"},children:e.jsx(ne,{})})]}),e.jsx("div",{ref:M})]}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("textarea",{ref:W,value:y,onChange:o=>S(o.target.value),onKeyDown:P,disabled:!t||b,placeholder:t?"Ask a question… (Enter to send, Shift+Enter for newline)":"Add an API key in Settings to start",rows:2,style:{flex:1,padding:"8px 12px",border:"1px solid #E5E5E0",borderRadius:"8px",fontSize:"13px",resize:"none",fontFamily:"inherit",outline:"none",background:"#F7F7F5",color:"#1B3A4B",lineHeight:"1.5",opacity:t?1:.5},onFocus:o=>{o.target.style.borderColor="#2DD4A8"},onBlur:o=>{o.target.style.borderColor="#E5E5E0"}}),e.jsx("button",{onClick:()=>T(y),disabled:!t||b||!y.trim(),style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",flexShrink:0,opacity:!t||!y.trim()?.4:1,transition:"opacity 0.15s"},children:"Send"})]}),u.length>0&&e.jsx("button",{onClick:H,style:{marginTop:"6px",background:"none",border:"none",color:"#9CA3AF",fontSize:"11px",cursor:"pointer",padding:0},children:"Clear conversation"})]})]}):e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data…"})}function ee({changes:t,approved:r,onToggle:f,onApply:s,onDiscard:p,applying:u}){const d=t.filter(x=>r.has(x.id)).length;return e.jsxs("div",{style:{marginLeft:"32px",border:"1px solid #FCD34D",borderRadius:"10px",background:"#FFFBEB",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #FDE68A",fontSize:"11px",fontWeight:700,color:"#92400E"},children:[t.length," proposed change",t.length===1?"":"s"," — nothing is written until you apply"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.map(x=>e.jsxs("label",{style:{display:"flex",gap:"8px",alignItems:"flex-start",padding:"8px 12px",borderBottom:"1px solid #FDE68A",cursor:"pointer",fontSize:"12px"},children:[e.jsx("input",{type:"checkbox",checked:r.has(x.id),onChange:()=>f(x.id),style:{marginTop:"2px",cursor:"pointer"}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:"#1B3A4B"},children:te(x)}),e.jsx("div",{style:{color:"#92400E",marginTop:"2px"},children:x.summary}),e.jsx(oe,{change:x})]})]},x.id))}),e.jsxs("div",{style:{padding:"8px 12px",display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:s,disabled:d===0||u,style:{padding:"6px 12px",borderRadius:"6px",border:"none",background:"#92400E",color:"#fff",fontSize:"11px",fontWeight:600,cursor:d===0||u?"default":"pointer",opacity:d===0||u?.4:1},children:u?"Applying…":`Apply ${d} selected`}),e.jsx("button",{onClick:p,disabled:u,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #FDE68A",background:"transparent",color:"#92400E",fontSize:"11px",cursor:"pointer"},children:"Discard all"})]})]})}function te(t){switch(t.kind){case"create-element":return`Create ${t.elementKind} · ${t.elementId}`;case"update-element":return`Update · ${t.elementId}`;case"create-relationship":return`Relate · ${t.sourceId} → ${t.targetId}`;case"delete-relationship":return`Remove relationship · ${t.relationshipId}`}}function oe({change:t}){const r={fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11px",color:"#374151",marginTop:"4px"};if(t.kind==="create-element"){const f=Object.entries(t.attributes??{});return e.jsxs("div",{style:r,children:[e.jsxs("div",{children:["name = ",t.name]}),t.layer&&e.jsxs("div",{children:["layer = ",t.layer]}),f.map(([s,p])=>e.jsxs("div",{children:[s," = ",p]},s))]})}if(t.kind==="update-element"){const f=new Set([...Object.keys(t.changes.attributes??{}),...t.changes.name!==void 0?["name"]:[],...t.changes.doc!==void 0?["doc"]:[]]);return e.jsx("div",{style:r,children:[...f].map(s=>{var d,x;const p=s==="name"?t.before.name:s==="doc"?t.before.doc:(d=t.before.attributes)==null?void 0:d[s],u=s==="name"?t.changes.name:s==="doc"?t.changes.doc:(x=t.changes.attributes)==null?void 0:x[s];return e.jsxs("div",{children:[s,": ",e.jsx("span",{style:{color:"#dc2626",textDecoration:"line-through"},children:p||"∅"})," → ",e.jsx("span",{style:{color:"#059669"},children:u})]},s)})})}return t.kind==="create-relationship"?e.jsxs("div",{style:r,children:[t.sourceId," —",t.relationshipType,"→ ",t.targetId]}):e.jsxs("div",{style:r,children:[t.sourceId," —",t.relationshipType,"→ ",t.targetId]})}function ne(){return e.jsxs("span",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[[0,1,2].map(t=>e.jsx("span",{style:{width:"5px",height:"5px",borderRadius:"50%",background:"#9CA3AF",animation:"llm-pulse 1.2s ease-in-out infinite",animationDelay:`${t*.2}s`}},t)),e.jsx("style",{children:"@keyframes llm-pulse{0%,80%,100%{opacity:0.3}40%{opacity:1}}"})]})}const re=["Add a PressureSensor component with a USB interface and a power port.","Create a hazard: AlarmFailure that causes patient harm in ICU setting.","Define a software item InfusionController with a requirement for dose limit checking.","Add a RiskControlMeasure that mitigates OverInfusion by adding a flow rate sensor."];function se(){const t=v(n=>n.llmAvailable),r=v(n=>n.llmProvider),f=v(n=>n.llmModel),s=v(n=>n.registerLlmRequest),[p,u]=a.useState(""),[d,x]=a.useState(!1),[l,y]=a.useState(null),[S,b]=a.useState(null),[j,k]=a.useState(!1),C=a.useCallback(async n=>{if(!n.trim()||d)return;x(!0),y(null),b(null),k(!1);const c=`gen-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const m=await new Promise((B,D)=>{s(c,B,D),U(c,n.trim()),setTimeout(()=>D(new Error("Request timed out after 60 seconds.")),6e4)});y(m)}catch(m){b((m==null?void 0:m.message)??"Unknown error")}finally{x(!1)}},[d,s]),w=()=>{l!=null&&l.sysml&&navigator.clipboard.writeText(l.sysml).then(()=>{k(!0),setTimeout(()=>k(!1),2e3)})},E=n=>(l==null?void 0:l.diagnostics.filter(c=>c.domain===n))??[];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"14px 20px 10px",borderBottom:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:"⟨/⟩"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"SysML Generator"}),e.jsx("div",{style:{fontSize:"11px",color:t?"#059669":"#dc2626",marginTop:"1px"},children:t?`${r??"LLM"} · ${f??"unknown model"} · natural language → SysML v2`:"No LLM provider — set ANTHROPIC_API_KEY or OPENAI_API_KEY"})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{fontSize:"12px",fontWeight:600,color:"#374151",display:"block",marginBottom:"6px"},children:"Describe what to generate"}),e.jsx("textarea",{value:p,onChange:n=>u(n.target.value),disabled:!t||d,rows:4,placeholder:"Describe the element(s) to generate in plain English…",style:{width:"100%",padding:"10px 12px",border:"1px solid #E5E5E0",borderRadius:"8px",fontSize:"13px",resize:"vertical",fontFamily:"inherit",outline:"none",background:"#fff",color:"#1B3A4B",lineHeight:"1.5",boxSizing:"border-box",opacity:t?1:.5},onFocus:n=>{n.target.style.borderColor="#2DD4A8"},onBlur:n=>{n.target.style.borderColor="#E5E5E0"},onKeyDown:n=>{n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),C(p))}}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:"Cmd+Enter to generate"}),e.jsx("button",{onClick:()=>C(p),disabled:!t||d||!p.trim(),style:{padding:"6px 16px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",opacity:!t||!p.trim()?.4:1},children:d?"Generating…":"Generate SysML"})]})]}),!l&&!d&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"8px"},children:"Examples"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"5px"},children:re.map(n=>e.jsx("button",{onClick:()=>{u(n)},disabled:!t,style:{textAlign:"left",padding:"7px 11px",borderRadius:"6px",background:"#fff",border:"1px solid #E5E5E0",fontSize:"12px",color:"#374151",cursor:"pointer",opacity:t?1:.5},onMouseEnter:c=>{t&&(c.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:c=>{c.currentTarget.style.borderColor="#E5E5E0"},children:n},n))})]}),d&&e.jsxs("div",{style:{background:"#fff",border:"1px solid #E5E5E0",borderRadius:"10px",padding:"20px",textAlign:"center",color:"#9CA3AF",fontSize:"13px"},children:[e.jsx("div",{style:{marginBottom:"8px",fontSize:"20px"},children:"⟨/⟩"}),"Generating SysML v2…"]}),S&&e.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"12px",color:"#dc2626",fontSize:"13px"},children:[e.jsx("strong",{children:"Error:"})," ",S]}),l&&!d&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs("div",{style:{background:"#F0FDF9",border:"1px solid #A7F3D0",borderRadius:"8px",padding:"12px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#065F46",marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Explanation"}),e.jsx("p",{style:{fontSize:"13px",color:"#1B3A4B",margin:0,lineHeight:"1.6"},children:l.explanation}),l.suggestedFile&&e.jsxs("div",{style:{marginTop:"8px",fontSize:"11px",color:"#6B7280"},children:["Suggested file: ",e.jsx("code",{style:{background:"#D1FAE5",padding:"1px 5px",borderRadius:"3px"},children:l.suggestedFile})]})]}),e.jsxs("div",{style:{background:"#1e293b",borderRadius:"10px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 14px",borderBottom:"1px solid #334155"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#94a3b8",fontWeight:600},children:"SysML v2"}),e.jsx("button",{onClick:w,style:{padding:"3px 10px",borderRadius:"4px",border:"none",background:j?"#059669":"#334155",color:"#fff",fontSize:"11px",cursor:"pointer",fontWeight:500},children:j?"Copied!":"Copy"})]}),e.jsx("pre",{style:{margin:0,padding:"14px 16px",fontSize:"12px",lineHeight:"1.6",color:"#e2e8f0",overflowX:"auto",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:e.jsx("code",{children:l.sysml})})]}),e.jsxs("details",{style:{background:"#fff",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"10px 12px"},children:[e.jsxs("summary",{style:{cursor:"pointer",fontSize:"12px",fontWeight:600},children:["Source diff",l.initialSysml===l.sysml?" (no repair changes)":""]}),e.jsxs("pre",{style:{margin:"8px 0 0",fontSize:"11px",whiteSpace:"pre-wrap"},children:[l.initialSysml??l.sysml,l.initialSysml!==l.sysml?`
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as l}from"./zustand-CrhqMOHB.js";import{u as O,M as N}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as l}from"./zustand-CrhqMOHB.js";import{u as O,M as N}from"./index-a2rpMs5Y.js";const _="memo.analysis.notebooks.v1",I="root",k={folders:[{id:I,name:"Notebooks"}],notebooks:[]};function R(){try{const n=localStorage.getItem(_);if(!n)return k;const o=JSON.parse(n);return!Array.isArray(o.folders)||!Array.isArray(o.notebooks)?k:o}catch{return k}}const C=[{template:"part-inventory",title:"Part inventory",description:"List part usages and their owners.",icon:"▦"},{template:"requirements-review",title:"Requirements review",description:"List requirements and their declared text.",icon:"☑"},{template:"ownership-tree",title:"Ownership tree",description:"Print the model hierarchy for review.",icon:"⌘"},{template:"syside-part-api",title:"Syside live model API",description:"Query typed PartUsage elements directly from SysML v2 files.",icon:"⌁"}];function z(n){switch(n){case"part-inventory":return[`# Part inventory from the current MEMO model snapshot
|
|
2
2
|
`,`parts = [element for element in elements if 'part' in (element.get('kind', '') + ' ' + element.get('construct', '')).lower()]
|
|
3
3
|
`,`[(part.get('shortId'), part.get('name'), part.get('kind')) for part in parts[:100]]
|
|
4
4
|
`];case"requirements-review":return[`# Requirements review from the current MEMO model snapshot
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as j,h as k}from"./index-CG-gfw-s.js";const C=[{id:"iso-14971",name:"ISO 14971",description:"Risk Management for Medical Devices",steps:[{id:"hazard-identification",label:"Hazard Identification",description:"Identify hazards and hazardous situations"},{id:"risk-estimation",label:"Risk Estimation",description:"Estimate severity and probability for each hazardous situation"},{id:"control-measures",label:"Risk Controls",description:"Define risk control measures and link to hazards"},{id:"verification",label:"Verification",description:"Verify risk control effectiveness"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],requiredRelationships:["causes","leadsTo","mitigates"]},{id:"iec-62304",name:"IEC 62304",description:"Software Lifecycle for Medical Devices",steps:[{id:"hazard-identification",label:"Software Items",description:"Identify software items and their safety classification"},{id:"risk-estimation",label:"Architecture",description:"Review software architecture decomposition"},{id:"control-measures",label:"Requirements Tracing",description:"Trace software requirements to system requirements"},{id:"verification",label:"Verification",description:"Verify test coverage for software items"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["SoftwareComponent","SoftwareModule","Requirement","Test"],requiredRelationships:["decomposedBy","traceTo","verify"]}];function w(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(n=>n.kind==="Hazard"),l=d.filter(n=>n.kind==="HazardousSituation"),u=d.filter(n=>n.kind==="Harm"),p=d.filter(n=>n.kind==="RiskControlMeasure");a.push({label:"Hazards identified",status:o.length>0?"pass":"fail",detail:`${o.length} hazards found`,elementIds:o.map(n=>n.id)}),a.push({label:"Hazardous situations linked",status:l.length>0?"pass":"warning",detail:`${l.length} hazardous situations`,elementIds:l.map(n=>n.id)}),a.push({label:"Harms documented",status:u.length>0?"pass":"warning",detail:`${u.length} harms identified`,elementIds:u.map(n=>n.id)});const c=new Set(i.relationships.filter(n=>n.type==="mitigates").map(n=>n.targetId)),t=o.filter(n=>!c.has(n.id));a.push({label:"Risk controls applied",status:t.length===0&&o.length>0?"pass":t.length>0?"fail":"warning",detail:t.length>0?`${t.length} hazards without controls`:`${p.length} controls applied`,elementIds:t.map(n=>n.id)});const h=new Set(i.relationships.filter(n=>n.type==="verify").map(n=>n.targetId)),f=p.filter(n=>!h.has(n.id));return a.push({label:"Controls verified",status:f.length===0&&p.length>0?"pass":f.length>0?"warning":"fail",detail:f.length>0?`${f.length} controls not verified`:`All ${p.length} controls verified`,elementIds:f.map(n=>n.id)}),a}function E(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(t=>t.kind==="SoftwareComponent"||t.kind==="SoftwareModule"),l=d.filter(t=>t.kind==="Requirement"),u=d.filter(t=>t.kind==="Test");a.push({label:"Software items identified",status:o.length>0?"pass":"fail",detail:`${o.length} software items`,elementIds:o.map(t=>t.id)}),a.push({label:"Software requirements defined",status:l.length>0?"pass":"fail",detail:`${l.length} software requirements`,elementIds:l.map(t=>t.id)});const p=new Set(i.relationships.filter(t=>t.type==="traceTo").map(t=>t.sourceId)),c=l.filter(t=>!p.has(t.id));return a.push({label:"Requirements traced",status:c.length===0&&l.length>0?"pass":c.length>0?"warning":"fail",detail:c.length>0?`${c.length} requirements not traced`:"All requirements traced",elementIds:c.map(t=>t.id)}),a.push({label:"Test coverage",status:u.length>0?"pass":"warning",detail:`${u.length} tests defined`,elementIds:u.map(t=>t.id)}),a}function A(){const i=j(d=>d.availableOntologies);return g.useMemo(()=>{const d=new Map;for(const a of i)for(const o of a.layers)for(const l of o.kinds)l.standard&&d.set(l.standard,(d.get(l.standard)??0)+1);return Array.from(d.entries()).map(([a,o])=>({standard:a,label:a.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),kindCount:o})).sort((a,o)=>a.standard.localeCompare(o.standard))},[i])}function z(){const i=j(s=>s.model),d=j(s=>s.selectElement),[a,o]=g.useState(null),[l,u]=g.useState(0),p=A(),c=C.find(s=>s.id===a),t=c==null?void 0:c.steps[l],h=g.useMemo(()=>!a||!i?[]:a==="iso-14971"?w(i):a==="iec-62304"?E(i):[],[a,i]),f=h.filter(s=>s.status==="pass").length,n=h.length,x=n>0?Math.round(f/n*100):0,v={pass:"#2ECC71",warning:"#F39C12",fail:"#E74C3C"},N={pass:"✓",warning:"⚠",fail:"✗"},y=g.useMemo(()=>{if(!i||!t)return[];const s=Object.values(i.elements);switch(t.id){case"hazard-identification":return a==="iso-14971"?s.filter(r=>r.kind==="Hazard"||r.kind==="HazardousSituation"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="SoftwareModule");case"risk-estimation":return a==="iso-14971"?s.filter(r=>r.kind==="HazardousSituation"||r.kind==="Harm"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="Subsystem"||r.kind==="Component");case"control-measures":return a==="iso-14971"?s.filter(r=>r.kind==="RiskControlMeasure"):s.filter(r=>r.kind==="Requirement"||r.kind==="Requirement");case"verification":return s.filter(r=>r.kind==="Test");default:return[]}},[i,t,a]);return a?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-64 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"px-4 py-3",style:{background:"linear-gradient(135deg, #1B3A4B, #2D6A7A)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{o(null),u(0)},className:"text-xs px-1.5 py-0.5 rounded",style:{color:"rgba(255,255,255,0.6)",background:"rgba(255,255,255,0.1)"},children:"←"}),e.jsx("h2",{className:"text-sm font-bold tracking-wide",style:{color:"#2DD4A8"},children:c.name})]}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(255,255,255,0.6)"},children:c.description})]}),e.jsxs("div",{className:"px-4 py-3",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium",style:{color:"#374151"},children:"Compliance"}),e.jsxs("span",{className:"text-xs font-bold",style:{color:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"},children:[x,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 rounded-full",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${x}%`,background:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"}})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:c.steps.map((s,r)=>{const m=l===r,b=r<l;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer mx-1 rounded-lg",style:{background:m?"#2DD4A818":"transparent",fontWeight:m?500:400},onMouseEnter:F=>{m||(F.currentTarget.style.background="#F0F0ED")},onMouseLeave:F=>{m||(F.currentTarget.style.background=m?"#2DD4A818":"transparent")},onClick:()=>u(r),children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs flex-shrink-0",style:{background:m?"#2DD4A8":b?"#2ECC7130":"#F3F4F6",color:m?"#FFFFFF":b?"#2ECC71":"#9CA3AF"},children:b?"✓":r+1}),e.jsx("span",{className:"text-xs",style:{color:m?"#1B3A4B":"#6B7280"},children:s.label})]},s.id)})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsx("div",{className:"max-w-3xl",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#374151"},children:t.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#9CA3AF"},children:["Step ",l+1," of ",c.steps.length]})]}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:t.description}),t.id==="summary"?e.jsx("div",{className:"space-y-2",children:h.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${v[s.status]}40`},children:[e.jsx("span",{className:"text-sm font-bold",style:{color:v[s.status]},children:N[s.status]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium",style:{color:"#374151"},children:s.label}),e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:s.detail})]}),s.elementIds&&s.elementIds.length>0&&s.status!=="pass"&&e.jsx("button",{onClick:()=>d(s.elementIds[0]),className:"text-xs px-2 py-0.5 rounded",style:{background:"#4A90D915",color:"#4A90D9"},children:"View"})]},r))}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#6B7280"},children:["Relevant Elements (",y.length,")"]}),y.length===0&&e.jsx("div",{className:"p-4 rounded-lg text-center text-xs",style:{background:"#FEF2F2",border:"1px solid #FECACA",color:"#E74C3C"},children:"No elements found for this step. Create the required element types in your .sysml files."}),e.jsx("div",{className:"space-y-1",children:y.map(s=>{const r=i.relationships.filter(m=>m.sourceId===s.id||m.targetId===s.id);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer text-xs",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:m=>m.currentTarget.style.background="#F0F0ED",onMouseLeave:m=>m.currentTarget.style.background="#FFFFFF",onClick:()=>d(s.id),children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:k[s.layer]||"#95A5A6"}}),e.jsx("span",{className:"font-medium flex-1 truncate",style:{color:"#374151"},children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{background:(k[s.layer]||"#95A5A6")+"18",color:k[s.layer]||"#95A5A6"},children:s.kind}),e.jsxs("span",{style:{color:"#9CA3AF"},children:[r.length," rels"]})]},s.id)})})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-6 pt-4",style:{borderTop:"1px solid #E5E5E0"},children:[l>0&&e.jsxs("button",{onClick:()=>u(l-1),className:"px-4 py-2 text-xs rounded-lg",style:{background:"#F3F4F6",color:"#6B7280"},children:["←"," Previous"]}),e.jsx("div",{className:"flex-1"}),l<c.steps.length-1&&e.jsxs("button",{onClick:()=>u(l+1),className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:["Next ","→"]})]})]})})})]}):e.jsx("div",{className:"flex-1 overflow-y-auto p-8",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Compliance Wizard"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:"Select a standard to walk through compliance requirements step by step."}),e.jsx("div",{className:"space-y-3",children:C.map(s=>e.jsxs("button",{onClick:()=>{o(s.id),u(0)},className:"w-full text-left p-4 rounded-lg transition-colors",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:r=>r.currentTarget.style.borderColor="#2DD4A8",onMouseLeave:r=>r.currentTarget.style.borderColor="#E5E5E0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-semibold",style:{color:"#1B3A4B"},children:s.name}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.steps.length," steps"]})]}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#6B7280"},children:s.description})]},s.id))}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mt-8 mb-3",style:{color:"#6B7280"},children:"Discovered Standards"}),e.jsx("div",{className:"space-y-2",children:p.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"#7C3AED"}}),e.jsx("span",{className:"text-sm font-medium flex-1",style:{color:"#374151"},children:s.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.kindCount," ",s.kindCount===1?"kind":"kinds"]})]},s.standard))})]})]})})}export{z as ComplianceWizard};
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as j,h as k}from"./index-a2rpMs5Y.js";const C=[{id:"iso-14971",name:"ISO 14971",description:"Risk Management for Medical Devices",steps:[{id:"hazard-identification",label:"Hazard Identification",description:"Identify hazards and hazardous situations"},{id:"risk-estimation",label:"Risk Estimation",description:"Estimate severity and probability for each hazardous situation"},{id:"control-measures",label:"Risk Controls",description:"Define risk control measures and link to hazards"},{id:"verification",label:"Verification",description:"Verify risk control effectiveness"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],requiredRelationships:["causes","leadsTo","mitigates"]},{id:"iec-62304",name:"IEC 62304",description:"Software Lifecycle for Medical Devices",steps:[{id:"hazard-identification",label:"Software Items",description:"Identify software items and their safety classification"},{id:"risk-estimation",label:"Architecture",description:"Review software architecture decomposition"},{id:"control-measures",label:"Requirements Tracing",description:"Trace software requirements to system requirements"},{id:"verification",label:"Verification",description:"Verify test coverage for software items"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["SoftwareComponent","SoftwareModule","Requirement","Test"],requiredRelationships:["decomposedBy","traceTo","verify"]}];function w(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(n=>n.kind==="Hazard"),l=d.filter(n=>n.kind==="HazardousSituation"),u=d.filter(n=>n.kind==="Harm"),p=d.filter(n=>n.kind==="RiskControlMeasure");a.push({label:"Hazards identified",status:o.length>0?"pass":"fail",detail:`${o.length} hazards found`,elementIds:o.map(n=>n.id)}),a.push({label:"Hazardous situations linked",status:l.length>0?"pass":"warning",detail:`${l.length} hazardous situations`,elementIds:l.map(n=>n.id)}),a.push({label:"Harms documented",status:u.length>0?"pass":"warning",detail:`${u.length} harms identified`,elementIds:u.map(n=>n.id)});const c=new Set(i.relationships.filter(n=>n.type==="mitigates").map(n=>n.targetId)),t=o.filter(n=>!c.has(n.id));a.push({label:"Risk controls applied",status:t.length===0&&o.length>0?"pass":t.length>0?"fail":"warning",detail:t.length>0?`${t.length} hazards without controls`:`${p.length} controls applied`,elementIds:t.map(n=>n.id)});const h=new Set(i.relationships.filter(n=>n.type==="verify").map(n=>n.targetId)),f=p.filter(n=>!h.has(n.id));return a.push({label:"Controls verified",status:f.length===0&&p.length>0?"pass":f.length>0?"warning":"fail",detail:f.length>0?`${f.length} controls not verified`:`All ${p.length} controls verified`,elementIds:f.map(n=>n.id)}),a}function E(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(t=>t.kind==="SoftwareComponent"||t.kind==="SoftwareModule"),l=d.filter(t=>t.kind==="Requirement"),u=d.filter(t=>t.kind==="Test");a.push({label:"Software items identified",status:o.length>0?"pass":"fail",detail:`${o.length} software items`,elementIds:o.map(t=>t.id)}),a.push({label:"Software requirements defined",status:l.length>0?"pass":"fail",detail:`${l.length} software requirements`,elementIds:l.map(t=>t.id)});const p=new Set(i.relationships.filter(t=>t.type==="traceTo").map(t=>t.sourceId)),c=l.filter(t=>!p.has(t.id));return a.push({label:"Requirements traced",status:c.length===0&&l.length>0?"pass":c.length>0?"warning":"fail",detail:c.length>0?`${c.length} requirements not traced`:"All requirements traced",elementIds:c.map(t=>t.id)}),a.push({label:"Test coverage",status:u.length>0?"pass":"warning",detail:`${u.length} tests defined`,elementIds:u.map(t=>t.id)}),a}function A(){const i=j(d=>d.availableOntologies);return g.useMemo(()=>{const d=new Map;for(const a of i)for(const o of a.layers)for(const l of o.kinds)l.standard&&d.set(l.standard,(d.get(l.standard)??0)+1);return Array.from(d.entries()).map(([a,o])=>({standard:a,label:a.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),kindCount:o})).sort((a,o)=>a.standard.localeCompare(o.standard))},[i])}function z(){const i=j(s=>s.model),d=j(s=>s.selectElement),[a,o]=g.useState(null),[l,u]=g.useState(0),p=A(),c=C.find(s=>s.id===a),t=c==null?void 0:c.steps[l],h=g.useMemo(()=>!a||!i?[]:a==="iso-14971"?w(i):a==="iec-62304"?E(i):[],[a,i]),f=h.filter(s=>s.status==="pass").length,n=h.length,x=n>0?Math.round(f/n*100):0,v={pass:"#2ECC71",warning:"#F39C12",fail:"#E74C3C"},N={pass:"✓",warning:"⚠",fail:"✗"},y=g.useMemo(()=>{if(!i||!t)return[];const s=Object.values(i.elements);switch(t.id){case"hazard-identification":return a==="iso-14971"?s.filter(r=>r.kind==="Hazard"||r.kind==="HazardousSituation"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="SoftwareModule");case"risk-estimation":return a==="iso-14971"?s.filter(r=>r.kind==="HazardousSituation"||r.kind==="Harm"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="Subsystem"||r.kind==="Component");case"control-measures":return a==="iso-14971"?s.filter(r=>r.kind==="RiskControlMeasure"):s.filter(r=>r.kind==="Requirement"||r.kind==="Requirement");case"verification":return s.filter(r=>r.kind==="Test");default:return[]}},[i,t,a]);return a?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-64 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"px-4 py-3",style:{background:"linear-gradient(135deg, #1B3A4B, #2D6A7A)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{o(null),u(0)},className:"text-xs px-1.5 py-0.5 rounded",style:{color:"rgba(255,255,255,0.6)",background:"rgba(255,255,255,0.1)"},children:"←"}),e.jsx("h2",{className:"text-sm font-bold tracking-wide",style:{color:"#2DD4A8"},children:c.name})]}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(255,255,255,0.6)"},children:c.description})]}),e.jsxs("div",{className:"px-4 py-3",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium",style:{color:"#374151"},children:"Compliance"}),e.jsxs("span",{className:"text-xs font-bold",style:{color:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"},children:[x,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 rounded-full",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${x}%`,background:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"}})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:c.steps.map((s,r)=>{const m=l===r,b=r<l;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer mx-1 rounded-lg",style:{background:m?"#2DD4A818":"transparent",fontWeight:m?500:400},onMouseEnter:F=>{m||(F.currentTarget.style.background="#F0F0ED")},onMouseLeave:F=>{m||(F.currentTarget.style.background=m?"#2DD4A818":"transparent")},onClick:()=>u(r),children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs flex-shrink-0",style:{background:m?"#2DD4A8":b?"#2ECC7130":"#F3F4F6",color:m?"#FFFFFF":b?"#2ECC71":"#9CA3AF"},children:b?"✓":r+1}),e.jsx("span",{className:"text-xs",style:{color:m?"#1B3A4B":"#6B7280"},children:s.label})]},s.id)})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsx("div",{className:"max-w-3xl",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#374151"},children:t.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#9CA3AF"},children:["Step ",l+1," of ",c.steps.length]})]}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:t.description}),t.id==="summary"?e.jsx("div",{className:"space-y-2",children:h.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${v[s.status]}40`},children:[e.jsx("span",{className:"text-sm font-bold",style:{color:v[s.status]},children:N[s.status]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium",style:{color:"#374151"},children:s.label}),e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:s.detail})]}),s.elementIds&&s.elementIds.length>0&&s.status!=="pass"&&e.jsx("button",{onClick:()=>d(s.elementIds[0]),className:"text-xs px-2 py-0.5 rounded",style:{background:"#4A90D915",color:"#4A90D9"},children:"View"})]},r))}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#6B7280"},children:["Relevant Elements (",y.length,")"]}),y.length===0&&e.jsx("div",{className:"p-4 rounded-lg text-center text-xs",style:{background:"#FEF2F2",border:"1px solid #FECACA",color:"#E74C3C"},children:"No elements found for this step. Create the required element types in your .sysml files."}),e.jsx("div",{className:"space-y-1",children:y.map(s=>{const r=i.relationships.filter(m=>m.sourceId===s.id||m.targetId===s.id);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer text-xs",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:m=>m.currentTarget.style.background="#F0F0ED",onMouseLeave:m=>m.currentTarget.style.background="#FFFFFF",onClick:()=>d(s.id),children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:k[s.layer]||"#95A5A6"}}),e.jsx("span",{className:"font-medium flex-1 truncate",style:{color:"#374151"},children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{background:(k[s.layer]||"#95A5A6")+"18",color:k[s.layer]||"#95A5A6"},children:s.kind}),e.jsxs("span",{style:{color:"#9CA3AF"},children:[r.length," rels"]})]},s.id)})})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-6 pt-4",style:{borderTop:"1px solid #E5E5E0"},children:[l>0&&e.jsxs("button",{onClick:()=>u(l-1),className:"px-4 py-2 text-xs rounded-lg",style:{background:"#F3F4F6",color:"#6B7280"},children:["←"," Previous"]}),e.jsx("div",{className:"flex-1"}),l<c.steps.length-1&&e.jsxs("button",{onClick:()=>u(l+1),className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:["Next ","→"]})]})]})})})]}):e.jsx("div",{className:"flex-1 overflow-y-auto p-8",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Compliance Wizard"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:"Select a standard to walk through compliance requirements step by step."}),e.jsx("div",{className:"space-y-3",children:C.map(s=>e.jsxs("button",{onClick:()=>{o(s.id),u(0)},className:"w-full text-left p-4 rounded-lg transition-colors",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:r=>r.currentTarget.style.borderColor="#2DD4A8",onMouseLeave:r=>r.currentTarget.style.borderColor="#E5E5E0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-semibold",style:{color:"#1B3A4B"},children:s.name}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.steps.length," steps"]})]}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#6B7280"},children:s.description})]},s.id))}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mt-8 mb-3",style:{color:"#6B7280"},children:"Discovered Standards"}),e.jsx("div",{className:"space-y-2",children:p.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"#7C3AED"}}),e.jsx("span",{className:"text-sm font-medium flex-1",style:{color:"#374151"},children:s.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.kindCount," ",s.kindCount===1?"kind":"kinds"]})]},s.standard))})]})]})})}export{z as ComplianceWizard};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-C9OlmOYw.js";import{a as w}from"./zustand-CrhqMOHB.js";import{_ as at,C as d,F as z,h as Se,S as Ke,T as ge,u as ue,i as lt,r as ae,j as dt}from"./index-CG-gfw-s.js";import{I as G,a as ct,T as pt,b as Oe}from"./DiagramToolbarControls-XMGLx08e.js";const ut=["composes","composedOf","decomposedBy","aggregation","includes","includesStep","containsEvent","moduleUses"];function ye(e){const a=new Set(e.relationships.map(n=>n.type));return ut.filter(n=>a.has(n))}function Ve(e){return[...new Set(e.relationships.map(a=>a.type))].sort()}function qe(e){const a=new Map;for(const n of Object.values(e.elements)){const o=n.layer||"unassigned";let s=a.get(o);s||(s=new Map,a.set(o,s)),s.set(n.kind,(s.get(n.kind)??0)+1)}return[...a.entries()].map(([n,o])=>({layer:n,elementCount:[...o.values()].reduce((s,i)=>s+i,0),kinds:[...o.entries()].map(([s,i])=>({kind:s,elementCount:i})).sort((s,i)=>i.elementCount-s.elementCount||s.kind.localeCompare(i.kind))})).sort((n,o)=>o.elementCount-n.elementCount||n.layer.localeCompare(o.layer))}function Ye(e,a){const n=new Set(a??ye(e)),o=new Map;for(const i of e.relationships){if(n.has(i.type))continue;const p=e.elements[i.sourceId],l=e.elements[i.targetId];!p||!l||p.layer!==l.layer||o.set(p.layer,(o.get(p.layer)??0)+1)}const s=qe(e);if(s.length!==0)return[...s].sort((i,p)=>(o.get(p.layer)??0)-(o.get(i.layer)??0)||p.elementCount-i.elementCount||i.layer.localeCompare(p.layer))[0].layer}function Dt(e,a){const n=new Set(ye(e)),o=new Map;for(const l of e.relationships){if(n.has(l.type))continue;const u=e.elements[l.sourceId],f=e.elements[l.targetId];if(!u||!f||u.layer===f.layer)continue;const k=`${u.layer}>${f.layer}`;o.set(k,(o.get(k)??0)+1)}const s=[...o.entries()].sort((l,u)=>u[1]-l[1]||l[0].localeCompare(u[0]))[0];if(!s){const l=Ye(e,a);return{rows:l,columns:l}}const[i,p]=s[0].split(">");return{rows:i,columns:p}}function ht(e,a){const n=new Map;for(const s of Object.values(e.elements)){const i=s.parentAction??s.owner;i&&e.elements[i]&&n.set(s.id,i)}const o=new Set(a);for(const s of e.relationships)o.has(s.type)&&(!e.elements[s.sourceId]||!e.elements[s.targetId]||s.sourceId!==s.targetId&&n.set(s.targetId,s.sourceId));for(const s of[...n.keys()]){const i=new Set([s]);let p=n.get(s);for(;p;){if(i.has(p)){n.delete(p);break}i.add(p),p=n.get(p)}}return n}function ft(e,a){const n=[],o=new Set([e]);let s=a.get(e);for(;s&&!o.has(s);)n.push(s),o.add(s),s=a.get(s);return n}function ze(e,a,n,o,s){const i=new Set((o==null?void 0:o.kinds)??[]),p=new Set((o==null?void 0:o.elementIds)??[]),l=b=>(!(o!=null&&o.layer)||b.layer===o.layer)&&(i.size===0||i.has(b.kind))&&(p.size===0||p.has(b.id)),u=new Set;for(const b of Object.values(e.elements))if(l(b)){u.add(b.id);for(const v of ft(b.id,a))u.add(v)}const f=new Map,k=b=>{const v=f.get(b);if(v)return v;const R=[b];f.set(b,R);for(const A of n.get(b)??[])A!==b&&R.push(...k(A));return R},c=new Map,x=(b,v)=>{const R=c.get(b);if(R)return R;const A=e.elements[b],P={id:b,name:(A==null?void 0:A.name)??b,kind:(A==null?void 0:A.kind)??"Unknown",layer:(A==null?void 0:A.layer)??"",isElement:!0,children:[],members:k(b),depth:v};return c.set(b,P),P.children=(n.get(b)??[]).filter(D=>u.has(D)&&D!==b).map(D=>x(D,v+1)),P};let g=[...u].filter(b=>{const v=a.get(b);return!v||!u.has(v)}).map(b=>x(b,0));s&&(g=xt(g,e));const S=new Map,m=new Map,C=(b,v)=>{v&&m.set(b.id,v),b.children.forEach(R=>C(R,b));for(const R of b.members)S.has(R)||S.set(R,b)};return g.forEach(b=>C(b,void 0)),{roots:g,ownerOf:S,parentNodeOf:m}}function xt(e,a){var p;const n=[],o=new Map,s=l=>{const u=l.join("::"),f=o.get(u);if(f)return f;const k={id:`pkg:${u}`,name:l[l.length-1],kind:"Package",layer:"",isElement:!1,children:[],members:[],depth:l.length-1};return o.set(u,k),l.length===1?n.push(k):s(l.slice(0,-1)).children.push(k),k};for(const l of e){const u=(p=a.elements[l.id])==null?void 0:p.package;if(!u){n.push(l);continue}s(u.split("::")).children.push(l)}const i=(l,u)=>{l.depth=u,l.children.forEach(f=>i(f,u+1)),l.isElement||(l.members=l.children.flatMap(f=>f.members))};return n.forEach(l=>i(l,0)),n}function De(e,a,n){const o=(l,u)=>l.name.localeCompare(u.name),s=(l,u)=>l.kind.localeCompare(u.kind)||o(l,u),i=l=>l.length<2?l:a==="natural"?[...l].sort(o):a==="kind"?[...l].sort(s):a==="partition"?gt(l,n):mt(l,n),p=l=>{const u=i(l);for(const f of u)f.children=p(f.children);return u};return p(e)}function gt(e,a){const n=[...e].sort((s,i)=>s.name.localeCompare(i.name)),o=[];for(;n.length>0;){const s=n.filter(i=>!n.some(p=>p!==i&&a(p,i)));if(s.length===0){o.push(...n);break}for(const i of s)o.push(i),n.splice(n.indexOf(i),1)}return o}function mt(e,a){const n=e.map((i,p)=>p),o=i=>n[i]===i?i:n[i]=o(n[i]);for(let i=0;i<e.length;i++)for(let p=i+1;p<e.length;p++)(a(e[i],e[p])||a(e[p],e[i]))&&(n[o(i)]=o(p));const s=new Map;return e.forEach((i,p)=>{const l=o(p),u=s.get(l);u?u.push(i):s.set(l,[i])}),[...s.values()].map(i=>i.sort((p,l)=>p.name.localeCompare(l.name))).sort((i,p)=>p.length-i.length||i[0].name.localeCompare(p[0].name)).flat()}function Ne(e,a){const n=[],o=(s,i,p)=>{const l=s.children.length>0,u=l&&a.has(s.id);if(n.push({node:s,index:n.length+1,depth:i,expandable:l,expanded:u,ancestorIds:p,memberCount:s.members.length}),!u)return;const f=[...p,s.id];for(const k of s.children)o(k,i+1,f)};return e.forEach(s=>o(s,0,[])),n}function he(e,a=1/0){const n=[],o=(s,i)=>{i>=a||(s.children.length>0&&n.push(s.id),s.children.forEach(p=>o(p,i+1)))};return e.forEach(s=>o(s,0)),n}function Be(e,a={}){var Q,K,Y,V;const n=a.containmentTypes??ye(e),o=ht(e,n),s=new Map;for(const[h,$]of o){const O=s.get($);O?O.push(h):s.set($,[h])}const i=new Set(a.dependencyTypes??[]),p=h=>(i.size===0||i.has(h.type))&&!n.includes(h.type),l=e.relationships.filter(p),u=a.groupByPackage??!1,f=ze(e,o,s,a.rows,u),k=ze(e,o,s,a.columns,u),c=h=>{const $=new Set,O=E=>{const L=[];let T=h.ownerOf.get(E);for(;T;)L.push(T.id),T=h.parentNodeOf.get(T.id);return L},F=(E,L)=>{for(const T of O(E))for(const W of O(L))T!==W&&$.add(`${T}>${W}`)};for(const E of l)F(E.sourceId,E.targetId),a.symmetric&&F(E.targetId,E.sourceId);return(E,L)=>E!==L&&$.has(`${E.id}>${L.id}`)},x=a.ordering??"natural",j=De(f.roots,((Q=a.rows)==null?void 0:Q.ordering)??x,c(f)),g=De(k.roots,((K=a.columns)==null?void 0:K.ordering)??x,c(k)),S=Ne(j,((Y=a.rows)==null?void 0:Y.expanded)??new Set),m=Ne(g,((V=a.columns)==null?void 0:V.expanded)??new Set),C=new Map;S.forEach((h,$)=>C.set(h.node.id,$));const b=new Map;m.forEach((h,$)=>b.set(h.node.id,$));const v=(h,$,O)=>{let F=$.ownerOf.get(h);const E=new Set;for(;F&&!E.has(F.id);){E.add(F.id);const L=O.get(F.id);if(L!==void 0)return L;F=$.parentNodeOf.get(F.id)}},R=Array.from({length:S.length},()=>Array.from({length:m.length},()=>null));let A=0,P=0;const D=(h,$,O)=>{const F=v($,f,C),E=v(O,k,b);if(F===void 0||E===void 0)return;const L=S[F],T=m[E],W=L.node.id===T.node.id;let _=R[F][E];_||(_={strength:0,types:[],relationshipIds:[],diagonal:W,aggregated:L.node.id!==$||T.node.id!==O},R[F][E]=_),_.strength++,(L.node.id!==$||T.node.id!==O)&&(_.aggregated=!0),_.types.includes(h.type)||_.types.push(h.type),_.relationshipIds.push(h.id),W?P++:A++};for(const h of l)D(h,h.sourceId,h.targetId),a.symmetric&&D(h,h.targetId,h.sourceId);return{rowRoots:j,columnRoots:g,rows:S,columns:m,matrix:R,totalDependencies:A,candidateDependencies:l.length,elementCount:Object.keys(e.elements).length,stats:yt(S,m,R,P),availableDependencyTypes:Ve(e)}}function yt(e,a,n,o){const s=new Map;a.forEach((k,c)=>s.set(k.node.id,c));let i=0,p=0,l=0,u=0;const f=new Array(a.length).fill(0);e.forEach((k,c)=>{let x=0;n[c].forEach((j,g)=>{if(!j||j.diagonal)return;x+=j.strength,f[g]+=j.strength;const S=s.get(k.node.id);S!==void 0&&g<S&&(i+=j.strength)}),u=Math.max(u,x)}),e.forEach((k,c)=>{const x=n[c].some(S=>S&&!S.diagonal),j=s.get(k.node.id),g=j!==void 0&&n.some(S=>S[j]&&!S[j].diagonal);!x&&!g&&l++});for(let k=0;k<e.length;k++){const c=s.get(e[k].node.id);if(c!==void 0)for(let x=0;x<a.length;x++){const j=n[k][x];if(!j||j.diagonal||x>=c)continue;const g=e.findIndex(S=>S.node.id===a[x].node.id);g>=0&&n[g][c]&&p++}}return f.forEach(k=>{u=Math.max(u,k)}),{feedback:i,couplings:p,isolated:l,maxDegree:u,internal:o}}const We=new Set(["Function","Function","UserActivity"]),_e=new Set(["System","Subsystem","Component","LogicalComponent","SoftwareComponent","SoftwareModule","Software"]);function bt(e){var f,k;const a=[],n=[];for(const c of Object.values(e.elements))We.has(c.kind)&&a.push(c),_e.has(c.kind)&&n.push(c);const o=[],s=new Set,i=new Map;for(const c of n)i.set(c.id,[]);for(const c of e.relationships){if(c.type!=="allocatedTo")continue;const x=e.elements[c.sourceId],j=e.elements[c.targetId];!x||!j||We.has(x.kind)&&_e.has(j.kind)&&(o.push({functionId:x.id,functionName:x.name,targetId:j.id,targetName:j.name}),s.add(x.id),i.has(j.id)||i.set(j.id,[]),i.get(j.id).push(x.id))}for(const c of a)if(c.allocatedTo&&!s.has(c.id)){const x=n.find(j=>j.name===c.allocatedTo||j.id===c.allocatedTo);x&&(o.push({functionId:c.id,functionName:c.name,targetId:x.id,targetName:x.name}),s.add(c.id),i.has(x.id)||i.set(x.id,[]),i.get(x.id).push(c.id))}const p=[];let l=0;for(const c of a)s.has(c.id)||p.push({id:`ci-${l++}`,type:"unallocated-function",severity:"warning",elementId:c.id,elementName:c.name,message:`Function "${c.name}" is not allocated to any component`});for(const c of n){const x=i.get(c.id);(!x||x.length===0)&&p.push({id:`ci-${l++}`,type:"no-functions-allocated",severity:"info",elementId:c.id,elementName:c.name,message:`Component "${c.name}" has no functions allocated to it`})}const u=new Map;for(const c of o)u.set(c.functionId,c.targetId);for(const c of e.relationships){if(c.type!=="flow")continue;const x=u.get(c.sourceId),j=u.get(c.targetId);if(x&&j&&x!==j){const g=e.elements[c.sourceId],S=e.elements[c.targetId];g&&S&&p.push({id:`ci-${l++}`,type:"cross-component-flow",severity:"info",elementId:c.sourceId,elementName:g.name,message:`Flow from "${g.name}" to "${S.name}" crosses component boundary (${(f=e.elements[x])==null?void 0:f.name} → ${(k=e.elements[j])==null?void 0:k.name})`,relatedIds:[c.targetId,x,j]})}}return{allocations:o,componentFunctions:i,issues:p,functions:a,structures:n}}function wt(e){const a=String(e);return/[",\r\n]/.test(a)?`"${a.replace(/"/g,'""')}"`:a}function Ze(e){return e?String(e.strength):""}function kt(e){const n=[["Row","Element type","Row index",...e.columns.map(o=>`${o.index}. ${o.node.name}`)]];return e.rows.forEach((o,s)=>{const i=[`${" ".repeat(o.depth)}${o.node.name}`,o.node.kind,o.index];e.columns.forEach((p,l)=>{const u=e.matrix[s][l];i.push(o.node.id===p.node.id?Ze(u):u?String(u.strength):"")}),n.push(i)}),`\uFEFF${n.map(o=>o.map(wt).join(",")).join(`\r
|
|
1
|
+
import{j as t}from"./reactflow-C9OlmOYw.js";import{a as w}from"./zustand-CrhqMOHB.js";import{_ as at,C as d,F as z,h as Se,S as Ke,T as ge,u as ue,i as lt,r as ae,j as dt}from"./index-a2rpMs5Y.js";import{I as G,a as ct,T as pt,b as Oe}from"./DiagramToolbarControls-XMGLx08e.js";const ut=["composes","composedOf","decomposedBy","aggregation","includes","includesStep","containsEvent","moduleUses"];function ye(e){const a=new Set(e.relationships.map(n=>n.type));return ut.filter(n=>a.has(n))}function Ve(e){return[...new Set(e.relationships.map(a=>a.type))].sort()}function qe(e){const a=new Map;for(const n of Object.values(e.elements)){const o=n.layer||"unassigned";let s=a.get(o);s||(s=new Map,a.set(o,s)),s.set(n.kind,(s.get(n.kind)??0)+1)}return[...a.entries()].map(([n,o])=>({layer:n,elementCount:[...o.values()].reduce((s,i)=>s+i,0),kinds:[...o.entries()].map(([s,i])=>({kind:s,elementCount:i})).sort((s,i)=>i.elementCount-s.elementCount||s.kind.localeCompare(i.kind))})).sort((n,o)=>o.elementCount-n.elementCount||n.layer.localeCompare(o.layer))}function Ye(e,a){const n=new Set(a??ye(e)),o=new Map;for(const i of e.relationships){if(n.has(i.type))continue;const p=e.elements[i.sourceId],l=e.elements[i.targetId];!p||!l||p.layer!==l.layer||o.set(p.layer,(o.get(p.layer)??0)+1)}const s=qe(e);if(s.length!==0)return[...s].sort((i,p)=>(o.get(p.layer)??0)-(o.get(i.layer)??0)||p.elementCount-i.elementCount||i.layer.localeCompare(p.layer))[0].layer}function Dt(e,a){const n=new Set(ye(e)),o=new Map;for(const l of e.relationships){if(n.has(l.type))continue;const u=e.elements[l.sourceId],f=e.elements[l.targetId];if(!u||!f||u.layer===f.layer)continue;const k=`${u.layer}>${f.layer}`;o.set(k,(o.get(k)??0)+1)}const s=[...o.entries()].sort((l,u)=>u[1]-l[1]||l[0].localeCompare(u[0]))[0];if(!s){const l=Ye(e,a);return{rows:l,columns:l}}const[i,p]=s[0].split(">");return{rows:i,columns:p}}function ht(e,a){const n=new Map;for(const s of Object.values(e.elements)){const i=s.parentAction??s.owner;i&&e.elements[i]&&n.set(s.id,i)}const o=new Set(a);for(const s of e.relationships)o.has(s.type)&&(!e.elements[s.sourceId]||!e.elements[s.targetId]||s.sourceId!==s.targetId&&n.set(s.targetId,s.sourceId));for(const s of[...n.keys()]){const i=new Set([s]);let p=n.get(s);for(;p;){if(i.has(p)){n.delete(p);break}i.add(p),p=n.get(p)}}return n}function ft(e,a){const n=[],o=new Set([e]);let s=a.get(e);for(;s&&!o.has(s);)n.push(s),o.add(s),s=a.get(s);return n}function ze(e,a,n,o,s){const i=new Set((o==null?void 0:o.kinds)??[]),p=new Set((o==null?void 0:o.elementIds)??[]),l=b=>(!(o!=null&&o.layer)||b.layer===o.layer)&&(i.size===0||i.has(b.kind))&&(p.size===0||p.has(b.id)),u=new Set;for(const b of Object.values(e.elements))if(l(b)){u.add(b.id);for(const v of ft(b.id,a))u.add(v)}const f=new Map,k=b=>{const v=f.get(b);if(v)return v;const R=[b];f.set(b,R);for(const A of n.get(b)??[])A!==b&&R.push(...k(A));return R},c=new Map,x=(b,v)=>{const R=c.get(b);if(R)return R;const A=e.elements[b],P={id:b,name:(A==null?void 0:A.name)??b,kind:(A==null?void 0:A.kind)??"Unknown",layer:(A==null?void 0:A.layer)??"",isElement:!0,children:[],members:k(b),depth:v};return c.set(b,P),P.children=(n.get(b)??[]).filter(D=>u.has(D)&&D!==b).map(D=>x(D,v+1)),P};let g=[...u].filter(b=>{const v=a.get(b);return!v||!u.has(v)}).map(b=>x(b,0));s&&(g=xt(g,e));const S=new Map,m=new Map,C=(b,v)=>{v&&m.set(b.id,v),b.children.forEach(R=>C(R,b));for(const R of b.members)S.has(R)||S.set(R,b)};return g.forEach(b=>C(b,void 0)),{roots:g,ownerOf:S,parentNodeOf:m}}function xt(e,a){var p;const n=[],o=new Map,s=l=>{const u=l.join("::"),f=o.get(u);if(f)return f;const k={id:`pkg:${u}`,name:l[l.length-1],kind:"Package",layer:"",isElement:!1,children:[],members:[],depth:l.length-1};return o.set(u,k),l.length===1?n.push(k):s(l.slice(0,-1)).children.push(k),k};for(const l of e){const u=(p=a.elements[l.id])==null?void 0:p.package;if(!u){n.push(l);continue}s(u.split("::")).children.push(l)}const i=(l,u)=>{l.depth=u,l.children.forEach(f=>i(f,u+1)),l.isElement||(l.members=l.children.flatMap(f=>f.members))};return n.forEach(l=>i(l,0)),n}function De(e,a,n){const o=(l,u)=>l.name.localeCompare(u.name),s=(l,u)=>l.kind.localeCompare(u.kind)||o(l,u),i=l=>l.length<2?l:a==="natural"?[...l].sort(o):a==="kind"?[...l].sort(s):a==="partition"?gt(l,n):mt(l,n),p=l=>{const u=i(l);for(const f of u)f.children=p(f.children);return u};return p(e)}function gt(e,a){const n=[...e].sort((s,i)=>s.name.localeCompare(i.name)),o=[];for(;n.length>0;){const s=n.filter(i=>!n.some(p=>p!==i&&a(p,i)));if(s.length===0){o.push(...n);break}for(const i of s)o.push(i),n.splice(n.indexOf(i),1)}return o}function mt(e,a){const n=e.map((i,p)=>p),o=i=>n[i]===i?i:n[i]=o(n[i]);for(let i=0;i<e.length;i++)for(let p=i+1;p<e.length;p++)(a(e[i],e[p])||a(e[p],e[i]))&&(n[o(i)]=o(p));const s=new Map;return e.forEach((i,p)=>{const l=o(p),u=s.get(l);u?u.push(i):s.set(l,[i])}),[...s.values()].map(i=>i.sort((p,l)=>p.name.localeCompare(l.name))).sort((i,p)=>p.length-i.length||i[0].name.localeCompare(p[0].name)).flat()}function Ne(e,a){const n=[],o=(s,i,p)=>{const l=s.children.length>0,u=l&&a.has(s.id);if(n.push({node:s,index:n.length+1,depth:i,expandable:l,expanded:u,ancestorIds:p,memberCount:s.members.length}),!u)return;const f=[...p,s.id];for(const k of s.children)o(k,i+1,f)};return e.forEach(s=>o(s,0,[])),n}function he(e,a=1/0){const n=[],o=(s,i)=>{i>=a||(s.children.length>0&&n.push(s.id),s.children.forEach(p=>o(p,i+1)))};return e.forEach(s=>o(s,0)),n}function Be(e,a={}){var Q,K,Y,V;const n=a.containmentTypes??ye(e),o=ht(e,n),s=new Map;for(const[h,$]of o){const O=s.get($);O?O.push(h):s.set($,[h])}const i=new Set(a.dependencyTypes??[]),p=h=>(i.size===0||i.has(h.type))&&!n.includes(h.type),l=e.relationships.filter(p),u=a.groupByPackage??!1,f=ze(e,o,s,a.rows,u),k=ze(e,o,s,a.columns,u),c=h=>{const $=new Set,O=E=>{const L=[];let T=h.ownerOf.get(E);for(;T;)L.push(T.id),T=h.parentNodeOf.get(T.id);return L},F=(E,L)=>{for(const T of O(E))for(const W of O(L))T!==W&&$.add(`${T}>${W}`)};for(const E of l)F(E.sourceId,E.targetId),a.symmetric&&F(E.targetId,E.sourceId);return(E,L)=>E!==L&&$.has(`${E.id}>${L.id}`)},x=a.ordering??"natural",j=De(f.roots,((Q=a.rows)==null?void 0:Q.ordering)??x,c(f)),g=De(k.roots,((K=a.columns)==null?void 0:K.ordering)??x,c(k)),S=Ne(j,((Y=a.rows)==null?void 0:Y.expanded)??new Set),m=Ne(g,((V=a.columns)==null?void 0:V.expanded)??new Set),C=new Map;S.forEach((h,$)=>C.set(h.node.id,$));const b=new Map;m.forEach((h,$)=>b.set(h.node.id,$));const v=(h,$,O)=>{let F=$.ownerOf.get(h);const E=new Set;for(;F&&!E.has(F.id);){E.add(F.id);const L=O.get(F.id);if(L!==void 0)return L;F=$.parentNodeOf.get(F.id)}},R=Array.from({length:S.length},()=>Array.from({length:m.length},()=>null));let A=0,P=0;const D=(h,$,O)=>{const F=v($,f,C),E=v(O,k,b);if(F===void 0||E===void 0)return;const L=S[F],T=m[E],W=L.node.id===T.node.id;let _=R[F][E];_||(_={strength:0,types:[],relationshipIds:[],diagonal:W,aggregated:L.node.id!==$||T.node.id!==O},R[F][E]=_),_.strength++,(L.node.id!==$||T.node.id!==O)&&(_.aggregated=!0),_.types.includes(h.type)||_.types.push(h.type),_.relationshipIds.push(h.id),W?P++:A++};for(const h of l)D(h,h.sourceId,h.targetId),a.symmetric&&D(h,h.targetId,h.sourceId);return{rowRoots:j,columnRoots:g,rows:S,columns:m,matrix:R,totalDependencies:A,candidateDependencies:l.length,elementCount:Object.keys(e.elements).length,stats:yt(S,m,R,P),availableDependencyTypes:Ve(e)}}function yt(e,a,n,o){const s=new Map;a.forEach((k,c)=>s.set(k.node.id,c));let i=0,p=0,l=0,u=0;const f=new Array(a.length).fill(0);e.forEach((k,c)=>{let x=0;n[c].forEach((j,g)=>{if(!j||j.diagonal)return;x+=j.strength,f[g]+=j.strength;const S=s.get(k.node.id);S!==void 0&&g<S&&(i+=j.strength)}),u=Math.max(u,x)}),e.forEach((k,c)=>{const x=n[c].some(S=>S&&!S.diagonal),j=s.get(k.node.id),g=j!==void 0&&n.some(S=>S[j]&&!S[j].diagonal);!x&&!g&&l++});for(let k=0;k<e.length;k++){const c=s.get(e[k].node.id);if(c!==void 0)for(let x=0;x<a.length;x++){const j=n[k][x];if(!j||j.diagonal||x>=c)continue;const g=e.findIndex(S=>S.node.id===a[x].node.id);g>=0&&n[g][c]&&p++}}return f.forEach(k=>{u=Math.max(u,k)}),{feedback:i,couplings:p,isolated:l,maxDegree:u,internal:o}}const We=new Set(["Function","Function","UserActivity"]),_e=new Set(["System","Subsystem","Component","LogicalComponent","SoftwareComponent","SoftwareModule","Software"]);function bt(e){var f,k;const a=[],n=[];for(const c of Object.values(e.elements))We.has(c.kind)&&a.push(c),_e.has(c.kind)&&n.push(c);const o=[],s=new Set,i=new Map;for(const c of n)i.set(c.id,[]);for(const c of e.relationships){if(c.type!=="allocatedTo")continue;const x=e.elements[c.sourceId],j=e.elements[c.targetId];!x||!j||We.has(x.kind)&&_e.has(j.kind)&&(o.push({functionId:x.id,functionName:x.name,targetId:j.id,targetName:j.name}),s.add(x.id),i.has(j.id)||i.set(j.id,[]),i.get(j.id).push(x.id))}for(const c of a)if(c.allocatedTo&&!s.has(c.id)){const x=n.find(j=>j.name===c.allocatedTo||j.id===c.allocatedTo);x&&(o.push({functionId:c.id,functionName:c.name,targetId:x.id,targetName:x.name}),s.add(c.id),i.has(x.id)||i.set(x.id,[]),i.get(x.id).push(c.id))}const p=[];let l=0;for(const c of a)s.has(c.id)||p.push({id:`ci-${l++}`,type:"unallocated-function",severity:"warning",elementId:c.id,elementName:c.name,message:`Function "${c.name}" is not allocated to any component`});for(const c of n){const x=i.get(c.id);(!x||x.length===0)&&p.push({id:`ci-${l++}`,type:"no-functions-allocated",severity:"info",elementId:c.id,elementName:c.name,message:`Component "${c.name}" has no functions allocated to it`})}const u=new Map;for(const c of o)u.set(c.functionId,c.targetId);for(const c of e.relationships){if(c.type!=="flow")continue;const x=u.get(c.sourceId),j=u.get(c.targetId);if(x&&j&&x!==j){const g=e.elements[c.sourceId],S=e.elements[c.targetId];g&&S&&p.push({id:`ci-${l++}`,type:"cross-component-flow",severity:"info",elementId:c.sourceId,elementName:g.name,message:`Flow from "${g.name}" to "${S.name}" crosses component boundary (${(f=e.elements[x])==null?void 0:f.name} → ${(k=e.elements[j])==null?void 0:k.name})`,relatedIds:[c.targetId,x,j]})}}return{allocations:o,componentFunctions:i,issues:p,functions:a,structures:n}}function wt(e){const a=String(e);return/[",\r\n]/.test(a)?`"${a.replace(/"/g,'""')}"`:a}function Ze(e){return e?String(e.strength):""}function kt(e){const n=[["Row","Element type","Row index",...e.columns.map(o=>`${o.index}. ${o.node.name}`)]];return e.rows.forEach((o,s)=>{const i=[`${" ".repeat(o.depth)}${o.node.name}`,o.node.kind,o.index];e.columns.forEach((p,l)=>{const u=e.matrix[s][l];i.push(o.node.id===p.node.id?Ze(u):u?String(u.strength):"")}),n.push(i)}),`\uFEFF${n.map(o=>o.map(wt).join(",")).join(`\r
|
|
2
2
|
`)}\r
|
|
3
3
|
`}function jt(e,a="memo-dsm.csv"){const n=new Blob([kt(e)],{type:"text/csv;charset=utf-8"}),o=URL.createObjectURL(n),s=document.createElement("a");s.href=o,s.download=a,s.click(),URL.revokeObjectURL(o)}async function vt(e,a="memo-dsm.xlsx"){const n=await at(()=>import("./xlsx-CkFp8p6R.js"),[]),o=[["Row","Element type","Row index",...e.columns.map(f=>`${f.index}. ${f.node.name}`)]];e.rows.forEach((f,k)=>{const c=[`${" ".repeat(f.depth)}${f.node.name}`,f.node.kind,f.index];e.columns.forEach((x,j)=>{const g=e.matrix[k][j];c.push(f.node.id===x.node.id?Ze(g):g?g.strength:"")}),o.push(c)});const s=n.utils.aoa_to_sheet(o);s["!rows"]=[{hpx:24},...e.rows.map(f=>({level:Math.min(7,f.depth),hidden:f.depth>0}))],s["!cols"]=[{wch:34},{wch:22},{wch:11},...e.columns.map(f=>({wch:Math.max(8,Math.min(26,f.node.name.length+2)),level:Math.min(7,f.depth),hidden:f.depth>0}))];const i=n.utils.book_new();n.utils.book_append_sheet(i,s,"DSM");const p=n.write(i,{bookType:"xlsx",type:"array",compression:!0}),l=URL.createObjectURL(new Blob([p],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})),u=document.createElement("a");u.href=l,u.download=a,u.click(),URL.revokeObjectURL(l)}const Qe=300,ve=24,St=9e4;function oe(e){return e<=0?"2px solid #94A3B8":e===1?"1px solid #B6C4D0":`1px solid ${d.borderLight}`}function Pe(e){return e.map((a,n)=>{if(n===0)return null;const o=e[n-1];return a.ancestorIds.includes(o.node.id)?null:Math.min(a.depth,o.depth)})}function Ct({result:e,onToggleRow:a,onToggleColumn:n,onSelectElement:o,selectedElementId:s,renderCell:i,onCellClick:p,onCellDoubleClick:l,cellSize:u=26,showColumnNames:f=!1,onHideRow:k,onHideColumn:c,cornerHeader:x,footer:j}){const[g,S]=w.useState(null),{rows:m,columns:C,matrix:b}=e,v=w.useMemo(()=>Pe(m),[m]),R=w.useMemo(()=>Pe(C),[C]),A=Math.max(10,Math.round(u*.34)),P=Math.max(11,Math.round(u*.34)),D=h=>h.ancestorIds[0]??h.node.id,Q=h=>h.length>ve?`${h.slice(0,ve-1)}…`:h,K=Math.min(ve,Math.max(0,...C.map(h=>h.node.name.length))),Y=Math.max(x?76:0,f?42+(K+2)*P*.62:44);if(m.length===0||C.length===0)return t.jsx("div",{className:"flex-1 flex items-center justify-center",style:{padding:"40px"},children:t.jsxs("div",{style:{textAlign:"center",maxWidth:"340px"},children:[t.jsx("div",{style:{fontSize:"34px",opacity:.35,marginBottom:"10px"},children:"▦"}),t.jsx("h3",{style:{fontSize:z.md,fontWeight:600,color:d.secondary,marginBottom:"6px"},children:"Nothing to plot"}),t.jsx("p",{style:{fontSize:z.xs,color:d.faint,lineHeight:1.6},children:"No element matches the chosen row and column types. Widen either axis, or clear the type filter to see the whole model."})]})});const V=m.length*C.length>St;return t.jsxs("div",{style:{padding:"14px",overflow:"auto",flex:1},children:[V&&t.jsxs("div",{style:{marginBottom:"10px",padding:"8px 10px",borderRadius:"6px",background:"#FEF3C7",border:"1px solid #FCD34D",fontSize:z.xs,color:"#92400E"},children:[m.length.toLocaleString()," × ",C.length.toLocaleString()," is past what stays responsive to draw. Collapse a few subsystems, or narrow the row and column types."]}),!V&&t.jsxs("div",{style:{display:"inline-block",minWidth:"100%"},children:[t.jsxs("div",{style:{display:"flex",position:"sticky",top:0,zIndex:20,background:d.surface},children:[t.jsx("div",{style:{width:Qe,flexShrink:0,height:Y,display:"flex",alignItems:x?"stretch":"flex-end",justifyContent:"flex-end",gap:"5px",padding:x?"8px 12px":"0 8px 3px 0",fontSize:"10px",color:d.faint,background:x?d.surfaceAlt:void 0,borderRight:x?`1px solid ${d.border}`:void 0,borderBottom:`1px solid ${d.border}`},children:x??t.jsxs("span",{children:[m.length," rows ","×"," ",C.length," cols"]})}),C.map((h,$)=>{const O=(g==null?void 0:g.column)===$;return t.jsxs("div",{onClick:()=>h.expandable?n(h.node.id):o==null?void 0:o(h.node.id),onMouseEnter:()=>S({row:m.findIndex(F=>F.node.id===h.node.id),column:$}),onMouseLeave:()=>S(null),title:`${h.index}. ${h.node.name} (${h.node.kind})${h.expandable?" — click to expand":""}`,style:{width:u,flexShrink:0,height:Y,position:"relative",cursor:"pointer",borderLeft:R[$]===null?void 0:oe(R[$]),borderRight:$===C.length-1?oe(0):void 0,borderBottom:`1px solid ${d.border}`,background:O?"#EAF7F3":"transparent"},children:[f&&t.jsxs("div",{style:{position:"absolute",top:"42px",bottom:"4px",left:0,right:0,display:"flex",alignItems:"center",justifyContent:"flex-start",writingMode:"vertical-rl",transform:"rotate(180deg)",overflow:"hidden",fontSize:`${P}px`,lineHeight:1,color:O?d.primary:d.muted,fontWeight:600},children:[h.expandable?h.expanded?"− ":"+ ":"",Q(h.node.name)]}),t.jsx("div",{style:{position:"absolute",top:"3px",width:"100%",left:0,display:"block",textAlign:"center",fontSize:`${Math.max(10,A-2)}px`,color:O?d.primary:d.faint,fontWeight:O?700:400},children:t.jsx("span",{children:h.index})}),h.node.isElement&&c&&t.jsx("span",{style:{position:"absolute",top:"22px",left:"50%",transform:"translateX(-50%)"},children:t.jsx(Je,{title:`Hide ${h.node.name} column`,ariaLabel:`Hide ${h.node.name} column`,onClick:()=>c(h.node.id)})})]},h.node.id)})]}),m.map((h,$)=>{const O=(g==null?void 0:g.row)===$,F=s===h.node.id;return t.jsxs("div",{style:{display:"flex",borderTop:v[$]===null?void 0:oe(v[$]),borderBottom:$===m.length-1?oe(0):void 0},children:[t.jsx($t,{entry:h,height:u,fontSize:P,onHide:h.node.isElement&&k?()=>k(h.node.id):void 0,hovered:O,selected:F,onToggle:()=>a(h.node.id),onSelect:()=>o==null?void 0:o(h.node.id)}),C.map((E,L)=>{const T=b[$][L],W=i?i(T,h,E):It(T),_=(g==null?void 0:g.row)===$||(g==null?void 0:g.column)===L,de=D(h)===D(E),J=h.node.id===E.node.id,H=W.background??(J?"#E3E8EE":_?"#F1F7F5":de?"#FAFBFC":d.surface),ce=W.text,ee=!!T||W.actionable;return t.jsx("div",{onMouseEnter:()=>S({row:$,column:L}),onMouseLeave:()=>S(null),onClick:ee?()=>p==null?void 0:p(h,E,T):void 0,onDoubleClick:ee?()=>l==null?void 0:l(h,E,T):void 0,title:W.title??Et(T,h,E),style:{width:u,height:u,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${A}px`,fontWeight:600,color:W.color??(J?d.faint:d.secondary),background:H,borderRight:L===C.length-1?oe(0):`1px solid ${d.borderLight}`,borderBottom:`1px solid ${d.borderLight}`,borderLeft:R[L]===null?void 0:oe(R[L]),cursor:ee?"pointer":"default",outline:(g==null?void 0:g.row)===$&&(g==null?void 0:g.column)===L?`2px solid ${d.accent}`:void 0,outlineOffset:"-2px"},children:ce},E.node.id)})]},h.node.id)})]}),j]})}function Je({title:e,ariaLabel:a,onClick:n}){return t.jsx("button",{type:"button",title:e,"aria-label":a,onClick:o=>{o.stopPropagation(),n()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",padding:0,border:"none",borderRadius:"4px",background:"rgba(255,255,255,0.82)",color:d.muted,cursor:"pointer"},children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M1.5 8s2.3-4 6.5-4 6.5 4 6.5 4-2.3 4-6.5 4-6.5-4-6.5-4Z"}),t.jsx("circle",{cx:"8",cy:"8",r:"2"})]})})}function $t({entry:e,height:a,fontSize:n,hovered:o,selected:s,onToggle:i,onSelect:p,onHide:l}){const u=e.depth*14,f={width:Qe,flexShrink:0,height:a,display:"flex",alignItems:"center",gap:"5px",paddingLeft:`${6+u}px`,paddingRight:"7px",position:"sticky",left:0,zIndex:10,background:s?"#E8F8F3":o?"#F1F7F5":d.surface,borderRight:`1px solid ${d.border}`,borderBottom:`1px solid ${d.borderLight}`,fontSize:`${n}px`,color:o||s?d.primary:d.secondary,fontWeight:e.expandable?600:400};return t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontSize:`${Math.max(10,n-3)}px`,color:d.faint,width:"18px",textAlign:"center",flexShrink:0},children:e.index}),t.jsx("span",{style:{width:"18px",height:"18px",flexShrink:0},children:l&&t.jsx(Je,{title:`Hide ${e.node.name} row`,ariaLabel:`Hide ${e.node.name} row`,onClick:l})}),t.jsx("button",{type:"button",onClick:e.expandable?i:void 0,"aria-label":e.expandable?`${e.expanded?"Collapse":"Expand"} ${e.node.name}`:void 0,disabled:!e.expandable,style:{width:"13px",height:"13px",flexShrink:0,padding:0,lineHeight:"11px",borderRadius:"3px",fontSize:`${Math.max(11,n-2)}px`,border:e.expandable?`1px solid ${d.border}`:"1px solid transparent",background:e.expandable?d.surface:"transparent",color:d.muted,cursor:e.expandable?"pointer":"default"},children:e.expandable?e.expanded?"−":"+":""}),t.jsx("span",{style:{width:"3px",height:"13px",borderRadius:"2px",flexShrink:0,background:e.node.isElement?Se[e.node.layer]||"#9CA3AF":"#CBD5E1"}}),t.jsx("span",{onClick:p,title:`${e.node.name} (${e.node.kind})`,style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:e.node.name}),e.expandable&&!e.expanded&&e.memberCount>1&&t.jsx("span",{style:{fontSize:`${Math.max(10,n-3)}px`,color:d.faint},title:`${e.memberCount} elements rolled up`,children:e.memberCount})]})}function It(e){return e?e.diagonal?{text:String(e.strength),color:d.muted}:{text:String(e.strength),color:d.primary}:{}}function Et(e,a,n){const o=`${a.node.name} → ${n.node.name}`;if(!e)return a.node.id===n.node.id?`${a.node.name}: no internal dependencies`:o;if(e.diagonal)return`${a.node.name}: ${e.strength} internal dependenc${e.strength===1?"y":"ies"}`;const s=e.types.join(", ");return`${o}
|
|
4
4
|
${e.strength} dependenc${e.strength===1?"y":"ies"} (${s})${e.aggregated?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";import{u as g,H as j,h}from"./index-CG-gfw-s.js";function k(i,d,s){var u,p;const n=Object.values(i.elements),o={},r={};for(const t of n)o[t.layer]=(o[t.layer]||0)+1,r[t.kind.toLowerCase()]=(r[t.kind.toLowerCase()]||0)+1;const c={};for(const t of i.relationships)c[t.type.toLowerCase()]=(c[t.type.toLowerCase()]||0)+1;return{totalElements:n.length,totalRelationships:i.relationships.length,violations:d,completenessPercent:s,riskCount:(o.risk||0)+(o.analysis||0),requirementsCount:o.requirements||0,architectureCount:["logical","physical","functional","logical_structure","software_structure","hardware_structure","functions","interfaces","system","context","operational","behavior"].reduce((t,a)=>t+(o[a]||0),0),verificationCount:(o.verification||0)+(o.assurance||0),hazardCount:r.hazard||0,requirementCount:Object.entries(r).filter(([t])=>t.endsWith("requirement")).reduce((t,[,a])=>t+a,0),riskControlCount:r.riskcontrol||0,systemCount:(r.system||0)+(r.subsystem||0)+(r.softwaresystem||0)+(r.logicalcomponent||0)+(r.hardwareassembly||0)+(r.softwarecomponent||0)+(r.processingnode||0),testCount:(r.verificationcase||0)+(r.validationcase||0)+(r.testartifact||0)+(r.test||0),mitigatesCount:Object.entries(c).filter(([t])=>t.startsWith("mitigat")).reduce((t,[,a])=>t+a,0),verificationLinkCount:Object.entries(c).filter(([t])=>t.startsWith("verif")||t.startsWith("validate")||t==="testedbyusability").reduce((t,[,a])=>t+a,0),diagramCount:((u=i.diagrams)==null?void 0:u.length)??0,projectName:((p=i.metadata)==null?void 0:p.projectName)||i.projectName||i.name||"My Device Project"}}function F(i){return i.totalElements===0?{icon:"🚀",title:"Add your first model elements",description:"Start with intended use, actors, and a system requirement. Or use the Workflow Wizard to guide you step by step.",urgency:"high"}:i.requirementCount===0?{icon:"📋",title:"Define your first requirement",description:"Your model has elements but no system requirements yet. Add a Requirement in the Model Explorer.",urgency:"high"}:i.hazardCount===0?{icon:"⚠️",title:"Add your first hazard",description:`You have ${i.requirementCount} requirement(s) but no hazard analysis yet. ISO 14971 requires hazard identification early.`,urgency:"high"}:i.hazardCount>0&&i.mitigatesCount===0?{icon:"🔗",title:"Connect hazards to risk controls",description:`You have ${i.hazardCount} hazard(s) but no MitigatesHazard relationships. Connect hazards to risk controls to complete the ISO 14971 chain.`,urgency:"high"}:i.systemCount===0?{icon:"🏗️",title:"Define your system architecture",description:"No architecture components found (SoftwareSystem, LogicalComponent, HardwareAssembly, …). Add an architecture layer to ground your requirements and risk analysis.",urgency:"medium"}:i.testCount===0?{icon:"🧪",title:"Add verification tests",description:`${i.requirementCount} requirement(s) have no verification tests yet. Add VerificationCases and link them to requirements with VerifiedBy.`,urgency:"medium"}:i.verificationLinkCount===0&&i.testCount>0?{icon:"↔️",title:"Link tests to requirements",description:"Verification cases exist but no VerifiedBy links found. Open the Traceability Matrix to connect tests to their requirements.",urgency:"medium"}:{icon:"✅",title:"Good coverage so far",description:"Requirements, hazards, and risk controls are in place. Check the GapBar (⌘⇧P) for completeness gaps before your review.",urgency:"low"}}function m({label:i,value:d,color:s,subtitle:n}){return e.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px 24px",display:"flex",flexDirection:"column",gap:"4px"},children:[e.jsx("div",{style:{fontSize:"28px",fontWeight:800,color:s,lineHeight:1},children:d}),e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"#374151"},children:i}),n&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function y({layer:i,label:d,count:s,color:n,onClick:o}){const r=s>0;return e.jsxs("button",{onClick:o,style:{background:r?`${n}12`:"#F9FAFB",border:`1px solid ${r?n+"30":"#E5E5E0"}`,borderRadius:"12px",padding:"16px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},onMouseEnter:c=>{c.currentTarget.style.background=r?`${n}20`:"#F3F4F6",c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)"},onMouseLeave:c=>{c.currentTarget.style.background=r?`${n}12`:"#F9FAFB",c.currentTarget.style.transform="none",c.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:r?n:"#9CA3AF"},children:d}),e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:r?n+"20":"#F3F4F6",color:r?n:"#9CA3AF"},children:[s," elements"]})]}),e.jsx("div",{style:{width:"100%",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:r?n:"transparent",width:r?`${Math.min(100,s/10*100)}%`:"0",transition:"width 0.4s ease"}})}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"8px"},children:r?"Click to explore →":"Not started"})]})}function x({icon:i,label:d,onClick:s,variant:n="secondary"}){const o=n==="primary";return e.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:600,border:"none",background:o?"#1B3A4B":"rgba(255,255,255,0.7)",color:o?"#FFFFFF":"#374151",backdropFilter:"blur(4px)",transition:"all 0.15s"},onMouseEnter:r=>{r.currentTarget.style.background=o?"#244D63":"rgba(255,255,255,0.95)",r.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.1)"},onMouseLeave:r=>{r.currentTarget.style.background=o?"#1B3A4B":"rgba(255,255,255,0.7)",r.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:d})]})}function E(){var b;const i=g(l=>l.model),d=g(l=>l.validation),s=g(l=>l.completeness),n=g(l=>l.setActiveView),o=g(l=>l.setExplorerTab),r=j(),c=g(l=>l.toggleGapBar),u=((b=d==null?void 0:d.violations)==null?void 0:b.length)??0,p=f.useMemo(()=>{if(typeof(s==null?void 0:s.overall)=="number")return Math.round(s.overall);if(!(s!=null&&s.layers)||s.layers.length===0)return 0;const l=s.layers.reduce((C,v)=>C+(v.completeness||0),0)/s.layers.length;return Math.round(l)},[s]),t=f.useMemo(()=>i?k(i,u,p):null,[i,u,p]),a=f.useMemo(()=>t?F(t):null,[t]);return!t||!i?e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"Loading dashboard…"})}):e.jsx("div",{style:{flex:1,overflowY:"auto",background:"linear-gradient(135deg, #EEF7F3 0%, #EAF2F8 55%, #F2EEF8 100%)",padding:"32px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{marginBottom:"28px"},children:[e.jsxs("div",{style:{position:"relative",width:260,height:154,overflow:"hidden",margin:"0 auto -10px",opacity:.62},title:"MEMO Architect","aria-label":"MEMO Architect",children:[e.jsx("img",{src:"/logo.png",alt:"","aria-hidden":"true",style:{width:260,height:260,objectFit:"contain",transform:"translateY(-32px)",mixBlendMode:"multiply"}}),e.jsx("span",{style:{position:"absolute",left:"59%",top:115,color:"#8B949E",fontSize:20,fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap"},children:"Architect"})]}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:t.projectName}),e.jsxs("p",{style:{fontSize:"13px",color:"#4B6E80",margin:0},children:["Model dashboard · ",new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px",marginBottom:"24px"},children:[e.jsx(m,{label:"Elements",value:t.totalElements,color:"#1B3A4B"}),e.jsx(m,{label:"Relationships",value:t.totalRelationships,color:"#4A90D9"}),e.jsx(m,{label:"Completeness",value:`${p}%`,color:p>=70?"#2ECC71":p>=40?"#F39C12":"#E74C3C"}),e.jsx(m,{label:"Violations",value:u,color:u===0?"#2ECC71":"#E74C3C",subtitle:u===0?"All rules passing":"Open the GapBar"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",margin:"0 0 12px 0"},children:"Layer Coverage"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[e.jsx(y,{layer:"requirements",label:"Requirements",count:t.requirementsCount,color:h.requirements,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"risk",label:"Risk",count:t.riskCount,color:h.risk,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"logical",label:"Architecture",count:t.architectureCount,color:h.logical,onClick:()=>{o("views"),n({type:"welcome"})}}),e.jsx(y,{layer:"verification",label:"Verification",count:t.verificationCount,color:h.verification,onClick:()=>n({type:"traceability"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"24px"},children:[a&&e.jsxs("div",{style:{background:a.urgency==="high"?"rgba(231,76,60,0.06)":a.urgency==="medium"?"rgba(243,156,18,0.06)":"rgba(46,204,113,0.06)",border:`1px solid ${a.urgency==="high"?"#E74C3C30":a.urgency==="medium"?"#F39C1230":"#2ECC7130"}`,borderRadius:"12px",padding:"20px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"10px"},children:"💡 Suggested Next Step"}),e.jsx("div",{style:{fontSize:"16px",marginBottom:"6px"},children:a.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px"},children:a.title}),e.jsx("div",{style:{fontSize:"12px",color:"#4B6E80",lineHeight:"1.6"},children:a.description}),a.urgency!=="low"&&e.jsx("button",{onClick:()=>n({type:"workflow-wizard"}),style:{marginTop:"14px",padding:"8px 14px",fontSize:"12px",fontWeight:600,background:"#1B3A4B",color:"#FFFFFF",border:"none",borderRadius:"6px",cursor:"pointer"},onMouseEnter:l=>l.currentTarget.style.background="#244D63",onMouseLeave:l=>l.currentTarget.style.background="#1B3A4B",children:"Open Workflow Wizard →"})]}),e.jsxs("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"20px",backdropFilter:"blur(4px)"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"14px"},children:"Quick Actions"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(x,{icon:"🗂️",label:"Browse Model",onClick:()=>{o("model"),r("/catalog")}}),e.jsx(x,{icon:"📊",label:"Open Viewpoints",onClick:()=>{o("views"),r("/diagrams")}}),e.jsx(x,{icon:"↔️",label:"Traceability Matrix",onClick:()=>n({type:"traceability"})}),e.jsx(x,{icon:"📋",label:"First Review Dashboard",onClick:()=>n({type:"review-dashboard"})}),e.jsx(x,{icon:"✅",label:"Check Completeness",onClick:()=>c()}),e.jsx(x,{icon:"📈",label:"Full Statistics",onClick:()=>n({type:"statistics"})})]})]})]}),t.diagramCount>0&&e.jsx("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"16px 20px",backdropFilter:"blur(4px)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:[t.diagramCount," model view",t.diagramCount!==1?"s":""," in this project"]}),e.jsx("button",{onClick:()=>o("views"),style:{fontSize:"12px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Browse viewpoints →"})]})})]})})}export{E as Dashboard};
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";import{u as g,H as j,h}from"./index-a2rpMs5Y.js";function k(i,d,s){var u,p;const n=Object.values(i.elements),o={},r={};for(const t of n)o[t.layer]=(o[t.layer]||0)+1,r[t.kind.toLowerCase()]=(r[t.kind.toLowerCase()]||0)+1;const c={};for(const t of i.relationships)c[t.type.toLowerCase()]=(c[t.type.toLowerCase()]||0)+1;return{totalElements:n.length,totalRelationships:i.relationships.length,violations:d,completenessPercent:s,riskCount:(o.risk||0)+(o.analysis||0),requirementsCount:o.requirements||0,architectureCount:["logical","physical","functional","logical_structure","software_structure","hardware_structure","functions","interfaces","system","context","operational","behavior"].reduce((t,a)=>t+(o[a]||0),0),verificationCount:(o.verification||0)+(o.assurance||0),hazardCount:r.hazard||0,requirementCount:Object.entries(r).filter(([t])=>t.endsWith("requirement")).reduce((t,[,a])=>t+a,0),riskControlCount:r.riskcontrol||0,systemCount:(r.system||0)+(r.subsystem||0)+(r.softwaresystem||0)+(r.logicalcomponent||0)+(r.hardwareassembly||0)+(r.softwarecomponent||0)+(r.processingnode||0),testCount:(r.verificationcase||0)+(r.validationcase||0)+(r.testartifact||0)+(r.test||0),mitigatesCount:Object.entries(c).filter(([t])=>t.startsWith("mitigat")).reduce((t,[,a])=>t+a,0),verificationLinkCount:Object.entries(c).filter(([t])=>t.startsWith("verif")||t.startsWith("validate")||t==="testedbyusability").reduce((t,[,a])=>t+a,0),diagramCount:((u=i.diagrams)==null?void 0:u.length)??0,projectName:((p=i.metadata)==null?void 0:p.projectName)||i.projectName||i.name||"My Device Project"}}function F(i){return i.totalElements===0?{icon:"🚀",title:"Add your first model elements",description:"Start with intended use, actors, and a system requirement. Or use the Workflow Wizard to guide you step by step.",urgency:"high"}:i.requirementCount===0?{icon:"📋",title:"Define your first requirement",description:"Your model has elements but no system requirements yet. Add a Requirement in the Model Explorer.",urgency:"high"}:i.hazardCount===0?{icon:"⚠️",title:"Add your first hazard",description:`You have ${i.requirementCount} requirement(s) but no hazard analysis yet. ISO 14971 requires hazard identification early.`,urgency:"high"}:i.hazardCount>0&&i.mitigatesCount===0?{icon:"🔗",title:"Connect hazards to risk controls",description:`You have ${i.hazardCount} hazard(s) but no MitigatesHazard relationships. Connect hazards to risk controls to complete the ISO 14971 chain.`,urgency:"high"}:i.systemCount===0?{icon:"🏗️",title:"Define your system architecture",description:"No architecture components found (SoftwareSystem, LogicalComponent, HardwareAssembly, …). Add an architecture layer to ground your requirements and risk analysis.",urgency:"medium"}:i.testCount===0?{icon:"🧪",title:"Add verification tests",description:`${i.requirementCount} requirement(s) have no verification tests yet. Add VerificationCases and link them to requirements with VerifiedBy.`,urgency:"medium"}:i.verificationLinkCount===0&&i.testCount>0?{icon:"↔️",title:"Link tests to requirements",description:"Verification cases exist but no VerifiedBy links found. Open the Traceability Matrix to connect tests to their requirements.",urgency:"medium"}:{icon:"✅",title:"Good coverage so far",description:"Requirements, hazards, and risk controls are in place. Check the GapBar (⌘⇧P) for completeness gaps before your review.",urgency:"low"}}function m({label:i,value:d,color:s,subtitle:n}){return e.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px 24px",display:"flex",flexDirection:"column",gap:"4px"},children:[e.jsx("div",{style:{fontSize:"28px",fontWeight:800,color:s,lineHeight:1},children:d}),e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"#374151"},children:i}),n&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function y({layer:i,label:d,count:s,color:n,onClick:o}){const r=s>0;return e.jsxs("button",{onClick:o,style:{background:r?`${n}12`:"#F9FAFB",border:`1px solid ${r?n+"30":"#E5E5E0"}`,borderRadius:"12px",padding:"16px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},onMouseEnter:c=>{c.currentTarget.style.background=r?`${n}20`:"#F3F4F6",c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)"},onMouseLeave:c=>{c.currentTarget.style.background=r?`${n}12`:"#F9FAFB",c.currentTarget.style.transform="none",c.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:r?n:"#9CA3AF"},children:d}),e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:r?n+"20":"#F3F4F6",color:r?n:"#9CA3AF"},children:[s," elements"]})]}),e.jsx("div",{style:{width:"100%",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:r?n:"transparent",width:r?`${Math.min(100,s/10*100)}%`:"0",transition:"width 0.4s ease"}})}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"8px"},children:r?"Click to explore →":"Not started"})]})}function x({icon:i,label:d,onClick:s,variant:n="secondary"}){const o=n==="primary";return e.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:600,border:"none",background:o?"#1B3A4B":"rgba(255,255,255,0.7)",color:o?"#FFFFFF":"#374151",backdropFilter:"blur(4px)",transition:"all 0.15s"},onMouseEnter:r=>{r.currentTarget.style.background=o?"#244D63":"rgba(255,255,255,0.95)",r.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.1)"},onMouseLeave:r=>{r.currentTarget.style.background=o?"#1B3A4B":"rgba(255,255,255,0.7)",r.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:d})]})}function E(){var b;const i=g(l=>l.model),d=g(l=>l.validation),s=g(l=>l.completeness),n=g(l=>l.setActiveView),o=g(l=>l.setExplorerTab),r=j(),c=g(l=>l.toggleGapBar),u=((b=d==null?void 0:d.violations)==null?void 0:b.length)??0,p=f.useMemo(()=>{if(typeof(s==null?void 0:s.overall)=="number")return Math.round(s.overall);if(!(s!=null&&s.layers)||s.layers.length===0)return 0;const l=s.layers.reduce((C,v)=>C+(v.completeness||0),0)/s.layers.length;return Math.round(l)},[s]),t=f.useMemo(()=>i?k(i,u,p):null,[i,u,p]),a=f.useMemo(()=>t?F(t):null,[t]);return!t||!i?e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"Loading dashboard…"})}):e.jsx("div",{style:{flex:1,overflowY:"auto",background:"linear-gradient(135deg, #EEF7F3 0%, #EAF2F8 55%, #F2EEF8 100%)",padding:"32px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{marginBottom:"28px"},children:[e.jsxs("div",{style:{position:"relative",width:260,height:154,overflow:"hidden",margin:"0 auto -10px",opacity:.62},title:"MEMO Architect","aria-label":"MEMO Architect",children:[e.jsx("img",{src:"/logo.png",alt:"","aria-hidden":"true",style:{width:260,height:260,objectFit:"contain",transform:"translateY(-32px)",mixBlendMode:"multiply"}}),e.jsx("span",{style:{position:"absolute",left:"59%",top:115,color:"#8B949E",fontSize:20,fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap"},children:"Architect"})]}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:t.projectName}),e.jsxs("p",{style:{fontSize:"13px",color:"#4B6E80",margin:0},children:["Model dashboard · ",new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px",marginBottom:"24px"},children:[e.jsx(m,{label:"Elements",value:t.totalElements,color:"#1B3A4B"}),e.jsx(m,{label:"Relationships",value:t.totalRelationships,color:"#4A90D9"}),e.jsx(m,{label:"Completeness",value:`${p}%`,color:p>=70?"#2ECC71":p>=40?"#F39C12":"#E74C3C"}),e.jsx(m,{label:"Violations",value:u,color:u===0?"#2ECC71":"#E74C3C",subtitle:u===0?"All rules passing":"Open the GapBar"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",margin:"0 0 12px 0"},children:"Layer Coverage"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[e.jsx(y,{layer:"requirements",label:"Requirements",count:t.requirementsCount,color:h.requirements,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"risk",label:"Risk",count:t.riskCount,color:h.risk,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"logical",label:"Architecture",count:t.architectureCount,color:h.logical,onClick:()=>{o("views"),n({type:"welcome"})}}),e.jsx(y,{layer:"verification",label:"Verification",count:t.verificationCount,color:h.verification,onClick:()=>n({type:"traceability"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"24px"},children:[a&&e.jsxs("div",{style:{background:a.urgency==="high"?"rgba(231,76,60,0.06)":a.urgency==="medium"?"rgba(243,156,18,0.06)":"rgba(46,204,113,0.06)",border:`1px solid ${a.urgency==="high"?"#E74C3C30":a.urgency==="medium"?"#F39C1230":"#2ECC7130"}`,borderRadius:"12px",padding:"20px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"10px"},children:"💡 Suggested Next Step"}),e.jsx("div",{style:{fontSize:"16px",marginBottom:"6px"},children:a.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px"},children:a.title}),e.jsx("div",{style:{fontSize:"12px",color:"#4B6E80",lineHeight:"1.6"},children:a.description}),a.urgency!=="low"&&e.jsx("button",{onClick:()=>n({type:"workflow-wizard"}),style:{marginTop:"14px",padding:"8px 14px",fontSize:"12px",fontWeight:600,background:"#1B3A4B",color:"#FFFFFF",border:"none",borderRadius:"6px",cursor:"pointer"},onMouseEnter:l=>l.currentTarget.style.background="#244D63",onMouseLeave:l=>l.currentTarget.style.background="#1B3A4B",children:"Open Workflow Wizard →"})]}),e.jsxs("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"20px",backdropFilter:"blur(4px)"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"14px"},children:"Quick Actions"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(x,{icon:"🗂️",label:"Browse Model",onClick:()=>{o("model"),r("/catalog")}}),e.jsx(x,{icon:"📊",label:"Open Viewpoints",onClick:()=>{o("views"),r("/diagrams")}}),e.jsx(x,{icon:"↔️",label:"Traceability Matrix",onClick:()=>n({type:"traceability"})}),e.jsx(x,{icon:"📋",label:"First Review Dashboard",onClick:()=>n({type:"review-dashboard"})}),e.jsx(x,{icon:"✅",label:"Check Completeness",onClick:()=>c()}),e.jsx(x,{icon:"📈",label:"Full Statistics",onClick:()=>n({type:"statistics"})})]})]})]}),t.diagramCount>0&&e.jsx("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"16px 20px",backdropFilter:"blur(4px)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:[t.diagramCount," model view",t.diagramCount!==1?"s":""," in this project"]}),e.jsx("button",{onClick:()=>o("views"),style:{fontSize:"12px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Browse viewpoints →"})]})})]})})}export{E as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as S}from"./index-CG-gfw-s.js";const y=[{id:"rmp",title:"Risk Management Plan",standards:["ISO 14971:2019 §4.4"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure","RiskAcceptabilityCriteria"],group:"risk"},{id:"har",title:"Hazard Analysis Report",standards:["ISO 14971:2019 §5","ISO 14971:2019 §6"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],group:"risk"},{id:"fmea",title:"Failure Mode and Effects Analysis",standards:["IEC 60812:2018"],layers:["risk","functional","physical"],relevantKinds:["Hazard","RiskControlMeasure","Function","Component","Subsystem"],group:"risk"},{id:"rtm",title:"Requirements Traceability Matrix",standards:["IEC 62304:2006 §5.1.1"],layers:["requirements","functional","verification"],relevantKinds:["Requirement","Requirement","DesignInput","DesignOutput","TestCase","VerificationActivity"],group:"design"},{id:"sad",title:"System Architecture Description",standards:["ISO/IEC/IEEE 42010:2022"],layers:["functional","logical","physical","software","interfaces"],relevantKinds:["Function","Component","Subsystem","Interface","Port","SoftwareElement","SOUPComponent"],group:"design"},{id:"sds",title:"Software Design Specification",standards:["IEC 62304:2006 §5.4"],layers:["software"],relevantKinds:["SoftwareElement","SoftwareUnit","SoftwareSystem","SOUPComponent","Interface"],group:"design"},{id:"soup",title:"SOUP List",standards:["IEC 62304:2006 §8.1.2"],layers:["software"],relevantKinds:["SOUPComponent"],group:"design"},{id:"dip",title:"Design Input Plan",standards:["ISO 13485:2016 §7.3.3"],layers:["requirements","business"],relevantKinds:["DesignInput","Requirement","Need","UseCase"],group:"design"},{id:"dop",title:"Design Output Plan",standards:["ISO 13485:2016 §7.3.4"],layers:["functional","physical","software"],relevantKinds:["DesignOutput","Component","SoftwareElement","Function"],group:"design"},{id:"vvp",title:"Verification & Validation Plan",standards:["ISO 13485:2016 §7.3.6"],layers:["verification"],relevantKinds:["TestCase","VerificationActivity","ValidationActivity","TestProtocol"],group:"verification"},{id:"vvr",title:"Verification & Validation Report",standards:["ISO 13485:2016 §7.3.7"],layers:["verification"],relevantKinds:["TestCase","VerificationActivity","ValidationActivity","TestResult"],group:"verification"},{id:"sdp",title:"Software Development Plan",standards:["IEC 62304:2006 §5.1"],layers:["software","verification"],relevantKinds:["SoftwareElement","SoftwareUnit","SoftwareSystem","TestCase"],group:"compliance"},{id:"csr",title:"Clinical Safety Report",standards:["ISO 14971:2019 §10"],layers:["risk","verification"],relevantKinds:["Hazard","RiskControlMeasure","ClinicalEvidence","ValidationActivity"],group:"compliance"},{id:"uer",title:"Usability Engineering Report",standards:["IEC 62366-1:2015"],layers:["ui","requirements"],relevantKinds:["UseCase","UserActivity","UserInterface","UsabilityRequirement"],group:"compliance"},{id:"cybersecurity",title:"Cybersecurity Documentation",standards:["IEC 81001-5-1:2021"],layers:["software","interfaces"],relevantKinds:["ThreatModel","SecurityControl","Interface","SOUPComponent"],group:"compliance"},{id:"labeling",title:"Labeling Specification",standards:["21 CFR 801"],layers:["requirements","ui"],relevantKinds:["LabelingRequirement","Requirement"],group:"compliance"},{id:"dhf-index",title:"Design History File Index",standards:["ISO 13485:2016 §4.2.4"],layers:[],relevantKinds:[],group:"all"},{id:"change-log",title:"Design Change Log",standards:["ISO 13485:2016 §7.3.9"],layers:[],relevantKinds:[],group:"all"}],k={risk:"Risk Management",design:"Design & Architecture",verification:"Verification & Validation",compliance:"Compliance & Standards",all:"General"},C={risk:"#E74C3C",design:"#4A90D9",verification:"#2ECC71",compliance:"#8E44AD",all:"#6B7280"};function I(s,i,r){const a=Object.values(i.elements).filter(l=>s.relevantKinds.includes(l.kind)),x=((r==null?void 0:r.violations)||[]).filter(l=>s.relevantKinds.includes(l.elementKind)||s.layers.includes(l.layer)),p=x.filter(l=>l.severity==="error").length;return{elementCount:a.length,gapCount:p,status:a.length===0?"empty":p===0?"complete":"partial",violations:x}}function M(){const s=S(t=>t.model),i=S(t=>t.validation),r=S(t=>t.completeness),[a,x]=g.useState(null),[p,l]=g.useState(null),[n,c]=g.useState(!1),f=s==null?void 0:s.standardsReport,b=g.useMemo(()=>{const t=new Map;if(!f)return t;for(const o of f.standards){const d=o.totals.gaps;if(d!==0)for(const u of y)for(const j of u.standards)j.startsWith(o.designation.split(":")[0])&&t.set(u.id,(t.get(u.id)??0)+d)}return t},[f]),v=g.useMemo(()=>{if(!s)return new Map;const t=new Map;for(const o of y)t.set(o.id,I(o,s,i));return t},[s,i]),B=g.useMemo(()=>{let t=y;return p&&(t=t.filter(o=>o.group===p||o.group==="all")),n&&(t=t.filter(o=>(b.get(o.id)??0)>0)),t},[p,n,b]),w=g.useMemo(()=>{const t=new Map;for(const o of B){const d=o.group;t.has(d)||t.set(d,[]),t.get(d).push(o)}return t},[B]),m=g.useMemo(()=>{let t=0,o=0,d=0;for(const u of v.values())u.status==="complete"?t++:u.status==="partial"?o++:d++;return{complete:t,partial:o,empty:d,total:y.length}},[v]);if(!s)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data..."});const R=a?y.find(t=>t.id===a):null,D=a?v.get(a):null;return e.jsxs("div",{style:{height:"100%",overflow:"auto",background:"#F7F7F5",padding:"24px"},children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1B3A4B",margin:0},children:"Documents"}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"13px",marginTop:"4px"},children:["Design history file · ",m.total," documents | ",m.complete," complete | ",m.partial," partial | ",m.empty," empty",r&&` | Overall completeness: ${r.overall}%`]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"12px",marginBottom:"24px"},children:[e.jsx(h,{label:"Complete",value:m.complete,color:"#059669"}),e.jsx(h,{label:"Partial",value:m.partial,color:"#d97706"}),e.jsx(h,{label:"Empty",value:m.empty,color:"#dc2626"}),e.jsx(h,{label:"Completeness",value:`${(r==null?void 0:r.overall)||0}%`,color:"#2563eb"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"20px",flexWrap:"wrap"},children:[e.jsx(A,{label:"All",active:!p&&!n,onClick:()=>{l(null),c(!1)}}),Object.entries(k).filter(([t])=>t!=="all").map(([t,o])=>e.jsx(A,{label:o,active:p===t,onClick:()=>{l(p===t?null:t),c(!1)},color:C[t]},t)),f&&e.jsx(A,{label:`Has gaps (${b.size})`,active:n,onClick:()=>{c(!n),l(null)},color:"#dc2626"})]}),a?e.jsx(E,{doc:R,status:D,model:s,validation:i,onBack:()=>x(null)}):Array.from(w.entries()).map(([t,o])=>e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:C[t]||"#374151",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:C[t]||"#6B7280",display:"inline-block"}}),k[t]||t]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},children:o.map(d=>{const u=v.get(d.id),j=b.get(d.id)??0;return e.jsx(z,{doc:d,status:u,standardsGap:j,onClick:()=>x(d.id)},d.id)})})]},t))]})}function h({label:s,value:i,color:r}){return e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"14px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:700,color:r},children:i}),e.jsx("div",{style:{fontSize:"11px",color:"#6B7280",marginTop:"2px"},children:s})]})}function A({label:s,active:i,onClick:r,color:a}){return e.jsx("button",{onClick:r,style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:500,border:`1px solid ${i?a||"#2DD4A8":"#e5e7eb"}`,background:i?(a||"#2DD4A8")+"15":"#fff",color:i?a||"#1B3A4B":"#6B7280",cursor:"pointer"},children:s})}function z({doc:s,status:i,standardsGap:r=0,onClick:a}){const x=i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626",p=i.status==="complete"?"#ecfdf5":i.status==="partial"?"#fffbeb":"#fef2f2",l=i.status==="complete"?"Complete":i.status==="partial"?"Partial":"Empty";return e.jsxs("div",{onClick:a,style:{background:"#fff",border:`1px solid ${r>0?"#fecaca":"#e5e7eb"}`,borderRadius:"8px",padding:"16px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},onMouseEnter:n=>{n.currentTarget.style.borderColor="#2DD4A8",n.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)"},onMouseLeave:n=>{n.currentTarget.style.borderColor=r>0?"#fecaca":"#e5e7eb",n.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:"#6B7280",fontFamily:"monospace"},children:s.id.toUpperCase()}),e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[r>0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:"#fef2f2",color:"#dc2626"},title:`${r} standard clause${r!==1?"s":""} unclaimed`,children:[r," clauses"]}),e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:p,color:x},children:l})]})]}),e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"#1B3A4B",marginBottom:"6px"},children:s.title}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"8px"},children:s.standards[0]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"12px",color:"#6B7280"},children:[e.jsxs("span",{children:[i.elementCount," elements"]}),i.gapCount>0&&e.jsxs("span",{style:{color:"#dc2626"},children:[i.gapCount," gaps"]})]})]})}function E({doc:s,status:i,model:r,validation:a,onBack:x}){const p=Object.values(r.elements).filter(n=>s.relevantKinds.includes(n.kind)),l=new Map;for(const n of p)l.has(n.kind)||l.set(n.kind,[]),l.get(n.kind).push(n);return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("button",{onClick:x,style:{background:"none",border:"none",color:"#2563eb",cursor:"pointer",fontSize:"13px",padding:0,marginBottom:"8px"},children:"← Back to dashboard"}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:700,color:"#1B3A4B",margin:0},children:s.title}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"12px",marginTop:"4px"},children:[s.id.toUpperCase()," | ",s.standards.join(", ")]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:"12px",marginBottom:"20px"},children:[e.jsx(h,{label:"Elements",value:i.elementCount,color:"#2563eb"}),e.jsx(h,{label:"Gaps",value:i.gapCount,color:i.gapCount>0?"#dc2626":"#059669"}),e.jsx(h,{label:"Status",value:i.status,color:i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626"})]}),Array.from(l.entries()).sort().map(([n,c])=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#374151",marginBottom:"8px"},children:[n," (",c.length,")"]}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f3f4f6"},children:[e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Name"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Layer"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Description"})]})}),e.jsx("tbody",{children:c.slice(0,50).map(f=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb",fontWeight:500},children:f.name}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:f.layer}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.doc||"—"})]},f.id))})]}),c.length>50&&e.jsxs("div",{style:{padding:"8px 10px",fontSize:"11px",color:"#9CA3AF",background:"#f9fafb"},children:["...and ",c.length-50," more"]})]})]},n)),i.violations.length>0&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#dc2626",marginBottom:"8px"},children:["Validation Issues (",i.violations.length,")"]}),e.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f3f4f6"},children:[e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Severity"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Rule"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Element"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Description"})]})}),e.jsx("tbody",{children:i.violations.slice(0,50).map((n,c)=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px"},children:e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"3px",background:n.severity==="error"?"#fef2f2":"#fffbeb",color:n.severity==="error"?"#dc2626":"#d97706"},children:n.severity})}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",fontFamily:"monospace",fontSize:"11px"},children:n.ruleId}),e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb"},children:n.elementName}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:n.description})]},c))})]})})]}),p.length===0&&e.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"#9CA3AF",background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px"},children:[e.jsx("p",{style:{fontSize:"14px",marginBottom:"4px"},children:"No model elements found for this document type."}),e.jsxs("p",{style:{fontSize:"12px"},children:["Add elements of kinds: ",s.relevantKinds.join(", ")]})]})]})}export{M as DhfDashboard};
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as S}from"./index-a2rpMs5Y.js";const y=[{id:"rmp",title:"Risk Management Plan",standards:["ISO 14971:2019 §4.4"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure","RiskAcceptabilityCriteria"],group:"risk"},{id:"har",title:"Hazard Analysis Report",standards:["ISO 14971:2019 §5","ISO 14971:2019 §6"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],group:"risk"},{id:"fmea",title:"Failure Mode and Effects Analysis",standards:["IEC 60812:2018"],layers:["risk","functional","physical"],relevantKinds:["Hazard","RiskControlMeasure","Function","Component","Subsystem"],group:"risk"},{id:"rtm",title:"Requirements Traceability Matrix",standards:["IEC 62304:2006 §5.1.1"],layers:["requirements","functional","verification"],relevantKinds:["Requirement","Requirement","DesignInput","DesignOutput","TestCase","VerificationActivity"],group:"design"},{id:"sad",title:"System Architecture Description",standards:["ISO/IEC/IEEE 42010:2022"],layers:["functional","logical","physical","software","interfaces"],relevantKinds:["Function","Component","Subsystem","Interface","Port","SoftwareElement","SOUPComponent"],group:"design"},{id:"sds",title:"Software Design Specification",standards:["IEC 62304:2006 §5.4"],layers:["software"],relevantKinds:["SoftwareElement","SoftwareUnit","SoftwareSystem","SOUPComponent","Interface"],group:"design"},{id:"soup",title:"SOUP List",standards:["IEC 62304:2006 §8.1.2"],layers:["software"],relevantKinds:["SOUPComponent"],group:"design"},{id:"dip",title:"Design Input Plan",standards:["ISO 13485:2016 §7.3.3"],layers:["requirements","business"],relevantKinds:["DesignInput","Requirement","Need","UseCase"],group:"design"},{id:"dop",title:"Design Output Plan",standards:["ISO 13485:2016 §7.3.4"],layers:["functional","physical","software"],relevantKinds:["DesignOutput","Component","SoftwareElement","Function"],group:"design"},{id:"vvp",title:"Verification & Validation Plan",standards:["ISO 13485:2016 §7.3.6"],layers:["verification"],relevantKinds:["TestCase","VerificationActivity","ValidationActivity","TestProtocol"],group:"verification"},{id:"vvr",title:"Verification & Validation Report",standards:["ISO 13485:2016 §7.3.7"],layers:["verification"],relevantKinds:["TestCase","VerificationActivity","ValidationActivity","TestResult"],group:"verification"},{id:"sdp",title:"Software Development Plan",standards:["IEC 62304:2006 §5.1"],layers:["software","verification"],relevantKinds:["SoftwareElement","SoftwareUnit","SoftwareSystem","TestCase"],group:"compliance"},{id:"csr",title:"Clinical Safety Report",standards:["ISO 14971:2019 §10"],layers:["risk","verification"],relevantKinds:["Hazard","RiskControlMeasure","ClinicalEvidence","ValidationActivity"],group:"compliance"},{id:"uer",title:"Usability Engineering Report",standards:["IEC 62366-1:2015"],layers:["ui","requirements"],relevantKinds:["UseCase","UserActivity","UserInterface","UsabilityRequirement"],group:"compliance"},{id:"cybersecurity",title:"Cybersecurity Documentation",standards:["IEC 81001-5-1:2021"],layers:["software","interfaces"],relevantKinds:["ThreatModel","SecurityControl","Interface","SOUPComponent"],group:"compliance"},{id:"labeling",title:"Labeling Specification",standards:["21 CFR 801"],layers:["requirements","ui"],relevantKinds:["LabelingRequirement","Requirement"],group:"compliance"},{id:"dhf-index",title:"Design History File Index",standards:["ISO 13485:2016 §4.2.4"],layers:[],relevantKinds:[],group:"all"},{id:"change-log",title:"Design Change Log",standards:["ISO 13485:2016 §7.3.9"],layers:[],relevantKinds:[],group:"all"}],k={risk:"Risk Management",design:"Design & Architecture",verification:"Verification & Validation",compliance:"Compliance & Standards",all:"General"},C={risk:"#E74C3C",design:"#4A90D9",verification:"#2ECC71",compliance:"#8E44AD",all:"#6B7280"};function I(s,i,r){const a=Object.values(i.elements).filter(l=>s.relevantKinds.includes(l.kind)),x=((r==null?void 0:r.violations)||[]).filter(l=>s.relevantKinds.includes(l.elementKind)||s.layers.includes(l.layer)),p=x.filter(l=>l.severity==="error").length;return{elementCount:a.length,gapCount:p,status:a.length===0?"empty":p===0?"complete":"partial",violations:x}}function M(){const s=S(t=>t.model),i=S(t=>t.validation),r=S(t=>t.completeness),[a,x]=g.useState(null),[p,l]=g.useState(null),[n,c]=g.useState(!1),f=s==null?void 0:s.standardsReport,b=g.useMemo(()=>{const t=new Map;if(!f)return t;for(const o of f.standards){const d=o.totals.gaps;if(d!==0)for(const u of y)for(const j of u.standards)j.startsWith(o.designation.split(":")[0])&&t.set(u.id,(t.get(u.id)??0)+d)}return t},[f]),v=g.useMemo(()=>{if(!s)return new Map;const t=new Map;for(const o of y)t.set(o.id,I(o,s,i));return t},[s,i]),B=g.useMemo(()=>{let t=y;return p&&(t=t.filter(o=>o.group===p||o.group==="all")),n&&(t=t.filter(o=>(b.get(o.id)??0)>0)),t},[p,n,b]),w=g.useMemo(()=>{const t=new Map;for(const o of B){const d=o.group;t.has(d)||t.set(d,[]),t.get(d).push(o)}return t},[B]),m=g.useMemo(()=>{let t=0,o=0,d=0;for(const u of v.values())u.status==="complete"?t++:u.status==="partial"?o++:d++;return{complete:t,partial:o,empty:d,total:y.length}},[v]);if(!s)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data..."});const R=a?y.find(t=>t.id===a):null,D=a?v.get(a):null;return e.jsxs("div",{style:{height:"100%",overflow:"auto",background:"#F7F7F5",padding:"24px"},children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1B3A4B",margin:0},children:"Documents"}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"13px",marginTop:"4px"},children:["Design history file · ",m.total," documents | ",m.complete," complete | ",m.partial," partial | ",m.empty," empty",r&&` | Overall completeness: ${r.overall}%`]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"12px",marginBottom:"24px"},children:[e.jsx(h,{label:"Complete",value:m.complete,color:"#059669"}),e.jsx(h,{label:"Partial",value:m.partial,color:"#d97706"}),e.jsx(h,{label:"Empty",value:m.empty,color:"#dc2626"}),e.jsx(h,{label:"Completeness",value:`${(r==null?void 0:r.overall)||0}%`,color:"#2563eb"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"20px",flexWrap:"wrap"},children:[e.jsx(A,{label:"All",active:!p&&!n,onClick:()=>{l(null),c(!1)}}),Object.entries(k).filter(([t])=>t!=="all").map(([t,o])=>e.jsx(A,{label:o,active:p===t,onClick:()=>{l(p===t?null:t),c(!1)},color:C[t]},t)),f&&e.jsx(A,{label:`Has gaps (${b.size})`,active:n,onClick:()=>{c(!n),l(null)},color:"#dc2626"})]}),a?e.jsx(E,{doc:R,status:D,model:s,validation:i,onBack:()=>x(null)}):Array.from(w.entries()).map(([t,o])=>e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:C[t]||"#374151",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:C[t]||"#6B7280",display:"inline-block"}}),k[t]||t]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},children:o.map(d=>{const u=v.get(d.id),j=b.get(d.id)??0;return e.jsx(z,{doc:d,status:u,standardsGap:j,onClick:()=>x(d.id)},d.id)})})]},t))]})}function h({label:s,value:i,color:r}){return e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"14px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:700,color:r},children:i}),e.jsx("div",{style:{fontSize:"11px",color:"#6B7280",marginTop:"2px"},children:s})]})}function A({label:s,active:i,onClick:r,color:a}){return e.jsx("button",{onClick:r,style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:500,border:`1px solid ${i?a||"#2DD4A8":"#e5e7eb"}`,background:i?(a||"#2DD4A8")+"15":"#fff",color:i?a||"#1B3A4B":"#6B7280",cursor:"pointer"},children:s})}function z({doc:s,status:i,standardsGap:r=0,onClick:a}){const x=i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626",p=i.status==="complete"?"#ecfdf5":i.status==="partial"?"#fffbeb":"#fef2f2",l=i.status==="complete"?"Complete":i.status==="partial"?"Partial":"Empty";return e.jsxs("div",{onClick:a,style:{background:"#fff",border:`1px solid ${r>0?"#fecaca":"#e5e7eb"}`,borderRadius:"8px",padding:"16px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},onMouseEnter:n=>{n.currentTarget.style.borderColor="#2DD4A8",n.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)"},onMouseLeave:n=>{n.currentTarget.style.borderColor=r>0?"#fecaca":"#e5e7eb",n.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:"#6B7280",fontFamily:"monospace"},children:s.id.toUpperCase()}),e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[r>0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:"#fef2f2",color:"#dc2626"},title:`${r} standard clause${r!==1?"s":""} unclaimed`,children:[r," clauses"]}),e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:p,color:x},children:l})]})]}),e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"#1B3A4B",marginBottom:"6px"},children:s.title}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"8px"},children:s.standards[0]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"12px",color:"#6B7280"},children:[e.jsxs("span",{children:[i.elementCount," elements"]}),i.gapCount>0&&e.jsxs("span",{style:{color:"#dc2626"},children:[i.gapCount," gaps"]})]})]})}function E({doc:s,status:i,model:r,validation:a,onBack:x}){const p=Object.values(r.elements).filter(n=>s.relevantKinds.includes(n.kind)),l=new Map;for(const n of p)l.has(n.kind)||l.set(n.kind,[]),l.get(n.kind).push(n);return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("button",{onClick:x,style:{background:"none",border:"none",color:"#2563eb",cursor:"pointer",fontSize:"13px",padding:0,marginBottom:"8px"},children:"← Back to dashboard"}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:700,color:"#1B3A4B",margin:0},children:s.title}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"12px",marginTop:"4px"},children:[s.id.toUpperCase()," | ",s.standards.join(", ")]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:"12px",marginBottom:"20px"},children:[e.jsx(h,{label:"Elements",value:i.elementCount,color:"#2563eb"}),e.jsx(h,{label:"Gaps",value:i.gapCount,color:i.gapCount>0?"#dc2626":"#059669"}),e.jsx(h,{label:"Status",value:i.status,color:i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626"})]}),Array.from(l.entries()).sort().map(([n,c])=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#374151",marginBottom:"8px"},children:[n," (",c.length,")"]}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f3f4f6"},children:[e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Name"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Layer"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Description"})]})}),e.jsx("tbody",{children:c.slice(0,50).map(f=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb",fontWeight:500},children:f.name}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:f.layer}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.doc||"—"})]},f.id))})]}),c.length>50&&e.jsxs("div",{style:{padding:"8px 10px",fontSize:"11px",color:"#9CA3AF",background:"#f9fafb"},children:["...and ",c.length-50," more"]})]})]},n)),i.violations.length>0&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#dc2626",marginBottom:"8px"},children:["Validation Issues (",i.violations.length,")"]}),e.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f3f4f6"},children:[e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Severity"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Rule"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Element"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Description"})]})}),e.jsx("tbody",{children:i.violations.slice(0,50).map((n,c)=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px"},children:e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"3px",background:n.severity==="error"?"#fef2f2":"#fffbeb",color:n.severity==="error"?"#dc2626":"#d97706"},children:n.severity})}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",fontFamily:"monospace",fontSize:"11px"},children:n.ruleId}),e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb"},children:n.elementName}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:n.description})]},c))})]})})]}),p.length===0&&e.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"#9CA3AF",background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px"},children:[e.jsx("p",{style:{fontSize:"14px",marginBottom:"4px"},children:"No model elements found for this document type."}),e.jsxs("p",{style:{fontSize:"12px"},children:["Add elements of kinds: ",s.relevantKinds.join(", ")]})]})]})}export{M as DhfDashboard};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{u as $,p as te,M as oe,_ as ne}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-a2rpMs5Y.js","assets/reactflow-C9OlmOYw.js","assets/zustand-CrhqMOHB.js","assets/index-Cdkjp-H4.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as $,p as te,M as oe,_ as ne}from"./index-a2rpMs5Y.js";import{j as e}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";const re=/<div class="memo-doc-diagram" data-diagram-id="([^"]*)"><\/div>/;function m(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function U(t,r){const n=t.split(`
|
|
3
3
|
`).map(o=>o.trim()).filter(Boolean);return n.length===0?`<tr><td colspan="4" style="color:#9CA3AF;font-style:italic">No ${r.toLowerCase()}s defined</td></tr>`:n.map(o=>{const[s="",a=""]=o.split("|").map(u=>u.trim());return`<tr><td>${m(s)}</td><td>${m(a||r)}</td><td style="color:#9CA3AF">—</td><td style="color:#9CA3AF">—</td></tr>`}).join("")}function ie(t){const r=t.authors.trim().length>0,n=t.approvers.trim().length>0,o="<thead><tr><th>Name</th><th>Role</th><th>Signature</th><th>Date</th></tr></thead>";return`
|
|
4
4
|
<h2>Authors</h2>
|
|
5
5
|
<table>${o}<tbody>${U(t.authors,"Author")}</tbody></table>
|
|
@@ -60,7 +60,7 @@ ${o.word?'<meta name="ProgId" content="Word.Document"><!--[if gte mso 9]><xml><w
|
|
|
60
60
|
<style>${X(n)}${ce}${o.word?pe:""}</style>
|
|
61
61
|
</head>
|
|
62
62
|
<body>${a}</body>
|
|
63
|
-
</html>`}function G(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function L(t,r,n){const o=new Blob([r],{type:n}),s=URL.createObjectURL(o),a=document.createElement("a");a.href=s,a.download=t,a.click(),URL.revokeObjectURL(s)}function he(t,r,n){L(`${t.id}.html`,H(t,r,n),"text/html;charset=utf-8")}function xe(t,r,n){L(`${t.id}.doc`,H(t,r,n,{word:!0}),"application/msword")}function fe(t){L(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function ge(t,r,n){const o=window.open("","_blank");o&&(o.document.write(H(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const Y=f.lazy(()=>ne(()=>import("./index-
|
|
63
|
+
</html>`}function G(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function L(t,r,n){const o=new Blob([r],{type:n}),s=URL.createObjectURL(o),a=document.createElement("a");a.href=s,a.download=t,a.click(),URL.revokeObjectURL(s)}function he(t,r,n){L(`${t.id}.html`,H(t,r,n),"text/html;charset=utf-8")}function xe(t,r,n){L(`${t.id}.doc`,H(t,r,n,{word:!0}),"application/msword")}function fe(t){L(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function ge(t,r,n){const o=window.open("","_blank");o&&(o.document.write(H(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const Y=f.lazy(()=>ne(()=>import("./index-a2rpMs5Y.js").then(t=>t.a0),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.DhfSettingsPanel}))),K=[{id:"q-hazards",label:"Hazard Table",description:"All hazards in the risk layer",category:"query",code:'```memo-query\nkind: Hazard\ndisplay: table\ncolumns: name, layer, doc\nsort: name\nempty: "No hazards defined."\n```'},{id:"q-hazardous-situations",label:"Hazardous Situations",description:"All hazardous situations",category:"query",code:"```memo-query\nkind: HazardousSituation\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-risk-controls",label:"Risk Controls",description:"All risk control measures",category:"query",code:"```memo-query\nkind: RiskControlMeasure\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-requirements",label:"Requirements",description:"All system requirements",category:"query",code:"```memo-query\nkind: Requirement\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-soup",label:"SOUP List",description:"All SOUP components",category:"query",code:"```memo-query\nkind: SOUPComponent\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-sw-items",label:"Software Items",description:"All software items",category:"query",code:"```memo-query\nkind: SoftwareElement\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-test-cases",label:"Test Cases",description:"All test cases",category:"query",code:"```memo-query\nkind: TestCase\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-hazard-count",label:"Hazard Count (metric)",description:"Metric badge with hazard count",category:"query",code:"```memo-query\nkind: Hazard\ndisplay: count\nlabel: Total hazards\n```"},{id:"s-unmitigated",label:"Unmitigated Hazards",description:"Hazards without risk controls",category:"script",code:"```memo-script\nconst hazards = query({ kind: 'Hazard' });\nconst unmitigated = hazards.filter(h => h.mitigatedBy?.length === 0);\nif (unmitigated.length === 0) return 'All hazards have associated risk controls.';\nreturn table(unmitigated, ['name', 'layer', 'doc']);\n```"},{id:"s-coverage",label:"Requirements Coverage",description:"Requirements with/without test cases",category:"script",code:"```memo-script\nconst reqs = query({ kind: 'Requirement' });\nconst covered = reqs.filter(r => r.verifiedBy?.length > 0);\nreturn count(covered, `covered of ${reqs.length} requirements`);\n```"},{id:"i-doc-header",label:"Document Control Header",description:"Standard doc control table",category:"include",code:"{{include:shared/snippets/document-control-header.md}}"},{id:"i-approval",label:"Approval Block",description:"Reviewer/approver signature table",category:"include",code:"{{include:shared/snippets/approval-block.md}}"},{id:"i-revision",label:"Revision History",description:"Revision history table",category:"include",code:"{{include:shared/snippets/revision-history-table.md}}"},{id:"i-references",label:"References Section",description:"Normative references block",category:"include",code:"{{include:shared/snippets/references-section.md}}"},{id:"d-toc",label:"Table of Contents",description:"Auto-generated TOC (on export)",category:"directive",code:"{{toc}}"},{id:"d-glossary",label:"Glossary",description:"Auto-generated glossary (on export)",category:"directive",code:"{{glossary}}"}],Z={query:"#2563eb",script:"#7c3aed",include:"#0891b2",directive:"#6B7280"},ee={query:"Query",script:"Script",include:"Snippet",directive:"Directive"};function $e(){const t=$(i=>i.model),r=$(i=>i.activeView),n=$(i=>i.dhfDocuments),o=$(i=>i.updateDhfDocumentContent),s=$(i=>i.updateDhfDocumentMeta),a=$(i=>i.llmAvailable),u=$(i=>i.registerLlmRequest),l=$(i=>i.dhfSettings),[d,x]=f.useState("split"),p=f.useRef(null),[j,c]=f.useState(!1),[k,y]=f.useState(null),[b,w]=f.useState(!1),[g,B]=f.useState(!1),[F,M]=f.useState(!1),[z,h]=f.useState("all"),C=f.useCallback(async(i,A)=>{c(!0),y(null);const W=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`,_=A.split("/").pop()??A;try{const E=await new Promise((O,I)=>{u(W,O,I),te(W,_),setTimeout(()=>I(new Error("Request timed out after 120 seconds.")),12e4)});o(i,E.markdown)}catch(E){y((E==null?void 0:E.message)??"Unknown error")}finally{c(!1)}},[u,o]),R=f.useCallback(i=>{if(!p.current)return;const A=p.current,W=A.selectionStart,_=A.selectionEnd,E=`
|
|
64
64
|
|
|
65
65
|
${i.code}
|
|
66
66
|
|