@memoarchitect/architect 0.6.6 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +26 -4
  2. package/dist/assets/AiWorkspace-Bu9TlIWg.js +7 -0
  3. package/dist/assets/AnalysisWorkspace-CodmoI-v.js +39 -0
  4. package/dist/assets/{ComplianceWizard-k98NZ2ec.js → ComplianceWizard-CTihkUi-.js} +1 -1
  5. package/dist/assets/DSMView-BiC845df.js +1 -0
  6. package/dist/assets/Dashboard-CgnNLhKq.js +1 -0
  7. package/dist/assets/{DhfDashboard-B9V_n7kg.js → DhfDashboard-w-dJoJHU.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-TOnZkdUU.js → DhfWorkbench-o6B_MT-0.js} +15 -15
  9. package/dist/assets/DiagramCanvas-CqGqDbgT.js +3 -0
  10. package/dist/assets/DiagramEditor-UJDHcAUF.js +4 -0
  11. package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +1 -0
  12. package/dist/assets/ElementDetailView-10U0rr33.js +2 -0
  13. package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +3 -0
  14. package/dist/assets/{ImportView-CyMm-tSP.js → ImportView-D8svP04Q.js} +1 -1
  15. package/dist/assets/{LayerGrid-DNPZYTsD.js → LayerGrid-DEe0Ryz-.js} +1 -1
  16. package/dist/assets/{LayerTable-DhOq1DHo.js → LayerTable-CN_b2rDr.js} +2 -2
  17. package/dist/assets/{MaxGraphCanvas-DqKU1PTY.js → MaxGraphCanvas-bo8oPBct.js} +6 -6
  18. package/dist/assets/{ModelDiff-BbqIoesG.js → ModelDiff-xe95oVua.js} +1 -1
  19. package/dist/assets/OntologyDecompositionDiagram-BL9R8bdB.js +1 -0
  20. package/dist/assets/{OntologyViewer-BIpJC66j.js → OntologyViewer-CtqNkkCn.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-B9bqt4zl.js → RelationshipOverlay-DL0N8Vmk.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-DttMvF2i.js → RelationshipsSection-BoJ0aUXe.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-DKoExM8K.js → ReviewDashboard-DeTge2oC.js} +1 -1
  24. package/dist/assets/ScenarioEditor-FAEYTHgP.js +3 -0
  25. package/dist/assets/{StatisticsDashboard-B8BduIDz.js → StatisticsDashboard-BAZRqIPN.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-Die2RUsz.js → SysmlCodeEditor-BBfup_Ni.js} +1 -1
  27. package/dist/assets/TabularView-I4LjHhoH.js +1 -0
  28. package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +1 -0
  30. package/dist/assets/{WorkflowWizard-7--f9OH2.js → WorkflowWizard-VwpEHt3R.js} +1 -1
  31. package/dist/assets/element-options-B7AgTB8R.js +3 -0
  32. package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
  33. package/dist/assets/index-BWMNo4wW.css +1 -0
  34. package/dist/assets/index-Bij8Q4Kg.js +45 -0
  35. package/dist/assets/index.es-ClbJxlAQ.js +18 -0
  36. package/dist/assets/jspdf.es.min-DZ68BGxk.js +170 -0
  37. package/dist/assets/notation-scene-DT8LpWVK.js +1 -0
  38. package/dist/assets/purify.es-DP5U8-sc.js +3 -0
  39. package/dist/assets/{reactflow-CsCqNKB-.js → reactflow-s7jmJtXx.js} +5 -5
  40. package/dist/index.html +3 -3
  41. package/lib/__tests__/compiler-bundling.test.d.ts +2 -0
  42. package/lib/__tests__/compiler-bundling.test.d.ts.map +1 -0
  43. package/lib/__tests__/compiler-bundling.test.js +32 -0
  44. package/lib/__tests__/compiler-bundling.test.js.map +1 -0
  45. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts +2 -0
  46. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts.map +1 -0
  47. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js +22 -0
  48. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js.map +1 -0
  49. package/lib/__tests__/supervised-child-args.test.d.ts +2 -0
  50. package/lib/__tests__/supervised-child-args.test.d.ts.map +1 -0
  51. package/lib/__tests__/supervised-child-args.test.js +35 -0
  52. package/lib/__tests__/supervised-child-args.test.js.map +1 -0
  53. package/lib/bin/memo-architect.js +30 -4
  54. package/lib/bin/memo-architect.js.map +1 -1
  55. package/lib/commands/dev.d.ts +18 -2
  56. package/lib/commands/dev.d.ts.map +1 -1
  57. package/lib/commands/dev.js +56 -8
  58. package/lib/commands/dev.js.map +1 -1
  59. package/lib/commands/example.d.ts +1 -0
  60. package/lib/commands/example.d.ts.map +1 -1
  61. package/lib/commands/example.js +2 -0
  62. package/lib/commands/example.js.map +1 -1
  63. package/package.json +11 -5
  64. package/dist/assets/AiWorkspace-DS79vBOT.js +0 -3
  65. package/dist/assets/AnalysisWorkspace-D_u4shRY.js +0 -39
  66. package/dist/assets/DSMView-DGheBwZ0.js +0 -1
  67. package/dist/assets/Dashboard-BRUQvUFK.js +0 -1
  68. package/dist/assets/DhfSettingsPanel-B8aLsWn6.js +0 -1
  69. package/dist/assets/DiagramCanvas-B9d4aLKt.js +0 -1
  70. package/dist/assets/DiagramEditor-CJ7OG2IC.js +0 -4
  71. package/dist/assets/ElementDetailView-CDcm1rvf.js +0 -2
  72. package/dist/assets/OntologyDecompositionDiagram-DkxTe2C_.js +0 -1
  73. package/dist/assets/ScenarioEditor-JQ3huCnz.js +0 -3
  74. package/dist/assets/TabularView-BXfFSluC.js +0 -1
  75. package/dist/assets/TraceabilityMatrix-CHZHFucA.js +0 -1
  76. package/dist/assets/index-CVW92JY7.js +0 -3280
  77. package/dist/assets/index-Y1UZTZg-.css +0 -1
  78. package/dist/assets/layout-selection-ClQ295Xc.js +0 -1
@@ -1,3280 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ScenarioEditor-JQ3huCnz.js","assets/reactflow-CsCqNKB-.js","assets/zustand-CrhqMOHB.js","assets/DiagramEditor-CJ7OG2IC.js","assets/DSMView-DGheBwZ0.js","assets/OntologyViewer-BIpJC66j.js","assets/TraceabilityMatrix-CHZHFucA.js","assets/ModelDiff-BbqIoesG.js","assets/ComplianceWizard-k98NZ2ec.js","assets/StatisticsDashboard-B8BduIDz.js","assets/DhfDashboard-B9V_n7kg.js","assets/DhfWorkbench-TOnZkdUU.js","assets/AiWorkspace-DS79vBOT.js","assets/ElementDetailView-CDcm1rvf.js","assets/Dashboard-BRUQvUFK.js","assets/ReviewDashboard-DKoExM8K.js","assets/WorkflowWizard-7--f9OH2.js","assets/TabularView-BXfFSluC.js","assets/ImportView-CyMm-tSP.js","assets/AnalysisWorkspace-D_u4shRY.js"])))=>i.map(i=>d[i]);
2
- import{r as Ir,j as t}from"./reactflow-CsCqNKB-.js";import{a as p,b as Un,W as _r}from"./zustand-CrhqMOHB.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var et={},an;function Nr(){if(an)return et;an=1;var e=Ir();return et.createRoot=e.createRoot,et.hydrateRoot=e.hydrateRoot,et}var Mr=Nr();/**
3
- * react-router v7.13.2
4
- *
5
- * Copyright (c) Remix Software Inc.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE.md file in the root directory of this source tree.
9
- *
10
- * @license MIT
11
- */var ln="popstate";function dn(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Or(e={}){function r(o,s){var d;let i=(d=s.state)==null?void 0:d.masked,{pathname:a,search:l,hash:c}=i||o.location;return Pt("",{pathname:a,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",i?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function n(o,s){return typeof s=="string"?s:Je(s)}return zr(r,n,null,e)}function X(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function ge(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Pr(){return Math.random().toString(36).substring(2,10)}function cn(e,r){return{usr:e.state,key:e.key,idx:r,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Pt(e,r,n=null,o,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof r=="string"?ze(r):r,state:n,key:r&&r.key||o||Pr(),unstable_mask:s}}function Je({pathname:e="/",search:r="",hash:n=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ze(e){let r={};if(e){let n=e.indexOf("#");n>=0&&(r.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(r.search=e.substring(o),e=e.substring(0,o)),e&&(r.pathname=e)}return r}function zr(e,r,n,o={}){let{window:s=document.defaultView,v5Compat:i=!1}=o,a=s.history,l="POP",c=null,d=u();d==null&&(d=0,a.replaceState({...a.state,idx:d},""));function u(){return(a.state||{idx:null}).idx}function m(){l="POP";let w=u(),h=w==null?null:w-d;d=w,c&&c({action:l,location:f.location,delta:h})}function y(w,h){l="PUSH";let C=dn(w)?w:Pt(f.location,w,h);d=u()+1;let A=cn(C,d),b=f.createHref(C.unstable_mask||C);try{a.pushState(A,"",b)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;s.location.assign(b)}i&&c&&c({action:l,location:f.location,delta:1})}function S(w,h){l="REPLACE";let C=dn(w)?w:Pt(f.location,w,h);d=u();let A=cn(C,d),b=f.createHref(C.unstable_mask||C);a.replaceState(A,"",b),i&&c&&c({action:l,location:f.location,delta:0})}function x(w){return Lr(w)}let f={get action(){return l},get location(){return e(s,a)},listen(w){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(ln,m),c=w,()=>{s.removeEventListener(ln,m),c=null}},createHref(w){return r(s,w)},createURL:x,encodeLocation(w){let h=x(w);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:y,replace:S,go(w){return a.go(w)}};return f}function Lr(e,r=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),X(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:Je(e);return o=o.replace(/ $/,"%20"),!r&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Hn(e,r,n="/"){return Br(e,r,n,!1)}function Br(e,r,n,o){let s=typeof r=="string"?ze(r):r,i=we(s.pathname||"/",n);if(i==null)return null;let a=Kn(e);qr(a);let l=null;for(let c=0;l==null&&c<a.length;++c){let d=Qr(i);l=Jr(a[c],d,o)}return l}function Kn(e,r=[],n=[],o="",s=!1){let i=(a,l,c=s,d)=>{let u={relativePath:d===void 0?a.path||"":d,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(o)&&c)return;X(u.relativePath.startsWith(o),`Absolute route path "${u.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(o.length)}let m=he([o,u.relativePath]),y=n.concat(u);a.children&&a.children.length>0&&(X(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Kn(a.children,r,y,m,c)),!(a.path==null&&!a.index)&&r.push({path:m,score:Gr(m,a.index),routesMeta:y})};return e.forEach((a,l)=>{var c;if(a.path===""||!((c=a.path)!=null&&c.includes("?")))i(a,l);else for(let d of Gn(a.path))i(a,l,!0,d)}),r}function Gn(e){let r=e.split("/");if(r.length===0)return[];let[n,...o]=r,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(o.length===0)return s?[i,""]:[i];let a=Gn(o.join("/")),l=[];return l.push(...a.map(c=>c===""?i:[i,c].join("/"))),s&&l.push(...a),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function qr(e){e.sort((r,n)=>r.score!==n.score?n.score-r.score:Yr(r.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var Vr=/^:[\w-]+$/,Wr=3,$r=2,Ur=1,Hr=10,Kr=-2,un=e=>e==="*";function Gr(e,r){let n=e.split("/"),o=n.length;return n.some(un)&&(o+=Kr),r&&(o+=$r),n.filter(s=>!un(s)).reduce((s,i)=>s+(Vr.test(i)?Wr:i===""?Ur:Hr),o)}function Yr(e,r){return e.length===r.length&&e.slice(0,-1).every((o,s)=>o===r[s])?e[e.length-1]-r[r.length-1]:0}function Jr(e,r,n=!1){let{routesMeta:o}=e,s={},i="/",a=[];for(let l=0;l<o.length;++l){let c=o[l],d=l===o.length-1,u=i==="/"?r:r.slice(i.length)||"/",m=yt({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),y=c.route;if(!m&&d&&n&&!o[o.length-1].route.index&&(m=yt({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!m)return null;Object.assign(s,m.params),a.push({params:s,pathname:he([i,m.pathname]),pathnameBase:no(he([i,m.pathnameBase])),route:y}),m.pathnameBase!=="/"&&(i=he([i,m.pathnameBase]))}return a}function yt(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Xr(e.path,e.caseSensitive,e.end),s=r.match(n);if(!s)return null;let i=s[0],a=i.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:o.reduce((d,{paramName:u,isOptional:m},y)=>{if(u==="*"){let x=l[y]||"";a=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const S=l[y];return m&&!S?d[u]=void 0:d[u]=(S||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:a,pattern:e}}function Xr(e,r=!1,n=!0){ge(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,l,c,d,u)=>{if(o.push({paramName:l,isOptional:c!=null}),c){let m=u.charAt(d+a.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,r?void 0:"i"),o]}function Qr(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return ge(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function we(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let n=r.endsWith("/")?r.length-1:r.length,o=e.charAt(n);return o&&o!=="/"?null:e.slice(n)||"/"}var Zr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function eo(e,r="/"){let{pathname:n,search:o="",hash:s=""}=typeof e=="string"?ze(e):e,i;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?i=pn(n.substring(1),"/"):i=pn(n,r)):i=r,{pathname:i,search:ro(o),hash:oo(s)}}function pn(e,r){let n=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function wt(e,r,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function to(e){return e.filter((r,n)=>n===0||r.route.path&&r.route.path.length>0)}function Yn(e){let r=to(e);return r.map((n,o)=>o===r.length-1?n.pathname:n.pathnameBase)}function Ht(e,r,n,o=!1){let s;typeof e=="string"?s=ze(e):(s={...e},X(!s.pathname||!s.pathname.includes("?"),wt("?","pathname","search",s)),X(!s.pathname||!s.pathname.includes("#"),wt("#","pathname","hash",s)),X(!s.search||!s.search.includes("#"),wt("#","search","hash",s)));let i=e===""||s.pathname==="",a=i?"/":s.pathname,l;if(a==null)l=n;else{let m=r.length-1;if(!o&&a.startsWith("..")){let y=a.split("/");for(;y[0]==="..";)y.shift(),m-=1;s.pathname=y.join("/")}l=m>=0?r[m]:"/"}let c=eo(s,l),d=a&&a!=="/"&&a.endsWith("/"),u=(i||a===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var he=e=>e.join("/").replace(/\/\/+/g,"/"),no=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ro=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,oo=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,so=class{constructor(e,r,n,o=!1){this.status=e,this.statusText=r||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function io(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ao(e){return e.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Jn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xn(e,r){let n=e;if(typeof n!="string"||!Zr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,s=!1;if(Jn)try{let i=new URL(window.location.href),a=n.startsWith("//")?new URL(i.protocol+n):new URL(n),l=we(a.pathname,r);a.origin===i.origin&&l!=null?n=l+a.search+a.hash:s=!0}catch{ge(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Qn=["POST","PUT","PATCH","DELETE"];new Set(Qn);var lo=["GET",...Qn];new Set(lo);var Le=p.createContext(null);Le.displayName="DataRouter";var xt=p.createContext(null);xt.displayName="DataRouterState";var co=p.createContext(!1),Zn=p.createContext({isTransitioning:!1});Zn.displayName="ViewTransition";var uo=p.createContext(new Map);uo.displayName="Fetchers";var po=p.createContext(null);po.displayName="Await";var de=p.createContext(null);de.displayName="Navigation";var Be=p.createContext(null);Be.displayName="Location";var ye=p.createContext({outlet:null,matches:[],isDataRoute:!1});ye.displayName="Route";var Kt=p.createContext(null);Kt.displayName="RouteError";var er="REACT_ROUTER_ERROR",mo="REDIRECT",fo="ROUTE_ERROR_RESPONSE";function ho(e){if(e.startsWith(`${er}:${mo}:{`))try{let r=JSON.parse(e.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function go(e){if(e.startsWith(`${er}:${fo}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new so(r.status,r.statusText,r.data)}catch{}}function yo(e,{relative:r}={}){X(Qe(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=p.useContext(de),{hash:s,pathname:i,search:a}=Ze(e,{relative:r}),l=i;return n!=="/"&&(l=i==="/"?n:he([n,i])),o.createHref({pathname:l,search:a,hash:s})}function Qe(){return p.useContext(Be)!=null}function xe(){return X(Qe(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Be).location}function xo(){return p.useContext(Be).navigationType}var tr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function nr(e){p.useContext(de).static||p.useLayoutEffect(e)}function Se(){let{isDataRoute:e}=p.useContext(ye);return e?To():bo()}function bo(){X(Qe(),"useNavigate() may be used only in the context of a <Router> component.");let e=p.useContext(Le),{basename:r,navigator:n}=p.useContext(de),{matches:o}=p.useContext(ye),{pathname:s}=xe(),i=JSON.stringify(Yn(o)),a=p.useRef(!1);return nr(()=>{a.current=!0}),p.useCallback((c,d={})=>{if(ge(a.current,tr),!a.current)return;if(typeof c=="number"){n.go(c);return}let u=Ht(c,JSON.parse(i),s,d.relative==="path");e==null&&r!=="/"&&(u.pathname=u.pathname==="/"?r:he([r,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[r,n,i,s,e])}p.createContext(null);function Gt(){let{matches:e}=p.useContext(ye),r=e[e.length-1];return r?r.params:{}}function Ze(e,{relative:r}={}){let{matches:n}=p.useContext(ye),{pathname:o}=xe(),s=JSON.stringify(Yn(n));return p.useMemo(()=>Ht(e,JSON.parse(s),o,r==="path"),[e,s,o,r])}function vo(e,r){return rr(e,r)}function rr(e,r,n){var w;X(Qe(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=p.useContext(de),{matches:s}=p.useContext(ye),i=s[s.length-1],a=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let h=d&&d.path||"";sr(l,!d||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${h}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
12
-
13
- Please change the parent <Route path="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let u=xe(),m;if(r){let h=typeof r=="string"?ze(r):r;X(c==="/"||((w=h.pathname)==null?void 0:w.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${h.pathname}" was given in the \`location\` prop.`),m=h}else m=u;let y=m.pathname||"/",S=y;if(c!=="/"){let h=c.replace(/^\//,"").split("/");S="/"+y.replace(/^\//,"").split("/").slice(h.length).join("/")}let x=Hn(e,{pathname:S});ge(d||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),ge(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let f=Co(x&&x.map(h=>Object.assign({},h,{params:Object.assign({},a,h.params),pathname:he([c,o.encodeLocation?o.encodeLocation(h.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:he([c,o.encodeLocation?o.encodeLocation(h.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),s,n);return r&&f?p.createElement(Be.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},f):f}function wo(){let e=Fo(),r=io(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:o},i={padding:"2px 4px",backgroundColor:o},a=null;return console.error("Error handled by React Router default ErrorBoundary:",e),a=p.createElement(p.Fragment,null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:i},"ErrorBoundary")," or"," ",p.createElement("code",{style:i},"errorElement")," prop on your route.")),p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},r),n?p.createElement("pre",{style:s},n):null,a)}var So=p.createElement(wo,null),or=class extends p.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=go(e.digest);n&&(e=n)}let r=e!==void 0?p.createElement(ye.Provider,{value:this.props.routeContext},p.createElement(Kt.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?p.createElement(ko,{error:e},r):r}};or.contextType=co;var St=new WeakMap;function ko({children:e,error:r}){let{basename:n}=p.useContext(de);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let o=ho(r.digest);if(o){let s=St.get(r);if(s)throw s;let i=Xn(o.location,n);if(Jn&&!St.get(r))if(i.isExternal||o.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const a=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:o.replace}));throw St.set(r,a),a}return p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function Eo({routeContext:e,match:r,children:n}){let o=p.useContext(Le);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),p.createElement(ye.Provider,{value:e},n)}function Co(e,r=[],n){let o=n==null?void 0:n.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(r.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let s=e,i=o==null?void 0:o.errors;if(i!=null){let u=s.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);X(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),s=s.slice(0,Math.min(s.length,u+1))}let a=!1,l=-1;if(n&&o){a=o.renderFallback;for(let u=0;u<s.length;u++){let m=s[u];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=u),m.route.id){let{loaderData:y,errors:S}=o,x=m.route.loader&&!y.hasOwnProperty(m.route.id)&&(!S||S[m.route.id]===void 0);if(m.route.lazy||x){n.isStatic&&(a=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n==null?void 0:n.onError,d=o&&c?(u,m)=>{var y,S;c(u,{location:o.location,params:((S=(y=o.matches)==null?void 0:y[0])==null?void 0:S.params)??{},unstable_pattern:ao(o.matches),errorInfo:m})}:void 0;return s.reduceRight((u,m,y)=>{let S,x=!1,f=null,w=null;o&&(S=i&&m.route.id?i[m.route.id]:void 0,f=m.route.errorElement||So,a&&(l<0&&y===0?(sr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,w=null):l===y&&(x=!0,w=m.route.hydrateFallbackElement||null)));let h=r.concat(s.slice(0,y+1)),C=()=>{let A;return S?A=f:x?A=w:m.route.Component?A=p.createElement(m.route.Component,null):m.route.element?A=m.route.element:A=u,p.createElement(Eo,{match:m,routeContext:{outlet:u,matches:h,isDataRoute:o!=null},children:A})};return o&&(m.route.ErrorBoundary||m.route.errorElement||y===0)?p.createElement(or,{location:o.location,revalidation:o.revalidation,component:f,error:S,children:C(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):C()},null)}function Yt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function jo(e){let r=p.useContext(Le);return X(r,Yt(e)),r}function Do(e){let r=p.useContext(xt);return X(r,Yt(e)),r}function Ao(e){let r=p.useContext(ye);return X(r,Yt(e)),r}function Jt(e){let r=Ao(e),n=r.matches[r.matches.length-1];return X(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ro(){return Jt("useRouteId")}function Fo(){var o;let e=p.useContext(Kt),r=Do("useRouteError"),n=Jt("useRouteError");return e!==void 0?e:(o=r.errors)==null?void 0:o[n]}function To(){let{router:e}=jo("useNavigate"),r=Jt("useNavigate"),n=p.useRef(!1);return nr(()=>{n.current=!0}),p.useCallback(async(s,i={})=>{ge(n.current,tr),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:r,...i}))},[e,r])}var mn={};function sr(e,r,n){!r&&!mn[e]&&(mn[e]=!0,ge(!1,n))}p.memo(Io);function Io({routes:e,future:r,state:n,isStatic:o,onError:s}){return rr(e,void 0,{state:n,isStatic:o,onError:s})}function pe(e){X(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function _o({basename:e="/",children:r=null,location:n,navigationType:o="POP",navigator:s,static:i=!1,unstable_useTransitions:a}){X(!Qe(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=p.useMemo(()=>({basename:l,navigator:s,static:i,unstable_useTransitions:a,future:{}}),[l,s,i,a]);typeof n=="string"&&(n=ze(n));let{pathname:d="/",search:u="",hash:m="",state:y=null,key:S="default",unstable_mask:x}=n,f=p.useMemo(()=>{let w=we(d,l);return w==null?null:{location:{pathname:w,search:u,hash:m,state:y,key:S,unstable_mask:x},navigationType:o}},[l,d,u,m,y,S,o,x]);return ge(f!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${m}" because it does not start with the basename, so the <Router> won't render anything.`),f==null?null:p.createElement(de.Provider,{value:c},p.createElement(Be.Provider,{children:r,value:f}))}function No({children:e,location:r}){return vo(zt(e),r)}function zt(e,r=[]){let n=[];return p.Children.forEach(e,(o,s)=>{if(!p.isValidElement(o))return;let i=[...r,s];if(o.type===p.Fragment){n.push.apply(n,zt(o.props.children,i));return}X(o.type===pe,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),X(!o.props.index||!o.props.children,"An index route cannot have child routes.");let a={id:o.props.id||i.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(a.children=zt(o.props.children,i)),n.push(a)}),n}var mt="get",ft="application/x-www-form-urlencoded";function bt(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Mo(e){return bt(e)&&e.tagName.toLowerCase()==="button"}function Oo(e){return bt(e)&&e.tagName.toLowerCase()==="form"}function Po(e){return bt(e)&&e.tagName.toLowerCase()==="input"}function zo(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Lo(e,r){return e.button===0&&(!r||r==="_self")&&!zo(e)}var tt=null;function Bo(){if(tt===null)try{new FormData(document.createElement("form"),0),tt=!1}catch{tt=!0}return tt}var qo=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function kt(e){return e!=null&&!qo.has(e)?(ge(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ft}"`),null):e}function Vo(e,r){let n,o,s,i,a;if(Oo(e)){let l=e.getAttribute("action");o=l?we(l,r):null,n=e.getAttribute("method")||mt,s=kt(e.getAttribute("enctype"))||ft,i=new FormData(e)}else if(Mo(e)||Po(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(o=c?we(c,r):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||mt,s=kt(e.getAttribute("formenctype"))||kt(l.getAttribute("enctype"))||ft,i=new FormData(l,e),!Bo()){let{name:d,type:u,value:m}=e;if(u==="image"){let y=d?`${d}.`:"";i.append(`${y}x`,"0"),i.append(`${y}y`,"0")}else d&&i.append(d,m)}}else{if(bt(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=mt,o=null,s=ft,a=e}return i&&s==="text/plain"&&(a=i,i=void 0),{action:o,method:n.toLowerCase(),encType:s,formData:i,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Wo(e,r,n,o){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${o}`:s.pathname=`${s.pathname}.${o}`:s.pathname==="/"?s.pathname=`_root.${o}`:r&&we(s.pathname,r)==="/"?s.pathname=`${r.replace(/\/$/,"")}/_root.${o}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${o}`,s}async function $o(e,r){if(e.id in r)return r[e.id];try{let n=await import(e.module);return r[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Uo(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Ho(e,r,n){let o=await Promise.all(e.map(async s=>{let i=r.routes[s.route.id];if(i){let a=await $o(i,n);return a.links?a.links():[]}return[]}));return Jo(o.flat(1).filter(Uo).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function fn(e,r,n,o,s,i){let a=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var u;return n[d].pathname!==c.pathname||((u=n[d].route.path)==null?void 0:u.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return i==="assets"?r.filter((c,d)=>a(c,d)||l(c,d)):i==="data"?r.filter((c,d)=>{var m;let u=o.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(a(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let y=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function Ko(e,r,{includeHydrateFallback:n}={}){return Go(e.map(o=>{let s=r.routes[o.route.id];if(!s)return[];let i=[s.module];return s.clientActionModule&&(i=i.concat(s.clientActionModule)),s.clientLoaderModule&&(i=i.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(i=i.concat(s.hydrateFallbackModule)),s.imports&&(i=i.concat(s.imports)),i}).flat(1))}function Go(e){return[...new Set(e)]}function Yo(e){let r={},n=Object.keys(e).sort();for(let o of n)r[o]=e[o];return r}function Jo(e,r){let n=new Set;return new Set(r),e.reduce((o,s)=>{let i=JSON.stringify(Yo(s));return n.has(i)||(n.add(i),o.push({key:i,link:s})),o},[])}function ir(){let e=p.useContext(Le);return Xt(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Xo(){let e=p.useContext(xt);return Xt(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Qt=p.createContext(void 0);Qt.displayName="FrameworkContext";function ar(){let e=p.useContext(Qt);return Xt(e,"You must render this element inside a <HydratedRouter> element"),e}function Qo(e,r){let n=p.useContext(Qt),[o,s]=p.useState(!1),[i,a]=p.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:m}=r,y=p.useRef(null);p.useEffect(()=>{if(e==="render"&&a(!0),e==="viewport"){let f=h=>{h.forEach(C=>{a(C.isIntersecting)})},w=new IntersectionObserver(f,{threshold:.5});return y.current&&w.observe(y.current),()=>{w.disconnect()}}},[e]),p.useEffect(()=>{if(o){let f=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(f)}}},[o]);let S=()=>{s(!0)},x=()=>{s(!1),a(!1)};return n?e!=="intent"?[i,y,{}]:[i,y,{onFocus:Ve(l,S),onBlur:Ve(c,x),onMouseEnter:Ve(d,S),onMouseLeave:Ve(u,x),onTouchStart:Ve(m,S)}]:[!1,y,{}]}function Ve(e,r){return n=>{e&&e(n),n.defaultPrevented||r(n)}}function Zo({page:e,...r}){let{router:n}=ir(),o=p.useMemo(()=>Hn(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?p.createElement(ts,{page:e,matches:o,...r}):null}function es(e){let{manifest:r,routeModules:n}=ar(),[o,s]=p.useState([]);return p.useEffect(()=>{let i=!1;return Ho(e,r,n).then(a=>{i||s(a)}),()=>{i=!0}},[e,r,n]),o}function ts({page:e,matches:r,...n}){let o=xe(),{future:s,manifest:i,routeModules:a}=ar(),{basename:l}=ir(),{loaderData:c,matches:d}=Xo(),u=p.useMemo(()=>fn(e,r,d,i,o,"data"),[e,r,d,i,o]),m=p.useMemo(()=>fn(e,r,d,i,o,"assets"),[e,r,d,i,o]),y=p.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let f=new Set,w=!1;if(r.forEach(C=>{var b;let A=i.routes[C.route.id];!A||!A.hasLoader||(!u.some(R=>R.route.id===C.route.id)&&C.route.id in c&&((b=a[C.route.id])!=null&&b.shouldRevalidate)||A.hasClientLoader?w=!0:f.add(C.route.id))}),f.size===0)return[];let h=Wo(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return w&&f.size>0&&h.searchParams.set("_routes",r.filter(C=>f.has(C.route.id)).map(C=>C.route.id).join(",")),[h.pathname+h.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,o,i,u,r,e,a]),S=p.useMemo(()=>Ko(m,i),[m,i]),x=es(m);return p.createElement(p.Fragment,null,y.map(f=>p.createElement("link",{key:f,rel:"prefetch",as:"fetch",href:f,...n})),S.map(f=>p.createElement("link",{key:f,rel:"modulepreload",href:f,...n})),x.map(({key:f,link:w})=>p.createElement("link",{key:f,nonce:n.nonce,...w,crossOrigin:w.crossOrigin??n.crossOrigin})))}function ns(...e){return r=>{e.forEach(n=>{typeof n=="function"?n(r):n!=null&&(n.current=r)})}}var rs=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{rs&&(window.__reactRouterVersion="7.13.2")}catch{}function os({basename:e,children:r,unstable_useTransitions:n,window:o}){let s=p.useRef();s.current==null&&(s.current=Or({window:o,v5Compat:!0}));let i=s.current,[a,l]=p.useState({action:i.action,location:i.location}),c=p.useCallback(d=>{n===!1?l(d):p.startTransition(()=>l(d))},[n]);return p.useLayoutEffect(()=>i.listen(c),[i,c]),p.createElement(_o,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:i,unstable_useTransitions:n})}var lr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,dr=p.forwardRef(function({onClick:r,discover:n="render",prefetch:o="none",relative:s,reloadDocument:i,replace:a,unstable_mask:l,state:c,target:d,to:u,preventScrollReset:m,viewTransition:y,unstable_defaultShouldRevalidate:S,...x},f){let{basename:w,navigator:h,unstable_useTransitions:C}=p.useContext(de),A=typeof u=="string"&&lr.test(u),b=Xn(u,w);u=b.to;let R=yo(u,{relative:s}),T=xe(),O=null;if(l){let Q=Ht(l,[],T.unstable_mask?T.unstable_mask.pathname:"/",!0);w!=="/"&&(Q.pathname=Q.pathname==="/"?w:he([w,Q.pathname])),O=h.createHref(Q)}let[D,P,F]=Qo(o,x),N=ls(u,{replace:a,unstable_mask:l,state:c,target:d,preventScrollReset:m,relative:s,viewTransition:y,unstable_defaultShouldRevalidate:S,unstable_useTransitions:C});function L(Q){r&&r(Q),Q.defaultPrevented||N(Q)}let Z=!(b.isExternal||i),ee=p.createElement("a",{...x,...F,href:(Z?O:void 0)||b.absoluteURL||R,onClick:Z?L:r,ref:ns(f,P),target:d,"data-discover":!A&&n==="render"?"true":void 0});return D&&!A?p.createElement(p.Fragment,null,ee,p.createElement(Zo,{page:R})):ee});dr.displayName="Link";var ss=p.forwardRef(function({"aria-current":r="page",caseSensitive:n=!1,className:o="",end:s=!1,style:i,to:a,viewTransition:l,children:c,...d},u){let m=Ze(a,{relative:d.relative}),y=xe(),S=p.useContext(xt),{navigator:x,basename:f}=p.useContext(de),w=S!=null&&ms(m)&&l===!0,h=x.encodeLocation?x.encodeLocation(m).pathname:m.pathname,C=y.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;n||(C=C.toLowerCase(),A=A?A.toLowerCase():null,h=h.toLowerCase()),A&&f&&(A=we(A,f)||A);const b=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let R=C===h||!s&&C.startsWith(h)&&C.charAt(b)==="/",T=A!=null&&(A===h||!s&&A.startsWith(h)&&A.charAt(h.length)==="/"),O={isActive:R,isPending:T,isTransitioning:w},D=R?r:void 0,P;typeof o=="function"?P=o(O):P=[o,R?"active":null,T?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let F=typeof i=="function"?i(O):i;return p.createElement(dr,{...d,"aria-current":D,className:P,ref:u,style:F,to:a,viewTransition:l},typeof c=="function"?c(O):c)});ss.displayName="NavLink";var is=p.forwardRef(({discover:e="render",fetcherKey:r,navigate:n,reloadDocument:o,replace:s,state:i,method:a=mt,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:m,unstable_defaultShouldRevalidate:y,...S},x)=>{let{unstable_useTransitions:f}=p.useContext(de),w=us(),h=ps(l,{relative:d}),C=a.toLowerCase()==="get"?"get":"post",A=typeof l=="string"&&lr.test(l),b=R=>{if(c&&c(R),R.defaultPrevented)return;R.preventDefault();let T=R.nativeEvent.submitter,O=(T==null?void 0:T.getAttribute("formmethod"))||a,D=()=>w(T||R.currentTarget,{fetcherKey:r,method:O,navigate:n,replace:s,state:i,relative:d,preventScrollReset:u,viewTransition:m,unstable_defaultShouldRevalidate:y});f&&n!==!1?p.startTransition(()=>D()):D()};return p.createElement("form",{ref:x,method:C,action:h,onSubmit:o?c:b,...S,"data-discover":!A&&e==="render"?"true":void 0})});is.displayName="Form";function as(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function cr(e){let r=p.useContext(Le);return X(r,as(e)),r}function ls(e,{target:r,replace:n,unstable_mask:o,state:s,preventScrollReset:i,relative:a,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let u=Se(),m=xe(),y=Ze(e,{relative:a});return p.useCallback(S=>{if(Lo(S,r)){S.preventDefault();let x=n!==void 0?n:Je(m)===Je(y),f=()=>u(e,{replace:x,unstable_mask:o,state:s,preventScrollReset:i,relative:a,viewTransition:l,unstable_defaultShouldRevalidate:c});d?p.startTransition(()=>f()):f()}},[m,u,y,n,o,s,r,e,i,a,l,c,d])}var ds=0,cs=()=>`__${String(++ds)}__`;function us(){let{router:e}=cr("useSubmit"),{basename:r}=p.useContext(de),n=Ro(),o=e.fetch,s=e.navigate;return p.useCallback(async(i,a={})=>{let{action:l,method:c,encType:d,formData:u,body:m}=Vo(i,r);if(a.navigate===!1){let y=a.fetcherKey||cs();await o(y,n,a.action||l,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:u,body:m,formMethod:a.method||c,formEncType:a.encType||d,flushSync:a.flushSync})}else await s(a.action||l,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:u,body:m,formMethod:a.method||c,formEncType:a.encType||d,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[o,s,r,n])}function ps(e,{relative:r}={}){let{basename:n}=p.useContext(de),o=p.useContext(ye);X(o,"useFormAction must be used inside a RouteContext");let[s]=o.matches.slice(-1),i={...Ze(e||".",{relative:r})},a=xe();if(e==null){i.search=a.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let u=l.toString();i.search=u?`?${u}`:""}}return(!e||e===".")&&s.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:he([n,i.pathname])),Je(i)}function ms(e,{relative:r}={}){let n=p.useContext(Zn);X(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=cr("useViewTransitionState"),s=Ze(e,{relative:r});if(!n.isTransitioning)return!1;let i=we(n.currentLocation.pathname,o)||n.currentLocation.pathname,a=we(n.nextLocation.pathname,o)||n.nextLocation.pathname;return yt(s.pathname,a)!=null||yt(s.pathname,i)!=null}const fs="modulepreload",hs=function(e){return"/"+e},hn={},te=function(r,n,o){let s=Promise.resolve();if(n&&n.length>0){let a=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=a(n.map(d=>{if(d=hs(d),d in hn)return;hn[d]=!0;const u=d.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${m}`))return;const y=document.createElement("link");if(y.rel=u?"stylesheet":fs,u||(y.as="script"),y.crossOrigin="",y.href=d,c&&y.setAttribute("nonce",c),document.head.appendChild(y),u)return new Promise((S,x)=>{y.addEventListener("load",S),y.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return r().catch(i)})},gs={dependsOn:{}};function ys(e,r){return new Set([e,...(r??gs).dependsOn[e]??[]])}function xs(e,r){const n=r instanceof Set?r:new Set(r);return n.size===0?!1:e.some(o=>n.has(o))}function Lt(e){return(e.sourceEnd.type?1:0)+(e.targetEnd.type?1:0)}function bs(e){return Lt(e)===0}function vs(e,r){return Lt(r)-Lt(e)||e.label.localeCompare(r.label)}function ur(e){return new Map(e.map(r=>[r.name,r]))}function Zt(e,r){if(e)return r.relationships.find(n=>n.name===e||n.sysmlName===e)}function nt(e,r,n){var a;if(!r)return!0;if(!e)return!1;if(e===r)return!0;const o=Array.isArray(n)?ur(n):n;let s=e;const i=new Set;for(;s&&!i.has(s);){if(s===r)return!0;i.add(s),s=(a=o.get(s))==null?void 0:a.superType}return!1}function ws(e,r,n){const o=ur(n.kinds),s=[];for(const i of n.relationships)i.isAbstract||(nt(e.kind,i.sourceEnd.type,o)&&nt(r.kind,i.targetEnd.type,o)&&s.push({definition:i,direction:"outgoing",sourceId:e.id,targetId:r.id}),nt(r.kind,i.sourceEnd.type,o)&&nt(e.kind,i.targetEnd.type,o)&&s.push({definition:i,direction:"incoming",sourceId:r.id,targetId:e.id}));return s.sort((i,a)=>vs(i.definition,a.definition))}const Ss=["general","interconnection","actionflow","statetransition","sequence","grid","browser","geometry"];new Set(Ss);const ks={id:"requirements-matrix",name:"Requirements Matrix",description:"Standard requirements spreadsheet with ID, title, description, priority columns. Typical export from DOORS, Jama, or a simple Excel requirements log.",defaultKind:"Requirement",columnMappings:[{sourceColumn:"req id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"requirement id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"req #",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"number",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"title",targetAttribute:"name",required:!0},{sourceColumn:"requirement title",targetAttribute:"name",required:!0},{sourceColumn:"name",targetAttribute:"name",required:!0},{sourceColumn:"summary",targetAttribute:"name"},{sourceColumn:"description",targetAttribute:"doc"},{sourceColumn:"text",targetAttribute:"doc"},{sourceColumn:"statement",targetAttribute:"doc"},{sourceColumn:"requirement text",targetAttribute:"doc"},{sourceColumn:"kind",targetAttribute:"kind"},{sourceColumn:"type",targetAttribute:"kind"},{sourceColumn:"category",targetAttribute:"category"},{sourceColumn:"priority",targetAttribute:"priority"},{sourceColumn:"rationale",targetAttribute:"rationale"},{sourceColumn:"verification method",targetAttribute:"verificationMethod"},{sourceColumn:"status",targetAttribute:"status"}]},Es={id:"hazard-log",name:"Hazard Log",description:"ISO 14971 hazard analysis spreadsheet with hazard ID, description, severity, probability and risk level columns.",defaultKind:"Hazard",columnMappings:[{sourceColumn:"hazard id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"haz id",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"hazard",targetAttribute:"name",required:!0},{sourceColumn:"hazard description",targetAttribute:"name",required:!0},{sourceColumn:"name",targetAttribute:"name",required:!0},{sourceColumn:"description",targetAttribute:"doc"},{sourceColumn:"hazardous situation",targetAttribute:"doc"},{sourceColumn:"kind",targetAttribute:"kind"},{sourceColumn:"severity",targetAttribute:"severity"},{sourceColumn:"probability",targetAttribute:"probability"},{sourceColumn:"risk level",targetAttribute:"riskLevel"},{sourceColumn:"risk",targetAttribute:"riskLevel"},{sourceColumn:"harm",targetAttribute:"harm"},{sourceColumn:"foreseeable misuse",targetAttribute:"foreseeableMisuse"},{sourceColumn:"mitigation",targetAttribute:"mitigation"},{sourceColumn:"residual risk",targetAttribute:"residualRisk"},{sourceColumn:"status",targetAttribute:"status"}]},Cs={id:"fmea-worksheet",name:"FMEA Worksheet",description:"Failure Mode and Effects Analysis spreadsheet. Maps component failure modes to MEMO Failure kind with FMEA attributes (severity, occurrence, detection, RPN).",defaultKind:"Failure",columnMappings:[{sourceColumn:"id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"fmea id",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"failure mode",targetAttribute:"name",required:!0},{sourceColumn:"failure mode description",targetAttribute:"name"},{sourceColumn:"name",targetAttribute:"name",required:!0},{sourceColumn:"description",targetAttribute:"doc"},{sourceColumn:"effect",targetAttribute:"doc"},{sourceColumn:"effect of failure",targetAttribute:"effect"},{sourceColumn:"kind",targetAttribute:"kind"},{sourceColumn:"component",targetAttribute:"component"},{sourceColumn:"function",targetAttribute:"function"},{sourceColumn:"severity",targetAttribute:"severity"},{sourceColumn:"s",targetAttribute:"severity"},{sourceColumn:"occurrence",targetAttribute:"occurrence"},{sourceColumn:"o",targetAttribute:"occurrence"},{sourceColumn:"detection",targetAttribute:"detection"},{sourceColumn:"d",targetAttribute:"detection"},{sourceColumn:"rpn",targetAttribute:"rpn"},{sourceColumn:"risk priority number",targetAttribute:"rpn"},{sourceColumn:"cause",targetAttribute:"cause"},{sourceColumn:"controls",targetAttribute:"controls"},{sourceColumn:"action",targetAttribute:"action"}]},js={id:"verification-table",name:"Verification Table",description:"Verification and validation traceability matrix mapping requirements to test methods and results.",defaultKind:"VerificationTest",columnMappings:[{sourceColumn:"test id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"verification id",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"id",targetAttribute:"id",transform:"sanitize-id",required:!0},{sourceColumn:"test name",targetAttribute:"name",required:!0},{sourceColumn:"name",targetAttribute:"name",required:!0},{sourceColumn:"title",targetAttribute:"name"},{sourceColumn:"description",targetAttribute:"doc"},{sourceColumn:"objective",targetAttribute:"doc"},{sourceColumn:"kind",targetAttribute:"kind"},{sourceColumn:"requirement id",targetAttribute:"requirementId"},{sourceColumn:"req id",targetAttribute:"requirementId"},{sourceColumn:"method",targetAttribute:"method"},{sourceColumn:"test method",targetAttribute:"method"},{sourceColumn:"verification method",targetAttribute:"method"},{sourceColumn:"result",targetAttribute:"result"},{sourceColumn:"pass/fail",targetAttribute:"result"},{sourceColumn:"status",targetAttribute:"status"},{sourceColumn:"evidence",targetAttribute:"evidence"},{sourceColumn:"notes",targetAttribute:"notes"}]},gn=[ks,Es,Cs,js];function Ds(e,r){return e.map(n=>{const o=n.trim().toLowerCase();if(r){const a=r.columnMappings.find(l=>l.sourceColumn.toLowerCase()===o);if(a)return{...a,sourceColumn:n}}const s=As.find(a=>a.sourceColumn.toLowerCase()===o);if(s)return{...s,sourceColumn:n};const i=Is(n);return{sourceColumn:n,targetAttribute:i}})}const As=[{sourceColumn:"id",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"identifier",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"uid",targetAttribute:"id",transform:"sanitize-id"},{sourceColumn:"name",targetAttribute:"name"},{sourceColumn:"title",targetAttribute:"name"},{sourceColumn:"label",targetAttribute:"name"},{sourceColumn:"description",targetAttribute:"doc"},{sourceColumn:"text",targetAttribute:"doc"},{sourceColumn:"notes",targetAttribute:"doc"},{sourceColumn:"kind",targetAttribute:"kind"},{sourceColumn:"type",targetAttribute:"kind"},{sourceColumn:"category",targetAttribute:"kind"},{sourceColumn:"construct",targetAttribute:"construct"}];function Rs(e,r,n,o){const s=[],i=[],a=new Set,l=[];for(const f of r){if(!f.targetAttribute){i.push(f.sourceColumn);continue}a.has(f.targetAttribute)||(a.add(f.targetAttribute),l.push(f))}const c=a.has("id"),d=a.has("name"),u=a.has("kind");c||s.push("No column mapped to 'id' — id will be auto-generated from row number"),d||s.push("No column mapped to 'name'"),!u&&!o&&s.push("No column mapped to 'kind' and no defaultKind set");const m=["id","name","kind","construct","doc"],y=Array.from(a).filter(f=>!m.includes(f)),S=[...m.filter(f=>a.has(f)),...y];for(const f of["id","name","kind"])S.includes(f)||S.unshift(f);const x=[S.map(yn).join(",")];return e.forEach((f,w)=>{const h={};for(const b of l){const R=f[b.sourceColumn]??"";h[b.targetAttribute]=Fs(R,b.transform)}(!h.id||h.id.trim()==="")&&(h.id=`row_${w+1}`),(!h.kind||h.kind.trim()==="")&&o&&(h.kind=o);const C=h.kind;C&&n.kinds&&!n.kinds[C]&&s.push(`Row ${w+2}: unknown kind '${C}' (not in config)`);const A=S.map(b=>yn(h[b]??""));x.push(A.join(","))}),{csv:x.join(`
14
- `)+`
15
- `,skippedColumns:i,warnings:s}}function Fs(e,r){if(!r)return e;switch(r){case"sanitize-id":return Ts(e);case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}}function Ts(e){let r=e.trim().replace(/[\s\-]+/g,"_").replace(/[^a-zA-Z0-9_]/g,"").toLowerCase();return/^\d/.test(r)&&(r="e_"+r),r}function Is(e){return e.trim().replace(/[^a-zA-Z0-9 _-]/g,"").split(/[\s_-]+/).map((r,n)=>n===0?r.toLowerCase():r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function yn(e){return e.includes(",")||e.includes('"')||e.includes(`
16
- `)?`"${e.replace(/"/g,'""')}"`:e}let M=null,rt=null,Et=0;const _s=1e4;let je=!1,ht=null;const Oe=new Map;function Ns(e){const r=Oe.get(e.requestId);r&&(clearTimeout(r.timer),Oe.delete(e.requestId),e.success||e.conflict?r.resolve(e):r.reject(new Error(e.error||`Could not ${e.operation} diagram source.`)))}function Ms(e){for(const r of Oe.values())clearTimeout(r.timer),r.reject(new Error(e));Oe.clear()}const en=new Map,tn=new Map;function xn(e,r){const n=r.get(e.requestId);n&&(clearTimeout(n.timer),r.delete(e.requestId),n.resolve(e))}function Os(e){for(const r of[en,tn]){for(const n of r.values())clearTimeout(n.timer),n.reject(new Error(e));r.clear()}}function pr(e,r,n){if(!M||M.readyState!==WebSocket.OPEN)return Promise.reject(new Error("The development server is not connected."));const o=`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return new Promise((s,i)=>{const a=setTimeout(()=>{n.delete(o),i(new Error("The server did not answer the relationship request."))},15e3);n.set(o,{resolve:s,reject:i,timer:a}),M.send(JSON.stringify({type:e,payload:{...r,requestId:o}}))})}function Ps(){const e=window.__MEMO_DATA__;if(!e)return!1;const r=E.getState();return r.setConnected(!0),e.model&&r.setModel(e.model),e.validation&&r.setValidation(e.validation),e.completeness&&r.setCompleteness(e.completeness),!0}function mr(e){if(window.__MEMO_DATA__)return;Bs();const r=`ws://${window.location.host}`;if(M&&(M.readyState===WebSocket.OPEN||M.readyState===WebSocket.CONNECTING))return;M=new WebSocket(r);const n=E.getState();M.onopen=()=>{n.setConnected(!0),Et=0,ht=null,je=!1,n.setRestartRequired(null),rt&&(clearTimeout(rt),rt=null)},M.onmessage=o=>{try{const s=JSON.parse(o.data);zs(s)}catch{}},M.onclose=()=>{n.setConnected(!1),Ms("The development server disconnected."),Os("The development server disconnected."),M=null,Et++;const o=Math.min(2e3*Math.pow(2,Et-1),_s);rt=setTimeout(()=>mr(),o)},M.onerror=()=>{}}function zs(e){const r=E.getState();switch(e.type){case"app:restart-required":je=!0,r.setRestartRequired(e);return;case"model:update":if(je)return;r.setModel(e.payload);break;case"source:changed":if(je)return;r.applySourceChange(e.payload);break;case"validation:update":if(je)return;r.setValidation(e.payload);break;case"completeness:update":if(je)return;r.setCompleteness(e.payload);break;case"methodology:update":if(je)return;r.setMethodology(e.payload);break;case"error":console.error("[MEMO] Server error:",e.payload.message);break;case"diagram:parse:result":r.applyDiagramParseResult(e.payload.diagramId,e.payload.elementIds,e.payload.errors);break;case"diagram:source:result":Ns(e.payload);break;case"relationship:create:result":xn(e.payload,en);break;case"relationship:delete:result":xn(e.payload,tn);break;case"ontology:packages":{const n=e.payload.ontologyHash;if(n){if(ht===null)ht=n;else if(ht!==n){je=!0,r.setRestartRequired({type:"app:restart-required",reason:"ontology-source-changed",changedFile:"(server restarted with different ontology)",instruction:"Reload the page to connect to the new server."});return}}r.setAvailableOntologies(e.payload.packages);break}case"ontology:install:result":r.setOntologyInstallStatus({installing:!1,lastInstalled:e.payload.success?e.payload.packageName:void 0,error:e.payload.error});break;case"ontology:remove:result":r.setOntologyInstallStatus({installing:!1});break;case"diagram:layout":r.mergeDiagramLayouts(e.payload.layouts);break;case"import:result":r.setImportResult(e.payload);break;case"llm:status":r.setLlmStatus(e.payload.available,e.payload.provider,e.payload.model);break;case"llm:settings":r.setLlmSettings(e.payload.settings);break;case"llm:ask:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,e.payload.answer);break;case"llm:chat:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,{answer:e.payload.answer,proposedChanges:e.payload.proposedChanges??[],messages:e.payload.messages??[],truncated:e.payload.truncated});break;case"llm:chat:apply:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,{applied:e.payload.applied??[],failed:e.payload.failed??[]});break;case"llm:settings:save:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,e.payload.settings);break;case"llm:generate:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,{sysml:e.payload.sysml,explanation:e.payload.explanation,suggestedFile:e.payload.suggestedFile});break;case"llm:draft:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,{markdown:e.payload.markdown,summary:e.payload.summary});break;case"llm:suggest:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,e.payload.suggestions);break;case"dhf:docs":bn(()=>r.setDhfDocuments(e.payload.docs));break;case"dhf:settings":bn(()=>r.hydrateDhfSettings(e.payload.settings));break;case"dhf:templates:result":r.resolveLlmRequest(e.payload.requestId,e.payload.templates);break;case"dhf:template:content":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,e.payload.content);break;case"dhf:template:save:result":e.payload.error?r.rejectLlmRequest(e.payload.requestId,e.payload.error):r.resolveLlmRequest(e.payload.requestId,{path:e.payload.path});break}}let Bt=!1;const fr=600,Ke=new Map;let ot=null;function bn(e){Bt=!0;try{e()}finally{Bt=!1}}function Pe(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify(e))}function Ls(e){const r=Ke.get(e.id);r&&clearTimeout(r),Ke.set(e.id,setTimeout(()=>{Ke.delete(e.id);const n=E.getState().dhfDocuments.find(o=>o.id===e.id);n&&Pe({type:"dhf:doc:save",payload:{doc:n}})},fr))}let vn=!1;function Bs(){vn||(vn=!0,E.subscribe((e,r)=>{if(!Bt){if(e.dhfDocuments!==r.dhfDocuments){const n=new Map(r.dhfDocuments.map(o=>[o.id,o]));for(const o of e.dhfDocuments)n.get(o.id)!==o&&Ls(o),n.delete(o.id);for(const o of n.keys()){const s=Ke.get(o);s&&(clearTimeout(s),Ke.delete(o)),Pe({type:"dhf:doc:delete",payload:{docId:o}})}}e.dhfSettings!==r.dhfSettings&&(ot&&clearTimeout(ot),ot=setTimeout(()=>{ot=null,Pe({type:"dhf:settings:save",payload:{settings:E.getState().dhfSettings}})},fr))}}))}function qs(e){Pe({type:"dhf:templates:list",payload:{requestId:e}})}function Vs(e,r){Pe({type:"dhf:template:read",payload:{requestId:e,path:r}})}function Ws(e,r,n){Pe({type:"dhf:template:save",payload:{requestId:e,title:r,content:n}})}function Te(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"element:update",payload:e}))}function wn(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"element:create",payload:e}))}function $s(e){return pr("relationship:create",e,en)}function Us(e){return pr("relationship:delete",e,tn)}function Hs(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"diagram:create",payload:e}))}function Sn(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"diagram:update",payload:e}))}function Ks(e){if(M&&M.readyState===WebSocket.OPEN){const r={id:e};M.send(JSON.stringify({type:"diagram:delete",payload:r}))}}function bd(e,r){if(M&&M.readyState===WebSocket.OPEN){const n={diagramId:e,text:r};M.send(JSON.stringify({type:"diagram:parse",payload:n}))}}function hr(e,r,n){if(!M||M.readyState!==WebSocket.OPEN)return Promise.reject(new Error("The development server is not connected."));const o=`diagram-source-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return new Promise((s,i)=>{const a=setTimeout(()=>{Oe.delete(o),i(new Error(`Timed out while trying to ${e} the SysML source.`))},1e4);Oe.set(o,{resolve:s,reject:i,timer:a}),M.send(JSON.stringify({type:e==="load"?"diagram:source:request":"diagram:source:save",payload:{requestId:o,diagramId:r,...e==="save"?n:{}}}))})}function vd(e){return hr("load",e)}function wd(e,r,n){return hr("save",e,{text:r,baseRevision:n})}function Gs(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"element:remap-kinds",payload:{mappings:e}}))}function Ct(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"ontology:save-selection",payload:{selected:e}}))}function Sd(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"ontology:install",payload:{source:e}}))}function kd(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"open-file",payload:{path:e}}))}function Ed(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"ontology:remove",payload:{packageName:e}}))}function Cd(e,r){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"diagram:layout:update",payload:{diagramId:e,layout:r}}))}function Ys(e){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"csv:import",payload:e}))}function jd(e,r,n,o){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"llm:chat",payload:{requestId:e,question:r,history:n,allowEdits:o}}))}function Dd(e,r){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"llm:chat:apply",payload:{requestId:e,changes:r}}))}function Ad(e,r){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"llm:settings:save",payload:{requestId:e,...r}}))}function Rd(e,r){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"llm:generate",payload:{requestId:e,description:r}}))}function Fd(e,r,n){M&&M.readyState===WebSocket.OPEN&&M.send(JSON.stringify({type:"llm:draft",payload:{requestId:e,documentTypeId:r,targetSections:n}}))}const kn="memo:userViewpoints",qt="memo:activeView";function Js(){try{const e=JSON.parse(sessionStorage.getItem(qt)??"null");if((e==null?void 0:e.type)==="diagram"&&typeof e.diagramId=="string")return e}catch{}return{type:"welcome"}}function En(e){try{e.type==="diagram"?sessionStorage.setItem(qt,JSON.stringify(e)):sessionStorage.removeItem(qt)}catch{}}function Xs(){try{const e=localStorage.getItem(kn);if(e){const r=JSON.parse(e);return localStorage.removeItem(kn),r.length>0&&console.warn(`[MEMO] Migrated ${r.length} user viewpoint(s) from localStorage. Save them to memo.viewpoints.yaml to persist across sessions.`),r}}catch{}return[]}const De="_folder",st=Js(),E=Un((e,r)=>({model:null,validation:null,completeness:null,connected:!1,restartRequired:null,methodology:null,lastSourceChange:null,activeMode:st.type==="diagram"?"diagram":"catalog",activeView:st,explorerTab:"model",selectedElementId:null,selectedRelationshipId:null,selectedElementIds:new Set,recentlyVisited:[],selectedViewpointId:null,selectedDiagramId:st.type==="diagram"?st.diagramId:null,searchTerm:"",sidebarCollapsed:!1,propertiesPanelCollapsed:!0,hiddenLayers:new Set,ontologyGroupBy:"layer",collapsedGroups:new Set,availableOntologies:[],selectedOntologies:new Set,focusedOntologyId:null,selectedOntologyKind:null,ontologyViewMode:"visual",showOntologyRelationships:!1,highlightedRelationshipType:null,hiddenEdgeTypes:new Set(["extends"]),ontologyInstallStatus:{installing:!1},gapBarExpanded:!1,gapBarHeight:160,catalogGroupBy:"semantic",catalogCollapsed:new Set,contextMenu:null,attributeFilter:null,labelFilter:null,tagFilters:[],userViewpoints:Xs(),diagramLayouts:{},mergeDiagramLayouts:n=>e(o=>({diagramLayouts:{...o.diagramLayouts,...n}})),setNodeLayout:(n,o,s)=>e(i=>{const a=i.diagramLayouts[n]??{nodes:{},edges:{}};return{diagramLayouts:{...i.diagramLayouts,[n]:{...a,nodes:{...a.nodes,[o]:{...a.nodes[o]??{},...s}}}}}}),diagramParseErrors:{},dhfDocuments:[],dhfSettings:{company:"",product:"",deviceType:"",version:"0.1",phase:"",logoUrl:"",compactLogoUrl:"",primaryColor:"#1B3A4B",compactMode:!1,headerTemplate:"**{{project.product}}** | {{id}} | Rev {{project.version}}",footerTemplate:"Confidential — {{project.company}} | Page {{page}}",documentNumberingPrefix:"DOC"},bulkImportOpen:!1,importResult:null,llmAvailable:!1,llmProvider:void 0,llmModel:void 0,llmPending:new Map,llmSettings:null,setLlmSettings:n=>e({llmSettings:n,llmAvailable:n.configured,llmProvider:n.provider,llmModel:n.model}),setLlmStatus:(n,o,s)=>e({llmAvailable:n,llmProvider:o,llmModel:s}),registerLlmRequest:(n,o,s)=>e(i=>{const a=new Map(i.llmPending);return a.set(n,{resolve:o,reject:s}),{llmPending:a}}),resolveLlmRequest:(n,o)=>e(s=>{const i=s.llmPending.get(n);if(i){i.resolve(o);const a=new Map(s.llmPending);return a.delete(n),{llmPending:a}}return{}}),rejectLlmRequest:(n,o)=>e(s=>{const i=s.llmPending.get(n);if(i){i.reject(new Error(o));const a=new Map(s.llmPending);return a.delete(n),{llmPending:a}}return{}}),analysisIssues:[],editingElementId:null,pendingEdits:new Map,pendingRelationships:[],createRelationship:async n=>{const o=`pending-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,s=Zs(r().model,n.type);e(a=>({pendingRelationships:[...a.pendingRelationships,{pendingId:o,type:n.type,label:(s==null?void 0:s.label)??n.type,sourceId:n.sourceId,targetId:n.targetId,direction:n.direction,status:"saving"}]}));const i=(a,l)=>(e(c=>({pendingRelationships:c.pendingRelationships.map(d=>d.pendingId===o?{...d,status:"failed",error:a}:d)})),{success:!1,error:a,diagnostics:l});try{const a=await $s(n);return a.success?(e(l=>({pendingRelationships:l.pendingRelationships.filter(c=>c.pendingId!==o)})),{success:!0,relationshipId:a.relationshipId,sourceFile:a.sourceFile,diagnostics:a.diagnostics}):i(a.error??"The relationship could not be created.",a.diagnostics)}catch(a){return i(a instanceof Error?a.message:String(a))}},deleteRelationship:async n=>{try{const o=await Us({relationshipId:n});return o.success?(e(s=>s.model?{model:{...s.model,relationships:s.model.relationships.filter(i=>i.id!==n)},selectedRelationshipId:s.selectedRelationshipId===n?null:s.selectedRelationshipId}:{}),{success:!0,sourceFile:o.sourceFile}):{success:!1,error:o.error??"The relationship could not be deleted."}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}},dismissPendingRelationship:n=>e(o=>({pendingRelationships:o.pendingRelationships.filter(s=>s.pendingId!==n)})),setRestartRequired:n=>e({restartRequired:n}),applySourceChange:n=>e(o=>{var s;return{lastSourceChange:{...n,seq:(((s=o.lastSourceChange)==null?void 0:s.seq)??0)+1}}}),setMethodology:n=>e({methodology:n}),setModel:n=>e(o=>{var l,c,d,u;let s=o.activeView,i=o.selectedDiagramId,a=o.selectedViewpointId;if(s.type==="diagram"){const m=s.diagramId,y=(l=n.diagrams)==null?void 0:l.find(f=>f.id===m),S=(d=(c=o.model)==null?void 0:c.diagrams)==null?void 0:d.find(f=>f.id===m),x=y??(S!=null&&S.sourceFile?(u=n.diagrams)==null?void 0:u.find(f=>f.sourceFile===S.sourceFile):void 0);x&&(x.id!==m&&(s={type:"diagram",diagramId:x.id},En(s)),i=x.id,a=x.viewpointId==="__model"?null:x.viewpointId)}else(s.type==="welcome"||s.type==="dashboard")&&Object.keys(n.elements).length>0&&(s={type:"dashboard"});return{model:n,activeView:s,selectedDiagramId:i,selectedViewpointId:a}}),setValidation:n=>e({validation:n}),setCompleteness:n=>e({completeness:n}),setConnected:n=>e({connected:n}),setAnalysisIssues:n=>e({analysisIssues:n}),setActiveMode:n=>e({activeMode:n}),setActiveView:n=>{En(n),e({activeView:n})},setExplorerTab:n=>e({explorerTab:n}),selectElement:n=>{e(n?o=>{const s=[n,...o.recentlyVisited.filter(i=>i!==n)].slice(0,20);return{selectedElementId:n,activeView:{type:"element-detail",elementId:n},recentlyVisited:s}}:{selectedElementId:n})},inspectElement:n=>e(o=>({selectedElementId:n,selectedRelationshipId:null,propertiesPanelCollapsed:n?!1:o.propertiesPanelCollapsed,recentlyVisited:n?[n,...o.recentlyVisited.filter(s=>s!==n)].slice(0,20):o.recentlyVisited})),inspectRelationship:n=>e({selectedRelationshipId:n,selectedElementId:null,propertiesPanelCollapsed:n?!1:r().propertiesPanelCollapsed}),toggleElementSelection:n=>e(o=>{const s=new Set(o.selectedElementIds);return s.has(n)?s.delete(n):s.add(n),{selectedElementIds:s}}),selectAllElements:n=>e({selectedElementIds:new Set(n)}),clearElementSelection:()=>e({selectedElementIds:new Set}),updateElementKind:(n,o)=>{const{model:s}=r();if(!s)return;const i=s.elements[n];if(!i)return;const a={...i,kind:o};e(l=>({model:l.model?{...l.model,elements:{...l.model.elements,[n]:a}}:null})),Te(a)},bulkUpdateAttributes:(n,o)=>{const{model:s}=r();if(!s)return;const i={...s.elements};for(const a of n){const l=i[a];if(!l)continue;const c={...l,attributes:{...l.attributes,...o}};i[a]=c,Te(c)}e(a=>({model:a.model?{...a.model,elements:i}:null}))},selectViewpoint:n=>e({selectedViewpointId:n,selectedDiagramId:null}),selectDiagram:n=>{var i;if(!n){e({selectedDiagramId:null});return}const{model:o}=r(),s=(i=o==null?void 0:o.diagrams)==null?void 0:i.find(a=>a.id===n);e(s?{selectedDiagramId:n,selectedViewpointId:s.viewpointId==="__model"?null:s.viewpointId}:{selectedDiagramId:n})},setSearchTerm:n=>e({searchTerm:n}),toggleSidebar:()=>e(n=>({sidebarCollapsed:!n.sidebarCollapsed})),togglePropertiesPanel:()=>e(n=>({propertiesPanelCollapsed:!n.propertiesPanelCollapsed})),toggleLayerVisibility:n=>e(o=>{const s=new Set(o.hiddenLayers);return s.has(n)?s.delete(n):s.add(n),{hiddenLayers:s}}),setOntologyGroupBy:n=>e({ontologyGroupBy:n,collapsedGroups:new Set}),toggleGroupCollapsed:n=>e(o=>{const s=new Set(o.collapsedGroups);return s.has(n)?s.delete(n):s.add(n),{collapsedGroups:s}}),setAvailableOntologies:n=>e(o=>{let s=new Set(n.filter(l=>l.selected).map(l=>l.name));const i=["@memoarchitect/ontology"];for(const l of n)i.includes(l.name)&&s.add(l.name);s.size===0&&n.length>0&&(s=new Set(n.map(l=>l.name)));const a=o.focusedOntologyId??(s.size>0?[...s][0]:null);return{availableOntologies:n,selectedOntologies:s,focusedOntologyId:a}}),toggleOntologySelection:n=>e(o=>{const s=new Set(o.selectedOntologies);return s.has(n)?s.delete(n):s.add(n),{selectedOntologies:s}}),setFocusedOntology:n=>e({focusedOntologyId:n}),setSelectedOntologyKind:n=>e({selectedOntologyKind:n}),setOntologyViewMode:n=>e({ontologyViewMode:n}),toggleOntologyRelationships:()=>e(n=>({showOntologyRelationships:!n.showOntologyRelationships})),setHighlightedRelationshipType:n=>e(o=>({highlightedRelationshipType:o.highlightedRelationshipType===n?null:n})),toggleHiddenEdgeType:n=>e(o=>{const s=new Set(o.hiddenEdgeTypes);return s.has(n)?s.delete(n):s.add(n),{hiddenEdgeTypes:s}}),saveOntologySelection:()=>{const{model:n,availableOntologies:o,selectedOntologies:s}=r();if(!n)return{success:!0};const i=o.filter(c=>!s.has(c.name)),a=new Set;for(const c of i)for(const d of c.layers)for(const u of d.kinds)a.add(u.name);const l=[];if(a.size>0){for(const c of Object.values(n.elements))if(a.has(c.kind)){const d=i.find(u=>u.layers.some(m=>m.kinds.some(y=>y.name===c.kind)));l.push({elementId:c.id,elementName:c.name,kind:c.kind,fromOntology:(d==null?void 0:d.name)??"unknown"})}}return{success:!0,orphanedElements:l}},setOntologyInstallStatus:n=>e({ontologyInstallStatus:n}),toggleGapBar:()=>e(n=>({gapBarExpanded:!n.gapBarExpanded})),setGapBarHeight:n=>e({gapBarHeight:Math.max(80,Math.min(400,n))}),setCatalogGroupBy:n=>e({catalogGroupBy:n,catalogCollapsed:new Set}),toggleCatalogCollapsed:n=>e(o=>{const s=new Set(o.catalogCollapsed);return s.has(n)?s.delete(n):s.add(n),{catalogCollapsed:s}}),setCatalogCollapsedAll:n=>e(o=>n?{catalogCollapsed:new Set(["__ALL__"])}:{catalogCollapsed:new Set}),setContextMenu:n=>e({contextMenu:n}),setAttributeFilter:n=>e({attributeFilter:n}),setLabelFilter:n=>e({labelFilter:n}),toggleTagFilter:n=>e(o=>({tagFilters:o.tagFilters.includes(n)?o.tagFilters.filter(i=>i!==n):[...o.tagFilters,n]})),clearTagFilters:()=>e({tagFilters:[]}),setEditingElement:n=>e({editingElementId:n}),updateElementField:(n,o,s)=>e(i=>{const a=new Map(i.pendingEdits),l=a.get(n)||{};return a.set(n,{...l,[o]:s}),{pendingEdits:a}}),updateElementAttribute:(n,o,s)=>e(i=>{const a=new Map(i.pendingEdits),l=a.get(n)||{},c={...l.attributes||{},[o]:s};return a.set(n,{...l,attributes:c}),{pendingEdits:a}}),updateElementFolder:(n,o)=>{var a;const s=(a=r().model)==null?void 0:a.elements[n];if(!s)return;const i={...s,attributes:{...s.attributes,[De]:o}};e(l=>({model:l.model?{...l.model,elements:{...l.model.elements,[n]:i}}:null})),Te(i)},moveFolder:(n,o,s)=>{const i=r();if(!i.model)return;const a={...i.model.elements},l=[];for(const[c,d]of Object.entries(a))if(d.kind===n){const u=d.attributes[De]||"";if(u===o||u.startsWith(o+"/")){const m=u.slice(o.length),y=(s+m).replace("//","/"),S={...d,attributes:{...d.attributes,[De]:y}};a[c]=S,l.push(c)}}if(l.length!==0){e(c=>({model:c.model?{...c.model,elements:a}:null}));for(const c of l)Te(a[c])}},addElement:(n,o,s)=>{const i=r();if(!i.model)return;const a=`${n.toLowerCase().replace(/\s+/g,"_")}_${Math.random().toString(36).substr(2,5)}`,l=Object.values(i.model.elements).find(d=>d.kind===n),c={id:a,name:o,kind:n,construct:(l==null?void 0:l.construct)||"part",layer:(l==null?void 0:l.layer)||"Other",doc:"",attributes:{[De]:s},file:(l==null?void 0:l.file)||"model/generated.sysml"};e(d=>({model:d.model?{...d.model,elements:{...d.model.elements,[a]:c}}:null,selectedElementId:a,activeView:{type:"element-detail",elementId:a}})),wn(c)},deleteFolder:(n,o)=>{const s=r();if(!s.model)return;const i={...s.model.elements},a=o.includes("/")?o.split("/").slice(0,-1).join("/"):"",l=[];for(const[c,d]of Object.entries(i))if(d.kind===n){const u=d.attributes[De]||"";if(u===o||u.startsWith(o+"/")){const m=u.replace(o,a).replace("//","/"),y={...d,attributes:{...d.attributes,[De]:m}};i[c]=y,l.push(c)}}if(l.length!==0){e(c=>({model:c.model?{...c.model,elements:i}:null}));for(const c of l)Te(i[c])}},addUserViewpoint:n=>e(o=>({userViewpoints:[...o.userViewpoints,n]})),updateUserViewpoint:n=>e(o=>({userViewpoints:o.userViewpoints.map(s=>s.id===n.id?n:s)})),deleteUserViewpoint:n=>e(o=>({userViewpoints:o.userViewpoints.filter(s=>s.id!==n),selectedViewpointId:o.selectedViewpointId===n?null:o.selectedViewpointId})),createDiagram:({name:n,diagramType:o,viewpointId:s})=>{const i=`diag_${Math.random().toString(36).substr(2,9)}`,a={id:i,name:n,diagramType:o,viewpointId:s,auto:!1,elementIds:[]};e(l=>({model:l.model?{...l.model,diagrams:[...l.model.diagrams??[],a]}:null,selectedDiagramId:i,activeView:{type:"diagram",diagramId:i}})),Hs({id:i,name:n,diagramType:o,viewpointId:s,elementIds:[]})},addElementToDiagram:(n,o)=>{var l;const{model:s}=r(),i=(l=s==null?void 0:s.diagrams)==null?void 0:l.find(c=>c.id===n);if(!i)return;const a=i.elementIds??[];a.includes(o)||r().updateDiagramElementIds(n,[...a,o])},updateDiagramElementIds:(n,o)=>{const{model:s}=r();if(!(s!=null&&s.diagrams))return;const i=s.diagrams.findIndex(c=>c.id===n);if(i<0)return;const a={...s.diagrams[i],elementIds:o},l=[...s.diagrams];l[i]=a,e(c=>({model:c.model?{...c.model,diagrams:l}:null})),Sn({id:n,elementIds:o})},deleteDiagram:n=>{e(o=>({model:o.model?{...o.model,diagrams:(o.model.diagrams??[]).filter(s=>s.id!==n)}:null,selectedDiagramId:o.selectedDiagramId===n?null:o.selectedDiagramId,activeView:o.activeView.type==="diagram"&&o.activeView.diagramId===n?{type:"welcome"}:o.activeView})),Ks(n)},applyDiagramParseResult:(n,o,s)=>{const{model:i}=r();if(!(i!=null&&i.diagrams))return;const a=i.diagrams.findIndex(l=>l.id===n);if(a>=0){const l={...i.diagrams[a],elementIds:o},c=[...i.diagrams];c[a]=l,e(d=>({model:d.model?{...d.model,diagrams:c}:null,diagramParseErrors:{...d.diagramParseErrors,[n]:s}})),Sn({id:n,elementIds:o})}else e(l=>({diagramParseErrors:{...l.diagramParseErrors,[n]:s}}))},addDhfDocument:n=>e(o=>({dhfDocuments:[...o.dhfDocuments,n]})),setDhfDocuments:n=>e({dhfDocuments:n}),hydrateDhfSettings:n=>e(o=>({dhfSettings:{...o.dhfSettings,...n}})),updateDhfSettings:n=>e(o=>({dhfSettings:{...o.dhfSettings,...n}})),updateDhfDocumentMeta:(n,o)=>e(s=>({dhfDocuments:s.dhfDocuments.map(i=>i.id===n?{...i,...o}:i)})),updateDhfDocumentContent:(n,o)=>e(s=>({dhfDocuments:s.dhfDocuments.map(i=>i.id===n?{...i,content:o}:i)})),removeDhfDocument:n=>e(o=>({dhfDocuments:o.dhfDocuments.filter(s=>s.id!==n),activeView:o.activeView.type==="dhf-document"&&o.activeView.docId===n?{type:"dhf-dashboard"}:o.activeView})),setBulkImportOpen:n=>e({bulkImportOpen:n}),setImportResult:n=>e({importResult:n}),clearImportResult:()=>e({importResult:null}),cancelEdit:n=>e(o=>{const s=new Map(o.pendingEdits);return s.delete(n),{pendingEdits:s}}),applyEdit:async n=>{const{pendingEdits:o,model:s}=r(),i=o.get(n);if(!i||!s)return;const a=s.elements[n];if(!a)return;const l={...a};i.doc!==void 0&&(l.doc=i.doc),i.attributes&&(l.attributes={...a.attributes,...i.attributes}),n.startsWith("new_")?wn(l):Te(l);const c={...s,elements:{...s.elements,[n]:l}},d=new Map(o);d.delete(n),e({model:c,pendingEdits:d})}})),Qs={relationships:[],kinds:[]};function gr(e){return(e==null?void 0:e.registries)??Qs}function Zs(e,r){return Zt(r,gr(e))}function Td(e){const r=new Map;if(!e)return r;for(const n of Object.values(e.elements))r.has(n.layer)||r.set(n.layer,[]),r.get(n.layer).push(n);return r}function ei(e,r){return e?e.relationships.filter(n=>n.sourceId===r||n.targetId===r):[]}function vt(e,r){return!e||!r||!e.diagrams?null:e.diagrams.find(n=>n.id===r)??null}function Id(e,r){const n=vt(e,r);return n?n.sourceFiles&&n.sourceFiles.length>0?n.sourceFiles:n.sourceFile?[n.sourceFile]:[]:[]}function ti(e,r){var o;const n=r?(o=e==null?void 0:e.elements[r])==null?void 0:o.file:void 0;return n?[...ys(n,e==null?void 0:e.sourceGraph)]:[]}function ni(e,r){return e?xs(e.files,r):!1}function yr(e,r){return e!=null&&e.diagrams?e.diagrams.filter(n=>{var o;return n.viewpointId===r||((o=n.viewpointIds)==null?void 0:o.includes(r))}):[]}const nn={dashboard:"/",dsm:"/dsm",ontology:"/ontology",traceability:"/traceability","scenario-editor":"/use-cases","model-diff":"/diff","compliance-wizard":"/compliance",statistics:"/statistics","dhf-dashboard":"/dhf","dhf-dashboard-legacy":"/dhf/legacy",ai:"/ai",ask:"/ask","sysml-generator":"/generate","review-dashboard":"/review","workflow-wizard":"/workflow",import:"/import",analysis:"/analysis"},xr={"/dashboard":"dashboard","/scenarios":"scenario-editor"},ri={...Object.fromEntries(Object.entries(nn).map(([e,r])=>[r,e])),...xr};function oi(e){return e.toLowerCase().replace(/\s+/g,"-")}function si(e){switch(e.type){case"welcome":return"/";case"ontology-detail":return e.layerId?`/ontology/${encodeURIComponent(e.packageName)}/${encodeURIComponent(e.layerId)}`:`/ontology/${encodeURIComponent(e.packageName)}`;case"dhf-document":return`/dhf/${encodeURIComponent(e.docId)}`;case"tabular":{const r=new URLSearchParams;e.viewpointId&&r.set("viewpoint",e.viewpointId),e.diagramId&&r.set("diagram",e.diagramId);const n=r.toString();return n?`/table?${n}`:"/table"}case"element-detail":case"diagram":return null;default:return nn[e.type]??null}}function ii(e,r=""){const n=e.length>1?e.replace(/\/+$/,""):e,o=ri[n];if(o)return{type:o};if(n==="/table"){const i=new URLSearchParams(r);return{type:"tabular",viewpointId:i.get("viewpoint")??void 0,diagramId:i.get("diagram")??void 0}}const s=n.split("/").filter(Boolean);return s[0]==="dhf"&&s.length===2?{type:"dhf-document",docId:decodeURIComponent(s[1])}:s[0]==="ontology"&&s.length>=2?{type:"ontology-detail",packageName:decodeURIComponent(s[1]),layerId:s[2]?decodeURIComponent(s[2]):void 0}:null}function ai(e){const r=e.split("/").filter(Boolean);return r[0]==="catalog"&&r.length===3||r[0]==="diagrams"&&r.length===3}function li(){return[...Object.values(nn),...Object.keys(xr)].filter(e=>e!=="/")}const di=[{id:"ai-tools",label:"AI Tools",description:"Model Assistant (model Q&A and proposed edits) and SysML Generator (natural language → SysML v2). Generated content is unreviewed and carries no design-control provenance, so the surface stays off by default.",stage:"experimental"},{id:"ontology",label:"Ontology Explorer",description:"Direct ontology browsing is an advanced workbench surface and stays off in the default regulated workspace.",stage:"experimental"},{id:"import",label:"Import",description:"Model import is an advanced transformation surface and stays off in the default regulated workspace.",stage:"experimental"},{id:"model-tools",label:"Model Tools",description:"Matrices, diagnostics, review, and workflow tools are available together only in the experimental workbench.",stage:"experimental"},{id:"analysis",label:"Analysis & Jupyter",description:"Analysis provides direct access to the user’s live local JupyterLab notebook workspace.",stage:"stable"}];function ci(){return typeof window>"u"?{}:window.__MEMO_FLAGS__??{}}function oe(e){const r=di.find(n=>n.id===e);return r?r.stage==="stable"?!0:ci().experimental===!0:!1}const ui=new Set(["catalog","diagram","dhf"]);function it(){E(c=>c.model);const e=E(c=>c.setActiveView),r=E(c=>c.setActiveMode),n=E(c=>c.sidebarCollapsed),o=E(c=>c.toggleSidebar),s=E(c=>c.activeMode),i=Se(),a=ui.has(s);function l(){r("catalog"),e({type:"welcome"}),i("/")}return t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:{background:"#0B1E2D",borderBottom:"1px solid rgba(255,255,255,0.06)",position:"relative",zIndex:10},children:[t.jsx("button",{onClick:a?o:void 0,title:n?"Show explorer":"Hide explorer",style:{width:"28px",height:"28px",borderRadius:"6px",background:"none",border:"none",cursor:a?"pointer":"default",color:a?n?"rgba(255,255,255,0.35)":"#2DD4A8":"rgba(255,255,255,0.12)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",flexShrink:0,transition:"color 150ms"},onMouseEnter:c=>{a&&(c.currentTarget.style.color="#2DD4A8")},onMouseLeave:c=>{a&&(c.currentTarget.style.color=n?"rgba(255,255,255,0.35)":"#2DD4A8")},children:"☰"}),t.jsx("button",{onClick:l,className:"text-sm font-bold transition-opacity",style:{color:"#2DD4A8",letterSpacing:"0.04em",background:"none",border:"none",cursor:"pointer",padding:0},onMouseEnter:c=>c.currentTarget.style.opacity="0.75",onMouseLeave:c=>c.currentTarget.style.opacity="1",title:"Go to home",children:"MEMO Architect"}),t.jsx("div",{className:"flex-1"}),t.jsx("img",{src:"/logo.png",alt:"MEMO",style:{height:40,opacity:.9,cursor:"pointer"},onClick:l,title:"Go to home"})]})}const br="memo-working-sets",vr="memo-quick-slots";function pi(){return`ws-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function at(e){try{localStorage.setItem(br,JSON.stringify(e))}catch{}}function mi(){try{const e=localStorage.getItem(br);return e?JSON.parse(e):[]}catch{return[]}}function Cn(){try{const e=localStorage.getItem(vr);return e?JSON.parse(e):[null,null,null,null]}catch{return[null,null,null,null]}}function jn(e){try{localStorage.setItem(vr,JSON.stringify(e))}catch{}}const jt=Un((e,r)=>({workingSets:[],activeWorkingSetId:null,quickSlots:Cn(),loadFromStorage:()=>{const n=mi(),o=Cn();e({workingSets:n,quickSlots:o})},saveWorkingSet:(n,o)=>{const s=pi(),i=Date.now(),a={id:s,name:n,createdAt:i,updatedAt:i,state:o},l=[...r().workingSets,a];return e({workingSets:l,activeWorkingSetId:s}),at(l),s},updateWorkingSet:(n,o)=>{const s=r().workingSets.map(i=>i.id===n?{...i,state:o,updatedAt:Date.now()}:i);e({workingSets:s}),at(s)},renameWorkingSet:(n,o)=>{const s=r().workingSets.map(i=>i.id===n?{...i,name:o,updatedAt:Date.now()}:i);e({workingSets:s}),at(s)},deleteWorkingSet:n=>{const o=r().workingSets.filter(i=>i.id!==n),s=r().activeWorkingSetId===n?null:r().activeWorkingSetId;e({workingSets:o,activeWorkingSetId:s}),at(o)},setActiveWorkingSet:n=>e({activeWorkingSetId:n}),saveQuickSlot:(n,o,s)=>{const i=["Last Session","Slot 1","Slot 2","Slot 3"],a=[...r().quickSlots];for(;a.length<4;)a.push(null);a[n]={name:s??i[n],state:o,savedAt:Date.now()},jn(a),e({quickSlots:a})},clearQuickSlot:n=>{const o=[...r().quickSlots];o[n]=null,jn(o),e({quickSlots:o})}})),j={badge:"12px",xs:"12px",sm:"13px",md:"14px",lg:"15px",explorer:{group:"13px",kind:"12px",item:"13px",element:"13px",count:"12px",search:"13px"}},g={primary:"#082744",secondary:"#324E67",muted:"#5C7188",faint:"#8CA0B1",surface:"#FFFFFF",surfaceAlt:"#EEF4F7",border:"#D8E2E9",borderLight:"#E6EDF2",accent:"#2DD4A8",accentDark:"#0B1E2D"},_d={sm:"0 1px 3px rgba(0,0,0,0.08)",md:"0 2px 8px rgba(0,0,0,0.1)",selected:"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)"},Nd={md:"10px"},Md={defaultWidth:2,flowWidth:2.5,arrowSize:16,labelBgPadding:[6,4],labelBgRadius:6,labelBgStyle:{fill:"#FFFFFF",fillOpacity:.92,stroke:"#E5E5E0",strokeWidth:.5}};function Dt(){const e=E.getState();return{activeView:e.activeView,explorerTab:e.explorerTab,selectedElementId:e.selectedElementId,selectedViewpointId:e.selectedViewpointId,selectedDiagramId:e.selectedDiagramId,sidebarCollapsed:e.sidebarCollapsed,propertiesPanelCollapsed:e.propertiesPanelCollapsed,hiddenLayers:Array.from(e.hiddenLayers)}}function At(e){const r=E.getState();r.setActiveView(e.activeView),r.setExplorerTab(e.explorerTab),r.selectElement(e.selectedElementId),e.selectedDiagramId&&r.selectDiagram(e.selectedDiagramId),e.selectedViewpointId&&r.selectViewpoint(e.selectedViewpointId)}function fi(){const[e,r]=p.useState(!1),n=p.useRef(null),o=jt(l=>l.quickSlots),s=jt(l=>l.saveQuickSlot),i=jt(l=>l.clearQuickSlot);p.useEffect(()=>{if(!e)return;const l=c=>{n.current&&!n.current.contains(c.target)&&r(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[e]),p.useEffect(()=>{const l=()=>{s(0,Dt(),"Last Session")};return window.addEventListener("beforeunload",l),()=>window.removeEventListener("beforeunload",l)},[s]),p.useEffect(()=>{const l=c=>{if(!(c.ctrlKey||c.metaKey))return;const d=c.key==="1"?1:c.key==="2"?2:c.key==="3"?3:null;if(d)if(c.preventDefault(),c.shiftKey)s(d,Dt());else{const u=o[d];u&&At(u.state)}};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[o,s]);const a=["Last Session","Slot 1","Slot 2","Slot 3"];return t.jsxs("div",{ref:n,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>r(l=>!l),className:"flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-md transition-all",style:e?{background:"rgba(45,212,168,0.15)",color:"#2DD4A8"}:{background:"transparent",color:"rgba(255,255,255,0.5)"},title:"Workspaces (Ctrl+1/2/3 to restore, Ctrl+Shift+1/2/3 to save)",children:[t.jsx("span",{children:"⊟"}),t.jsx("span",{style:{fontSize:"10px",marginLeft:"2px",opacity:.7},children:"▾"})]}),e&&t.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",right:0,zIndex:100,background:"#132D3E",border:"1px solid rgba(45,212,168,0.2)",borderRadius:"8px",minWidth:"240px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden"},children:[t.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:j.xs,color:"rgba(255,255,255,0.4)",fontWeight:600},children:"WORKSPACES"}),t.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{style:{fontSize:j.xs,color:"rgba(255,255,255,0.5)",fontWeight:600},children:"Last Session"}),o[0]?t.jsx("button",{onClick:()=>{At(o[0].state),r(!1)},className:"px-2 py-0.5 rounded text-xs",style:{background:"rgba(45,212,168,0.15)",color:"#2DD4A8",border:"none",cursor:"pointer"},children:"Restore"}):t.jsx("span",{style:{fontSize:"10px",color:"rgba(255,255,255,0.25)"},children:"— none saved —"})]}),o[0]&&t.jsx("div",{style:{fontSize:"10px",color:"rgba(255,255,255,0.3)",marginTop:2},children:new Date(o[0].savedAt).toLocaleString()})]}),[1,2,3].map(l=>{const c=o[l];return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid rgba(255,255,255,0.04)"},children:[t.jsxs("span",{style:{fontSize:"10px",fontWeight:700,color:"rgba(255,255,255,0.3)",minWidth:"16px"},children:["⌃",l]}),t.jsx("div",{className:"flex-1 min-w-0",children:c?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{fontSize:j.xs,color:"rgba(255,255,255,0.7)",fontWeight:500},children:c.name}),t.jsx("div",{style:{fontSize:"10px",color:"rgba(255,255,255,0.3)"},children:new Date(c.savedAt).toLocaleTimeString()})]}):t.jsx("span",{style:{fontSize:j.xs,color:"rgba(255,255,255,0.25)",fontStyle:"italic"},children:"empty"})}),t.jsxs("div",{className:"flex gap-1",children:[c&&t.jsx("button",{onClick:()=>{At(c.state),r(!1)},style:{fontSize:"10px",padding:"2px 6px",borderRadius:3,background:"rgba(45,212,168,0.15)",color:"#2DD4A8",border:"none",cursor:"pointer"},children:"Restore"}),t.jsx("button",{onClick:()=>s(l,Dt(),a[l]),style:{fontSize:"10px",padding:"2px 6px",borderRadius:3,background:"rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",border:"none",cursor:"pointer"},title:`Save current view to Slot ${l} (⌃⇧${l})`,children:"Save"}),c&&t.jsx("button",{onClick:()=>i(l),style:{fontSize:"10px",padding:"2px 4px",borderRadius:3,background:"transparent",color:"rgba(255,255,255,0.3)",border:"none",cursor:"pointer"},title:"Clear slot",children:"✕"})]})]},l)})]})]})}const hi="/help/",gi="http://127.0.0.1:8888/lab/tree/",yi=[{id:"dashboard",label:"Dashboard",icon:"⌂"},{id:"catalog",label:"Model Explorer",icon:"☰"},{id:"diagram",label:"Viewpoints",icon:"⊟"},{id:"dhf",label:"Documents",icon:"⊞"},{id:"scenario",label:"Use Cases",icon:"▶"},{id:"ai",label:"AI Tools",icon:"✦",feature:"ai-tools"}],xi=new Set(["dsm","traceability","statistics","compliance-wizard","model-diff","review-dashboard","workflow-wizard","ontology","ontology-detail","import"]);function bi(){const[e,r]=p.useState(!1),n=p.useRef(null);return p.useEffect(()=>{function o(s){n.current&&!n.current.contains(s.target)&&r(!1)}return e&&document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e]),t.jsxs("div",{ref:n,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>r(o=>!o),"aria-expanded":e,"aria-haspopup":"menu",className:"flex items-center gap-1 px-4 py-1.5 text-sm font-medium rounded-md transition-all",style:e?{background:"rgba(45, 212, 168, 0.15)",color:"#2DD4A8"}:{background:"transparent",color:"rgba(255,255,255,0.5)"},children:[t.jsx("span",{className:"mr-0.5",children:"◫"}),"Analysis",t.jsx("span",{style:{fontSize:"10px",marginLeft:"2px",opacity:.7},children:"▾"})]}),e&&t.jsx("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:100,background:"#132D3E",border:"1px solid rgba(45,212,168,0.2)",borderRadius:"8px",minWidth:"220px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden"},children:t.jsxs("a",{href:gi,target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:()=>r(!1),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors",style:{fontSize:"13px",color:"rgba(255,255,255,0.75)",textDecoration:"none"},onMouseEnter:o=>{o.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:[t.jsx("span",{style:{width:"18px",textAlign:"center",opacity:.7},children:"⌁"}),"Jupyter Notebooks"]})})]})}const Dn=[{id:"ontology",label:"Ontology Explorer",icon:"◉",view:{type:"ontology"}},{id:"import",label:"Import Model",icon:"↓",view:{type:"import"}},{id:"dsm",label:"Design Structure Matrix",icon:"▤",view:{type:"dsm"}},{id:"traceability",label:"Traceability Matrix",icon:"☷",view:{type:"traceability"}},{id:"statistics",label:"Statistics Dashboard",icon:"⊠",view:{type:"statistics"}},{id:"compliance-wizard",label:"Compliance Wizard",icon:"☑",view:{type:"compliance-wizard"}},{id:"model-diff",label:"Model Diff",icon:"↔",view:{type:"model-diff"}},{id:"review-dashboard",label:"Design Review Dashboard",icon:"📋",view:{type:"review-dashboard"}},{id:"workflow-wizard",label:"Workflow Wizard",icon:"🧙",view:{type:"workflow-wizard"}}];function vi({activeViewType:e}){const r=E(l=>l.setActiveView);E(l=>l.setActiveMode);const[n,o]=p.useState(!1),s=p.useRef(null),a=Dn.map(l=>l.id).includes(e);return p.useEffect(()=>{function l(c){s.current&&!s.current.contains(c.target)&&o(!1)}return n&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]),t.jsxs("div",{ref:s,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>o(l=>!l),className:"flex items-center gap-1 px-4 py-1.5 text-sm font-medium rounded-md transition-all",style:a||n?{background:"rgba(45, 212, 168, 0.15)",color:"#2DD4A8"}:{background:"transparent",color:"rgba(255,255,255,0.5)"},children:[t.jsx("span",{className:"mr-0.5",children:"⚙"}),"Tools",t.jsx("span",{style:{fontSize:"10px",marginLeft:"2px",opacity:.7},children:"▾"})]}),n&&t.jsx("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:100,background:"#132D3E",border:"1px solid rgba(45,212,168,0.2)",borderRadius:"8px",minWidth:"220px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",overflow:"hidden"},children:Dn.filter(l=>(l.id!=="ontology"||oe("ontology"))&&(l.id!=="import"||oe("import"))).map((l,c)=>{const d=e===l.view.type;return t.jsxs("button",{onClick:()=>{r(d?{type:"welcome"}:l.view),o(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors",style:{fontSize:"13px",color:d?"#2DD4A8":"rgba(255,255,255,0.75)",background:d?"rgba(45,212,168,0.1)":"transparent",borderTop:c>0?"1px solid rgba(255,255,255,0.05)":"none"},onMouseEnter:u=>{d||(u.currentTarget.style.background="rgba(255,255,255,0.06)")},onMouseLeave:u=>{d||(u.currentTarget.style.background="transparent")},children:[t.jsx("span",{style:{width:"18px",textAlign:"center",opacity:.7},children:l.icon}),l.label]},l.id)})})]})}function wi(){const e=E(m=>m.activeMode),r=E(m=>m.setActiveMode),n=E(m=>m.activeView),o=E(m=>m.setActiveView),s=E(m=>m.setExplorerTab),i=E(m=>m.sidebarCollapsed),a=E(m=>m.toggleSidebar),l=Se(),c=["catalog","diagram","dhf","scenario"],d=xi.has(n.type)?"":e==="dhf"||n.type==="dhf-dashboard"?"dhf":n.type==="scenario-editor"||e==="scenario"&&n.type==="diagram"?"scenario":n.type==="analysis"?"analysis":n.type==="ai"||n.type==="ask"||n.type==="sysml-generator"?"ai":n.type==="diagram"||e==="diagram"?"diagram":e==="catalog"?"catalog":n.type==="dashboard"?"dashboard":e;function u(m){if(m===d&&c.includes(m)){a();return}switch(c.includes(m)&&i&&a(),r(m),m){case"dashboard":o({type:"dashboard"});break;case"catalog":o({type:"welcome"}),l("/catalog");break;case"diagram":s("views"),o({type:"welcome"}),l("/diagrams");break;case"dhf":o({type:"dhf-dashboard"});break;case"scenario":o({type:"scenario-editor"});break;case"ai":o({type:"ai"});break}}return t.jsxs("div",{className:"flex items-center gap-1 px-5 py-3",style:{background:"#1B3A4B",borderBottom:"1px solid rgba(255,255,255,0.08)",overflow:"visible",position:"relative",zIndex:10},children:[yi.filter(m=>!("feature"in m)||oe(m.feature)).map(m=>t.jsxs("button",{onClick:()=>u(m.id),className:"px-4 py-1.5 text-sm font-medium rounded-md transition-all",style:d===m.id?{background:"rgba(45, 212, 168, 0.15)",color:"#2DD4A8"}:{background:"transparent",color:"rgba(255,255,255,0.5)"},children:[t.jsx("span",{className:"mr-1.5",children:m.icon}),m.label]},m.id)),oe("analysis")&&t.jsx(bi,{}),t.jsx("div",{style:{width:"1px",height:"20px",background:"rgba(255,255,255,0.12)",margin:"0 4px"}}),oe("model-tools")&&t.jsx(vi,{activeViewType:n.type}),t.jsx("div",{className:"flex-1"}),t.jsx(fi,{}),t.jsx("a",{href:hi,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-1.5 text-sm font-medium rounded-md transition-all",style:{color:"rgba(255,255,255,0.4)",textDecoration:"none"},onMouseEnter:m=>m.currentTarget.style.color="rgba(255,255,255,0.75)",onMouseLeave:m=>m.currentTarget.style.color="rgba(255,255,255,0.4)",children:"? Help"}),t.jsx("img",{src:"/memo-top.png",alt:"MEMO",className:"ml-3",style:{height:56,marginTop:-4,marginBottom:-10}})]})}const ne={operational:"#0F766E",business:"#8E44AD",requirements:"#4A90D9",risk:"#E74C3C",functional:"#E67E22",behavior:"#FF6B6B",logical:"#7B68EE",physical:"#95A5A6",software:"#F39C12",interfaces:"#1ABC9C",verification:"#2ECC71",ui:"#3498DB"},Xe={operational:"Operational Analysis",business:"Business Analysis",requirements:"Requirements",risk:"Risk Management",functional:"Functional Analysis",behavior:"Behavior",logical:"Logical Architecture",physical:"Physical Architecture",software:"Software Architecture",interfaces:"Interfaces & Ports",verification:"Verification",ui:"UI Wireframe"},Si=["context","operational","system","system_of_systems","functions","logical_structure","logical","interfaces","software_structure","hardware_structure","physical","ui","behavior","requirements","risk","cybersecurity","human_factors","verification","assurance","architecture"],Ue=["operational","business","requirements","risk","functional","behavior","logical","physical","software","interfaces","verification","ui"],Od={mitigates:"#E74C3C",causes:"#C0392B",leadsTo:"#E74C3C",identifies:"#D35400",traceTo:"#4A90D9",satisfy:"#2ECC71",verify:"#27AE60",allocateTo:"#E67E22",aggregation:"#7B68EE",composedOf:"#8E44AD",decomposedBy:"#D35400",flow:"#3498DB",succession:"#95A5A6"},ki={general:{label:"GEN",fullName:"General View",color:"#7B68EE"},interconnection:{label:"INT",fullName:"Interconnection View",color:"#1ABC9C"},actionflow:{label:"ACT",fullName:"Action Flow View",color:"#F39C12"},statetransition:{label:"STM",fullName:"State Transition View",color:"#FF6B6B"},sequence:{label:"SEQ",fullName:"Sequence View",color:"#3498DB"},grid:{label:"GRID",fullName:"Grid View",color:"#2ECC71"},browser:{label:"BRW",fullName:"Browser View",color:"#95A5A6"},geometry:{label:"GEO",fullName:"Geometry View",color:"#8E44AD"}},Re={bdd:{code:"BDD",label:"BDD",fullName:"Block Definition Diagram",color:"#7B68EE",viewKind:"general"},ibd:{code:"IBD",label:"IBD",fullName:"Internal Block Diagram",color:"#1ABC9C",viewKind:"interconnection"},req:{code:"REQ",label:"REQ",fullName:"Requirements Diagram",color:"#4A90D9",viewKind:"general"},ucd:{code:"UCD",label:"UCD",fullName:"Use Case Diagram",color:"#E67E22",viewKind:"general"},context:{code:"CTX",label:"CTX",fullName:"System Context Diagram",color:"#5DADE2",viewKind:"general"},act:{code:"ACT",label:"ACT",fullName:"Activity Diagram",color:"#F39C12",viewKind:"actionflow"},afd:{code:"AFD",label:"AFD",fullName:"Action Flow Diagram",color:"#FF6B6B",viewKind:"actionflow"},ofd:{code:"OFD",label:"OFD",fullName:"Operational Flow Diagram",color:"#F39C12",viewKind:"actionflow"},ffd:{code:"FFD",label:"FFD",fullName:"Functional Flow Diagram",color:"#F39C12",viewKind:"actionflow"},pkg:{code:"PKG",label:"PKG",fullName:"Package Diagram",color:"#95A5A6",viewKind:"general"},par:{code:"PAR",label:"PAR",fullName:"Parametric Diagram",color:"#2ECC71",viewKind:"interconnection"},risk:{code:"RISK",label:"RISK",fullName:"Risk Diagram",color:"#E74C3C",viewKind:"general"},stm:{code:"STM",label:"STM",fullName:"State Transition Diagram",color:"#FF6B6B",viewKind:"statetransition"},seq:{code:"SEQ",label:"SEQ",fullName:"Sequence Diagram",color:"#3498DB",viewKind:"sequence"},fmea:{code:"FMEA",label:"FMEA",fullName:"FMEA Matrix",color:"#E74C3C",viewKind:"grid"},alloc:{code:"ALLOC",label:"ALLOC",fullName:"Allocation Matrix",color:"#E67E22",viewKind:"grid"},"threat-model":{code:"THREAT",label:"THREAT",fullName:"Threat Model Diagram",color:"#C0392B",viewKind:"general"}};function Ei(e){const r=e.diagramType.trim().toLowerCase();return r==="ofd"||r==="ffd"?r:"afd"}const Pd=["#FFFFFF","#f8fafc","#f0f9ff","#fdf2f8","#f0fdf4"];function Ce({label:e,onClick:r,icon:n}){return t.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs",style:{color:"#374151",background:"transparent",border:"none",cursor:"pointer",whiteSpace:"nowrap"},onMouseEnter:o=>o.currentTarget.style.background="#F0F0ED",onMouseLeave:o=>o.currentTarget.style.background="transparent",onClick:o=>{o.stopPropagation(),r()},children:[n&&t.jsx("span",{style:{fontSize:"12px",width:"14px",flexShrink:0},children:n}),e]})}function Ci(){return t.jsx("div",{style:{height:"1px",background:"#E5E5E0",margin:"3px 0"}})}function ji({x:e,y:r,target:n,onViewVisual:o,onViewTable:s,onToggleSelection:i,onViewProperties:a,onClose:l}){const c=p.useRef(null);p.useEffect(()=>{if(!c.current)return;const u=c.current,{innerWidth:m,innerHeight:y}=window,S=u.getBoundingClientRect();S.right>m&&(u.style.left=`${e-S.width}px`),S.bottom>y&&(u.style.top=`${r-S.height}px`)},[e,r]);const d={position:"fixed",top:r,left:e,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",zIndex:9999,minWidth:"180px",padding:"4px 0"};return n.type==="package"?t.jsxs("div",{ref:c,style:d,onMouseDown:u=>u.stopPropagation(),children:[t.jsx(Ce,{icon:"⬜",label:"View Visual Layout",onClick:()=>{o(n.pkgName),l()}}),t.jsx(Ce,{icon:"☰",label:"View as Table",onClick:()=>{s(n.pkgName),l()}}),t.jsx(Ci,{}),t.jsx(Ce,{icon:n.isSelected?"☑":"☐",label:n.isSelected?"Deselect for Project":"Select for Project",onClick:()=>i(n.pkgName)})]}):n.type==="layer"?t.jsxs("div",{ref:c,style:d,onMouseDown:u=>u.stopPropagation(),children:[t.jsx(Ce,{icon:"⬜",label:"View Visual Layout",onClick:()=>{o(n.pkgName),l()}}),t.jsx(Ce,{icon:"☰",label:"View as Table",onClick:()=>s(n.pkgName,n.layerId)})]}):t.jsxs("div",{ref:c,style:d,onMouseDown:u=>u.stopPropagation(),children:[t.jsx(Ce,{icon:"🔍",label:"View Properties",onClick:()=>a(n.kindName,n.pkgName)}),t.jsx(Ce,{icon:"☰",label:"View as Table",onClick:()=>s(n.pkgName,n.layerId)}),t.jsx(Ce,{icon:"⬜",label:"Show in Visual Layout",onClick:()=>{o(n.pkgName),l()}})]})}function Di({kindsToRemap:e,onConfirm:r,onCancel:n}){const o=E(u=>u.availableOntologies),s=E(u=>u.selectedOntologies),i=o.filter(u=>s.has(u.name)).flatMap(u=>u.layers.flatMap(m=>m.kinds.map(y=>y.name))).filter((u,m,y)=>y.indexOf(u)===m).sort(),[a,l]=p.useState(Object.fromEntries(e.map(u=>[u,""])));function c(u,m){l(y=>({...y,[u]:m}))}const d=e.every(u=>a[u]);return t.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},children:t.jsxs("div",{className:"rounded-xl shadow-2xl max-w-lg w-full mx-4 overflow-hidden",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"px-6 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[t.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Remap Orphaned Kinds"}),t.jsx("p",{className:"text-xs mt-1",style:{color:"#6B7280"},children:"Map each orphaned kind to a kind in the selected ontologies. Model elements will be updated to use the new kind."})]}),t.jsx("div",{className:"px-6 py-4 space-y-3 max-h-64 overflow-y-auto",children:e.map(u=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 px-2 py-1 rounded text-xs font-medium",style:{background:"#FEF2F2",color:"#EF4444",border:"1px solid #FCA5A5"},children:u}),t.jsx("span",{style:{color:"#9CA3AF"},children:"→"}),t.jsxs("select",{value:a[u],onChange:m=>c(u,m.target.value),className:"flex-1 text-xs rounded-md px-2 py-1 focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#1a1a1a",background:"#FFFFFF"},children:[t.jsx("option",{value:"",children:"Select target kind…"}),i.map(m=>t.jsx("option",{value:m,children:m},m))]})]},u))}),t.jsxs("div",{className:"px-6 py-4 flex gap-2 justify-end",style:{borderTop:"1px solid #E5E5E0"},children:[t.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs rounded-md",style:{background:"#F0F0ED",color:"#374151"},children:"Back"}),t.jsx("button",{onClick:()=>r(a),disabled:!d,className:"px-3 py-1.5 text-xs rounded-md font-medium",style:{background:d?"#1B3A4B":"#E5E5E0",color:d?"#FFFFFF":"#9CA3AF",cursor:d?"pointer":"not-allowed"},children:"Apply Remapping"})]})]})})}function Ai({orphans:e,onKeep:r,onRemap:n,onCancel:o}){const[s,i]=p.useState(!1),a=new Map;for(const l of e)a.has(l.kind)||a.set(l.kind,[]),a.get(l.kind).push(l);return s?t.jsx(Di,{kindsToRemap:[...a.keys()],onConfirm:n,onCancel:()=>i(!1)}):t.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:l=>{l.target===l.currentTarget&&o()},children:t.jsxs("div",{className:"rounded-xl shadow-2xl max-w-md w-full mx-4 overflow-hidden",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"px-6 py-4",style:{borderBottom:"1px solid #E5E5E0",background:"#FEF2F2"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-red-500 text-lg",children:"⚠"}),t.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Orphaned Elements"})]}),t.jsxs("p",{className:"text-xs mt-1",style:{color:"#6B7280"},children:[e.length," element",e.length!==1?"s":""," use kinds from the deselected ontology."]})]}),t.jsx("div",{className:"px-6 py-4 max-h-48 overflow-y-auto",children:[...a.entries()].map(([l,c])=>t.jsxs("div",{className:"mb-3",children:[t.jsxs("div",{className:"text-xs font-semibold mb-1",style:{color:"#374151"},children:[l,t.jsxs("span",{className:"ml-1 font-normal",style:{color:"#9CA3AF"},children:["(",c.length," element",c.length!==1?"s":"",")"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.slice(0,5).map(d=>t.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:"#FEF2F2",color:"#EF4444",border:"1px solid #FCA5A5"},children:d.elementName},d.elementId)),c.length>5&&t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:["+",c.length-5," more"]})]})]},l))}),t.jsxs("div",{className:"px-6 py-4 flex gap-2 justify-end",style:{borderTop:"1px solid #E5E5E0"},children:[t.jsx("button",{onClick:o,className:"px-3 py-1.5 text-xs rounded-md",style:{background:"#F0F0ED",color:"#374151"},children:"Cancel"}),t.jsx("button",{onClick:r,className:"px-3 py-1.5 text-xs rounded-md",style:{background:"#FEF2F2",color:"#EF4444",border:"1px solid #FCA5A5"},children:"Keep (mark orphaned)"}),t.jsx("button",{onClick:()=>i(!0),className:"px-3 py-1.5 text-xs rounded-md font-medium",style:{background:"#1B3A4B",color:"#FFFFFF"},children:"Remap kinds →"})]})]})})}const An={ontology:"📦",profile:"🔧",extension:"🧩"};function Ri(e){const r=new Map(e.map(l=>[l.name,l])),n=new Map;function o(l){if(n.has(l))return n.get(l);const c=r.get(l);if(!c||!c.derivesFrom||!r.has(c.derivesFrom))return n.set(l,0),0;const d=o(c.derivesFrom)+1;return n.set(l,d),d}for(const l of e)o(l.name);const s=new Map;for(const l of e){const c=n.get(l.name)??0,d=s.get(c)??[];d.push(l),s.set(c,d)}const i=Math.max(...s.keys()),a=[];for(let l=0;l<=i;l++){const c=s.get(l)??[];a.push(...c.sort((d,u)=>d.name.localeCompare(u.name)))}return a}function Fi(e){const r=new Map(e.map(l=>[l.name,l])),n=new Map;function o(l){if(n.has(l))return n.get(l);const c=r.get(l);if(!c||!c.extends||!r.has(c.extends))return n.set(l,0),0;const d=o(c.extends)+1;return n.set(l,d),d}for(const l of e)o(l.name);const s=new Map;for(const l of e){const c=n.get(l.name)??0,d=s.get(c)??[];d.push(l),s.set(c,d)}const i=s.size>0?Math.max(...s.keys()):0,a=[];for(let l=0;l<=i;l++){const c=s.get(l)??[];a.push(...c.sort((d,u)=>d.name.localeCompare(u.name)))}return a}function Ti({pkgName:e,onCancel:r,onConfirm:n}){const o=e.replace(/^@memo(?:architect)?\//,"");return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.45)"},onMouseDown:s=>{s.target===s.currentTarget&&r()},children:t.jsxs("div",{className:"rounded-xl p-5 shadow-2xl",style:{background:"#FFFFFF",maxWidth:"340px",width:"90vw"},children:[t.jsx("div",{className:"font-semibold mb-1.5",style:{fontSize:j.sm,color:g.primary},children:"Remove ontology?"}),t.jsxs("div",{className:"mb-4",style:{fontSize:j.xs,color:g.secondary,lineHeight:1.5},children:["Removing ",t.jsx("strong",{children:o})," will affect all model elements that depend on its kinds. Those elements will become orphaned until you add a compatible ontology."]}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:r,className:"px-3 py-1.5 rounded-md font-medium",style:{fontSize:j.xs,background:g.surfaceAlt,color:g.secondary,border:`1px solid ${g.border}`,cursor:"pointer"},children:"Cancel"}),t.jsx("button",{onClick:n,className:"px-3 py-1.5 rounded-md font-medium",style:{fontSize:j.xs,background:"#DC2626",color:"#FFFFFF",border:"none",cursor:"pointer"},children:"Remove"})]})]})})}function Ii(){const e=E(v=>v.availableOntologies),r=E(v=>v.selectedOntologies),n=E(v=>v.toggleOntologySelection),o=E(v=>v.saveOntologySelection),s=E(v=>v.selectedOntologyKind),i=E(v=>v.setSelectedOntologyKind),a=E(v=>v.setActiveView),l=E(v=>v.setOntologyViewMode),c=E(v=>v.activeView),[d,u]=p.useState(""),[m,y]=p.useState(()=>new Set(e.filter(v=>v.selected).map(v=>v.name))),[S,x]=p.useState(new Set),[f,w]=p.useState(()=>new Set(e.filter(v=>v.selected).map(v=>v.name))),h=p.useMemo(()=>{if(r.size!==f.size)return!0;for(const v of r)if(!f.has(v))return!0;return!1},[r,f]),[C,A]=p.useState(null),[b,R]=p.useState(null),[T,O]=p.useState(null),D=p.useRef(new Map),P=p.useMemo(()=>{const v=d.trim()?e.map(k=>({...k,layers:k.layers.map(I=>({...I,kinds:I.kinds.filter(q=>q.name.toLowerCase().includes(d.toLowerCase())||q.label.toLowerCase().includes(d.toLowerCase())||q.layer.toLowerCase().includes(d.toLowerCase()))})).filter(I=>I.kinds.length>0)})).filter(k=>k.layers.length>0||k.name.toLowerCase().includes(d.toLowerCase())):e;return Fi(v)},[e,d]);p.useEffect(()=>{d.trim()&&(y(new Set(P.map(v=>v.name))),x(new Set(P.flatMap(v=>v.layers.map(k=>`${v.name}:${k.id}`)))))},[d,P]),p.useEffect(()=>{if(s&&D.current.has(s)){for(const v of e)for(const k of v.layers)if(k.kinds.find(I=>I.name===s)){y(I=>new Set([...I,v.name])),x(I=>new Set([...I,`${v.name}:${k.id}`]));break}setTimeout(()=>{var v;(v=D.current.get(s))==null||v.scrollIntoView({behavior:"smooth",block:"nearest"})},80)}},[s,e]);function F(v){a({type:"ontology-detail",packageName:v})}function N(v,k){a({type:"ontology-detail",packageName:v,layerId:k})}function L(v,k){i(s===v?null:v),a({type:"ontology-detail",packageName:k})}function Z(v){y(k=>{const I=new Set(k);return I.has(v)?I.delete(v):I.add(v),I})}function ee(v){x(k=>{const I=new Set(k);return I.has(v)?I.delete(v):I.add(v),I})}function Q(v,k,I){v.stopPropagation(),I?R(k):n(k)}function _(){const v=o();v.orphanedElements&&v.orphanedElements.length>0?A(v.orphanedElements):(Ct([...r]),w(new Set(r)))}function W(){Ct([...r]),w(new Set(r)),A(null)}function K(v){Gs(v),Ct([...r]),w(new Set(r)),A(null)}function B(v,k){v.preventDefault(),v.stopPropagation(),O({x:v.clientX,y:v.clientY,target:k})}function U(v,k){l("table"),a({type:"ontology-detail",packageName:v,layerId:k}),O(null)}function re(v){l("visual"),a({type:"ontology-detail",packageName:v}),O(null)}function fe(v){r.has(v)?R(v):n(v),O(null)}function be(v,k){i(v),a({type:"ontology-detail",packageName:k}),O(null)}if(p.useEffect(()=>{function v(k){k.key==="Escape"&&(i(null),O(null),R(null))}return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[i]),p.useEffect(()=>{if(!T)return;function v(){O(null)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[T]),e.length===0)return t.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:t.jsxs("div",{className:"text-center",style:{color:g.faint},children:[t.jsx("div",{className:"text-xl mb-2",children:"◉"}),t.jsx("div",{style:{fontSize:j.xs},children:"No ontology packages"}),t.jsx("div",{style:{fontSize:j.xs,opacity:.7,marginTop:"4px"},children:"Start memo-architect dev to load"})]})});const Y=c.type==="ontology-detail"?c.packageName:null;return t.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",style:{fontSize:j.explorer.item},children:[t.jsx("div",{className:"px-3 py-2 sticky top-0 z-10",style:{background:g.surface,borderBottom:`1px solid ${g.border}`},children:t.jsx("input",{type:"text",placeholder:"Search kinds...",value:d,onChange:v=>u(v.target.value),className:"w-full px-2.5 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.explorer.search,border:`1px solid ${g.border}`,background:g.surfaceAlt,color:g.primary},onFocus:v=>v.currentTarget.style.borderColor="#2563EB",onBlur:v=>v.currentTarget.style.borderColor=g.border})}),t.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:P.map(v=>{const k=r.has(v.name),I=Y===v.name,q=m.has(v.name),$=v.name.replace(/^@memo(?:architect)?\//,""),J=An[v.type]??An.ontology;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer",style:{borderRadius:"6px",margin:"0 4px",background:I?`${g.accent}18`:"transparent",borderLeft:I?`3px solid ${g.accentDark}`:"3px solid transparent",opacity:k?1:.55},onMouseEnter:z=>{I||(z.currentTarget.style.background="#F0F0ED")},onMouseLeave:z=>{z.currentTarget.style.background=I?`${g.accent}18`:"transparent"},onClick:z=>{z.stopPropagation(),Z(v.name)},onDoubleClick:()=>F(v.name),onContextMenu:z=>B(z,{type:"package",pkgName:v.name,isSelected:k}),children:[t.jsx("input",{type:"checkbox",checked:k,onChange:z=>Q(z,v.name,k),onClick:z=>z.stopPropagation(),style:{cursor:"pointer",accentColor:"#2563EB",flexShrink:0},title:k?"Deselect for project":"Select for project"}),t.jsx("span",{style:{color:g.muted,fontSize:"10px"},children:q?"▾":"▸"}),t.jsx("span",{children:J}),t.jsx("span",{className:"font-semibold truncate flex-1",style:{color:g.primary,fontSize:j.explorer.group},children:$}),t.jsx("span",{style:{color:g.faint},children:v.kindCount})]}),q&&v.layers.map(z=>{const se=ne[z.id]??z.color??g.muted,ve=`${v.name}:${z.id}`,ce=S.has(ve),V=Ri(z.kinds);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 cursor-pointer",style:{borderRadius:"4px",margin:"0 4px 0 20px"},onMouseEnter:H=>H.currentTarget.style.background="#F0F0ED",onMouseLeave:H=>H.currentTarget.style.background="transparent",onClick:H=>{H.stopPropagation(),ee(ve)},onDoubleClick:()=>N(v.name,z.id),onContextMenu:H=>B(H,{type:"layer",pkgName:v.name,layerId:z.id,layerLabel:z.label}),children:[t.jsx("span",{style:{color:g.faint,fontSize:"9px"},children:ce?"▾":"▸"}),t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:se}}),t.jsx("span",{className:"flex-1 truncate capitalize",style:{color:g.muted,fontSize:j.explorer.kind},children:z.label}),t.jsx("span",{style:{color:g.faint},children:z.kindCount})]}),ce&&(()=>{const H=new Map;for(const G of V){const ae=G.derivesFrom?H.get(G.derivesFrom)??0:0;H.set(G.name,G.derivesFrom?ae+1:0)}const ue=G=>{const ae=s===G.name,on=H.get(G.name)??0,sn=on===0,Tr=36+on*12;return t.jsxs("div",{ref:Ee=>{Ee&&D.current.set(G.name,Ee)},className:"flex items-center gap-1.5 px-3 py-0.5 cursor-pointer",style:{borderRadius:"4px",margin:`0 4px 0 ${Tr}px`,background:ae?`${g.accent}18`:"transparent",borderLeft:ae?`2px solid ${se}`:"2px solid transparent",transition:"background 150ms ease"},onMouseEnter:Ee=>{ae||(Ee.currentTarget.style.background="#F0F0ED")},onMouseLeave:Ee=>{Ee.currentTarget.style.background=ae?`${g.accent}18`:"transparent"},onClick:()=>L(G.name,v.name),onContextMenu:Ee=>B(Ee,{type:"kind",kindName:G.name,pkgName:v.name,layerId:z.id}),children:[!sn&&t.jsx("span",{style:{color:g.faint,fontSize:"9px",flexShrink:0},children:"↳"}),t.jsx("span",{className:"truncate",style:{color:ae?g.accentDark:g.primary,fontWeight:sn?500:400,fontSize:j.explorer.item},children:G.name}),G.instanceCount>0&&t.jsxs("span",{style:{color:g.faint,fontSize:"10px"},children:["·",G.instanceCount]})]},G.name)},ke=[],qe=new Map;for(const G of V){const ae=G.group??"";qe.has(ae)||(qe.set(ae,[]),ke.push(ae)),qe.get(ae).push(G)}return ke.filter(G=>G!=="").length<=1?V.map(ue):ke.map(G=>t.jsxs("div",{children:[G&&t.jsxs("div",{className:"px-3 py-0.5 flex items-center gap-1.5",style:{margin:"0 4px 0 30px"},children:[t.jsx("span",{className:"capitalize truncate",style:{color:g.faint,fontSize:j.explorer.kind,letterSpacing:"0.02em"},children:G.replace(/_/g," ")}),t.jsx("span",{style:{color:g.faint,fontSize:"10px"},children:qe.get(G).length})]}),qe.get(G).map(ue)]},`grp:${ve}:${G||"_root"}`))})()]},ve)})]},v.name)})}),h&&t.jsx("div",{className:"px-3 py-2 flex-shrink-0",style:{borderTop:`1px solid ${g.border}`,background:g.surfaceAlt},children:t.jsx("button",{onClick:_,className:"w-full py-1.5 rounded-md font-medium",style:{fontSize:j.xs,background:"#2563EB",color:"#FFFFFF",border:"none",cursor:"pointer"},children:"Save Selection"})}),b&&t.jsx(Ti,{pkgName:b,onCancel:()=>R(null),onConfirm:()=>{n(b),R(null)}}),C&&t.jsx(Ai,{orphans:C,onKeep:W,onRemap:K,onCancel:()=>A(null)}),T&&t.jsx(ji,{x:T.x,y:T.y,target:T.target,onViewVisual:re,onViewTable:U,onToggleSelection:fe,onViewProperties:be,onClose:()=>O(null)})]})}function _i(){const e=E(l=>l.model),r=E(l=>l.recentlyVisited),n=E(l=>l.selectElement),o=p.useMemo(()=>e?r.map(l=>e.elements[l]).filter(Boolean):[],[r,e]),s=o,i="Recently visited",a=o.length>0?`${o.length} item${o.length===1?"":"s"} this session`:"Items you inspect appear here";return t.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[t.jsxs("div",{className:"px-3 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[t.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:g.muted,marginBottom:"2px"},children:i}),t.jsx("div",{style:{fontSize:"11px",color:g.muted,opacity:.8},children:a})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",style:{padding:"4px 0"},children:s.length===0?t.jsx("div",{style:{padding:"24px 16px",textAlign:"center",fontSize:"12px",color:g.muted,lineHeight:"1.6"},children:"Nothing visited yet. Use Model Explorer or Viewpoints to begin."}):s.map(l=>{const c=ne[l.layer]||g.muted;return t.jsx("button",{onClick:()=>n(l.id),style:{display:"flex",alignItems:"flex-start",gap:"8px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",borderLeft:`3px solid ${c}`,cursor:"pointer",textAlign:"left",transition:"background 0.1s"},onMouseEnter:d=>d.currentTarget.style.background=g.surfaceAlt,onMouseLeave:d=>d.currentTarget.style.background="transparent",children:t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:j.explorer.item,fontWeight:500,color:g.primary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l.name}),t.jsxs("div",{style:{fontSize:"10px",color:g.muted,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.jsx("span",{style:{color:c,fontWeight:600},children:l.kind}),l.shortId&&t.jsx("span",{style:{marginLeft:"6px",fontFamily:"monospace",opacity:.7},children:l.shortId})]})]})},l.id)})})]})}function Ni({element:e,selected:r=!1,fontSize:n=j.explorer.item,fontWeight:o}){const s=e.shortId??"ID-PENDING";return t.jsxs("span",{className:"truncate flex-1",style:{color:r?g.accentDark:g.primary,fontSize:n,fontWeight:o??(r?500:400)},title:`${s} ${e.name}`,children:[t.jsxs("span",{style:{color:g.muted,fontWeight:500,marginRight:"4px"},children:["[",s,"]"]}),e.name]})}function Rn({count:e,color:r,title:n}){return t.jsx("span",{className:"px-1.5 py-0.5 rounded-full",style:{background:r+"25",color:r,fontSize:j.explorer.count,fontWeight:600,minWidth:"20px",textAlign:"center"},title:n,children:e})}const Mi=`---
17
- id: change-record
18
- title: Design Change Record
19
- standard: 21 CFR Part 820
20
- clauses: ["820.30(i)"]
21
- required_for: ["FDA_510k", "FDA_PMA"]
22
- ---
23
-
24
- {{include:shared/snippets/document-control-header.md}}
25
-
26
- ---
27
-
28
- ## 1. Purpose
29
-
30
- Documents design changes for **{{project.product}}** per 21 CFR 820.30(i). All changes must be evaluated for safety impact and approved before implementation.
31
-
32
- ---
33
-
34
- ## 2. Change Log
35
-
36
- Record each change with its identifier, description, affected items, and verification status:
37
-
38
- | Change # | Date | Description | Reason | Impact Assessment | Approved By |
39
- | --- | --- | --- | --- | --- | --- |
40
- | CHG-001 | | | | | |
41
-
42
- ---
43
-
44
- ## 3. Substantial Equivalence Assessment
45
-
46
- Assess substantial equivalence to the predicate device, comparing intended use and technological characteristics.
47
-
48
- _[TODO: For FDA-cleared devices, assess whether any changes affect substantial equivalence]_
49
-
50
- ---
51
-
52
- ## 4. Risk Assessment for Changes
53
-
54
- Assess the risk impact of each change per ISO 14971, including effects on existing risk controls.
55
-
56
- _[TODO: Document risk management activity triggered by each significant change]_
57
-
58
- ---
59
-
60
- {{include:shared/snippets/revision-history-table.md}}
61
- `,Oi=`---
62
- id: design-input
63
- title: Design Input Plan
64
- standard: 21 CFR Part 820
65
- clauses: ["820.30(c)"]
66
- required_for: ["FDA_510k", "FDA_PMA"]
67
- ---
68
-
69
- {{include:shared/snippets/document-control-header.md}}
70
-
71
- {{toc}}
72
-
73
- ---
74
-
75
- ## 1. Purpose
76
-
77
- Defines design inputs for **{{project.product}}** per 21 CFR 820.30(c). Design inputs are the physical and performance requirements to which the device design must conform.
78
-
79
- ---
80
-
81
- ## 2. Design Input Requirements
82
-
83
- ### 2.1 Performance Requirements
84
-
85
- \`\`\`memo-query
86
- kind: Requirement
87
- display: table
88
- columns: name, layer, doc
89
- sort: name
90
- empty: "No system requirements defined."
91
- \`\`\`
92
-
93
- ### 2.2 Design Inputs from User Needs
94
-
95
- \`\`\`memo-query
96
- kind: [DesignInput, Need]
97
- display: table
98
- columns: name, layer, doc
99
- sort: name
100
- empty: "No design inputs defined. Add DesignInput elements."
101
- \`\`\`
102
-
103
- ---
104
-
105
- ## 3. Regulatory and Standards Requirements
106
-
107
- Complete the table below for **{{project.product}}**:
108
-
109
- | Standard | Requirement | Input Reference |
110
- | --- | --- | --- |
111
- | 21 CFR 820.30 | Design controls | |
112
- | ISO 14971 | Risk management requirements | |
113
- | IEC 62304 | Software development | |
114
-
115
- ---
116
-
117
- ## 4. Design Input Review
118
-
119
- Record the review of design inputs for completeness, unambiguity, and absence of conflicts per 21 CFR 820.30(c).
120
-
121
- _[TODO: Document the design input review process and sign-off]_
122
-
123
- ---
124
-
125
- {{include:shared/snippets/revision-history-table.md}}
126
-
127
- {{include:shared/snippets/approval-block.md}}
128
- `,Pi=`---
129
- id: design-output
130
- title: Design Output Plan
131
- standard: 21 CFR Part 820
132
- clauses: ["820.30(d)"]
133
- required_for: ["FDA_510k", "FDA_PMA"]
134
- ---
135
-
136
- {{include:shared/snippets/document-control-header.md}}
137
-
138
- {{toc}}
139
-
140
- ---
141
-
142
- ## 1. Purpose
143
-
144
- Defines design outputs for **{{project.product}}** per 21 CFR 820.30(d). Design outputs are the results of the design process, forming the basis for manufacturing.
145
-
146
- ---
147
-
148
- ## 2. Design Outputs
149
-
150
- ### 2.1 Hardware Design Outputs
151
-
152
- \`\`\`memo-query
153
- kind: [Component, Subsystem, DesignOutput]
154
- where: layer == "physical"
155
- display: table
156
- columns: name, kind, layer, doc
157
- sort: name
158
- empty: "No hardware design outputs defined."
159
- \`\`\`
160
-
161
- ### 2.2 Software Design Outputs
162
-
163
- \`\`\`memo-query
164
- kind: [SoftwareItem, SoftwareUnit, DesignOutput]
165
- where: layer == "software"
166
- display: table
167
- columns: name, kind, layer, doc
168
- sort: name
169
- empty: "No software design outputs defined."
170
- \`\`\`
171
-
172
- ### 2.3 All Design Outputs
173
-
174
- \`\`\`memo-query
175
- kind: DesignOutput
176
- display: table
177
- columns: name, layer, doc
178
- sort: name
179
- empty: "No DesignOutput elements defined. Add DesignOutput elements."
180
- \`\`\`
181
-
182
- ---
183
-
184
- ## 3. Design Output → Input Traceability
185
-
186
- Traceability from design outputs back to design inputs, generated live from the model:
187
-
188
- _[TODO: Demonstrate that each design output meets a design input requirement]_
189
-
190
- ---
191
-
192
- ## 4. Essential Design Output Documents
193
-
194
- List the documents constituting the essential design outputs for the DHF.
195
-
196
- | Document | Description | Status |
197
- | --- | --- | --- |
198
- | Engineering drawings | Physical design specifications | |
199
- | Software architecture | Software design specifications | |
200
- | Manufacturing specs | Production procedures | |
201
- | Labeling | Device labels and IFU | |
202
-
203
- ---
204
-
205
- {{include:shared/snippets/revision-history-table.md}}
206
-
207
- {{include:shared/snippets/approval-block.md}}
208
- `,zi=`---
209
- id: design-review
210
- title: Design Review Record
211
- standard: 21 CFR Part 820
212
- clauses: ["820.30(e)"]
213
- required_for: ["FDA_510k", "FDA_PMA"]
214
- ---
215
-
216
- {{include:shared/snippets/document-control-header.md}}
217
-
218
- ---
219
-
220
- ## 1. Purpose
221
-
222
- Documents formal design reviews for **{{project.product}}** per 21 CFR 820.30(e).
223
-
224
- ---
225
-
226
- ## 2. Design Review Log
227
-
228
- Record of formal design reviews with dates, participants, and outcomes:
229
-
230
- | Review | Date | Stage | Attendees | Outcome | Actions |
231
- | --- | --- | --- | --- | --- | --- |
232
- | DR-001 | | Preliminary Design | | | |
233
- | DR-002 | | Critical Design | | | |
234
- | DR-003 | | Final Design | | | |
235
-
236
- ---
237
-
238
- ## 3. Open Action Items
239
-
240
- Action items raised during review, their owners, and due dates:
241
-
242
- _[TODO: Track all open action items from design reviews]_
243
-
244
- ---
245
-
246
- ## 4. Design Status at Review
247
-
248
- Snapshot of the design state at the time of review, computed from the model:
249
-
250
- \`\`\`memo-query
251
- kind: [Requirement, Requirement, DesignInput, DesignOutput]
252
- display: count
253
- label: Total design elements at last review
254
- \`\`\`
255
-
256
- ---
257
-
258
- {{include:shared/snippets/revision-history-table.md}}
259
- `,Li=`---
260
- id: design-validation
261
- title: Design Validation Records
262
- standard: 21 CFR Part 820
263
- clauses: ["820.30(g)"]
264
- required_for: ["FDA_510k", "FDA_PMA"]
265
- ---
266
-
267
- {{include:shared/snippets/document-control-header.md}}
268
-
269
- ---
270
-
271
- ## 1. Purpose
272
-
273
- Documents design validation confirming the device meets user needs and intended use for **{{project.product}}** per 21 CFR 820.30(g).
274
-
275
- ---
276
-
277
- ## 2. Validation Plan Reference
278
-
279
- Reference the validation plan governing these activities and note any deviations from it.
280
-
281
- _[TODO: Reference V&V Plan]_
282
-
283
- ---
284
-
285
- ## 3. Clinical/Bench Validation
286
-
287
- Describe clinical or bench validation activities demonstrating conformity with user needs under actual or simulated use conditions.
288
-
289
- \`\`\`memo-query
290
- kind: ValidationActivity
291
- display: table
292
- columns: name, layer, doc
293
- sort: name
294
- empty: "No validation activities defined."
295
- \`\`\`
296
-
297
- ---
298
-
299
- ## 4. User Need Coverage
300
-
301
- Coverage of user needs by validation activities, computed live from the model:
302
-
303
- \`\`\`memo-query
304
- kind: [Need, Requirement]
305
- display: table
306
- columns: name, layer, doc
307
- empty: "No user needs defined."
308
- \`\`\`
309
-
310
- ---
311
-
312
- ## 5. Conclusion
313
-
314
- Summarize the outcome and state the overall conclusion, including any conditions or follow-up actions.
315
-
316
- _[TODO: State validation conclusion — device meets intended use for intended users]_
317
-
318
- ---
319
-
320
- {{include:shared/snippets/revision-history-table.md}}
321
-
322
- {{include:shared/snippets/approval-block.md}}
323
- `,Bi=`---
324
- id: design-verification
325
- title: Design Verification Records
326
- standard: 21 CFR Part 820
327
- clauses: ["820.30(f)"]
328
- required_for: ["FDA_510k", "FDA_PMA"]
329
- ---
330
-
331
- {{include:shared/snippets/document-control-header.md}}
332
-
333
- ---
334
-
335
- ## 1. Purpose
336
-
337
- Documents design verification that design outputs meet design inputs for **{{project.product}}** per 21 CFR 820.30(f).
338
-
339
- ---
340
-
341
- ## 2. Verification Matrix
342
-
343
- The verification traceability below is generated live from the model — every requirement should be covered by at least one verification activity:
344
-
345
- \`\`\`memo-query
346
- kind: VerificationActivity
347
- display: table
348
- columns: name, layer, doc
349
- sort: name
350
- empty: "No verification activities defined."
351
- \`\`\`
352
-
353
- ---
354
-
355
- ## 3. Test Results
356
-
357
- Test executions and their outcomes are summarized below from the model:
358
-
359
- \`\`\`memo-query
360
- kind: TestCase
361
- display: table
362
- columns: name, layer, doc
363
- sort: name
364
- empty: "No test cases defined."
365
- \`\`\`
366
-
367
- ---
368
-
369
- ## 4. Design Input Coverage
370
-
371
- Coverage of design inputs by verification activities, computed live from the model:
372
-
373
- _[TODO: Demonstrate that all design inputs are verified by at least one test]_
374
-
375
- ---
376
-
377
- {{include:shared/snippets/revision-history-table.md}}
378
-
379
- {{include:shared/snippets/approval-block.md}}
380
- `,qi=`---
381
- id: dhf-index
382
- title: Design History File Index
383
- standard: 21 CFR Part 820
384
- clauses: ["820.30(j)", "ISO 13485:2016 §4.2.4"]
385
- required_for: ["FDA_510k", "FDA_PMA", "CE", "MDR"]
386
- ---
387
-
388
- {{include:shared/snippets/document-control-header.md}}
389
-
390
- {{toc}}
391
-
392
- ---
393
-
394
- ## 1. Purpose
395
-
396
- This Design History File (DHF) Index serves as the master index for all design and development records for **{{project.product}}** per 21 CFR 820.30(j).
397
-
398
- ---
399
-
400
- ## 2. Device Summary
401
-
402
- Key characteristics of **{{project.product}}**, drawn from the model:
403
-
404
- | Field | Value |
405
- | --- | --- |
406
- | Device Name | {{project.product}} |
407
- | Company | {{project.company}} |
408
- | Device Type | {{project.device_type}} |
409
- | Development Phase | {{project.phase}} |
410
- | Version | {{project.version}} |
411
-
412
- ---
413
-
414
- ## 3. DHF Documents
415
-
416
- ### Risk Management
417
-
418
- | Document | Standard | Status |
419
- | --- | --- | --- |
420
- | Risk Management Plan | ISO 14971:2019 §4.4 | |
421
- | Hazard Analysis Report | ISO 14971:2019 §5-7 | |
422
- | FMEA | IEC 60812:2018 | |
423
- | Risk Management Report | ISO 14971:2019 §9 | |
424
-
425
- ### Design Controls
426
-
427
- | Document | Standard | Status |
428
- | --- | --- | --- |
429
- | User Needs | 21 CFR 820.30(c) | |
430
- | Design Input Plan | 21 CFR 820.30(c) | |
431
- | Design Output Plan | 21 CFR 820.30(d) | |
432
- | V&V Plan | 21 CFR 820.30(f-g) | |
433
- | V&V Report | 21 CFR 820.30(f-g) | |
434
- | Design Transfer Plan | 21 CFR 820.30(h) | |
435
-
436
- ### Software Documentation
437
-
438
- | Document | Standard | Status |
439
- | --- | --- | --- |
440
- | Software Development Plan | IEC 62304 §5.1 | |
441
- | Software Requirements Specification | IEC 62304 §5.2 | |
442
- | Software Architecture Description | IEC 62304 §5.3 | |
443
- | SOUP List | IEC 62304 §8.1.2 | |
444
- | Software Traceability Matrix | IEC 62304 §5.7.5 | |
445
-
446
- ### Usability Engineering
447
-
448
- | Document | Standard | Status |
449
- | --- | --- | --- |
450
- | Usability Engineering Plan | IEC 62366-1 §4 | |
451
- | Use-Related Risk Analysis | IEC 62366-1 §5 | |
452
- | Summative Evaluation Report | IEC 62366-1 §5.9 | |
453
-
454
- ---
455
-
456
- ## 4. Model Summary
457
-
458
- Summary statistics of the system model at the time this document was generated:
459
-
460
- \`\`\`memo-query
461
- kind: [Requirement, Requirement]
462
- display: count
463
- label: Total requirements
464
- \`\`\`
465
-
466
- \`\`\`memo-query
467
- kind: Hazard
468
- display: count
469
- label: Total hazards
470
- \`\`\`
471
-
472
- \`\`\`memo-query
473
- kind: [TestCase, VerificationActivity]
474
- display: count
475
- label: Total test cases
476
- \`\`\`
477
-
478
- ---
479
-
480
- ## 5. All Model Elements
481
-
482
- {{glossary}}
483
-
484
- ---
485
-
486
- {{include:shared/snippets/revision-history-table.md}}
487
-
488
- {{include:shared/snippets/approval-block.md}}
489
-
490
- {{include:shared/snippets/references-section.md}}
491
- `,Vi=`---
492
- id: transfer-plan
493
- title: Design Transfer Plan
494
- standard: 21 CFR Part 820
495
- clauses: ["820.30(h)"]
496
- required_for: ["FDA_510k", "FDA_PMA"]
497
- ---
498
-
499
- {{include:shared/snippets/document-control-header.md}}
500
-
501
- ---
502
-
503
- ## 1. Purpose
504
-
505
- Defines design transfer activities for **{{project.product}}** per 21 CFR 820.30(h), ensuring device design is correctly translated to production specifications.
506
-
507
- ---
508
-
509
- ## 2. Transfer Checklist
510
-
511
- Checklist of items required before design transfer to production is complete:
512
-
513
- | Activity | Responsible | Completion Date | Status |
514
- | --- | --- | --- | --- |
515
- | Engineering drawings released to production | | | |
516
- | Software build process documented | | | |
517
- | Production procedures validated | | | |
518
- | Test equipment calibrated | | | |
519
- | Production personnel trained | | | |
520
- | First article inspection completed | | | |
521
-
522
- ---
523
-
524
- ## 3. Production Specifications
525
-
526
- Production specifications derived from the design outputs:
527
-
528
- \`\`\`memo-query
529
- kind: DesignOutput
530
- display: table
531
- columns: name, layer, doc
532
- sort: name
533
- empty: "No design outputs defined."
534
- \`\`\`
535
-
536
- ---
537
-
538
- {{include:shared/snippets/revision-history-table.md}}
539
-
540
- {{include:shared/snippets/approval-block.md}}
541
- `,Wi=`---
542
- id: user-needs
543
- title: User Needs Document
544
- standard: 21 CFR Part 820
545
- clauses: ["820.30(c)"]
546
- required_for: ["FDA_510k", "FDA_PMA"]
547
- ---
548
-
549
- {{include:shared/snippets/document-control-header.md}}
550
-
551
- {{toc}}
552
-
553
- ---
554
-
555
- ## 1. Purpose
556
-
557
- This document captures user needs for **{{project.product}}** per 21 CFR 820.30(c) Design Input requirements. User needs represent the intended purpose of the device as stated by customers and intended users.
558
-
559
- ---
560
-
561
- ## 2. Intended Users
562
-
563
- Identify every intended user group of **{{project.product}}**, including their roles, training assumptions, and use environments.
564
-
565
- _[TODO: Describe all intended user groups with their roles, training levels, and environments]_
566
-
567
- ---
568
-
569
- ## 3. User Needs
570
-
571
- User needs captured for **{{project.product}}** are listed below from the model. Each user need should trace forward to at least one design input:
572
-
573
- \`\`\`memo-query
574
- kind: [Need, Requirement]
575
- display: table
576
- columns: name, layer, doc
577
- sort: name
578
- empty: "No user need elements defined. Add Need or Requirement elements."
579
- \`\`\`
580
-
581
- ---
582
-
583
- ## 4. Use Cases
584
-
585
- Use cases describing how intended users interact with **{{project.product}}**, drawn from the model:
586
-
587
- \`\`\`memo-query
588
- kind: UseCase
589
- display: table
590
- columns: name, layer, doc
591
- sort: name
592
- empty: "No use cases defined."
593
- \`\`\`
594
-
595
- ---
596
-
597
- ## 5. Customer Requirements
598
-
599
- List customer-stated requirements that serve as input to the design process.
600
-
601
- _[TODO: List customer-stated requirements as input to the design process]_
602
-
603
- ---
604
-
605
- ## 6. Regulatory Requirements
606
-
607
- Regulatory and standards requirements applicable to **{{project.product}}**:
608
-
609
- | Standard | Applicability | Notes |
610
- | --- | --- | --- |
611
- | 21 CFR Part 820 | Quality System Regulation | |
612
- | IEC 62304 | Software lifecycle | If Class B/C SW |
613
- | ISO 14971 | Risk management | |
614
-
615
- ---
616
-
617
- {{include:shared/snippets/revision-history-table.md}}
618
-
619
- {{include:shared/snippets/approval-block.md}}
620
-
621
- {{include:shared/snippets/references-section.md}}
622
- `,$i=`---
623
- id: vv-plan
624
- title: Verification and Validation Plan
625
- standard: 21 CFR Part 820
626
- clauses: ["820.30(f)", "820.30(g)"]
627
- required_for: ["FDA_510k", "FDA_PMA", "CE"]
628
- ---
629
-
630
- {{include:shared/snippets/document-control-header.md}}
631
-
632
- {{toc}}
633
-
634
- ---
635
-
636
- ## 1. Purpose
637
-
638
- This V&V Plan defines verification and validation activities for **{{project.product}}** per 21 CFR 820.30(f)-(g) and ISO 13485:2016 §7.3.6-7.3.7.
639
-
640
- ---
641
-
642
- ## 2. Scope
643
-
644
- This plan covers:
645
- - Software verification (per IEC 62304 §5.6-5.7)
646
- - Hardware verification
647
- - System-level validation
648
- - Usability validation (per IEC 62366-1)
649
-
650
- ---
651
-
652
- ## 3. Verification Activities
653
-
654
- ### 3.1 Requirements to Verify
655
-
656
- \`\`\`memo-query
657
- kind: [Requirement, Requirement]
658
- display: table
659
- columns: name, layer, doc
660
- sort: name
661
- empty: "No requirements defined."
662
- \`\`\`
663
-
664
- ### 3.2 Verification Test Cases
665
-
666
- \`\`\`memo-query
667
- kind: [TestCase, VerificationActivity]
668
- display: table
669
- columns: name, kind, layer, doc
670
- sort: name
671
- empty: "No verification test cases defined."
672
- \`\`\`
673
-
674
- ---
675
-
676
- ## 4. Validation Activities
677
-
678
- Validation activities demonstrating that **{{project.product}}** meets user needs and intended uses:
679
-
680
- \`\`\`memo-query
681
- kind: ValidationActivity
682
- display: table
683
- columns: name, layer, doc
684
- sort: name
685
- empty: "No validation activities defined."
686
- \`\`\`
687
-
688
- ---
689
-
690
- ## 5. Acceptance Criteria
691
-
692
- State the objective criteria that must be met for the validation to be considered successful.
693
-
694
- _[TODO: Define objective acceptance criteria for all V&V activities]_
695
-
696
- ---
697
-
698
- ## 6. Test Environment
699
-
700
- Describe the hardware, software, tools, and configuration of the test environment in sufficient detail to reproduce the test setup.
701
-
702
- _[TODO: Describe hardware, software, and clinical test environments]_
703
-
704
- ---
705
-
706
- {{include:shared/snippets/revision-history-table.md}}
707
-
708
- {{include:shared/snippets/approval-block.md}}
709
-
710
- {{include:shared/snippets/references-section.md}}
711
- `,Ui=`---
712
- id: vv-report
713
- title: Verification and Validation Report
714
- standard: 21 CFR Part 820
715
- clauses: ["820.30(f)", "820.30(g)"]
716
- required_for: ["FDA_510k", "FDA_PMA", "CE"]
717
- ---
718
-
719
- {{include:shared/snippets/document-control-header.md}}
720
-
721
- {{toc}}
722
-
723
- ---
724
-
725
- ## 1. Purpose
726
-
727
- This V&V Report documents the results of all verification and validation activities for **{{project.product}}**.
728
-
729
- ---
730
-
731
- ## 2. Summary
732
-
733
- Summary metrics computed live from the model:
734
-
735
- \`\`\`memo-query
736
- kind: TestCase
737
- display: count
738
- label: Total test cases
739
- \`\`\`
740
-
741
- \`\`\`memo-query
742
- kind: [VerificationActivity, ValidationActivity]
743
- display: count
744
- label: V&V activities
745
- \`\`\`
746
-
747
- ---
748
-
749
- ## 3. Verification Results
750
-
751
- ### 3.1 Test Results by Requirement
752
-
753
- \`\`\`memo-query
754
- kind: [TestCase, VerificationActivity]
755
- display: table
756
- columns: name, kind, layer, doc
757
- sort: name
758
- empty: "No verification activities defined."
759
- \`\`\`
760
-
761
- ---
762
-
763
- ## 4. Validation Results
764
-
765
- Results of the validation activities are summarized below:
766
-
767
- \`\`\`memo-query
768
- kind: ValidationActivity
769
- display: table
770
- columns: name, layer, doc
771
- sort: name
772
- empty: "No validation activities defined."
773
- \`\`\`
774
-
775
- ---
776
-
777
- ## 5. Known Anomalies and Deviations
778
-
779
- Record any anomalies, deviations from plan, and their disposition, including rationale for acceptance of unresolved anomalies.
780
-
781
- _[TODO: List any unresolved anomalies and provide justification for acceptance]_
782
-
783
- ---
784
-
785
- ## 6. V&V Conclusion
786
-
787
- State the overall verification and validation conclusion for **{{project.product}}**, including any conditions, limitations, or required follow-up actions.
788
-
789
- _[TODO: State whether the device meets all design inputs and is fit for intended use]_
790
-
791
- ---
792
-
793
- {{include:shared/snippets/revision-history-table.md}}
794
-
795
- {{include:shared/snippets/approval-block.md}}
796
- `,Hi=`---
797
- id: incident-response
798
- title: Cybersecurity Incident Response Plan
799
- standard: FDA Cybersecurity Guidance 2023
800
- clauses: ["5.2"]
801
- required_for: ["FDA_510k", "FDA_PMA"]
802
- ---
803
-
804
- {{include:shared/snippets/document-control-header.md}}
805
-
806
- ---
807
-
808
- ## 1. Purpose
809
-
810
- Defines the incident response process for cybersecurity events affecting **{{project.product}}**.
811
-
812
- ---
813
-
814
- ## 2. Incident Classification
815
-
816
- Define the severity classes for security incidents and the criteria for assigning them.
817
-
818
- | Class | Description | Response Time | FDA Reporting |
819
- | --- | --- | --- | --- |
820
- | Class 1 | Exploited vulnerability affecting device safety | 24 hours | Required within 30 days |
821
- | Class 2 | Unpatched but known vulnerability | 72 hours | Likely required |
822
- | Class 3 | Suspected security event | 5 days | Assess case-by-case |
823
-
824
- ---
825
-
826
- ## 3. Response Team
827
-
828
- Identify the incident response team members, their roles, and contact paths.
829
-
830
- | Role | Responsible Party | Contact |
831
- | --- | --- | --- |
832
- | Incident Commander | | |
833
- | Security Lead | | |
834
- | Regulatory Affairs | | |
835
- | Clinical Safety | | |
836
- | Legal/Compliance | | |
837
-
838
- ---
839
-
840
- ## 4. Response Procedure
841
-
842
- 1. Detection and initial assessment
843
- 2. Containment of affected devices
844
- 3. Impact analysis (patient safety, data)
845
- 4. Develop and test patch
846
- 5. Deploy and verify patch
847
- 6. FDA notification (if required)
848
- 7. Customer notification
849
- 8. Post-incident review
850
-
851
- ---
852
-
853
- ## 5. Coordinated Vulnerability Disclosure
854
-
855
- Describe the process by which external researchers can report vulnerabilities and how reports are triaged and disclosed.
856
-
857
- _[TODO: Describe the coordinated disclosure policy for external researchers]_
858
-
859
- ---
860
-
861
- {{include:shared/snippets/revision-history-table.md}}
862
- `,Ki=`---
863
- id: postmarket-surveillance
864
- title: Post-Market Cybersecurity Surveillance Plan
865
- standard: FDA Cybersecurity Guidance 2023
866
- clauses: ["5"]
867
- required_for: ["FDA_510k", "FDA_PMA"]
868
- ---
869
-
870
- {{include:shared/snippets/document-control-header.md}}
871
-
872
- ---
873
-
874
- ## 1. Purpose
875
-
876
- Defines ongoing cybersecurity surveillance for **{{project.product}}** in the post-market phase per FDA's 2023 guidance.
877
-
878
- ---
879
-
880
- ## 2. Surveillance Sources
881
-
882
- - NVD / CVE database monitoring for SOUP vulnerabilities
883
- - ICS-CERT / FDA MedSun cybersecurity alerts
884
- - Vulnerability reports from customers and researchers
885
- - Threat intelligence feeds
886
-
887
- ---
888
-
889
- ## 3. SOUP Monitoring
890
-
891
- Describe the process for ongoing monitoring of SOUP components for newly published vulnerabilities.
892
-
893
- \`\`\`memo-query
894
- kind: SOUPComponent
895
- display: table
896
- columns: name, doc
897
- sort: name
898
- empty: "No SOUP components to monitor."
899
- \`\`\`
900
-
901
- ---
902
-
903
- ## 4. Response Timelines
904
-
905
- Define target timelines for triage, containment, remediation, and notification per incident class.
906
-
907
- | Severity | CVSS Score | Response Target |
908
- | --- | --- | --- |
909
- | Critical | 9.0–10.0 | 30 days |
910
- | High | 7.0–8.9 | 60 days |
911
- | Medium | 4.0–6.9 | 90 days |
912
- | Low | < 4.0 | Next release |
913
-
914
- ---
915
-
916
- ## 5. Patch and Update Process
917
-
918
- Describe how security patches are developed, verified, approved, and deployed to fielded devices.
919
-
920
- _[TODO: Describe how security patches are tested, validated, and released]_
921
-
922
- ---
923
-
924
- {{include:shared/snippets/revision-history-table.md}}
925
- `,Gi=`---
926
- id: security-arch
927
- title: Cybersecurity Architecture Description
928
- standard: FDA Cybersecurity Guidance 2023
929
- clauses: ["3.3"]
930
- required_for: ["FDA_510k", "FDA_PMA"]
931
- ---
932
-
933
- {{include:shared/snippets/document-control-header.md}}
934
-
935
- {{toc}}
936
-
937
- ---
938
-
939
- ## 1. Purpose
940
-
941
- Describes the cybersecurity architecture for **{{project.product}}** per FDA's 2023 guidance and IEC 81001-5-1:2021.
942
-
943
- ---
944
-
945
- ## 2. Security Architecture
946
-
947
- This section describes the security architecture of **{{project.product}}**. The security-relevant elements below are drawn from the model:
948
-
949
- {{diagram:security-architecture}}
950
-
951
- ---
952
-
953
- ## 3. Trusted Zones and Communication Paths
954
-
955
- Define the trusted zones, the communication paths crossing zone boundaries, and the protection applied at each crossing.
956
-
957
- \`\`\`memo-query
958
- kind: Interface
959
- display: table
960
- columns: name, layer, doc
961
- sort: name
962
- empty: "No interfaces defined."
963
- \`\`\`
964
-
965
- ---
966
-
967
- ## 4. Security Controls
968
-
969
- Security controls implemented in **{{project.product}}** are listed below from the model. Each control should trace to at least one identified threat:
970
-
971
- \`\`\`memo-query
972
- kind: SecurityControl
973
- display: table
974
- columns: name, layer, doc
975
- sort: name
976
- empty: "No security controls defined."
977
- \`\`\`
978
-
979
- ---
980
-
981
- ## 5. Cybersecurity Design Principles Applied
982
-
983
- Describe how core security principles (least privilege, defense in depth, secure defaults, fail secure) are applied in the design.
984
-
985
- _[TODO: Document which NIST CSF or IEC 81001-5-1 principles are applied]_
986
-
987
- | Principle | Implementation | Reference |
988
- | --- | --- | --- |
989
- | Least privilege | | |
990
- | Defense in depth | | |
991
- | Fail secure | | |
992
- | Cryptographic controls | | |
993
- | Secure boot | | |
994
-
995
- ---
996
-
997
- ## 6. Security Testing
998
-
999
- Describe the security testing performed (e.g. static analysis, fuzzing, penetration testing) and reference the detailed results.
1000
-
1001
- _[TODO: Describe penetration testing, vulnerability scanning, and security code review]_
1002
-
1003
- ---
1004
-
1005
- {{include:shared/snippets/revision-history-table.md}}
1006
-
1007
- {{include:shared/snippets/approval-block.md}}
1008
- `,Yi=`---
1009
- id: threat-model
1010
- title: Cybersecurity Threat Model
1011
- standard: FDA Cybersecurity Guidance 2023
1012
- clauses: ["3.2"]
1013
- required_for: ["FDA_510k", "FDA_PMA"]
1014
- ---
1015
-
1016
- {{include:shared/snippets/document-control-header.md}}
1017
-
1018
- {{toc}}
1019
-
1020
- ---
1021
-
1022
- ## 1. Purpose
1023
-
1024
- This threat model documents cybersecurity threats for **{{project.product}}** per FDA's 2023 Cybersecurity in Medical Devices guidance and IEC 81001-5-1:2021.
1025
-
1026
- ---
1027
-
1028
- ## 2. System Assets
1029
-
1030
- Assets requiring protection (data, functions, interfaces), drawn from the model:
1031
-
1032
- \`\`\`memo-query
1033
- kind: [SoftwareSystem, Interface, SOUPComponent]
1034
- display: table
1035
- columns: name, kind, layer, doc
1036
- sort: name
1037
- empty: "No system assets defined."
1038
- \`\`\`
1039
-
1040
- ---
1041
-
1042
- ## 3. Entry Points and Attack Surface
1043
-
1044
- Entry points and externally reachable interfaces constituting the attack surface, drawn from the model:
1045
-
1046
- \`\`\`memo-query
1047
- kind: Interface
1048
- display: table
1049
- columns: name, layer, doc
1050
- sort: name
1051
- empty: "No interfaces defined."
1052
- \`\`\`
1053
-
1054
- ---
1055
-
1056
- ## 4. Threat Catalog
1057
-
1058
- The threat catalog below is generated from the model. Each threat should be assessed for likelihood and impact and trace to mitigating security controls:
1059
-
1060
- \`\`\`memo-query
1061
- kind: ThreatModel
1062
- display: table
1063
- columns: name, layer, doc
1064
- sort: name
1065
- empty: "No threat model elements defined. Add ThreatModel elements."
1066
- \`\`\`
1067
-
1068
- ### 4.1 STRIDE Analysis
1069
-
1070
- | Threat Category | Description | Affected Assets | Likelihood | Impact |
1071
- | --- | --- | --- | --- | --- |
1072
- | Spoofing | | | | |
1073
- | Tampering | | | | |
1074
- | Repudiation | | | | |
1075
- | Information Disclosure | | | | |
1076
- | Denial of Service | | | | |
1077
- | Elevation of Privilege | | | | |
1078
-
1079
- ---
1080
-
1081
- ## 5. Security Controls
1082
-
1083
- Security controls implemented in **{{project.product}}** are listed below from the model. Each control should trace to at least one identified threat:
1084
-
1085
- \`\`\`memo-query
1086
- kind: SecurityControl
1087
- display: table
1088
- columns: name, layer, doc
1089
- sort: name
1090
- empty: "No security controls defined."
1091
- \`\`\`
1092
-
1093
- ---
1094
-
1095
- ## 6. Unmitigated Threats
1096
-
1097
- Threats without a mitigating security control are surfaced below by a live model query — this list should be empty before release:
1098
-
1099
- _[TODO: List any threats without security controls and provide residual risk justification]_
1100
-
1101
- ---
1102
-
1103
- {{include:shared/snippets/revision-history-table.md}}
1104
-
1105
- {{include:shared/snippets/approval-block.md}}
1106
-
1107
- {{include:shared/snippets/references-section.md}}
1108
- `,Ji=`---
1109
- id: vuln-assessment
1110
- title: Vulnerability Assessment and Penetration Testing Report
1111
- standard: FDA Cybersecurity Guidance 2023
1112
- clauses: ["3.4"]
1113
- required_for: ["FDA_510k", "FDA_PMA"]
1114
- ---
1115
-
1116
- {{include:shared/snippets/document-control-header.md}}
1117
-
1118
- {{toc}}
1119
-
1120
- ---
1121
-
1122
- ## 1. Purpose
1123
-
1124
- Documents cybersecurity vulnerability assessment and testing for **{{project.product}}** per FDA's 2023 cybersecurity guidance.
1125
-
1126
- ---
1127
-
1128
- ## 2. Scope of Assessment
1129
-
1130
- Define the boundaries of this assessment: components, interfaces, and threat classes in and out of scope.
1131
-
1132
- \`\`\`memo-query
1133
- kind: [SoftwareSystem, SoftwareItem, Interface]
1134
- display: table
1135
- columns: name, kind, layer
1136
- sort: name
1137
- empty: "No software assets defined."
1138
- \`\`\`
1139
-
1140
- ---
1141
-
1142
- ## 3. SOUP/Third-Party Component Vulnerabilities
1143
-
1144
- Known vulnerabilities in SOUP and third-party components (e.g. from CVE/NVD monitoring) and their disposition:
1145
-
1146
- \`\`\`memo-query
1147
- kind: SOUPComponent
1148
- display: table
1149
- columns: name, doc
1150
- sort: name
1151
- empty: "No SOUP components defined."
1152
- \`\`\`
1153
-
1154
- ---
1155
-
1156
- ## 4. Vulnerability Findings
1157
-
1158
- Identified vulnerabilities and their assessment are listed below:
1159
-
1160
- | CVE / Finding | Component | Severity (CVSS) | Status | Mitigation |
1161
- | --- | --- | --- | --- | --- |
1162
- | | | | | |
1163
-
1164
- ---
1165
-
1166
- ## 5. Penetration Test Results
1167
-
1168
- Summarize the scope, methodology, and findings of penetration testing.
1169
-
1170
- _[TODO: Summarize penetration testing scope, methodology, and findings]_
1171
-
1172
- ---
1173
-
1174
- ## 6. Residual Vulnerabilities
1175
-
1176
- Vulnerabilities remaining after mitigation, with the rationale for their acceptability:
1177
-
1178
- _[TODO: Document any accepted residual vulnerabilities with justification]_
1179
-
1180
- ---
1181
-
1182
- {{include:shared/snippets/revision-history-table.md}}
1183
-
1184
- {{include:shared/snippets/approval-block.md}}
1185
- `,Xi=`---
1186
- id: change-control
1187
- title: Software Change Control Log
1188
- standard: IEC 62304:2006+AMD1:2015
1189
- clauses: ["6"]
1190
- required_for: ["CE", "FDA_510k", "MDR"]
1191
- ---
1192
-
1193
- {{include:shared/snippets/document-control-header.md}}
1194
-
1195
- ---
1196
-
1197
- ## 1. Purpose
1198
-
1199
- This log documents all changes to **{{project.product}}** software, including the change description, impact assessment, and approval per IEC 62304:2006 §6.
1200
-
1201
- ---
1202
-
1203
- ## 2. Change Log
1204
-
1205
- Record each change with its identifier, description, affected items, and verification status:
1206
-
1207
- | Change ID | Date | Version | Description | Impact Assessment | Approved By |
1208
- | --- | --- | --- | --- | --- | --- |
1209
- | CHG-001 | | 1.0.0 | Initial release | N/A | |
1210
-
1211
- ---
1212
-
1213
- ## 3. Change Procedure
1214
-
1215
- All changes must:
1216
- 1. Be requested via the change request process
1217
- 2. Have an impact assessment (safety, requirements, design, test)
1218
- 3. Be approved prior to implementation
1219
- 4. Be verified and validated after implementation
1220
- 5. Be documented in this log
1221
-
1222
- ---
1223
-
1224
- {{include:shared/snippets/revision-history-table.md}}
1225
- `,Qi=`---
1226
- id: detailed-design
1227
- title: Software Detailed Design
1228
- standard: IEC 62304:2006+AMD1:2015
1229
- clauses: ["5.4"]
1230
- required_for: ["CE", "FDA_510k"]
1231
- ---
1232
-
1233
- {{include:shared/snippets/document-control-header.md}}
1234
-
1235
- {{toc}}
1236
-
1237
- ---
1238
-
1239
- ## 1. Purpose
1240
-
1241
- This document provides detailed design specifications for **{{project.product}}** software per IEC 62304:2006 §5.4, sufficient to implement and test each software unit.
1242
-
1243
- ---
1244
-
1245
- ## 2. Software Units
1246
-
1247
- The software units — the lowest level of decomposition per IEC 62304 — are listed below from the model:
1248
-
1249
- \`\`\`memo-query
1250
- kind: SoftwareUnit
1251
- display: table
1252
- columns: name, layer, doc
1253
- sort: name
1254
- empty: "No SoftwareUnit elements defined."
1255
- \`\`\`
1256
-
1257
- ---
1258
-
1259
- ## 3. Unit Specifications
1260
-
1261
- ### 3.1 Algorithms and Data Structures
1262
-
1263
- _[TODO: Describe key algorithms, data structures, and design patterns]_
1264
-
1265
- ### 3.2 State Machines
1266
-
1267
- {{diagram:state-machine}}
1268
-
1269
- _[TODO: Document state machine diagrams for stateful components]_
1270
-
1271
- ### 3.3 Interface Specifications
1272
-
1273
- \`\`\`memo-query
1274
- kind: Interface
1275
- display: table
1276
- columns: name, layer, doc
1277
- sort: name
1278
- empty: "No Interface elements defined."
1279
- \`\`\`
1280
-
1281
- ---
1282
-
1283
- ## 4. Design Verification Criteria
1284
-
1285
- The criteria used to verify that design outputs meet design inputs:
1286
-
1287
- _[TODO: List criteria that verify this design meets software requirements]_
1288
-
1289
- ---
1290
-
1291
- {{include:shared/snippets/revision-history-table.md}}
1292
-
1293
- {{include:shared/snippets/approval-block.md}}
1294
- `,Zi=`---
1295
- id: integration-test
1296
- title: Software Integration Test Plan
1297
- standard: IEC 62304:2006+AMD1:2015
1298
- clauses: ["5.6"]
1299
- required_for: ["CE", "FDA_510k", "MDR"]
1300
- ---
1301
-
1302
- {{include:shared/snippets/document-control-header.md}}
1303
-
1304
- {{toc}}
1305
-
1306
- ---
1307
-
1308
- ## 1. Purpose
1309
-
1310
- This Integration Test Plan defines the approach for integration testing of **{{project.product}}** software per IEC 62304:2006 §5.6.
1311
-
1312
- ---
1313
-
1314
- ## 2. Software Items Under Test
1315
-
1316
- The software items in scope for this test plan, drawn from the model:
1317
-
1318
- \`\`\`memo-query
1319
- kind: [SoftwareItem, SoftwareUnit]
1320
- display: table
1321
- columns: name, kind, layer, doc
1322
- sort: name
1323
- empty: "No software items defined."
1324
- \`\`\`
1325
-
1326
- ---
1327
-
1328
- ## 3. Integration Test Cases
1329
-
1330
- Integration test cases are listed below from the model:
1331
-
1332
- \`\`\`memo-query
1333
- kind: TestCase
1334
- where: layer == "verification"
1335
- display: table
1336
- columns: name, layer, doc
1337
- sort: name
1338
- empty: "No integration test cases defined. Add TestCase elements."
1339
- \`\`\`
1340
-
1341
- ---
1342
-
1343
- ## 4. Integration Sequence
1344
-
1345
- Describe the order in which software items are integrated and tested, and the rationale for that order.
1346
-
1347
- _[TODO: Define the order in which software items are integrated and tested]_
1348
-
1349
- ---
1350
-
1351
- ## 5. Pass/Fail Criteria
1352
-
1353
- State the objective criteria used to judge each test as passed or failed.
1354
-
1355
- _[TODO: Define objective pass/fail criteria for integration tests]_
1356
-
1357
- ---
1358
-
1359
- {{include:shared/snippets/revision-history-table.md}}
1360
-
1361
- {{include:shared/snippets/approval-block.md}}
1362
- `,ea=`---
1363
- id: sad
1364
- title: Software Architecture Description
1365
- standard: IEC 62304:2006+AMD1:2015
1366
- clauses: ["5.3"]
1367
- required_for: ["CE", "FDA_510k", "MDR"]
1368
- ---
1369
-
1370
- {{include:shared/snippets/document-control-header.md}}
1371
-
1372
- {{toc}}
1373
-
1374
- ---
1375
-
1376
- ## 1. Purpose
1377
-
1378
- This Software Architecture Description (SAD) defines the architecture of **{{project.product}}** software per IEC 62304:2006 §5.3 and ISO/IEC/IEEE 42010:2022.
1379
-
1380
- ---
1381
-
1382
- ## 2. System Overview
1383
-
1384
- This section gives a high-level overview of the **{{project.product}}** software system. The composition below is drawn live from the architecture model:
1385
-
1386
- \`\`\`memo-query
1387
- kind: SoftwareSystem
1388
- display: table
1389
- columns: name, layer, doc
1390
- sort: name
1391
- empty: "No SoftwareSystem defined."
1392
- \`\`\`
1393
-
1394
- **Total elements:**
1395
-
1396
- \`\`\`memo-query
1397
- kind: [SoftwareSystem, SoftwareItem, SoftwareUnit, SOUPComponent]
1398
- display: count
1399
- label: Total software elements
1400
- \`\`\`
1401
-
1402
- ---
1403
-
1404
- ## 3. Software Architecture
1405
-
1406
- This section describes the decomposition of the software into software items per IEC 62304 §5.3.1. The architecture view and the element tables that follow are generated from the model:
1407
-
1408
- {{diagram:software-architecture}}
1409
-
1410
- ### 3.1 Software Items
1411
-
1412
- \`\`\`memo-query
1413
- kind: SoftwareItem
1414
- display: table
1415
- columns: name, layer, doc
1416
- sort: name
1417
- empty: "No SoftwareItem elements defined."
1418
- \`\`\`
1419
-
1420
- ### 3.2 Software Units
1421
-
1422
- \`\`\`memo-query
1423
- kind: SoftwareUnit
1424
- display: table
1425
- columns: name, layer, doc
1426
- sort: name
1427
- empty: "No SoftwareUnit elements defined."
1428
- \`\`\`
1429
-
1430
- ### 3.3 Interfaces
1431
-
1432
- \`\`\`memo-query
1433
- kind: Interface
1434
- display: table
1435
- columns: name, layer, doc
1436
- sort: name
1437
- empty: "No Interface elements defined."
1438
- \`\`\`
1439
-
1440
- ---
1441
-
1442
- ## 4. SOUP Components
1443
-
1444
- Software of Unknown Provenance (SOUP) used by **{{project.product}}** is listed below per IEC 62304 §5.3.3–5.3.4. For each SOUP item, functional/performance requirements and required hardware/software must be specified:
1445
-
1446
- \`\`\`memo-query
1447
- kind: SOUPComponent
1448
- display: table
1449
- columns: name, doc, layer
1450
- sort: name
1451
- empty: "No SOUP components identified."
1452
- \`\`\`
1453
-
1454
- ---
1455
-
1456
- ## 5. Architecture Decisions
1457
-
1458
- Record the significant architecture decisions, the alternatives considered, and the rationale — including decisions driven by risk control measures (ISO 14971) or cybersecurity considerations.
1459
-
1460
- _[TODO: Document key architecture decisions and their rationale]_
1461
-
1462
- ---
1463
-
1464
- ## 6. Software Item Segregation
1465
-
1466
- Describe the segregation between software items that is necessary for risk control per IEC 62304 §5.3.5, and the rationale for the integrity of each segregation boundary.
1467
-
1468
- _[TODO: Describe how safety-critical software items are segregated from non-safety-critical items]_
1469
-
1470
- ---
1471
-
1472
- {{include:shared/snippets/revision-history-table.md}}
1473
-
1474
- {{include:shared/snippets/approval-block.md}}
1475
-
1476
- {{include:shared/snippets/references-section.md}}
1477
- `,ta=`---
1478
- id: sbom
1479
- title: Software Bill of Materials (SBOM)
1480
- standard: IEC 62304:2006+AMD1:2015
1481
- clauses: ["8.1.2"]
1482
- required_for: ["FDA_510k", "FDA_PMA", "CE"]
1483
- ---
1484
-
1485
- {{include:shared/snippets/document-control-header.md}}
1486
-
1487
- {{toc}}
1488
-
1489
- ---
1490
-
1491
- ## 1. Purpose
1492
-
1493
- This Software Bill of Materials (SBOM) provides a complete inventory of software components in **{{project.product}}**, including first-party code, SOUP, and open-source dependencies. Required for FDA cybersecurity submissions and EU MDR.
1494
-
1495
- ---
1496
-
1497
- ## 2. First-Party Software
1498
-
1499
- Software developed in-house for this system is listed below from the model:
1500
-
1501
- \`\`\`memo-query
1502
- kind: [SoftwareSystem, SoftwareItem, SoftwareUnit]
1503
- display: table
1504
- columns: name, kind, layer, doc
1505
- sort: name
1506
- empty: "No first-party software items defined."
1507
- \`\`\`
1508
-
1509
- ---
1510
-
1511
- ## 3. SOUP and Third-Party Components
1512
-
1513
- All third-party and SOUP components with their versions and origins, generated from the model:
1514
-
1515
- \`\`\`memo-query
1516
- kind: SOUPComponent
1517
- display: table
1518
- columns: name, doc, layer
1519
- sort: name
1520
- empty: "No SOUP components defined."
1521
- \`\`\`
1522
-
1523
- ---
1524
-
1525
- ## 4. Dependency Versions
1526
-
1527
- Exact component versions currently recorded in the model — keep these synchronized with the build system:
1528
-
1529
- _[TODO: Attach machine-readable SBOM (CycloneDX or SPDX format)]_
1530
-
1531
- ---
1532
-
1533
- ## 5. Vulnerability Assessment
1534
-
1535
- Assessment of component vulnerabilities and their disposition:
1536
-
1537
- _[TODO: Reference FDA cybersecurity submission or security assessment]_
1538
-
1539
- ---
1540
-
1541
- {{include:shared/snippets/revision-history-table.md}}
1542
-
1543
- {{include:shared/snippets/approval-block.md}}
1544
- `,na=`---
1545
- id: sdp
1546
- title: Software Development Plan
1547
- standard: IEC 62304:2006+AMD1:2015
1548
- clauses: ["5.1"]
1549
- required_for: ["CE", "FDA_510k", "MDR"]
1550
- ---
1551
-
1552
- {{include:shared/snippets/document-control-header.md}}
1553
-
1554
- {{toc}}
1555
-
1556
- ---
1557
-
1558
- ## 1. Purpose and Scope
1559
-
1560
- This Software Development Plan (SDP) defines the processes, activities, and tasks for the development of software for **{{project.product}}**. This plan is maintained per IEC 62304:2006 §5.1.
1561
-
1562
- ---
1563
-
1564
- ## 2. Software Classification
1565
-
1566
- <!-- [GUIDANCE] Classify software per IEC 62304 §4.3: Class A (no injury), Class B (non-serious injury), Class C (death or serious injury). -->
1567
-
1568
- | Software Item | Classification | Justification |
1569
- | --- | --- | --- |
1570
- | {{project.product}} Software System | Class B | |
1571
-
1572
- \`\`\`memo-query
1573
- kind: [SoftwareSystem, SoftwareItem]
1574
- display: table
1575
- columns: name, kind, layer, doc
1576
- sort: name
1577
- empty: "No software items defined. Add SoftwareSystem or SoftwareItem elements."
1578
- \`\`\`
1579
-
1580
- ---
1581
-
1582
- ## 3. Development Standards and Procedures
1583
-
1584
- Identify the coding standards, review procedures, and quality gates applied during development.
1585
-
1586
- | Activity | Standard | Reference Procedure |
1587
- | --- | --- | --- |
1588
- | Requirements | IEC 62304 §5.2 | SRS |
1589
- | Architecture | IEC 62304 §5.3 | SAD |
1590
- | Detailed Design | IEC 62304 §5.4 | SDS |
1591
- | Implementation | IEC 62304 §5.5 | Coding standard |
1592
- | Integration | IEC 62304 §5.6 | Integration Test Plan |
1593
- | System Testing | IEC 62304 §5.7 | System Test Plan |
1594
- | Release | IEC 62304 §5.8 | Release procedure |
1595
-
1596
- ---
1597
-
1598
- ## 4. Software Safety Activities
1599
-
1600
- ### 4.1 Software Items of Unknown Provenance (SOUP)
1601
-
1602
- \`\`\`memo-query
1603
- kind: SOUPComponent
1604
- display: table
1605
- columns: name, doc, layer
1606
- sort: name
1607
- empty: "No SOUP components defined."
1608
- \`\`\`
1609
-
1610
- ### 4.2 Software-Related Hazards
1611
-
1612
- \`\`\`memo-query
1613
- kind: Hazard
1614
- where: layer == "software"
1615
- display: table
1616
- columns: name, doc, layer
1617
- sort: name
1618
- empty: "No software-related hazards defined."
1619
- \`\`\`
1620
-
1621
- ---
1622
-
1623
- ## 5. Configuration Management
1624
-
1625
- Describe how configuration items are identified, versioned, and controlled per IEC 62304 §8.
1626
-
1627
- _[TODO: Describe version control, branching strategy, and release process]_
1628
-
1629
- ---
1630
-
1631
- ## 6. Problem Resolution
1632
-
1633
- Describe the problem resolution process per IEC 62304 §9, including how problems are reported, investigated, and tracked to closure.
1634
-
1635
- _[TODO: Describe defect tracking and resolution process]_
1636
-
1637
- ---
1638
-
1639
- ## 7. Development Environment
1640
-
1641
- Describe the toolchain, languages, build system, and environments used for development.
1642
-
1643
- _[TODO: List development tools, compilers, IDEs, and their versions]_
1644
-
1645
- ---
1646
-
1647
- {{include:shared/snippets/revision-history-table.md}}
1648
-
1649
- {{include:shared/snippets/approval-block.md}}
1650
-
1651
- {{include:shared/snippets/references-section.md}}
1652
- `,ra=`---
1653
- id: soup
1654
- title: SOUP List (Software of Unknown Provenance)
1655
- standard: IEC 62304:2006+AMD1:2015
1656
- clauses: ["8.1.2"]
1657
- required_for: ["CE", "FDA_510k", "MDR"]
1658
- ---
1659
-
1660
- {{include:shared/snippets/document-control-header.md}}
1661
-
1662
- {{toc}}
1663
-
1664
- ---
1665
-
1666
- ## 1. Purpose
1667
-
1668
- This document lists all Software of Unknown Provenance (SOUP) components used in **{{project.product}}** per IEC 62304:2006 §8.1.2. SOUP includes off-the-shelf software, open-source libraries, and third-party components that were not developed under a quality management system.
1669
-
1670
- ---
1671
-
1672
- ## 2. SOUP Inventory
1673
-
1674
- The complete inventory of SOUP and third-party components in **{{project.product}}**, generated from the model:
1675
-
1676
- \`\`\`memo-query
1677
- kind: SOUPComponent
1678
- display: table
1679
- columns: name, layer, doc
1680
- sort: name
1681
- empty: "No SOUP components defined. Add SOUPComponent elements to the model."
1682
- \`\`\`
1683
-
1684
- ---
1685
-
1686
- ## 3. SOUP Risk Assessment
1687
-
1688
- For each SOUP component, the potential impact on device safety must be evaluated.
1689
-
1690
- \`\`\`memo-query
1691
- kind: SOUPComponent
1692
- display: table
1693
- columns: name, doc
1694
- sort: name
1695
- empty: "No SOUP components to evaluate."
1696
- \`\`\`
1697
-
1698
- ### 3.1 Known Anomalies
1699
-
1700
- _[TODO: For each SOUP component, list known anomalies and assess impact on safety]_
1701
-
1702
- ---
1703
-
1704
- ## 4. SOUP Maintenance
1705
-
1706
- ### 4.1 Update Monitoring
1707
-
1708
- _[TODO: Describe the process for monitoring SOUP components for security patches and updates]_
1709
-
1710
- ### 4.2 Version Pinning
1711
-
1712
- _[TODO: Describe how SOUP versions are pinned in configuration management]_
1713
-
1714
- ---
1715
-
1716
- ## 5. SBOM Integration
1717
-
1718
- Describe how this document relates to the machine-readable SBOM (e.g. SPDX/CycloneDX) produced by the build pipeline.
1719
-
1720
- _[TODO: Reference Software Bill of Materials (SBOM) for FDA cybersecurity requirements]_
1721
-
1722
- ---
1723
-
1724
- {{include:shared/snippets/revision-history-table.md}}
1725
-
1726
- {{include:shared/snippets/approval-block.md}}
1727
-
1728
- {{include:shared/snippets/references-section.md}}
1729
- `,oa=`---
1730
- id: srs
1731
- title: Software Requirements Specification
1732
- standard: IEC 62304:2006+AMD1:2015
1733
- clauses: ["5.2"]
1734
- required_for: ["CE", "FDA_510k", "MDR"]
1735
- ---
1736
-
1737
- {{include:shared/snippets/document-control-header.md}}
1738
-
1739
- {{toc}}
1740
-
1741
- ---
1742
-
1743
- ## 1. Purpose
1744
-
1745
- This Software Requirements Specification (SRS) defines the software requirements for **{{project.product}}** in accordance with IEC 62304:2006 §5.2.
1746
-
1747
- ---
1748
-
1749
- ## 2. Requirements Summary
1750
-
1751
- Summary metrics for the requirements captured in the model:
1752
-
1753
- \`\`\`memo-query
1754
- kind: Requirement
1755
- display: count
1756
- label: Total software requirements
1757
- \`\`\`
1758
-
1759
- \`\`\`memo-query
1760
- kind: Requirement
1761
- display: count
1762
- label: System requirements
1763
- \`\`\`
1764
-
1765
- ---
1766
-
1767
- ## 3. Functional Requirements
1768
-
1769
- Functional requirements are listed below from the model:
1770
-
1771
- \`\`\`memo-query
1772
- kind: Requirement
1773
- where: doc contains "shall"
1774
- display: table
1775
- columns: name, layer, doc
1776
- sort: name
1777
- empty: "No functional software requirements defined."
1778
- \`\`\`
1779
-
1780
- ### All Software Requirements
1781
-
1782
- \`\`\`memo-query
1783
- kind: Requirement
1784
- display: table
1785
- columns: name, kind, layer, doc
1786
- sort: name
1787
- empty: "No software requirements defined. Add Requirement elements to model/requirements/*.sysml."
1788
- \`\`\`
1789
-
1790
- ---
1791
-
1792
- ## 4. System Requirements (Allocated to Software)
1793
-
1794
- System requirements allocated to software per IEC 62304 §5.2, drawn from the model:
1795
-
1796
- \`\`\`memo-query
1797
- kind: Requirement
1798
- display: table
1799
- columns: name, layer, doc
1800
- sort: name
1801
- empty: "No system requirements defined."
1802
- \`\`\`
1803
-
1804
- ---
1805
-
1806
- ## 5. Non-Functional Requirements
1807
-
1808
- ### 5.1 Performance Requirements
1809
-
1810
- _[TODO: Define performance requirements (response time, throughput, memory)]_
1811
-
1812
- ### 5.2 Safety Requirements
1813
-
1814
- \`\`\`memo-query
1815
- kind: Hazard
1816
- where: layer == "software"
1817
- display: table
1818
- columns: name, doc
1819
- sort: name
1820
- empty: "No software safety requirements derived from hazard analysis."
1821
- \`\`\`
1822
-
1823
- ### 5.3 Security Requirements
1824
-
1825
- \`\`\`memo-query
1826
- kind: [SecurityControl, ThreatModel]
1827
- display: table
1828
- columns: name, layer, doc
1829
- empty: "No security requirements defined."
1830
- \`\`\`
1831
-
1832
- ---
1833
-
1834
- ## 6. SOUP Requirements
1835
-
1836
- This section is generated from the system model. The table below lists the **SOUP Requirements** elements currently defined:
1837
-
1838
- \`\`\`memo-query
1839
- kind: SOUPComponent
1840
- display: table
1841
- columns: name, doc
1842
- sort: name
1843
- empty: "No SOUP components identified."
1844
- \`\`\`
1845
-
1846
- ---
1847
-
1848
- ## 7. Requirements Traceability
1849
-
1850
- This section is generated from the system model. The table below lists the **Requirements Traceability** elements currently defined:
1851
-
1852
- \`\`\`memo-query
1853
- kind: Requirement
1854
- display: table
1855
- columns: name, layer
1856
- sort: name
1857
- empty: "No software requirements to trace."
1858
- \`\`\`
1859
-
1860
- ---
1861
-
1862
- {{include:shared/snippets/revision-history-table.md}}
1863
-
1864
- {{include:shared/snippets/approval-block.md}}
1865
-
1866
- {{include:shared/snippets/references-section.md}}
1867
- `,sa=`---
1868
- id: sw-traceability
1869
- title: Software Traceability Matrix
1870
- standard: IEC 62304:2006+AMD1:2015
1871
- clauses: ["5.1.1", "5.7.5"]
1872
- required_for: ["CE", "FDA_510k", "MDR"]
1873
- ---
1874
-
1875
- {{include:shared/snippets/document-control-header.md}}
1876
-
1877
- {{toc}}
1878
-
1879
- ---
1880
-
1881
- ## 1. Purpose
1882
-
1883
- This Software Traceability Matrix demonstrates bidirectional traceability from system requirements through software requirements, design, implementation, and test for **{{project.product}}**.
1884
-
1885
- ---
1886
-
1887
- ## 2. Traceability Summary
1888
-
1889
- The following metric is computed live from the model:
1890
-
1891
- \`\`\`memo-query
1892
- kind: Requirement
1893
- display: count
1894
- label: System requirements
1895
- \`\`\`
1896
-
1897
- \`\`\`memo-query
1898
- kind: Requirement
1899
- display: count
1900
- label: Software requirements
1901
- \`\`\`
1902
-
1903
- \`\`\`memo-query
1904
- kind: TestCase
1905
- display: count
1906
- label: Test cases
1907
- \`\`\`
1908
-
1909
- ---
1910
-
1911
- ## 3. System → Software Requirements
1912
-
1913
- This section is generated from the system model. The table below lists the **System → Software Requirements** elements currently defined:
1914
-
1915
- \`\`\`memo-query
1916
- kind: Requirement
1917
- display: table
1918
- columns: name, layer, doc
1919
- sort: name
1920
- empty: "No system requirements defined."
1921
- \`\`\`
1922
-
1923
- ---
1924
-
1925
- ## 4. Software Requirements
1926
-
1927
- This section is generated from the system model. The table below lists the **Software Requirements** elements currently defined:
1928
-
1929
- \`\`\`memo-query
1930
- kind: Requirement
1931
- display: table
1932
- columns: name, layer, doc
1933
- sort: name
1934
- empty: "No software requirements defined."
1935
- \`\`\`
1936
-
1937
- ---
1938
-
1939
- ## 5. Software Requirements → Design Elements
1940
-
1941
- This section is generated from the system model. The table below lists the **Software Requirements → Design Elements** elements currently defined:
1942
-
1943
- \`\`\`memo-query
1944
- kind: [SoftwareItem, SoftwareUnit]
1945
- display: table
1946
- columns: name, kind, layer, doc
1947
- sort: name
1948
- empty: "No software design elements defined."
1949
- \`\`\`
1950
-
1951
- ---
1952
-
1953
- ## 6. Test Cases
1954
-
1955
- This section is generated from the system model. The table below lists the **Test Cases** elements currently defined:
1956
-
1957
- \`\`\`memo-query
1958
- kind: TestCase
1959
- display: table
1960
- columns: name, layer, doc
1961
- sort: name
1962
- empty: "No test cases defined. Add TestCase elements."
1963
- \`\`\`
1964
-
1965
- ---
1966
-
1967
- ## 7. Untraced Requirements
1968
-
1969
- Complete this section for **{{project.product}}** using the guidance below.
1970
-
1971
- _[TODO: List any software requirements without corresponding test cases]_
1972
-
1973
- ---
1974
-
1975
- {{include:shared/snippets/revision-history-table.md}}
1976
-
1977
- {{include:shared/snippets/approval-block.md}}
1978
- `,ia=`---
1979
- id: system-test
1980
- title: Software System Test Plan
1981
- standard: IEC 62304:2006+AMD1:2015
1982
- clauses: ["5.7"]
1983
- required_for: ["CE", "FDA_510k", "MDR"]
1984
- ---
1985
-
1986
- {{include:shared/snippets/document-control-header.md}}
1987
-
1988
- {{toc}}
1989
-
1990
- ---
1991
-
1992
- ## 1. Purpose
1993
-
1994
- This System Test Plan defines the approach for system-level testing of **{{project.product}}** per IEC 62304:2006 §5.7.
1995
-
1996
- ---
1997
-
1998
- ## 2. System Requirements Under Test
1999
-
2000
- This section is generated from the system model. The table below lists the **System Requirements Under Test** elements currently defined:
2001
-
2002
- \`\`\`memo-query
2003
- kind: Requirement
2004
- display: table
2005
- columns: name, layer, doc
2006
- sort: name
2007
- empty: "No system requirements defined."
2008
- \`\`\`
2009
-
2010
- ---
2011
-
2012
- ## 3. System Test Cases
2013
-
2014
- This section is generated from the system model. The table below lists the **System Test Cases** elements currently defined:
2015
-
2016
- \`\`\`memo-query
2017
- kind: [TestCase, ValidationActivity]
2018
- display: table
2019
- columns: name, kind, layer, doc
2020
- sort: name
2021
- empty: "No system test cases defined."
2022
- \`\`\`
2023
-
2024
- ---
2025
-
2026
- ## 4. Test Environment
2027
-
2028
- Describe the hardware, software, tools, and configuration of the test environment in sufficient detail to reproduce the test setup.
2029
-
2030
- _[TODO: Describe the test environment, tools, and hardware configuration]_
2031
-
2032
- ---
2033
-
2034
- ## 5. Anomaly Reporting
2035
-
2036
- Complete this section for **{{project.product}}** using the guidance below.
2037
-
2038
- _[TODO: Describe how test failures and anomalies are documented and tracked]_
2039
-
2040
- ---
2041
-
2042
- {{include:shared/snippets/revision-history-table.md}}
2043
-
2044
- {{include:shared/snippets/approval-block.md}}
2045
- `,aa=`---
2046
- id: formative-eval
2047
- title: Formative Usability Evaluation Report
2048
- standard: IEC 62366-1:2015+AMD1:2020
2049
- clauses: ["5.7"]
2050
- required_for: ["CE", "MDR"]
2051
- ---
2052
-
2053
- {{include:shared/snippets/document-control-header.md}}
2054
-
2055
- ---
2056
-
2057
- ## 1. Purpose
2058
-
2059
- Documents formative (iterative) usability evaluation activities for **{{project.product}}** during design development.
2060
-
2061
- ---
2062
-
2063
- ## 2. Evaluation Methods Used
2064
-
2065
- Complete this section for **{{project.product}}** using the guidance below.
2066
-
2067
- _[TODO: Describe methods used — expert review, cognitive walkthrough, prototype testing, etc.]_
2068
-
2069
- ---
2070
-
2071
- ## 3. Issues Identified and Resolved
2072
-
2073
- Complete the table below for **{{project.product}}**:
2074
-
2075
- | Issue | Severity | Resolution | Status |
2076
- | --- | --- | --- | --- |
2077
- | | | | |
2078
-
2079
- ---
2080
-
2081
- ## 4. Design Changes Made
2082
-
2083
- Complete this section for **{{project.product}}** using the guidance below.
2084
-
2085
- _[TODO: Summarize user interface design changes made as a result of formative evaluations]_
2086
-
2087
- ---
2088
-
2089
- {{include:shared/snippets/revision-history-table.md}}
2090
-
2091
- {{include:shared/snippets/approval-block.md}}
2092
- `,la=`---
2093
- id: summative-eval
2094
- title: Summative Usability Evaluation Report
2095
- standard: IEC 62366-1:2015+AMD1:2020
2096
- clauses: ["5.9"]
2097
- required_for: ["CE", "FDA_510k", "MDR"]
2098
- ---
2099
-
2100
- {{include:shared/snippets/document-control-header.md}}
2101
-
2102
- {{toc}}
2103
-
2104
- ---
2105
-
2106
- ## 1. Purpose
2107
-
2108
- This report documents the results of summative (validation) usability testing for **{{project.product}}** per IEC 62366-1:2015 §5.9.
2109
-
2110
- ---
2111
-
2112
- ## 2. Test Participants
2113
-
2114
- Complete this section for **{{project.product}}** using the guidance below.
2115
-
2116
- _[TODO: Describe participant demographics, number, and selection criteria]_
2117
-
2118
- ---
2119
-
2120
- ## 3. Test Scenarios
2121
-
2122
- This section is generated from the system model. The table below lists the **Test Scenarios** elements currently defined:
2123
-
2124
- \`\`\`memo-query
2125
- kind: [UseCase, ValidationActivity]
2126
- display: table
2127
- columns: name, layer, doc
2128
- sort: name
2129
- empty: "No validation scenarios defined."
2130
- \`\`\`
2131
-
2132
- ---
2133
-
2134
- ## 4. Results
2135
-
2136
- ### 4.1 Task Completion Rates
2137
-
2138
- _[TODO: Report task completion rates and time-on-task for each critical task]_
2139
-
2140
- ### 4.2 Use Errors Observed
2141
-
2142
- _[TODO: List all use errors observed during testing]_
2143
-
2144
- ### 4.3 Pass/Fail Assessment
2145
-
2146
- _[TODO: State whether each test scenario passed or failed per pre-defined criteria]_
2147
-
2148
- ---
2149
-
2150
- ## 5. Conclusions
2151
-
2152
- Complete this section for **{{project.product}}** using the guidance below.
2153
-
2154
- _[TODO: State whether the device passed summative usability evaluation]_
2155
-
2156
- ---
2157
-
2158
- {{include:shared/snippets/revision-history-table.md}}
2159
-
2160
- {{include:shared/snippets/approval-block.md}}
2161
- `,da=`---
2162
- id: task-analysis
2163
- title: Task Analysis
2164
- standard: IEC 62366-1:2015+AMD1:2020
2165
- clauses: ["5.4"]
2166
- required_for: ["CE", "MDR"]
2167
- ---
2168
-
2169
- {{include:shared/snippets/document-control-header.md}}
2170
-
2171
- {{toc}}
2172
-
2173
- ---
2174
-
2175
- ## 1. Purpose
2176
-
2177
- Documents task analysis for **{{project.product}}** per IEC 62366-1:2015 §5.4, identifying tasks that could cause hazardous situations if performed incorrectly.
2178
-
2179
- ---
2180
-
2181
- ## 2. User Tasks
2182
-
2183
- This section is generated from the system model. The table below lists the **User Tasks** elements currently defined:
2184
-
2185
- \`\`\`memo-query
2186
- kind: UserActivity
2187
- display: table
2188
- columns: name, layer, doc
2189
- sort: name
2190
- empty: "No UserActivity elements defined."
2191
- \`\`\`
2192
-
2193
- ---
2194
-
2195
- ## 3. Critical Tasks
2196
-
2197
- Complete this section for **{{project.product}}** using the guidance below.
2198
-
2199
- _[TODO: Identify which tasks are critical (could lead to hazardous situation if performed incorrectly)]_
2200
-
2201
- | Task | Critical | Hazardous Situation if Error | Mitigation |
2202
- | --- | --- | --- | --- |
2203
- | | | | |
2204
-
2205
- ---
2206
-
2207
- ## 4. Task Flow Analysis
2208
-
2209
- The diagram below is rendered from the corresponding model view and reflects the current state of the model:
2210
-
2211
- {{diagram:task-flow}}
2212
-
2213
- _[TODO: Document sequential and parallel task flows with decision points]_
2214
-
2215
- ---
2216
-
2217
- {{include:shared/snippets/revision-history-table.md}}
2218
- `,ca=`---
2219
- id: ue-plan
2220
- title: Usability Engineering Plan
2221
- standard: IEC 62366-1:2015+AMD1:2020
2222
- clauses: ["4"]
2223
- required_for: ["CE", "FDA_510k", "MDR"]
2224
- ---
2225
-
2226
- {{include:shared/snippets/document-control-header.md}}
2227
-
2228
- {{toc}}
2229
-
2230
- ---
2231
-
2232
- ## 1. Purpose
2233
-
2234
- This Usability Engineering Plan (UE Plan) defines the usability engineering activities for **{{project.product}}** per IEC 62366-1:2015.
2235
-
2236
- ---
2237
-
2238
- ## 2. Intended Users
2239
-
2240
- Identify every intended user group of **{{project.product}}**, including their roles, training assumptions, and use environments.
2241
-
2242
- _[TODO: Define all intended user groups (clinicians, patients, technicians, lay users)]_
2243
-
2244
- ---
2245
-
2246
- ## 3. Intended Use Environment
2247
-
2248
- Complete this section for **{{project.product}}** using the guidance below.
2249
-
2250
- _[TODO: Describe all use environments: clinical, home, ambulatory, etc.]_
2251
-
2252
- ---
2253
-
2254
- ## 4. Use-Related Hazards
2255
-
2256
- This section is generated from the system model. The table below lists the **Use-Related Hazards** elements currently defined:
2257
-
2258
- \`\`\`memo-query
2259
- kind: [UseCase, UserActivity]
2260
- display: table
2261
- columns: name, layer, doc
2262
- sort: name
2263
- empty: "No use cases or user activities defined."
2264
- \`\`\`
2265
-
2266
- ---
2267
-
2268
- ## 5. Usability Testing Plan
2269
-
2270
- ### 5.1 Formative Evaluation
2271
-
2272
- _[TODO: Describe formative evaluation approach: cognitive walkthrough, expert review, prototype testing]_
2273
-
2274
- ### 5.2 Summative Evaluation
2275
-
2276
- _[TODO: Describe summative usability testing: participants, scenarios, pass/fail criteria]_
2277
-
2278
- ---
2279
-
2280
- ## 6. User Interface Elements
2281
-
2282
- This section is generated from the system model. The table below lists the **User Interface Elements** elements currently defined:
2283
-
2284
- \`\`\`memo-query
2285
- kind: UserInterface
2286
- display: table
2287
- columns: name, layer, doc
2288
- sort: name
2289
- empty: "No UserInterface elements defined."
2290
- \`\`\`
2291
-
2292
- ---
2293
-
2294
- {{include:shared/snippets/revision-history-table.md}}
2295
-
2296
- {{include:shared/snippets/approval-block.md}}
2297
-
2298
- {{include:shared/snippets/references-section.md}}
2299
- `,ua=`---
2300
- id: ui-spec
2301
- title: User Interface Specification
2302
- standard: IEC 62366-1:2015+AMD1:2020
2303
- clauses: ["5.6"]
2304
- required_for: ["CE", "MDR"]
2305
- ---
2306
-
2307
- {{include:shared/snippets/document-control-header.md}}
2308
-
2309
- {{toc}}
2310
-
2311
- ---
2312
-
2313
- ## 1. Purpose
2314
-
2315
- Specifies the user interface design for **{{project.product}}** per IEC 62366-1:2015 §5.6.
2316
-
2317
- ---
2318
-
2319
- ## 2. User Interface Elements
2320
-
2321
- This section is generated from the system model. The table below lists the **User Interface Elements** elements currently defined:
2322
-
2323
- \`\`\`memo-query
2324
- kind: UserInterface
2325
- display: table
2326
- columns: name, layer, doc
2327
- sort: name
2328
- empty: "No UserInterface elements defined."
2329
- \`\`\`
2330
-
2331
- ---
2332
-
2333
- ## 3. Screen/Mode Specifications
2334
-
2335
- Complete this section for **{{project.product}}** using the guidance below.
2336
-
2337
- _[TODO: Document each screen, mode, and key interaction with screenshots or wireframes]_
2338
-
2339
- ---
2340
-
2341
- ## 4. Alerts and Alarms
2342
-
2343
- Complete this section for **{{project.product}}** using the guidance below.
2344
-
2345
- _[TODO: Document all alarms, alerts, and status indicators with their visual/auditory characteristics]_
2346
-
2347
- ---
2348
-
2349
- ## 5. Labeling on Device
2350
-
2351
- Complete this section for **{{project.product}}** using the guidance below.
2352
-
2353
- _[TODO: Document all labels, symbols, and icons used on the physical device]_
2354
-
2355
- ---
2356
-
2357
- {{include:shared/snippets/revision-history-table.md}}
2358
-
2359
- {{include:shared/snippets/approval-block.md}}
2360
- `,pa=`---
2361
- id: urra
2362
- title: Use-Related Risk Analysis
2363
- standard: IEC 62366-1:2015+AMD1:2020
2364
- clauses: ["5"]
2365
- required_for: ["CE", "FDA_510k", "MDR"]
2366
- ---
2367
-
2368
- {{include:shared/snippets/document-control-header.md}}
2369
-
2370
- {{toc}}
2371
-
2372
- ---
2373
-
2374
- ## 1. Purpose
2375
-
2376
- This Use-Related Risk Analysis (URRA) identifies use errors and use-related hazardous situations for **{{project.product}}** per IEC 62366-1:2015 §5.
2377
-
2378
- ---
2379
-
2380
- ## 2. Use Scenarios
2381
-
2382
- This section is generated from the system model. The table below lists the **Use Scenarios** elements currently defined:
2383
-
2384
- \`\`\`memo-query
2385
- kind: [UseCase, UserActivity]
2386
- display: table
2387
- columns: name, layer, doc
2388
- sort: name
2389
- empty: "No use scenarios defined. Add UseCase or UserActivity elements."
2390
- \`\`\`
2391
-
2392
- ---
2393
-
2394
- ## 3. Use Errors and Abnormal Use
2395
-
2396
- This section is generated from the system model. The table below lists the **Use Errors and Abnormal Use** elements currently defined:
2397
-
2398
- \`\`\`memo-query
2399
- kind: [Hazard, HazardousSituation]
2400
- where: layer == "ui"
2401
- display: table
2402
- columns: name, doc, layer
2403
- sort: name
2404
- empty: "No use-related hazards defined."
2405
- \`\`\`
2406
-
2407
- ---
2408
-
2409
- ## 4. Critical Tasks
2410
-
2411
- Complete this section for **{{project.product}}** using the guidance below.
2412
-
2413
- _[TODO: Identify the critical tasks whose failure could cause a hazardous situation]_
2414
-
2415
- ---
2416
-
2417
- ## 5. Mitigation Measures
2418
-
2419
- This section is generated from the system model. The table below lists the **Mitigation Measures** elements currently defined:
2420
-
2421
- \`\`\`memo-query
2422
- kind: [RiskControlMeasure, UsabilityRequirement]
2423
- display: table
2424
- columns: name, layer, doc
2425
- sort: name
2426
- empty: "No usability-related risk controls defined."
2427
- \`\`\`
2428
-
2429
- ---
2430
-
2431
- {{include:shared/snippets/revision-history-table.md}}
2432
-
2433
- {{include:shared/snippets/approval-block.md}}
2434
- `,ma=`---
2435
- id: use-spec
2436
- title: Intended Use and Indications for Use Specification
2437
- standard: IEC 62366-1:2015+AMD1:2020
2438
- clauses: ["5.1"]
2439
- required_for: ["CE", "FDA_510k", "MDR"]
2440
- ---
2441
-
2442
- {{include:shared/snippets/document-control-header.md}}
2443
-
2444
- ---
2445
-
2446
- ## 1. Intended Use
2447
-
2448
- Complete this section for **{{project.product}}** using the guidance below.
2449
-
2450
- _[TODO: Provide the FDA-required Indications for Use statement and intended use statement]_
2451
-
2452
- ---
2453
-
2454
- ## 2. Intended User Profile
2455
-
2456
- Complete this section for **{{project.product}}** using the guidance below.
2457
-
2458
- _[TODO: Describe user knowledge, training level, and physical/cognitive capabilities]_
2459
-
2460
- ---
2461
-
2462
- ## 3. Use Environment
2463
-
2464
- Complete this section for **{{project.product}}** using the guidance below.
2465
-
2466
- _[TODO: Describe physical, social, technical environments where the device will be used]_
2467
-
2468
- ---
2469
-
2470
- ## 4. Use Cases
2471
-
2472
- Use cases describing how intended users interact with **{{project.product}}**, drawn from the model:
2473
-
2474
- \`\`\`memo-query
2475
- kind: UseCase
2476
- display: table
2477
- columns: name, layer, doc
2478
- sort: name
2479
- empty: "No UseCase elements defined."
2480
- \`\`\`
2481
-
2482
- ---
2483
-
2484
- ## 5. Known Use-Related Constraints
2485
-
2486
- Complete this section for **{{project.product}}** using the guidance below.
2487
-
2488
- _[TODO: Describe contraindications, limitations, and warnings that constrain use]_
2489
-
2490
- ---
2491
-
2492
- {{include:shared/snippets/revision-history-table.md}}
2493
-
2494
- {{include:shared/snippets/approval-block.md}}
2495
- `,fa=`---
2496
- id: fmea
2497
- title: Failure Mode and Effects Analysis
2498
- standard: IEC 60812:2018
2499
- clauses: ["5", "6", "7"]
2500
- required_for: ["CE", "FDA_510k", "FDA_PMA"]
2501
- ---
2502
-
2503
- {{include:shared/snippets/document-control-header.md}}
2504
-
2505
- {{toc}}
2506
-
2507
- ---
2508
-
2509
- ## 1. Purpose and Scope
2510
-
2511
- This FMEA documents failure modes for **{{project.product}}** components, their effects, severity, and mitigations. Combines hardware, software, and system-level failure analysis.
2512
-
2513
- ---
2514
-
2515
- ## 2. Component Inventory
2516
-
2517
- This section is generated from the system model. The table below lists the **Component Inventory** elements currently defined:
2518
-
2519
- \`\`\`memo-query
2520
- kind: [Component, Subsystem, SoftwareItem]
2521
- display: table
2522
- columns: name, kind, layer, doc
2523
- sort: name
2524
- empty: "No components defined. Add Component, Subsystem, or SoftwareItem elements."
2525
- \`\`\`
2526
-
2527
- ---
2528
-
2529
- ## 3. FMEA Worksheet
2530
-
2531
- ### 3.1 Hardware Failures
2532
-
2533
- \`\`\`memo-query
2534
- kind: Component
2535
- display: table
2536
- columns: name, layer, doc
2537
- sort: name
2538
- empty: "No hardware components defined."
2539
- \`\`\`
2540
-
2541
- ### 3.2 Software Failures
2542
-
2543
- \`\`\`memo-query
2544
- kind: [SoftwareItem, SoftwareUnit]
2545
- display: table
2546
- columns: name, kind, layer, doc
2547
- sort: name
2548
- empty: "No software items defined."
2549
- \`\`\`
2550
-
2551
- ### 3.3 Interface Failures
2552
-
2553
- \`\`\`memo-query
2554
- kind: Interface
2555
- display: table
2556
- columns: name, layer, doc
2557
- sort: name
2558
- empty: "No interfaces defined."
2559
- \`\`\`
2560
-
2561
- ---
2562
-
2563
- ## 4. Risk Controls for FMEA Items
2564
-
2565
- This section is generated from the system model. The table below lists the **Risk Controls for FMEA Items** elements currently defined:
2566
-
2567
- \`\`\`memo-query
2568
- kind: RiskControlMeasure
2569
- display: table
2570
- columns: name, layer, doc
2571
- sort: name
2572
- empty: "No risk controls defined."
2573
- \`\`\`
2574
-
2575
- ---
2576
-
2577
- ## 5. Unmitigated Failures
2578
-
2579
- Complete this section for **{{project.product}}** using the guidance below.
2580
-
2581
- _[TODO: List any failure modes without risk controls and justify residual risk]_
2582
-
2583
- ---
2584
-
2585
- {{include:shared/snippets/revision-history-table.md}}
2586
-
2587
- {{include:shared/snippets/approval-block.md}}
2588
- `,ha=`---
2589
- id: fta
2590
- title: Fault Tree Analysis
2591
- standard: ISO 14971:2019
2592
- clauses: ["5", "6"]
2593
- required_for: ["CE"]
2594
- ---
2595
-
2596
- {{include:shared/snippets/document-control-header.md}}
2597
-
2598
- {{toc}}
2599
-
2600
- ---
2601
-
2602
- ## 1. Purpose
2603
-
2604
- This Fault Tree Analysis (FTA) complements the FMEA by providing a top-down analysis of failure modes that could lead to identified harms for **{{project.product}}**.
2605
-
2606
- ---
2607
-
2608
- ## 2. Top Events (Harms)
2609
-
2610
- This section is generated from the system model. The table below lists the **Top Events (Harms)** elements currently defined:
2611
-
2612
- \`\`\`memo-query
2613
- kind: Harm
2614
- display: table
2615
- columns: name, doc, layer
2616
- sort: name
2617
- empty: "No harm elements defined. Add Harm elements to the model."
2618
- \`\`\`
2619
-
2620
- ---
2621
-
2622
- ## 3. Contributing Failure Modes
2623
-
2624
- This section is generated from the system model. The table below lists the **Contributing Failure Modes** elements currently defined:
2625
-
2626
- \`\`\`memo-query
2627
- kind: [Hazard, HazardousSituation]
2628
- display: grouped
2629
- group_by: layer
2630
- columns: name, kind, doc
2631
- sort: name
2632
- empty: "No hazards or hazardous situations defined."
2633
- \`\`\`
2634
-
2635
- ---
2636
-
2637
- ## 4. Fault Tree Diagrams
2638
-
2639
- The diagram below is rendered from the corresponding model view and reflects the current state of the model:
2640
-
2641
- {{diagram:fta-diagram}}
2642
-
2643
- _[TODO: Attach or reference FTA diagram files]_
2644
-
2645
- ---
2646
-
2647
- ## 5. Cut Sets and Recommendations
2648
-
2649
- Complete this section for **{{project.product}}** using the guidance below.
2650
-
2651
- _[TODO: List minimal cut sets and associated risk reduction recommendations]_
2652
-
2653
- ---
2654
-
2655
- {{include:shared/snippets/revision-history-table.md}}
2656
-
2657
- {{include:shared/snippets/approval-block.md}}
2658
- `,ga=`---
2659
- id: har
2660
- title: Hazard Analysis Report
2661
- standard: ISO 14971:2019
2662
- clauses: ["5", "6", "7"]
2663
- required_for: ["CE", "FDA_510k", "FDA_PMA", "MDR"]
2664
- ---
2665
-
2666
- {{include:shared/snippets/document-control-header.md}}
2667
-
2668
- {{toc}}
2669
-
2670
- ---
2671
-
2672
- ## 1. Purpose
2673
-
2674
- This Hazard Analysis Report documents the systematic identification of hazards, hazardous situations, and harms associated with **{{project.product}}**, along with the associated risk estimation and risk control measures.
2675
-
2676
- ---
2677
-
2678
- ## 2. Hazard Summary
2679
-
2680
- The following metric is computed live from the model:
2681
-
2682
- \`\`\`memo-query
2683
- kind: Hazard
2684
- display: count
2685
- label: Total hazards identified
2686
- \`\`\`
2687
-
2688
- \`\`\`memo-query
2689
- kind: HazardousSituation
2690
- display: count
2691
- label: Hazardous situations
2692
- \`\`\`
2693
-
2694
- \`\`\`memo-query
2695
- kind: RiskControlMeasure
2696
- display: count
2697
- label: Risk control measures
2698
- \`\`\`
2699
-
2700
- ---
2701
-
2702
- ## 3. Hazard Identification
2703
-
2704
- All foreseeable hazards arising from the device, its intended use, and reasonably foreseeable misuse are listed below.
2705
-
2706
- ### 3.1 Energy Hazards
2707
-
2708
- \`\`\`memo-query
2709
- kind: Hazard
2710
- where: doc contains "energy"
2711
- display: table
2712
- columns: name, doc, layer
2713
- sort: name
2714
- empty: "No energy hazards identified."
2715
- \`\`\`
2716
-
2717
- ### 3.2 Biological and Chemical Hazards
2718
-
2719
- \`\`\`memo-query
2720
- kind: Hazard
2721
- where: doc contains "biolog"
2722
- display: table
2723
- columns: name, doc, layer
2724
- empty: "No biological/chemical hazards identified."
2725
- \`\`\`
2726
-
2727
- ### 3.3 Operational Hazards
2728
-
2729
- \`\`\`memo-query
2730
- kind: Hazard
2731
- display: grouped
2732
- group_by: layer
2733
- columns: name, doc
2734
- sort: name
2735
- empty: "No hazards defined. Add Hazard elements to model/risk/*.sysml."
2736
- \`\`\`
2737
-
2738
- ---
2739
-
2740
- ## 4. Hazardous Situations
2741
-
2742
- This section is generated from the system model. The table below lists the **Hazardous Situations** elements currently defined:
2743
-
2744
- \`\`\`memo-query
2745
- kind: HazardousSituation
2746
- display: table
2747
- columns: name, doc, layer
2748
- sort: name
2749
- empty: "No hazardous situations defined. Add HazardousSituation elements."
2750
- \`\`\`
2751
-
2752
- ---
2753
-
2754
- ## 5. Risk Estimation
2755
-
2756
- <!-- [GUIDANCE] For each hazardous situation, estimate probability of occurrence and severity of harm per ISO 14971:2019 §5. -->
2757
-
2758
- \`\`\`memo-query
2759
- kind: Harm
2760
- display: table
2761
- columns: name, doc, layer
2762
- sort: name
2763
- empty: "No harm elements defined. Add Harm elements linked to HazardousSituation."
2764
- \`\`\`
2765
-
2766
- ---
2767
-
2768
- ## 6. Risk Control Measures
2769
-
2770
- ### 6.1 Inherent Safety by Design
2771
-
2772
- \`\`\`memo-query
2773
- kind: RiskControlMeasure
2774
- where: doc contains "design"
2775
- display: table
2776
- columns: name, doc, layer
2777
- empty: "No inherent safety controls."
2778
- \`\`\`
2779
-
2780
- ### 6.2 Protective Measures
2781
-
2782
- \`\`\`memo-query
2783
- kind: RiskControlMeasure
2784
- display: table
2785
- columns: name, doc, layer
2786
- sort: name
2787
- empty: "No risk controls defined. Add RiskControlMeasure elements."
2788
- \`\`\`
2789
-
2790
- ### 6.3 Information for Safety
2791
-
2792
- _[TODO: List all warnings, cautions, and contraindications in labeling]_
2793
-
2794
- ---
2795
-
2796
- ## 7. Residual Risk Evaluation
2797
-
2798
- This section is generated from the system model. The table below lists the **Residual Risk Evaluation** elements currently defined:
2799
-
2800
- \`\`\`memo-query
2801
- kind: Hazard
2802
- display: table
2803
- columns: name, layer, doc
2804
- sort: name
2805
- empty: "All hazards have been evaluated."
2806
- \`\`\`
2807
-
2808
- ---
2809
-
2810
- ## 8. Benefit-Risk Analysis
2811
-
2812
- <!-- [GUIDANCE] Per ISO 14971:2019 §8, if residual risks remain after all control measures, the overall residual risk must be judged acceptable relative to medical benefits. -->
2813
-
2814
- _[TODO: Document benefit-risk justification if any residual risks remain]_
2815
-
2816
- ---
2817
-
2818
- {{include:shared/snippets/revision-history-table.md}}
2819
-
2820
- {{include:shared/snippets/approval-block.md}}
2821
-
2822
- {{include:shared/snippets/references-section.md}}
2823
- `,ya=`---
2824
- id: risk-benefit
2825
- title: Risk-Benefit Analysis
2826
- standard: ISO 14971:2019
2827
- clauses: ["8"]
2828
- required_for: ["CE", "MDR"]
2829
- ---
2830
-
2831
- {{include:shared/snippets/document-control-header.md}}
2832
-
2833
- ---
2834
-
2835
- ## 1. Purpose
2836
-
2837
- This document provides the benefit-risk analysis for **{{project.product}}** as required by ISO 14971:2019 §8. It is prepared when residual risks cannot be further reduced and a judgment of acceptability must be made.
2838
-
2839
- ---
2840
-
2841
- ## 2. Medical Benefits
2842
-
2843
- Complete this section for **{{project.product}}** using the guidance below.
2844
-
2845
- _[TODO: Describe the medical benefits of the device for its intended patient population]_
2846
-
2847
- ---
2848
-
2849
- ## 3. Residual Risks Summary
2850
-
2851
- This section is generated from the system model. The table below lists the **Residual Risks Summary** elements currently defined:
2852
-
2853
- \`\`\`memo-query
2854
- kind: Hazard
2855
- display: table
2856
- columns: name, doc, layer
2857
- sort: name
2858
- empty: "No residual risks identified — standard risk controls are sufficient."
2859
- \`\`\`
2860
-
2861
- ---
2862
-
2863
- ## 4. Benefit-Risk Conclusion
2864
-
2865
- Complete this section for **{{project.product}}** using the guidance below.
2866
-
2867
- _[TODO: State the conclusion: the medical benefits of the intended use outweigh the residual risks]_
2868
-
2869
- ---
2870
-
2871
- {{include:shared/snippets/revision-history-table.md}}
2872
-
2873
- {{include:shared/snippets/approval-block.md}}
2874
- `,xa=`---
2875
- id: risk-matrix
2876
- title: Risk Matrix
2877
- standard: ISO 14971:2019
2878
- clauses: ["5", "6"]
2879
- required_for: ["CE", "MDR"]
2880
- ---
2881
-
2882
- {{include:shared/snippets/document-control-header.md}}
2883
-
2884
- ---
2885
-
2886
- ## Risk Matrix
2887
-
2888
- This matrix shows the distribution of identified hazards across severity and probability levels.
2889
-
2890
- \`\`\`memo-query
2891
- kind: Hazard
2892
- display: matrix
2893
- row_kind: kind
2894
- col_kind: layer
2895
- empty: "No hazards defined."
2896
- \`\`\`
2897
-
2898
- ### Hazard Coverage by Layer
2899
-
2900
- \`\`\`memo-query
2901
- kind: [Hazard, HazardousSituation, Harm]
2902
- display: grouped
2903
- group_by: layer
2904
- columns: name, kind, doc
2905
- empty: "No risk elements defined."
2906
- \`\`\`
2907
-
2908
- ---
2909
-
2910
- ## Risk Control Coverage
2911
-
2912
- This section is generated from the system model. The table below lists the **Risk Control Coverage** elements currently defined:
2913
-
2914
- \`\`\`memo-query
2915
- kind: RiskControlMeasure
2916
- display: table
2917
- columns: name, layer, doc
2918
- sort: name
2919
- empty: "No risk controls defined."
2920
- \`\`\`
2921
-
2922
- ---
2923
-
2924
- {{include:shared/snippets/revision-history-table.md}}
2925
- `,ba=`---
2926
- id: rmp
2927
- title: Risk Management Plan
2928
- standard: ISO 14971:2019
2929
- clauses: ["4.4"]
2930
- required_for: ["CE", "FDA_510k", "FDA_PMA", "MDR"]
2931
- ---
2932
-
2933
- {{include:shared/snippets/document-control-header.md}}
2934
-
2935
- {{toc}}
2936
-
2937
- ---
2938
-
2939
- ## 1. Purpose and Scope
2940
-
2941
- This Risk Management Plan (RMP) defines the risk management activities for **{{project.product}}** developed by **{{project.company}}**. This plan is maintained throughout the product lifecycle in accordance with ISO 14971:2019.
2942
-
2943
- ### 1.1 Intended Use
2944
-
2945
- <!-- [GUIDANCE] Describe the intended use of the device, intended users, and intended use environment. -->
2946
-
2947
- _[TODO: Describe intended use, intended users, and intended use environment]_
2948
-
2949
- ### 1.2 Scope of Risk Management
2950
-
2951
- This plan applies to all phases of the product lifecycle: design, development, manufacture, post-market surveillance, and eventual decommission.
2952
-
2953
- ---
2954
-
2955
- ## 2. Regulatory Context
2956
-
2957
- Complete the table below for **{{project.product}}**:
2958
-
2959
- | Requirement | Reference |
2960
- | --- | --- |
2961
- | Risk Management Process | ISO 14971:2019 §4.1 |
2962
- | Risk Management Plan | ISO 14971:2019 §4.4 |
2963
- | Risk Estimation | ISO 14971:2019 §5 |
2964
- | Risk Evaluation | ISO 14971:2019 §6 |
2965
- | Risk Control | ISO 14971:2019 §7 |
2966
- | Overall Residual Risk | ISO 14971:2019 §8 |
2967
- | Risk Management Review | ISO 14971:2019 §9 |
2968
- | Post-production | ISO 14971:2019 §10 |
2969
-
2970
- ---
2971
-
2972
- ## 3. Risk Management Team
2973
-
2974
- <!-- [GUIDANCE] List all personnel involved in risk management activities. -->
2975
-
2976
- | Role | Name | Responsibilities |
2977
- | --- | --- | --- |
2978
- | Risk Management Lead | | Overall RM coordination |
2979
- | Clinical Representative | | Clinical risk input |
2980
- | Software Engineer | | Software FMEA and SOUP risk |
2981
- | Regulatory Affairs | | Standards compliance |
2982
- | Quality Engineer | | Process compliance |
2983
-
2984
- ---
2985
-
2986
- ## 4. Risk Acceptability Criteria
2987
-
2988
- ### 4.1 Severity Levels
2989
-
2990
- \`\`\`memo-query
2991
- kind: RiskAcceptabilityCriteria
2992
- display: table
2993
- columns: name, doc, layer
2994
- empty: "No risk acceptability criteria defined. Add RiskAcceptabilityCriteria elements to the model."
2995
- \`\`\`
2996
-
2997
- ### 4.2 Risk Policy
2998
-
2999
- <!-- [GUIDANCE] Define the risk policy: ALARP, broadly acceptable, or unacceptable regions. -->
3000
-
3001
- _[TODO: Define risk acceptability matrix — probability vs. severity]_
3002
-
3003
- Residual risk is acceptable when:
3004
- - All individual risks are reduced to ALARP or broadly acceptable level
3005
- - Overall residual risk is acceptable per §8 of ISO 14971:2019
3006
- - Unmitigated hazards:
3007
-
3008
- \`\`\`memo-query
3009
- kind: Hazard
3010
- where: layer == "risk"
3011
- display: count
3012
- label: Total hazards in model
3013
- \`\`\`
3014
-
3015
- ---
3016
-
3017
- ## 5. Risk Management Activities
3018
-
3019
- ### 5.1 Hazard Identification
3020
-
3021
- All hazard identification activities are documented in the Hazard Analysis Report (HAR).
3022
-
3023
- \`\`\`memo-query
3024
- kind: Hazard
3025
- display: table
3026
- columns: name, layer, doc
3027
- sort: name
3028
- empty: "No hazards defined. Add Hazard elements to model/risk/*.sysml."
3029
- \`\`\`
3030
-
3031
- ### 5.2 Risk Estimation and Evaluation
3032
-
3033
- Risk estimation is performed for each hazardous situation per ISO 14971:2019 §5–6.
3034
-
3035
- \`\`\`memo-query
3036
- kind: HazardousSituation
3037
- display: table
3038
- columns: name, layer, doc
3039
- sort: name
3040
- empty: "No hazardous situations defined."
3041
- \`\`\`
3042
-
3043
- ### 5.3 Risk Control Measures
3044
-
3045
- \`\`\`memo-query
3046
- kind: RiskControlMeasure
3047
- display: table
3048
- columns: name, layer, doc
3049
- sort: name
3050
- empty: "No risk controls defined."
3051
- \`\`\`
3052
-
3053
- ### 5.4 Residual Risk Evaluation
3054
-
3055
- Unmitigated hazards (hazards without associated risk controls):
3056
-
3057
- \`\`\`memo-query
3058
- kind: Hazard
3059
- display: table
3060
- columns: name, doc
3061
- empty: "All hazards have associated risk controls."
3062
- \`\`\`
3063
-
3064
- ---
3065
-
3066
- ## 6. Risk Management Documentation
3067
-
3068
- Complete the table below for **{{project.product}}**:
3069
-
3070
- | Document | Purpose | Reference |
3071
- | --- | --- | --- |
3072
- | Hazard Analysis Report (HAR) | Hazard identification and estimation | HAR |
3073
- | FMEA | Failure mode analysis | FMEA |
3074
- | Risk Benefit Analysis | Benefit-risk justification | N/A |
3075
- | Risk Management Report | Overall residual risk summary | N/A |
3076
-
3077
- ---
3078
-
3079
- ## 7. Plan Maintenance
3080
-
3081
- This plan shall be reviewed:
3082
- - At each major design change
3083
- - Following post-market surveillance findings
3084
- - Prior to each design review gate
3085
- - At least annually during active development
3086
-
3087
- ---
3088
-
3089
- {{include:shared/snippets/revision-history-table.md}}
3090
-
3091
- {{include:shared/snippets/approval-block.md}}
3092
-
3093
- {{include:shared/snippets/references-section.md}}
3094
- `,va=`---
3095
- id: rmr
3096
- title: Risk Management Report
3097
- standard: ISO 14971:2019
3098
- clauses: ["9"]
3099
- required_for: ["CE", "FDA_510k", "FDA_PMA", "MDR"]
3100
- ---
3101
-
3102
- {{include:shared/snippets/document-control-header.md}}
3103
-
3104
- {{toc}}
3105
-
3106
- ---
3107
-
3108
- ## 1. Purpose
3109
-
3110
- This Risk Management Report (RMR) summarizes the results of all risk management activities performed for **{{project.product}}** in accordance with ISO 14971:2019 §9.
3111
-
3112
- ---
3113
-
3114
- ## 2. Summary Statistics
3115
-
3116
- The following metric is computed live from the model:
3117
-
3118
- \`\`\`memo-query
3119
- kind: Hazard
3120
- display: count
3121
- label: Total hazards identified
3122
- \`\`\`
3123
-
3124
- \`\`\`memo-query
3125
- kind: RiskControlMeasure
3126
- display: count
3127
- label: Risk controls implemented
3128
- \`\`\`
3129
-
3130
- \`\`\`memo-query
3131
- kind: HazardousSituation
3132
- display: count
3133
- label: Hazardous situations analyzed
3134
- \`\`\`
3135
-
3136
- ---
3137
-
3138
- ## 3. Risk Management Plan Compliance
3139
-
3140
- <!-- [GUIDANCE] Confirm that the risk management plan was executed as documented. -->
3141
-
3142
- _[TODO: Confirm that all activities in the Risk Management Plan were completed]_
3143
-
3144
- | Activity | Status | Reference |
3145
- | --- | --- | --- |
3146
- | Hazard identification | | HAR |
3147
- | Risk estimation | | HAR |
3148
- | Risk evaluation | | HAR |
3149
- | Risk control implementation | | Design records |
3150
- | Residual risk evaluation | | HAR |
3151
- | Overall residual risk | | This document |
3152
- | Post-production monitoring | | Post-Market Surveillance Plan |
3153
-
3154
- ---
3155
-
3156
- ## 4. Overall Residual Risk Evaluation
3157
-
3158
- ### 4.1 Remaining Hazards
3159
-
3160
- \`\`\`memo-query
3161
- kind: Hazard
3162
- display: table
3163
- columns: name, layer, doc
3164
- sort: name
3165
- empty: "All identified hazards have been evaluated."
3166
- \`\`\`
3167
-
3168
- ### 4.2 Overall Residual Risk Conclusion
3169
-
3170
- <!-- [GUIDANCE] Conclude whether the overall residual risk is acceptable relative to the medical benefits of the device. -->
3171
-
3172
- _[TODO: State the overall residual risk conclusion with justification]_
3173
-
3174
- ---
3175
-
3176
- ## 5. Benefit-Risk Statement
3177
-
3178
- Complete this section for **{{project.product}}** using the guidance below.
3179
-
3180
- _[TODO: State clearly that the benefits of the device outweigh the residual risks for the intended use]_
3181
-
3182
- ---
3183
-
3184
- ## 6. Post-Production Information Collection
3185
-
3186
- Post-production information collection activities are documented in the Post-Market Surveillance Plan.
3187
-
3188
- ---
3189
-
3190
- {{include:shared/snippets/revision-history-table.md}}
3191
-
3192
- {{include:shared/snippets/approval-block.md}}
3193
-
3194
- {{include:shared/snippets/references-section.md}}
3195
- `,wa=`---
3196
- id: approval-block
3197
- title: Approval Block
3198
- ---
3199
-
3200
- ## Approvals
3201
-
3202
- This document has been reviewed and approved by the following personnel:
3203
-
3204
- | Name | Role | Signature | Date |
3205
- | --- | --- | --- | --- |
3206
- | | Quality Assurance | | |
3207
- | | Regulatory Affairs | | |
3208
- | | Engineering Lead | | |
3209
- | | Clinical Affairs | | |
3210
-
3211
- `,Sa=`---
3212
- id: document-control-header
3213
- title: Document Control Header
3214
- ---
3215
-
3216
- | Field | Value |
3217
- | --- | --- |
3218
- | **Product** | {{project.product}} |
3219
- | **Company** | {{project.company}} |
3220
- | **Device Type** | {{project.device_type}} |
3221
- | **Document Version** | {{project.version}} |
3222
- | **Development Phase** | {{project.phase}} |
3223
- | **Date** | — |
3224
- | **Confidentiality** | Confidential — {{project.company}} |
3225
-
3226
- `,ka=`---
3227
- id: references-section
3228
- title: References
3229
- ---
3230
-
3231
- ## References
3232
-
3233
- | Standard | Title |
3234
- | --- | --- |
3235
- | ISO 14971:2019 | Medical devices — Application of risk management to medical devices |
3236
- | IEC 62304:2006+AMD1:2015 | Medical device software — Software life cycle processes |
3237
- | IEC 62366-1:2015+AMD1:2020 | Medical devices — Usability engineering |
3238
- | ISO 13485:2016 | Medical devices — Quality management systems |
3239
- | 21 CFR Part 820 | Quality System Regulation |
3240
- | IEC 81001-5-1:2021 | Health software and health IT systems safety, effectiveness and security |
3241
-
3242
- `,Ea=`---
3243
- id: revision-history-table
3244
- title: Revision History Table
3245
- ---
3246
-
3247
- ## Revision History
3248
-
3249
- | Version | Date | Author | Description of Change |
3250
- | --- | --- | --- | --- |
3251
- | 1.0 | {{project.version}} | {{project.authors}} | Initial release |
3252
-
3253
- `,Ca=Object.assign({"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/change-record.md":Mi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/design-input.md":Oi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/design-output.md":Pi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/design-review.md":zi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/design-validation.md":Li,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/design-verification.md":Bi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/dhf-index.md":qi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/transfer-plan.md":Vi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/user-needs.md":Wi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/vv-plan.md":$i,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/21cfr820/vv-report.md":Ui,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/fda-cybersecurity/incident-response.md":Hi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/fda-cybersecurity/postmarket-surveillance.md":Ki,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/fda-cybersecurity/security-arch.md":Gi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/fda-cybersecurity/threat-model.md":Yi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/fda-cybersecurity/vuln-assessment.md":Ji,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/change-control.md":Xi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/detailed-design.md":Qi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/integration-test.md":Zi,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/sad.md":ea,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/sbom.md":ta,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/sdp.md":na,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/soup.md":ra,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/srs.md":oa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/sw-traceability.md":sa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62304/system-test.md":ia,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/formative-eval.md":aa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/summative-eval.md":la,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/task-analysis.md":da,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/ue-plan.md":ca,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/ui-spec.md":ua,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/urra.md":pa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iec-62366/use-spec.md":ma,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/fmea.md":fa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/fta.md":ha,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/har.md":ga,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/risk-benefit.md":ya,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/risk-matrix.md":xa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/rmp.md":ba,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/iso-14971/rmr.md":va,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/shared/snippets/approval-block.md":wa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/shared/snippets/document-control-header.md":Sa,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/shared/snippets/references-section.md":ka,"../../../../node_modules/@memoarchitect/ontology/src/compliance/dhf-templates/shared/snippets/revision-history-table.md":Ea}),rn={};for(const[e,r]of Object.entries(Ca)){const n=e.match(/dhf-templates\/(.+)\.md$/);n&&(rn[n[1]]=r)}function ja(e){return e.replace(/^---[\s\S]*?---\n?/,"")}function wr(e){return e.replace(/\{\{include:([^}]+)\}\}/g,(r,n)=>{const o=n.replace(/\.md$/,""),s=rn[o];return s?wr(ja(s)):`<!-- [include: ${n} — not found] -->`})}function Da(e){const r=rn[e];return r?wr(r):null}const Ne=[{id:"risk",label:"Risk Management",color:"#dc2626",templates:[{id:"iso-14971/rmp",title:"Risk Management Plan",prefix:"RMP"},{id:"iso-14971/har",title:"Hazard Analysis Report",prefix:"HAR"},{id:"iso-14971/fmea",title:"FMEA",prefix:"FMEA"},{id:"iso-14971/fta",title:"Fault Tree Analysis",prefix:"FTA"},{id:"iso-14971/risk-benefit",title:"Risk-Benefit Analysis",prefix:"RBA"},{id:"iso-14971/rmr",title:"Risk Management Report",prefix:"RMR"}]},{id:"software",label:"Software",color:"#2563eb",templates:[{id:"iec-62304/sdp",title:"Software Development Plan",prefix:"SDP"},{id:"iec-62304/srs",title:"Software Requirements Spec",prefix:"SRS"},{id:"iec-62304/sad",title:"Software Architecture Description",prefix:"SAD"},{id:"iec-62304/detailed-design",title:"Software Detailed Design",prefix:"DDS"},{id:"iec-62304/integration-test",title:"Integration Test Plan",prefix:"ITP"},{id:"iec-62304/system-test",title:"System Test Plan",prefix:"STP"},{id:"iec-62304/soup",title:"SOUP List",prefix:"SOUP"},{id:"iec-62304/sbom",title:"Software Bill of Materials",prefix:"SBOM"},{id:"iec-62304/sw-traceability",title:"SW Traceability Matrix",prefix:"STM"},{id:"iec-62304/change-control",title:"Change Control Log",prefix:"CCL"}]},{id:"usability",label:"Usability",color:"#7c3aed",templates:[{id:"iec-62366/ue-plan",title:"Usability Engineering Plan",prefix:"UEP"},{id:"iec-62366/use-spec",title:"Intended Use Specification",prefix:"USE"},{id:"iec-62366/ui-spec",title:"User Interface Specification",prefix:"UIS"},{id:"iec-62366/task-analysis",title:"Task Analysis",prefix:"TA"},{id:"iec-62366/urra",title:"Use-Related Risk Analysis",prefix:"URRA"},{id:"iec-62366/formative-eval",title:"Formative Evaluation",prefix:"FE"},{id:"iec-62366/summative-eval",title:"Summative Evaluation",prefix:"SE"}]},{id:"requirements",label:"Requirements",color:"#0891b2",templates:[{id:"21cfr820/user-needs",title:"User Needs",prefix:"UN"},{id:"21cfr820/design-input",title:"Design Input Specification",prefix:"DIS"},{id:"21cfr820/design-output",title:"Design Output Specification",prefix:"DOS"}]},{id:"vv",label:"Verification & Validation",color:"#0d9488",templates:[{id:"21cfr820/vv-plan",title:"V&V Plan",prefix:"VVP"},{id:"21cfr820/vv-report",title:"V&V Report",prefix:"VVR"},{id:"21cfr820/design-verification",title:"Design Verification Report",prefix:"DVR"},{id:"21cfr820/design-validation",title:"Design Validation Report",prefix:"DVAR"},{id:"21cfr820/design-review",title:"Design Review Record",prefix:"DRR"}]},{id:"release",label:"Release & Change",color:"#4f46e5",templates:[{id:"21cfr820/transfer-plan",title:"Design Transfer Plan",prefix:"DTP"},{id:"21cfr820/change-record",title:"Design Change Record",prefix:"DCR"},{id:"21cfr820/dhf-index",title:"DHF Index",prefix:"DHF"}]},{id:"system",label:"System",color:"#059669",templates:[{id:"system/srs",title:"System Requirements Specification",prefix:"SRS"},{id:"system/sad",title:"System Architecture Description",prefix:"SyAD"},{id:"system/sds",title:"System Design Specification",prefix:"SDS"},{id:"system/icd",title:"Interface Control Document",prefix:"ICD"},{id:"system/svvp",title:"System V&V Plan",prefix:"SVVP"},{id:"system/svvr",title:"System V&V Report",prefix:"SVVR"}]},{id:"hardware",label:"Hardware",color:"#b45309",templates:[{id:"hardware/hdp",title:"Hardware Development Plan",prefix:"HDP"},{id:"hardware/hds",title:"Hardware Design Specification",prefix:"HDS"},{id:"hardware/hvp",title:"Hardware Verification Plan",prefix:"HVP"},{id:"hardware/hvr",title:"Hardware Verification Report",prefix:"HVR"},{id:"hardware/hbom",title:"Hardware Bill of Materials",prefix:"HBOM"},{id:"hardware/haz",title:"Hardware Hazard Analysis",prefix:"HHA"}]},{id:"cybersecurity",label:"Cybersecurity",color:"#d97706",templates:[{id:"fda-cybersecurity/threat-model",title:"Threat Model",prefix:"TM"},{id:"fda-cybersecurity/security-arch",title:"Security Architecture",prefix:"SA"},{id:"fda-cybersecurity/vuln-assessment",title:"Vulnerability Assessment",prefix:"VA"},{id:"fda-cybersecurity/postmarket-surveillance",title:"Post-Market Surveillance",prefix:"PMS"},{id:"fda-cybersecurity/incident-response",title:"Incident Response Plan",prefix:"IRP"}]}],Vt="#6B7280";function Aa(e){var r;return((r=Ne.find(n=>n.label===e))==null?void 0:r.color)??Vt}function lt(e){const r=e.split(/[^a-zA-Z0-9]+/).filter(Boolean);return r.length>=2?r.slice(0,4).map(n=>n[0].toUpperCase()).join(""):r.length===1?r[0].slice(0,3).toUpperCase():"DOC"}const Ra={position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.4)"},Fa={background:"#fff",borderRadius:"12px",padding:"20px",width:"460px",maxHeight:"560px",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0,0,0,0.2)"},Fn=["Category","Template","Confirm"];function Rt(e,r=1e4){const{registerLlmRequest:n}=E.getState(),o=`dhf-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise((s,i)=>{n(o,s,i),e(o),setTimeout(()=>i(new Error("Request timed out.")),r)})}function Ta({initialGroupId:e,existingDocs:r,numberingPrefix:n,onCreate:o,onClose:s}){const i=E(k=>k.connected),a=Ne.find(k=>k.id===e)??null,[l,c]=p.useState(a?1:0),[d,u]=p.useState(a),[m,y]=p.useState(""),[S,x]=p.useState({builtIn:new Set,repo:new Set,blank:!1}),[f,w]=p.useState("Untitled Document"),[h,C]=p.useState(null),[A,b]=p.useState(null),[R,T]=p.useState(!1),[O,D]=p.useState(""),[P,F]=p.useState(""),[N,L]=p.useState({}),[Z,ee]=p.useState(!1),[Q,_]=p.useState(null),K=d===null&&l>0?m.trim()||"Other":(d==null?void 0:d.label)??"",B=(d==null?void 0:d.color)??Vt;p.useEffect(()=>{l!==1||h!==null||!i||Rt(k=>qs(k)).then(C).catch(k=>b((k==null?void 0:k.message)??"Could not list repository files."))},[l,h,i]);const U=p.useMemo(()=>{const k=[];for(const I of(d==null?void 0:d.templates)??[])S.builtIn.has(I.id)&&k.push({key:I.id,defaultTitle:I.title,prefix:I.prefix,templateId:I.id});for(const I of S.repo){const q=h==null?void 0:h.find(J=>J.path===I),$=(q==null?void 0:q.title)??I.split("/").pop().replace(/\.md$/,"");k.push({key:`repo:${I}`,defaultTitle:$,prefix:lt($),templateId:`repo:${I}`})}if(S.blank&&k.push({key:"blank",defaultTitle:f.trim()||"Untitled Document",prefix:lt(f),templateId:"blank"}),R&&O.trim()){const I=O.trim();k.push({key:"new-template",defaultTitle:I,prefix:lt(I),templateId:"new-template"})}return k},[S,d,h,f,R,O]),re=k=>N[k.key]??k.defaultTitle,fe=k=>k.templateId==="blank"||k.templateId==="new-template"||k.templateId.startsWith("repo:")?lt(re(k)):k.prefix,be=p.useMemo(()=>{const k=new Map;return U.map(I=>{const q=`${n}-${fe(I)}-`,$=r.filter(z=>z.id.startsWith(q)).length,J=k.get(q)??0;return k.set(q,J+1),`${q}${String($+J+1).padStart(3,"0")}`})},[U,N,r,n]);async function Y(){ee(!0),_(null);try{const k=[];for(const I of U){let q=null;if(I.templateId.startsWith("repo:"))q=await Rt($=>Vs($,I.templateId.slice(5)));else if(I.templateId==="new-template"){const $=P.trim()||`# ${re(I)}
3254
-
3255
- _[TODO: Add template content]_
3256
- `,J=await Rt(z=>Ws(z,re(I),$));k.push({title:re(I),prefix:fe(I),templateId:`repo:${J.path}`,groupLabel:K,content:$});continue}else I.templateId==="blank"&&(q=`# ${re(I)}
3257
-
3258
- _[TODO: Add content]_
3259
- `);k.push({title:re(I),prefix:fe(I),templateId:I.templateId,groupLabel:K,content:q})}o(k)}catch(k){_((k==null?void 0:k.message)??"Could not read template."),ee(!1)}}const v=l===0?!0:l===1?U.length>0:U.length>0&&!Z;return t.jsx("div",{style:Ra,onClick:k=>{k.target===k.currentTarget&&s()},children:t.jsxs("div",{style:Fa,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B",flex:1},children:"New Document"}),t.jsx("button",{onClick:s,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",fontSize:"18px",lineHeight:1},children:"×"})]}),t.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"14px"},children:Fn.map((k,I)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px",fontSize:"11px",fontWeight:I===l?700:500,color:I===l?"#1B3A4B":I<l?"#059669":"#9CA3AF"},children:[t.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"9px",fontWeight:700,color:"#fff",background:I===l?"#1B3A4B":I<l?"#059669":"#D1D5DB"},children:I<l?"✓":I+1}),k,I<Fn.length-1&&t.jsx("span",{style:{color:"#D1D5DB"},children:"—"})]},k))}),l===0&&t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",gap:"4px"},children:[Ne.map(k=>t.jsx(Tn,{label:k.label,color:k.color,detail:`${k.templates.length} meMO templates`,selected:(d==null?void 0:d.id)===k.id,onClick:()=>{u(k),x({builtIn:new Set,repo:new Set,blank:!1})}},k.id)),t.jsx(Tn,{label:"Other",color:Vt,detail:"Custom category — blank or repository template",selected:d===null&&m!=="",onClick:()=>{u(null),y(m||"Other"),x({builtIn:new Set,repo:new Set,blank:!1})}}),d===null&&m!==""&&t.jsx("input",{value:m,onChange:k=>y(k.target.value),placeholder:"Category name, e.g. Clinical",autoFocus:!0,style:{margin:"2px 0 0 26px",padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",outline:"none"}})]}),l===1&&t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",gap:"10px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"#6B7280"},children:[t.jsx("span",{style:{width:"9px",height:"9px",borderRadius:"50%",background:B,display:"inline-block"}}),t.jsx("strong",{style:{color:"#1B3A4B"},children:K}),t.jsx("span",{children:"— pick one or more sources"})]}),d&&d.templates.length>0&&t.jsx(Ft,{title:"meMO templates",hint:"Prefilled sections and model queries",children:d.templates.map(k=>t.jsx(dt,{label:k.title,sub:k.id,color:B,checked:S.builtIn.has(k.id),onToggle:()=>x(I=>{const q=new Set(I.builtIn);return q.has(k.id)?q.delete(k.id):q.add(k.id),{...I,builtIn:q}})},k.id))}),t.jsx(Ft,{title:"Blank document",hint:"Start from an empty page",children:t.jsx(dt,{label:S.blank?"":"Blank document",color:B,checked:S.blank,onToggle:()=>x(k=>({...k,blank:!k.blank})),children:S.blank&&t.jsx("input",{value:f,onChange:k=>w(k.target.value),onClick:k=>k.stopPropagation(),style:{flex:1,padding:"4px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",outline:"none"}})})}),t.jsxs(Ft,{title:"Project templates",hint:"Reusable templates in dhf/templates/",children:[!i&&t.jsx(We,{text:"Dev server not connected — project templates unavailable."}),i&&A&&t.jsx(We,{text:A,error:!0}),i&&!A&&h===null&&t.jsx(We,{text:"Loading project templates…"}),i&&(h==null?void 0:h.length)===0&&t.jsx(We,{text:"No project templates yet."}),i&&(h==null?void 0:h.map(k=>t.jsx(dt,{label:k.title,sub:k.path,color:B,checked:S.repo.has(k.path),onToggle:()=>x(I=>{const q=new Set(I.repo);return q.has(k.path)?q.delete(k.path):q.add(k.path),{...I,repo:q}})},k.path))),t.jsx(dt,{label:"Add new template",sub:"Save and reuse in this project",color:B,checked:R,disabled:!i,disabledNote:i?void 0:"server unavailable",onToggle:()=>T(k=>!k)}),R&&t.jsxs("div",{style:{marginLeft:"22px",display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsx("input",{value:O,onChange:k=>D(k.target.value),placeholder:"Template title",style:{padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",outline:"none"}}),t.jsx("textarea",{value:P,onChange:k=>F(k.target.value),placeholder:"Template Markdown (headings, instructions, and model queries)",rows:4,style:{padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"11px",fontFamily:"monospace",color:"#1B3A4B",outline:"none",resize:"vertical"}})]})]})]}),l===2&&t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{fontSize:"12px",color:"#6B7280",marginBottom:"4px"},children:[U.length," document",U.length===1?"":"s"," will be created in",t.jsxs("strong",{style:{color:"#1B3A4B"},children:[" ",K]})," and saved to ",t.jsx("code",{style:{background:"#F3F4F6",padding:"0 4px",borderRadius:"3px",fontSize:"11px"},children:"dhf/documents/"}),":"]}),U.map((k,I)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"7px 10px",border:"1px solid #E5E7EB",borderRadius:"6px"},children:[t.jsx("span",{style:{fontSize:"11px",fontFamily:"monospace",fontWeight:700,color:B,whiteSpace:"nowrap"},children:be[I]}),t.jsx("input",{value:re(k),onChange:q=>L($=>({...$,[k.key]:q.target.value})),style:{flex:1,padding:"4px 8px",border:"1px solid #E5E7EB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",outline:"none"}}),t.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",whiteSpace:"nowrap"},children:k.templateId==="blank"?"blank":k.templateId==="new-template"?"new template":k.templateId.startsWith("repo:")?"project":"meMO"})]},k.key)),Q&&t.jsx(We,{text:Q,error:!0})]}),t.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"16px"},children:[l>0&&t.jsx("button",{onClick:()=>c(k=>k-1),disabled:Z,style:{padding:"7px 14px",borderRadius:"6px",border:"1px solid #E5E7EB",background:"#fff",fontSize:"13px",cursor:"pointer",color:"#374151",marginRight:"auto"},children:"← Back"}),t.jsx("button",{onClick:s,style:{padding:"7px 14px",borderRadius:"6px",border:"1px solid #E5E7EB",background:"#fff",fontSize:"13px",cursor:"pointer",color:"#374151"},children:"Cancel"}),l<2?t.jsx("button",{onClick:()=>c(k=>k+1),disabled:!v,style:{padding:"7px 16px",borderRadius:"6px",border:"none",background:v?"#1B3A4B":"#E5E7EB",color:v?"#fff":"#9CA3AF",fontSize:"13px",fontWeight:600,cursor:v?"pointer":"default"},children:"Next →"}):t.jsx("button",{onClick:Y,disabled:!v,style:{padding:"7px 16px",borderRadius:"6px",border:"none",background:v?B:"#E5E7EB",color:v?"#fff":"#9CA3AF",fontSize:"13px",fontWeight:600,cursor:v?"pointer":"default"},children:Z?"Creating…":`Create ${U.length>0?`(${U.length})`:""}`})]})]})})}function Tn({label:e,color:r,detail:n,selected:o,onClick:s}){return t.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"10px",padding:"9px 10px",borderRadius:"6px",border:`1px solid ${o?r:"#E5E7EB"}`,background:o?`${r}10`:"#fff",cursor:"pointer",textAlign:"left"},children:[t.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"50%",background:r,flexShrink:0}}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:e}),t.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function Ft({title:e,hint:r,children:n}){return t.jsxs("div",{children:[t.jsxs("div",{style:{fontSize:"10px",fontWeight:700,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"2px"},children:[e," ",t.jsxs("span",{style:{fontWeight:400,textTransform:"none",letterSpacing:0,color:"#9CA3AF"},children:["— ",r]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:n})]})}function dt({label:e,sub:r,color:n,checked:o,disabled:s,disabledNote:i,onToggle:a,children:l}){return t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"6px 8px",borderRadius:"6px",cursor:s?"not-allowed":"pointer",background:o?`${n}10`:"transparent",opacity:s?.45:1},children:[t.jsx("input",{type:"checkbox",checked:o,disabled:s,onChange:()=>!s&&a(),style:{accentColor:n}}),e&&t.jsx("span",{style:{fontSize:"13px",color:"#1B3A4B"},children:e}),l,r&&t.jsx("span",{style:{marginLeft:"auto",fontSize:"10px",fontFamily:"monospace",color:"#9CA3AF",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"180px"},children:r}),s&&i&&t.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:i})]})}function We({text:e,error:r}){return t.jsx("div",{style:{fontSize:"11px",color:r?"#DC2626":"#9CA3AF",fontStyle:"italic",padding:"4px 8px"},children:e})}const Ia=p.lazy(()=>te(()=>import("./ScenarioEditor-JQ3huCnz.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.ScenarioEditor})));function Ae({expanded:e,size:r=14,color:n=g.muted}){return t.jsx("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:e?"rotate(90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M6 4L10 8L6 12",stroke:n,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Me({open:e,color:r=g.muted}){return e?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[t.jsx("path",{d:"M1.5 3.5h4.8l1.2 1.5H14.5v8H1.5z",fill:r,opacity:"0.15",stroke:r,strokeWidth:"1",strokeLinejoin:"round"}),t.jsx("path",{d:"M1.5 5h13v8H1.5z",fill:r,opacity:"0.08"})]}):t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:t.jsx("path",{d:"M1.5 3.5h4.8l1.2 1.5H14.5v8H1.5z",fill:r,opacity:"0.15",stroke:r,strokeWidth:"1",strokeLinejoin:"round"})})}function Wt({color:e=g.muted}){return t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[t.jsx("rect",{x:"2",y:"1.5",width:"12",height:"13",rx:"1.5",fill:e,opacity:"0.1",stroke:e,strokeWidth:"1"}),t.jsx("line",{x1:"5",y1:"5.5",x2:"11",y2:"5.5",stroke:e,strokeWidth:"0.8",opacity:"0.5"}),t.jsx("line",{x1:"5",y1:"8",x2:"11",y2:"8",stroke:e,strokeWidth:"0.8",opacity:"0.5"}),t.jsx("line",{x1:"5",y1:"10.5",x2:"9",y2:"10.5",stroke:e,strokeWidth:"0.8",opacity:"0.5"})]})}function _a({elementId:e,currentKind:r,onClose:n}){const o=E(d=>d.updateElementKind),s=E(d=>d.model),[i,a]=p.useState(r),l=p.useRef(null),c=p.useMemo(()=>{var d;return(((d=s==null?void 0:s.registries)==null?void 0:d.kinds)??[]).filter(u=>!u.isAbstract).map(u=>u.name).sort((u,m)=>u.localeCompare(m))},[s]);return p.useEffect(()=>{const d=u=>{l.current&&!l.current.contains(u.target)&&n()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]),t.jsxs("div",{ref:l,className:"fixed z-50 rounded-lg overflow-hidden py-3 px-4",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0 8px 32px rgba(0,0,0,0.16)",minWidth:"320px"},children:[t.jsx("div",{className:"font-semibold mb-3",style:{color:"#1B3A4B",fontSize:"13px"},children:"Change Element Type"}),t.jsxs("div",{className:"text-xs mb-1",style:{color:"#6B7280"},children:["Current: ",t.jsx("span",{style:{color:"#DC2626",fontWeight:600},children:r})," (not in ontology)"]}),t.jsx("select",{value:i,onChange:d=>a(d.target.value),className:"w-full px-3 py-2 rounded-lg mb-3 focus:outline-none",style:{background:"#F9F9F8",border:"1px solid #E5E7EB",color:"#1B3A4B",fontSize:"13px"},children:c.map(d=>t.jsx("option",{value:d,children:d},d))}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:n,className:"px-3 py-1.5 rounded",style:{fontSize:"12px",color:"#6B7280",background:"#F0F0ED"},children:"Cancel"}),t.jsx("button",{onClick:()=>{o(e,i),n()},className:"px-3 py-1.5 rounded font-medium",style:{fontSize:"12px",color:"#FFFFFF",background:"#2DD4A8"},children:"Apply"})]})]})}function Na({menu:e,onClose:r}){var S;const n=E(x=>x.model),o=E(x=>x.selectElement),s=E(x=>x.addElement),i=E(x=>x.updateElementFolder),a=E(x=>x.moveFolder),l=E(x=>x.deleteFolder),[c,d]=p.useState(null),u=p.useRef(null);if(p.useEffect(()=>{const x=f=>{u.current&&!u.current.contains(f.target)&&r()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[r]),!n)return null;let m="",y=[];if(e.type==="element"&&e.elementId){const x=n.elements[e.elementId];if(!x)return null;m=x.name;const f=!(((S=n.registries)==null?void 0:S.kinds)??[]).some(w=>w.name===x.kind);y=[{label:"View details",action:()=>o(x.id)},{label:"Move to folder...",action:()=>{const w=window.prompt("Enter new folder path (e.g., Manufacturers/Hardware):",x.attributes[De]||"");w!==null&&i(x.id,w)}},{label:"Copy ID",action:()=>{var w;return(w=navigator.clipboard)==null?void 0:w.writeText(x.id)}},...f?[{label:"⚠ Change Type…",action:()=>d({elementId:x.id,currentKind:x.kind})}]:[]]}else e.type==="folder"&&e.folderId&&e.kind?(m=`Folder: ${e.folderId.split("/").pop()}`,y=[{label:"Add Element here",action:()=>{const x=window.prompt("Enter element name:");x&&s(e.kind,x,e.folderId)}},{label:"Add Sub-group",action:()=>{const x=window.prompt("Enter group name:");if(x){const f=e.folderId?`${e.folderId}/${x}`:x;s(e.kind,`(new ${x} element)`,f)}}},{label:"Move Folder...",action:()=>{const x=window.prompt("Enter new folder path:",e.folderId);x&&x!==e.folderId&&a(e.kind,e.folderId,x)}},{label:"Delete Folder (Move items up)",danger:!0,action:()=>{window.confirm(`Move all elements in "${e.folderId}" to its parent group?`)&&l(e.kind,e.folderId)}}]):e.type==="kind"&&e.kind&&(m=`Category: ${e.kind}`,y=[{label:"Add Element",action:()=>{const x=window.prompt("Enter element name:");x&&s(e.kind,x,"")}},{label:"New Group",action:()=>{const x=window.prompt("Enter group name:");x&&s(e.kind,`(new ${x} element)`,x)}}]);return y.length?t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:u,className:"fixed z-50 rounded-lg overflow-hidden py-1",style:{left:e.x,top:e.y,background:g.surface,border:`1px solid ${g.border}`,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",minWidth:"220px"},children:[t.jsx("div",{className:"px-3 py-1.5 font-bold truncate bg-slate-50",style:{color:g.primary,fontSize:j.xs,borderBottom:`1px solid ${g.border}`},children:m.toUpperCase()}),y.map((x,f)=>t.jsx("div",{className:"px-3 py-2 cursor-pointer transition-colors",style:{color:x.danger?"#DC2626":g.secondary,fontSize:j.explorer.item},onMouseEnter:w=>w.currentTarget.style.background="#F0F0ED",onMouseLeave:w=>w.currentTarget.style.background="transparent",onClick:()=>{x.action(),c||r()},children:x.label},f))]}),c&&t.jsx(_a,{elementId:c.elementId,currentKind:c.currentKind,onClose:()=>{d(null),r()}})]}):null}function Ma(e){const r=[],n=[...e].sort((s,i)=>s.name.localeCompare(i.name));for(const s of n){const a=(s.attributes[De]||"").split("/").filter(Boolean);let l=r,c="";for(const d of a){c=c?`${c}/${d}`:d;const u=`f:${c}`;let m=l.find(y=>y.id===u);m||(m={id:u,name:d,type:"folder",children:[]},l.push(m)),l=m.children}l.push({id:s.id,name:s.name,type:"element",children:[],element:s})}const o=s=>{s.sort((i,a)=>i.type!==a.type?i.type==="folder"?-1:1:i.name.localeCompare(a.name));for(const i of s)i.children.length>0&&o(i.children)};return o(r),r}function Sr({nodes:e,level:r,expanded:n,toggleExpand:o,selectedElementId:s,selectElement:i,selectedElementIds:a,toggleElementSelection:l,violationCounts:c,baseColor:d,onContextMenu:u,onDragStart:m,onDrop:y,isUndefined:S}){return t.jsx(t.Fragment,{children:e.map(x=>{if(x.type==="folder"){const f=n.has(x.id);return t.jsxs("div",{style:{marginLeft:r>0?"16px":"0"},draggable:!0,onDragStart:w=>m(w,x),onDragOver:w=>w.preventDefault(),onDrop:w=>y(w,x.id.replace("f:","")),children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:w=>w.currentTarget.style.background="#F0F0ED",onMouseLeave:w=>w.currentTarget.style.background="transparent",onClick:()=>o(x.id),onContextMenu:w=>u(w,"folder",x.id),children:[t.jsx(Ae,{expanded:f,size:12,color:g.muted}),t.jsx(Me,{open:f,color:d}),t.jsx("span",{className:"font-medium flex-1 truncate",style:{color:g.secondary,fontSize:j.explorer.kind},children:x.name})]}),f&&t.jsx(Sr,{nodes:x.children,level:r+1,expanded:n,toggleExpand:o,selectedElementId:s,selectElement:i,selectedElementIds:a,toggleElementSelection:l,violationCounts:c,baseColor:d,onContextMenu:u,onDragStart:m,onDrop:y,isUndefined:S})]},x.id)}else{const f=x.element,w=s===f.id,h=a.has(f.id),C=c.get(f.id)||0,A=ne[f.layer]||d;return t.jsxs("div",{className:"group flex items-center gap-1.5 px-2 py-1 cursor-pointer",style:{borderRadius:"4px",margin:"0 4px",marginLeft:(r>0?16:0)+20+"px",background:h?"#FFF3CD":w?g.accent+"18":"transparent",fontWeight:w||h?500:400},draggable:!0,onDragStart:b=>m(b,{type:"element",element:f,id:f.id,name:f.name,children:[]}),onMouseEnter:b=>{!w&&!h&&(b.currentTarget.style.background="#F0F0ED")},onMouseLeave:b=>{b.currentTarget.style.background=h?"#FFF3CD":w?g.accent+"18":"transparent"},onClick:b=>{b.metaKey||b.ctrlKey||b.shiftKey?(b.preventDefault(),l(f.id)):i(f.id)},onContextMenu:b=>u(b,"element",f.id),children:[t.jsx("input",{type:"checkbox",checked:h,onChange:b=>{b.stopPropagation(),l(f.id)},onClick:b=>b.stopPropagation(),className:"flex-shrink-0",style:{width:"12px",height:"12px",cursor:"pointer",opacity:h?1:0,transition:"opacity 120ms",accentColor:"#2DD4A8"},onMouseEnter:b=>{b.currentTarget.style.opacity="1"},onMouseLeave:b=>{b.currentTarget.style.opacity=h?"1":"0"}}),t.jsx(Wt,{color:S?"#F59E0B":A}),t.jsx(Ni,{element:f,selected:w}),S&&t.jsx("span",{title:`Kind "${f.kind}" is not defined in the ontology`,style:{color:"#F59E0B",fontSize:"12px",flexShrink:0},children:"⚠"}),C>0&&t.jsx("span",{className:"px-1 py-0.5 rounded-full",style:{background:"#FEF2F2",color:"#DC2626",fontSize:j.explorer.count,fontWeight:600,minWidth:"16px",textAlign:"center"},children:C})]},f.id)}})})}function Oa(e,r,n){return e.endsWith("View")||r==="viewpoints"||r==="views"||n==="viewpoints"||n==="views"}function In(e,r,n){return Oa(e,r,n)||e==="ForkNode"||e==="JoinNode"||e==="ActionDefinition"||e==="ActionUsage"||e==="ItemDefinition"}function Pa(e,r){var s;const n=new Map,o=new Map;for(const i of r)for(const a of i.layers)o.has(a.id)||o.set(a.id,a);for(const i of e){const a=((s=i.namespace)==null?void 0:s[0])??i.layer;if(!a||a==="unknown")continue;let l=n.get(a);if(!l){const c=o.get(a);l={id:a,label:(c==null?void 0:c.label)??kr(a),color:(c==null?void 0:c.color)??ne[a]??"#6B7280",kinds:[]},n.set(a,l)}l.kinds.includes(i.name)||l.kinds.push(i.name)}return[...n.values()]}function za(e){var n;const r={};for(const o of e)r[o.name]=((n=o.namespace)==null?void 0:n[0])??o.layer;return r}function La(e){var n;const r={};for(const o of e)r[o.name]=(n=o.namespace)==null?void 0:n[1];return r}function Ba(e){const r={},n=new Set;for(const o of e)o.isAbstract&&n.add(o.name),r[o.name]=o.superType;for(const[o,s]of Object.entries(r))s&&n.has(s)&&(r[o]=void 0);return r}function kr(e){return e.split(/[_-]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function qa(e,r){const n={StateMachine:"State Machine",ModeState:"Mode State",BehaviorProperty:"Behavioral Constraint",AssumeProperty:"Assumption",GuaranteeProperty:"Guarantee"};if(n[e])return r===1?n[e]:n[e]+"s";const o=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2");return r===1||/(?:ss|Data|Status)$/i.test(o)||o.endsWith("s")?o:o+"s"}function Va(e,r,n,o){const s=r.toLowerCase(),i=new Set(["views","viewpoints","manifest"]),a=za(n),l=La(n),c=Ba(n),d=Pa(n,o).filter(x=>!i.has(x.id)),u=new Set(d.map(x=>x.id)),m=(x,f)=>{const w=new Map;for(const[h,C]of x.entries()){const A=l[h]??"",b=c[h]??h;w.has(A)||w.set(A,new Map);const R=w.get(A),T=R.get(b)??[];R.set(b,[...T,...Ma(C)])}return[...w.entries()].sort(([h],[C])=>h.localeCompare(C)).map(([h,C])=>({id:h,label:h?kr(h):"",color:h?ne[h]??f:f,kinds:C}))},y=[];for(const x of d){const f=new Map;for(const w of e){const h=a[w.kind]??w.layer,C=l[w.kind];if(In(w.kind,h,C))continue;const A=a[w.kind];A&&A===x.id&&(s&&!w.name.toLowerCase().includes(s)&&!w.kind.toLowerCase().includes(s)||(f.has(w.kind)||f.set(w.kind,[]),f.get(w.kind).push(w)))}f.size>0&&y.push({group:x,subGroups:m(f,x.color)})}const S=new Map;for(const x of e){const f=a[x.kind]??x.layer,w=l[x.kind];if(In(x.kind,f,w))continue;const h=a[x.kind];h&&u.has(h)||h&&i.has(h)||s&&!x.name.toLowerCase().includes(s)&&!x.kind.toLowerCase().includes(s)||(S.has(x.kind)||S.set(x.kind,[]),S.get(x.kind).push(x))}if(S.size>0){const x="#F59E0B";y.push({group:{id:"undefined",label:"Undefined — Not in Ontology",color:x,kinds:[]},subGroups:m(S,x)})}return y}function Wa({searchTerm:e}){const r=E(_=>_.model),n=E(_=>_.selectedElementId),o=E(_=>_.selectElement),s=E(_=>_.setActiveView),i=E(_=>_.selectedElementIds),a=E(_=>_.toggleElementSelection),l=E(_=>_.selectAllElements),c=E(_=>_.clearElementSelection),d=E(_=>_.updateElementFolder),u=E(_=>_.moveFolder),m=E(_=>_.validation),y=E(_=>_.availableOntologies),S=E(_=>_.setExplorerTab),x=E(_=>_.setActiveMode),f=E(_=>_.setSelectedOntologyKind),w=p.useCallback(_=>{o(_),s({type:"element-detail",elementId:_})},[o,s]),[h,C]=p.useState(new Set),[A,b]=p.useState(null),[R,T]=p.useState(null),O=p.useCallback((_,W)=>{W==null||W.stopPropagation(),C(K=>{const B=new Set(K);return B.has(_)?B.delete(_):B.add(_),B})},[]),D=p.useCallback((_,W,K,B)=>{_.preventDefault(),b({x:_.clientX,y:_.clientY,type:W,elementId:W==="element"?K:void 0,folderId:W==="folder"?K.replace("f:",""):void 0,kind:B||(W==="kind"?K.replace("k:","").split(":").pop():void 0)})},[]),P=p.useMemo(()=>{var _;return r?Va(Object.values(r.elements),e,((_=r.registries)==null?void 0:_.kinds)??[],y):[]},[r,e,y]),F=p.useCallback((_,W,K)=>{var B;T({id:W.id,kind:K}),_.dataTransfer.setData("application/memo-node",JSON.stringify({id:W.id,type:W.type,kind:K,name:W.name,elementId:(B=W.element)==null?void 0:B.id,folderPath:W.type==="folder"?W.id.replace("f:",""):void 0})),_.dataTransfer.effectAllowed="move"},[]),N=p.useCallback((_,W)=>{(R==null?void 0:R.kind)===W&&(_.preventDefault(),_.dataTransfer.dropEffect="move")},[R]),L=p.useCallback((_,W,K)=>{_.preventDefault(),T(null);try{const B=JSON.parse(_.dataTransfer.getData("application/memo-node"));if(B.kind!==K)return;if(B.type==="element")d(B.elementId,W);else if(B.type==="folder"){if(W===B.folderPath||W.startsWith(B.folderPath+"/"))return;const U=B.folderPath.includes("/")?B.folderPath.slice(B.folderPath.lastIndexOf("/")+1):B.folderPath,re=W?W+"/"+U:U;u(B.kind,B.folderPath,re)}}catch(B){console.error("Drop error:",B)}},[d,u]),Z=p.useMemo(()=>{const _=new Map;if(m)for(const W of m.violations)_.set(W.elementId,(_.get(W.elementId)||0)+1);return _},[m]),ee=p.useMemo(()=>{const _=[],W=K=>{for(const B of K)B.type==="element"&&B.element?_.push(B.element.id):W(B.children)};for(const{subGroups:K}of P)for(const B of K)for(const U of B.kinds.values())W(U);return _},[P]),Q=i.size;return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[Q>0&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 flex-shrink-0",style:{background:"#FFFBEB",borderBottom:"1px solid #FDE68A",fontSize:"12px"},children:[t.jsxs("span",{style:{color:"#92400E",fontWeight:600},children:[Q," selected"]}),t.jsx("span",{style:{color:"#B45309"},children:"— Cmd/Ctrl+click to multi-select"}),t.jsx("button",{onClick:c,className:"ml-auto px-2 py-0.5 rounded",style:{color:"#92400E",background:"#FDE68A",fontSize:"12px",fontWeight:500},children:"Clear"})]}),e&&ee.length>0&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",style:{background:"#F0F9FF",borderBottom:"1px solid #BAE6FD",fontSize:"12px"},children:[t.jsxs("span",{style:{color:"#0369A1"},children:[ee.length," matching"]}),t.jsx("button",{onClick:()=>l(ee),className:"ml-auto px-2 py-0.5 rounded",style:{color:"#0369A1",background:"#BAE6FD",fontSize:"12px",fontWeight:500},children:"Select All"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto py-1",style:{fontSize:j.explorer.item},children:[P.map(({group:_,subGroups:W})=>{const K=`g:${_.id}`,B=h.has(K),U=_.id==="undefined",re=Y=>Y.reduce((v,k)=>v+(k.type==="element"?1:re(k.children)),0),fe=Y=>Array.from(Y.kinds.values()).reduce((v,k)=>v+re(k),0),be=W.reduce((Y,v)=>Y+fe(v),0);return t.jsxs("div",{className:"mb-0.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer select-none",style:{margin:"0 4px",borderRadius:"4px",...U?{background:"#FFF3CD"}:{}},onMouseEnter:Y=>Y.currentTarget.style.background=U?"#FDE68A":"#F0F0ED",onMouseLeave:Y=>Y.currentTarget.style.background=U?"#FFF3CD":"transparent",onClick:()=>O(K),onContextMenu:Y=>D(Y,"group",K),children:[t.jsx(Ae,{expanded:B,size:14,color:_.color}),U?t.jsx("span",{style:{fontSize:"14px",lineHeight:1,flexShrink:0},children:"⚠"}):t.jsx(Me,{open:B,color:_.color}),t.jsx("span",{className:"font-semibold flex-1 truncate",style:{color:U?"#92400E":g.primary,fontSize:j.explorer.group},children:_.label}),t.jsx("span",{className:"px-1.5 py-0.5 rounded-full",style:{background:_.color+"25",color:_.color,fontSize:j.explorer.count,fontWeight:600,minWidth:"20px",textAlign:"center"},children:be})]}),(()=>{const Y=(v,k,I)=>{const q=`k:${_.id}:${I?I+":":""}${v}`,$=h.has(q),J=V=>{var H;for(const ue of V){if(ue.type==="element")return(H=ue.element)==null?void 0:H.layer;const ke=J(ue.children);if(ke)return ke}},z=J(k),se=U?"#F59E0B":z&&ne[z]||_.color,ve=V=>V.flatMap(H=>H.type==="element"&&H.element?[H.element.id]:ve(H.children)),ce=ve(k);return t.jsxs("div",{style:{marginLeft:"16px"},onDragOver:V=>N(V,v),onDrop:V=>L(V,"",v),children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:V=>V.currentTarget.style.background="#F0F0ED",onMouseLeave:V=>V.currentTarget.style.background="transparent",onClick:()=>O(q),onContextMenu:V=>D(V,"kind",q,v),children:[t.jsx(Ae,{expanded:$,size:12,color:g.muted}),t.jsx(Me,{open:$,color:se}),t.jsxs("span",{className:"font-medium flex-1 truncate",style:{color:U?"#B45309":g.secondary,fontSize:j.explorer.kind},children:[qa(v,ce.length),U&&t.jsx("span",{style:{color:"#F59E0B",marginLeft:"4px"},children:"·"})]}),t.jsx("button",{onClick:V=>{V.stopPropagation(),l(ce)},title:"Select all in this category",className:"px-1 rounded",style:{color:g.faint,fontSize:"10px",opacity:.6},onMouseEnter:V=>V.currentTarget.style.opacity="1",onMouseLeave:V=>V.currentTarget.style.opacity="0.6",children:"☑"}),!U&&t.jsx("button",{onClick:V=>{V.stopPropagation();for(const H of y)for(const ue of H.layers)if(ue.kinds.some(ke=>ke.name===v)){f(v),S("ontologies"),x("ontology"),s({type:"ontology-detail",packageName:H.name,layerId:ue.id});return}},title:"View kind in Ontology",className:"px-1 rounded",style:{color:g.faint,fontSize:"10px",opacity:.6},onMouseEnter:V=>V.currentTarget.style.opacity="1",onMouseLeave:V=>V.currentTarget.style.opacity="0.6",children:"⬡"})]}),$&&t.jsx(Sr,{nodes:k,level:0,expanded:h,toggleExpand:O,selectedElementId:n,selectElement:w,selectedElementIds:i,toggleElementSelection:a,violationCounts:Z,baseColor:se,onContextMenu:(V,H,ue)=>D(V,H,ue,v),onDragStart:(V,H)=>F(V,H,v),onDrop:(V,H)=>L(V,H,v),isUndefined:U})]},v)};return B?W.map(v=>{if(!v.id)return t.jsx("div",{children:Array.from(v.kinds.entries()).map(([$,J])=>Y($,J,""))},"__root");const k=`sg:${_.id}:${v.id}`,I=h.has(k),q=fe(v);return t.jsxs("div",{style:{marginLeft:"16px"},children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:$=>$.currentTarget.style.background="#F0F0ED",onMouseLeave:$=>$.currentTarget.style.background="transparent",onClick:()=>O(k),children:[t.jsx(Ae,{expanded:I,size:13,color:v.color}),t.jsx(Me,{open:I,color:v.color}),t.jsx("span",{className:"font-semibold flex-1 truncate",style:{color:g.primary,fontSize:j.explorer.kind},children:v.label}),t.jsx("span",{className:"px-1.5 py-0.5 rounded-full",style:{background:v.color+"25",color:v.color,fontSize:j.explorer.count,fontWeight:600,minWidth:"20px",textAlign:"center"},children:q})]}),I&&Array.from(v.kinds.entries()).map(([$,J])=>Y($,J,v.id))]},v.id)}):null})()]},_.id)}),A&&t.jsx(Na,{menu:A,onClose:()=>b(null)})]})]})}function $a({diagram:e}){const r=["afd","ofd","ffd"].includes(e.diagramType.toLowerCase())?Ei(e):e.diagramType,n=Re[r];return n?t.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:n.color+"20",color:n.color,fontSize:j.badge},title:n.fullName,children:n.code}):null}function Ua({viewpointId:e,onClose:r}){const n=E(d=>d.createDiagram),[o,s]=p.useState("Untitled"),[i,a]=p.useState("bdd"),l=p.useRef(null);p.useEffect(()=>{const d=u=>{l.current&&!l.current.contains(u.target)&&r()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[r]);const c=()=>{o.trim()&&(n({name:o.trim(),diagramType:i,viewpointId:e}),r())};return t.jsxs("div",{ref:l,className:"fixed z-50 rounded-lg overflow-hidden py-3 px-4",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0 8px 32px rgba(0,0,0,0.16)",minWidth:"300px"},children:[t.jsx("div",{className:"font-semibold mb-3",style:{color:g.primary,fontSize:"13px"},children:"New Model View"}),t.jsx("label",{className:"block mb-1",style:{fontSize:j.xs,color:g.secondary},children:"Name"}),t.jsx("input",{autoFocus:!0,value:o,onChange:d=>s(d.target.value),onKeyDown:d=>{d.key==="Enter"&&c(),d.key==="Escape"&&r()},className:"w-full px-3 py-2 rounded-lg mb-3 focus:outline-none",style:{background:"#F9F9F8",border:"1px solid #E5E7EB",color:g.primary,fontSize:"13px"}}),t.jsx("label",{className:"block mb-1",style:{fontSize:j.xs,color:g.secondary},children:"Type"}),t.jsx("select",{value:i,onChange:d=>a(d.target.value),className:"w-full px-3 py-2 rounded-lg mb-4 focus:outline-none",style:{background:"#F9F9F8",border:"1px solid #E5E7EB",color:g.primary,fontSize:"13px"},children:Object.entries(Re).map(([d,u])=>t.jsxs("option",{value:d,children:[u.fullName," (",u.code,")"]},d))}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:r,className:"px-3 py-1.5 rounded",style:{fontSize:"12px",color:g.secondary,background:"#F0F0ED"},children:"Cancel"}),t.jsx("button",{onClick:c,className:"px-3 py-1.5 rounded font-medium",style:{fontSize:"12px",color:"#FFFFFF",background:g.accent},children:"Create"})]})]})}const Ha=new Set(["__unassigned","__model"]),me="__uncategorized";function Er(e){const r=n=>{var i;const o=(i=n.declaredLayers)!=null&&i.length?n.declaredLayers:n.visibleLayers??[],s=Si.indexOf(o[0]);return s>=0?s:Number.MAX_SAFE_INTEGER};return e.slice().sort((n,o)=>r(n)-r(o)||n.label.localeCompare(o.label))}function Cr(e){if(e.length<2)return e;const r=e[0].split(" ");if(r.length<2)return e;const n=r[0];return e.every(s=>{const i=s.split(" ");return i.length>1&&i[0]===n})?e.map(s=>s.slice(n.length+1)):e}function Ka(e){const r=Er(((e==null?void 0:e.viewpoints)??[]).filter(o=>!Ha.has(o.id))),n=new Set;for(const o of r)for(const s of yr(e,o.id))n.add(s.id);return{viewpoints:r,uncategorized:((e==null?void 0:e.diagrams)??[]).filter(o=>!n.has(o.id))}}function Ga({searchTerm:e}){const r=E(b=>b.model),n=E(b=>b.activeView),o=E(b=>b.setActiveView),s=E(b=>b.selectViewpoint),i=E(b=>b.deleteDiagram),[a,l]=p.useState(new Set([me])),[c,d]=p.useState(null),u=b=>{l(R=>{const T=new Set(R);return T.has(b)?T.delete(b):T.add(b),T})},{viewpoints:m,uncategorized:y}=p.useMemo(()=>Ka(r),[r]),S=p.useMemo(()=>Cr(m.map(b=>b.label)),[m]),x=b=>{if(!e)return b;const R=e.toLowerCase();return b.filter(T=>T.name.toLowerCase().includes(R)||T.diagramType.toLowerCase().includes(R))},f=n.type==="diagram"?n.diagramId:null,w=x(y.filter(b=>!b.id.startsWith("diag-layer-"))),h=p.useMemo(()=>{const b=new Map;for(const R of w){const O=[...(R.elementIds??[]).map(D=>{var P;return(P=r==null?void 0:r.elements[D])==null?void 0:P.layer}).filter(D=>!!D)].sort((D,P)=>{const F=Ue.indexOf(D),N=Ue.indexOf(P);return(F<0?Number.MAX_SAFE_INTEGER:F)-(N<0?Number.MAX_SAFE_INTEGER:N)})[0]??"other";b.set(O,[...b.get(O)??[],R])}return[...b.entries()].sort(([R],[T])=>{const O=Ue.indexOf(R),D=Ue.indexOf(T);return(O<0?Number.MAX_SAFE_INTEGER:O)-(D<0?Number.MAX_SAFE_INTEGER:D)})},[w,r==null?void 0:r.elements]),C=(b,R)=>b.map(T=>t.jsx(Ya,{diag:T,isSelected:f===T.id,onSelect:()=>{o({type:"diagram",diagramId:T.id}),s(R==="__model"?null:R)},onDelete:T.auto?void 0:()=>i(T.id)},T.id)),A=(b,R)=>{const T=D=>D.group;if(!b.some(D=>T(D)))return C(b,R);const O=new Map;for(const D of b){const P=T(D)||"Other";O.set(P,[...O.get(P)??[],D])}return[...O.entries()].sort(([D],[P])=>D.localeCompare(P)).map(([D,P])=>t.jsxs("div",{style:{margin:"5px 4px 2px"},children:[t.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:g.muted,fontSize:j.xs},children:D}),t.jsx("div",{style:{marginLeft:"8px"},children:C(P,R)})]},D))};return t.jsxs("div",{className:"flex-1 overflow-y-auto py-1",style:{fontSize:j.explorer.item},children:[m.map((b,R)=>{var F;const T=a.has(b.id),O=(F=b.visibleLayers)!=null&&F[0]&&ne[b.visibleLayers[0]]||g.muted,D=yr(r,b.id),P=x(D.filter(N=>!N.id.startsWith("diag-layer-")));return t.jsxs("div",{className:"mb-0.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:N=>N.currentTarget.style.background="#F0F0ED",onMouseLeave:N=>N.currentTarget.style.background="transparent",onClick:()=>{s(b.id),u(b.id)},children:[t.jsx(Ae,{expanded:T,size:14,color:O}),t.jsx(Me,{open:T,color:O}),t.jsx("span",{className:"font-semibold flex-1 truncate",style:{color:g.primary,fontSize:j.explorer.group},children:S[R]}),t.jsx(Rn,{count:D.length,color:O,title:`${D.length} views`})]}),T&&t.jsxs("div",{style:{marginLeft:"16px"},children:[A(P,b.id),t.jsxs("button",{className:"flex items-center gap-1 px-2 py-1 w-full text-left",style:{borderRadius:"4px",margin:"2px 4px",color:g.accent,fontSize:j.xs,background:"transparent"},onMouseEnter:N=>N.currentTarget.style.background=g.accent+"12",onMouseLeave:N=>N.currentTarget.style.background="transparent",onClick:()=>d(b.id),children:[t.jsx("span",{style:{fontSize:"14px",lineHeight:1},children:"+"})," New View"]})]})]},b.id)}),w.length>0&&t.jsxs("div",{className:"mb-0.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:b=>b.currentTarget.style.background="#F0F0ED",onMouseLeave:b=>b.currentTarget.style.background="transparent",onClick:()=>{s(null),u(me)},children:[t.jsx(Ae,{expanded:a.has(me),size:14,color:g.muted}),t.jsx(Me,{open:a.has(me),color:g.muted}),t.jsx("span",{className:"font-semibold flex-1",style:{color:g.primary,fontSize:j.explorer.group},children:"Uncategorized"}),t.jsx("span",{title:"These views conform to no viewpoint. Bind one with viewpointDefinition to file them.",style:{color:g.faint,fontSize:j.badge},children:"no viewpoint"}),t.jsx(Rn,{count:w.length,color:g.muted,title:`${w.length} views`})]}),a.has(me)&&t.jsxs("div",{style:{marginLeft:"16px"},children:[w.some(b=>b.group)?A(w,me):h.map(([b,R])=>t.jsxs("div",{style:{margin:"5px 4px 2px"},children:[t.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:ne[b]??g.muted,fontSize:j.xs,borderLeft:`3px solid ${ne[b]??g.border}`},children:Xe[b]??`${b.charAt(0).toUpperCase()}${b.slice(1)}`}),t.jsx("div",{style:{marginLeft:"8px"},children:C(R,me)})]},b)),t.jsxs("button",{className:"flex items-center gap-1 px-2 py-1 w-full text-left",style:{borderRadius:"4px",margin:"2px 4px",color:g.accent,fontSize:j.xs,background:"transparent"},onMouseEnter:b=>b.currentTarget.style.background=g.accent+"12",onMouseLeave:b=>b.currentTarget.style.background="transparent",onClick:()=>d("__model"),children:[t.jsx("span",{style:{fontSize:"14px",lineHeight:1},children:"+"})," New View"]})]})]}),c!==null&&t.jsx(Ua,{viewpointId:c,onClose:()=>d(null)})]})}function Ya({diag:e,isSelected:r,onSelect:n,onDelete:o}){var c;const[s,i]=p.useState(!1),a=Re[e.diagramType],l=((c=e.elementIds)==null?void 0:c.length)??0;return t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer group",style:{borderRadius:"4px",margin:"0 4px",background:r?g.accent+"18":s?"#F0F0ED":"transparent",fontSize:j.explorer.item},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onClick:n,title:[a==null?void 0:a.fullName,e.description].filter(Boolean).join(" — "),children:[t.jsx($a,{diagram:e}),e.auto&&!e.sourceFile&&t.jsx("span",{className:"px-1 py-0.5 rounded",style:{background:"#F0F0ED",color:g.faint,fontSize:j.badge,fontWeight:600},children:"AUTO"}),t.jsxs("span",{className:"flex-1",style:{minWidth:0},children:[t.jsx("span",{className:"truncate block",style:{color:r?g.accentDark:g.primary},children:e.name}),t.jsx("span",{className:"truncate block font-mono",style:{color:g.faint,fontSize:"9px",marginTop:1},children:e.id})]}),l>0&&t.jsx("span",{className:"px-1.5 py-0.5 rounded-full",style:{background:"#F0F0ED",color:g.muted,fontSize:j.explorer.count,fontWeight:600,minWidth:"18px",textAlign:"center"},children:l}),o&&s&&t.jsx("button",{onClick:d=>{d.stopPropagation(),o()},title:"Delete diagram",style:{background:"none",border:"none",cursor:"pointer",color:"#DC2626",fontSize:"12px",padding:"0 2px",lineHeight:1},children:"×"})]})}function Ja(){const e=E(h=>h.setActiveView),r=E(h=>h.activeView),n=E(h=>h.dhfDocuments),o=E(h=>h.addDhfDocument),s=E(h=>h.removeDhfDocument),i=E(h=>h.dhfSettings),[a,l]=p.useState(new Set(Ne.map(h=>h.id))),[c,d]=p.useState(null),[u,m]=p.useState(null),y=r.type==="dhf-document"?r.docId:null,S=p.useMemo(()=>{const h=new Set(Ne.map(C=>C.label));return[...new Set(n.map(C=>C.group))].filter(C=>C&&!h.has(C)).sort()},[n]);function x(h){l(C=>{const A=new Set(C);return A.has(h)?A.delete(h):A.add(h),A})}function f(h,C){h.preventDefault(),h.stopPropagation(),m({x:h.clientX,y:h.clientY,groupId:C})}function w(h){const C=i.documentNumberingPrefix||"DOC",A=[];for(const b of h){const R=`${C}-${b.prefix}-`,T=[...n,...A].filter(L=>L.id.startsWith(R)),O=`${R}${String(T.length+1).padStart(3,"0")}`,D=L=>L.replace(/^---[\s\S]*?---\n?/,""),P=b.content!==null?D(b.content):(()=>{const L=Da(b.templateId);return L?D(L):`# ${b.title}
3260
-
3261
- _[TODO: Add content]_
3262
- `})(),F=`---
3263
- id: ${O}
3264
- title: ${b.title}
3265
- template: ${b.templateId}
3266
- ---
3267
-
3268
- ${P}`,N={id:O,title:b.title,group:b.groupLabel,templateId:b.templateId,content:F,createdAt:Date.now(),authors:"",approvers:""};o(N),A.push(N),A.length===1&&e({type:"dhf-document",docId:N.id})}d(null)}return p.useEffect(()=>{if(!u)return;function h(){m(null)}return window.addEventListener("click",h),()=>window.removeEventListener("click",h)},[u]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[t.jsx("div",{style:{padding:"4px 10px 8px"},children:t.jsxs("button",{onClick:()=>d({}),style:{width:"100%",padding:"7px 10px",borderRadius:"6px",border:"none",background:g.accentDark,fontSize:j.explorer.item,fontWeight:600,color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"},onMouseEnter:h=>{h.currentTarget.style.background="#254B60"},onMouseLeave:h=>{h.currentTarget.style.background=g.accentDark},children:[t.jsx("span",{style:{fontSize:"14px",lineHeight:1},children:"+"})," New Document"]})}),Ne.filter(h=>n.some(C=>C.group===h.label)).map(h=>{const C=a.has(h.id),A=n.filter(b=>b.group===h.label);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>x(h.id),onContextMenu:b=>f(b,h.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left",style:{fontSize:j.xs,fontWeight:600,color:g.secondary,borderRadius:"4px"},onMouseEnter:b=>b.currentTarget.style.background=g.surfaceAlt,onMouseLeave:b=>b.currentTarget.style.background="transparent",title:"Right-click to add documents",children:[t.jsx("span",{style:{display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",background:h.color,flexShrink:0}}),t.jsx("span",{className:"flex-1 uppercase tracking-wide",style:{fontSize:"10px"},children:h.label}),A.length>0&&t.jsx("span",{style:{fontSize:"10px",color:h.color,fontWeight:700},children:A.length}),t.jsx(Ae,{expanded:C,size:11})]}),C&&A.map(b=>{const R=y===b.id;return t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:"28px",paddingRight:"4px",background:R?`${h.color}18`:"transparent",borderLeft:R?`2px solid ${h.color}`:"2px solid transparent",cursor:"pointer"},onMouseEnter:T=>{R||(T.currentTarget.style.background=g.surfaceAlt)},onMouseLeave:T=>{T.currentTarget.style.background=R?`${h.color}18`:"transparent"},children:[t.jsxs("button",{onClick:()=>e({type:"dhf-document",docId:b.id}),style:{flex:1,display:"flex",alignItems:"center",gap:"6px",background:"none",border:"none",padding:"5px 0",fontSize:j.explorer.element,color:R?h.color:g.primary,fontWeight:R?600:400,cursor:"pointer",textAlign:"left"},children:[t.jsx(Wt,{color:h.color}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.id})]}),t.jsx("button",{onClick:T=>{T.stopPropagation(),s(b.id)},title:"Remove document",style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"2px 4px",borderRadius:"3px",fontSize:"12px",opacity:0,transition:"opacity 0.1s"},onMouseEnter:T=>{T.currentTarget.style.opacity="1",T.currentTarget.style.color="#ef4444"},onMouseLeave:T=>{T.currentTarget.style.opacity="0",T.currentTarget.style.color="#9CA3AF"},children:"×"})]},b.id)})]},h.id)}),S.map(h=>{const C=`custom:${h}`,A=a.has(C),b=Aa(h),R=n.filter(T=>T.group===h);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>x(C),className:"w-full flex items-center gap-2 px-3 py-2 text-left",style:{fontSize:j.xs,fontWeight:600,color:g.secondary,borderRadius:"4px"},onMouseEnter:T=>T.currentTarget.style.background=g.surfaceAlt,onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[t.jsx("span",{style:{display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",background:b,flexShrink:0}}),t.jsx("span",{className:"flex-1 uppercase tracking-wide",style:{fontSize:"10px"},children:h}),t.jsx("span",{style:{fontSize:"10px",color:b,fontWeight:700},children:R.length}),t.jsx(Ae,{expanded:A,size:11})]}),A&&R.map(T=>{const O=y===T.id;return t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:"28px",paddingRight:"4px",background:O?`${b}18`:"transparent",borderLeft:O?`2px solid ${b}`:"2px solid transparent",cursor:"pointer"},onMouseEnter:D=>{O||(D.currentTarget.style.background=g.surfaceAlt)},onMouseLeave:D=>{D.currentTarget.style.background=O?`${b}18`:"transparent"},children:[t.jsxs("button",{onClick:()=>e({type:"dhf-document",docId:T.id}),style:{flex:1,display:"flex",alignItems:"center",gap:"6px",background:"none",border:"none",padding:"5px 0",fontSize:j.explorer.element,color:O?b:g.primary,fontWeight:O?600:400,cursor:"pointer",textAlign:"left"},children:[t.jsx(Wt,{color:b}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.id})]}),t.jsx("button",{onClick:D=>{D.stopPropagation(),s(T.id)},title:"Remove document",style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"2px 4px",borderRadius:"3px",fontSize:"12px",opacity:0,transition:"opacity 0.1s"},onMouseEnter:D=>{D.currentTarget.style.opacity="1",D.currentTarget.style.color="#ef4444"},onMouseLeave:D=>{D.currentTarget.style.opacity="0",D.currentTarget.style.color="#9CA3AF"},children:"×"})]},T.id)})]},C)}),n.length===0&&t.jsxs("div",{style:{padding:"16px 14px",fontSize:"11px",color:"#9CA3AF",lineHeight:"1.6"},children:["No documents yet. Use ",t.jsx("strong",{children:"+ New Document"})," to create one from a meMO template, a reusable project template, a new template, or a blank page."]})]}),u&&t.jsx("div",{style:{position:"fixed",zIndex:9998,left:u.x,top:u.y,background:"#fff",borderRadius:"8px",border:"1px solid #E5E7EB",boxShadow:"0 8px 24px rgba(0,0,0,0.12)",padding:"4px 0",minWidth:"160px"},onClick:h=>h.stopPropagation(),children:t.jsx("button",{onClick:()=>{d({initialGroupId:u.groupId}),m(null)},style:{display:"block",width:"100%",padding:"8px 14px",background:"none",border:"none",textAlign:"left",fontSize:"13px",color:"#1B3A4B",cursor:"pointer"},onMouseEnter:h=>h.currentTarget.style.background="#F3F4F6",onMouseLeave:h=>h.currentTarget.style.background="none",children:"Add document…"})}),c&&t.jsx(Ta,{initialGroupId:c.initialGroupId,existingDocs:n,numberingPrefix:i.documentNumberingPrefix||"DOC",onCreate:w,onClose:()=>d(null)})]})}const jr="memo-explorer-width",Ge=300,Ye=240,$t=720,Xa=320;function Tt(){return typeof window>"u"||!window.innerWidth?$t:Math.max(Ye,Math.min($t,window.innerWidth-Xa))}function Qa(e){return Number.isFinite(e)?Math.min($t,Math.max(Ye,e)):Ge}function Za(){if(typeof window>"u")return Ge;try{const e=Number.parseInt(localStorage.getItem(jr)??"",10);return Number.isFinite(e)?Qa(e):Ge}catch{return Ge}}function el(){const e=E(f=>f.sidebarCollapsed);E(f=>f.explorerTab);const r=E(f=>f.setExplorerTab),n=E(f=>f.searchTerm),o=E(f=>f.setSearchTerm);E(f=>f.model);const s=E(f=>f.activeMode),i=E(f=>f.activeView),[a,l]=p.useState(Za),[c,d]=p.useState(Tt),u=Math.min(a,c),m=p.useRef(null),y=p.useCallback(f=>{l(Math.max(Ye,Math.min(Tt(),f)))},[]),S=p.useCallback(()=>{var f;(f=m.current)==null||f.call(m),m.current=null},[]),x=p.useCallback(f=>{if(f.button!==0)return;f.preventDefault(),S();const w=f.clientX,h=u,C=document.body.style.cursor,A=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const b=T=>{y(h+T.clientX-w)},R=()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R),document.body.style.cursor=C,document.body.style.userSelect=A,m.current=null};m.current=R,window.addEventListener("pointermove",b),window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R)},[y,u,S]);return p.useEffect(()=>{try{localStorage.setItem(jr,String(Math.round(a)))}catch{}},[a]),p.useEffect(()=>{const f=()=>d(Tt());return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f),S()}},[S]),p.useEffect(()=>{(i.type==="ontology"||i.type==="ontology-detail")&&r("ontologies")},[i.type]),e?null:t.jsxs("div",{className:"flex flex-col overflow-hidden flex-shrink-0",style:{position:"relative",width:`${u}px`,background:g.surface,borderRight:`1px solid ${g.border}`},children:[s==="dashboard"?t.jsx(_i,{}):s==="dhf"?t.jsx(Ja,{}):s==="diagram"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2",style:{borderBottom:`1px solid ${g.border}`},children:t.jsx("input",{type:"text",placeholder:"Search viewpoints and views...",value:n,onChange:f=>o(f.target.value),className:"w-full px-3 py-2 rounded-lg focus:outline-none",style:{background:g.surfaceAlt,border:`1px solid ${g.border}`,color:g.primary,fontSize:j.explorer.search}})}),t.jsx(Ga,{searchTerm:n})]}):s==="ontology"?t.jsx(Ii,{}):s==="scenario"?t.jsx(p.Suspense,{fallback:t.jsx("div",{className:"p-3",style:{color:g.faint,fontSize:j.explorer.item},children:"Loading use cases…"}),children:t.jsx(Ia,{explorerOnly:!0})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2",style:{borderBottom:`1px solid ${g.border}`},children:t.jsx("input",{type:"text",placeholder:"Search elements...",value:n,onChange:f=>o(f.target.value),className:"w-full px-3 py-2 rounded-lg focus:outline-none",style:{background:g.surfaceAlt,border:`1px solid ${g.border}`,color:g.primary,fontSize:j.explorer.search}})}),t.jsx(Wa,{searchTerm:n})]}),t.jsx("div",{className:"memo-explorer-resizer",role:"separator","aria-label":"Resize Model Explorer","aria-orientation":"vertical","aria-valuemin":Ye,"aria-valuemax":c,"aria-valuenow":Math.round(u),tabIndex:0,title:"Drag to resize · Double-click to reset",onPointerDown:x,onDoubleClick:()=>y(Ge),onKeyDown:f=>{f.key==="ArrowLeft"?(f.preventDefault(),y(u-20)):f.key==="ArrowRight"?(f.preventDefault(),y(u+20)):f.key==="Home"?(f.preventDefault(),y(Ye)):f.key==="End"&&(f.preventDefault(),y(c))}})]})}const _n="#E5E5E0",Nn="#2DD4A8",Ut=40;function Mn(e,r){var i;const n=e.id.toLowerCase(),o=((i=e.shortId)==null?void 0:i.toLowerCase())??"",s=e.name.toLowerCase();return n===r||o===r?0:n.startsWith(r)||o.startsWith(r)?1:s.startsWith(r)?2:n.includes(r)||s.includes(r)?3:4}function tl(e,r){const n=r.query.trim().toLowerCase();return n?Object.values(e).filter(o=>o.id!==r.excludeId).filter(o=>[o.id,o.shortId,o.name,o.kind].filter(Boolean).join(" ").toLowerCase().includes(n)).sort((o,s)=>Mn(o,n)-Mn(s,n)||o.name.localeCompare(s.name)).slice(0,r.limit??Ut):[]}function nl(e){const r=new Map;for(const n of e){let o=r.get(n.kind);o||(o={kind:n.kind,layer:n.layer,elements:[]},r.set(n.kind,o)),o.elements.push(n)}return[...r.values()]}function rl({element:e,model:r,registries:n,enabled:o,onCreate:s}){var F;const[i,a]=p.useState(""),[l,c]=p.useState(!1),[d,u]=p.useState(0),[m,y]=p.useState(null),[S,x]=p.useState(null),f=p.useRef(null),w=p.useRef(null);p.useEffect(()=>{a(""),y(null),x(null),c(!1),u(0)},[e.id]);const h=p.useMemo(()=>tl(r.elements,{query:i,excludeId:e.id}),[r.elements,e.id,i]),C=p.useMemo(()=>nl(h),[h]),A=p.useMemo(()=>C.flatMap(N=>N.elements),[C]);p.useEffect(()=>{u(0)},[i]),p.useEffect(()=>{var N,L;l&&((L=(N=w.current)==null?void 0:N.querySelector('[data-active="true"]'))==null||L.scrollIntoView({block:"nearest"}))},[d,l]);const b=p.useCallback(N=>{y(N),a(N.name||N.id),c(!1),x(null)},[]),R=p.useCallback(()=>{a(""),y(null),x(null),c(!1)},[]),T=p.useMemo(()=>m?ws(e,m,n):[],[e,m,n]);p.useEffect(()=>{x(T.length===1?T[0]:null)},[T]);const O=p.useMemo(()=>!S||!m?null:{type:S.definition.name,sourceId:S.sourceId,targetId:S.targetId,direction:S.direction},[S,m]),D=p.useCallback(N=>{if(N.key==="Escape"){if(l){c(!1);return}R();return}if(!l||A.length===0){N.key==="ArrowDown"&&A.length>0&&(N.preventDefault(),c(!0));return}if(N.key==="ArrowDown")N.preventDefault(),u(L=>(L+1)%A.length);else if(N.key==="ArrowUp")N.preventDefault(),u(L=>(L-1+A.length)%A.length);else if(N.key==="Enter"){N.preventDefault();const L=A[d];L&&b(L)}},[l,A,d,b,R]),P=(F=A[d])==null?void 0:F.id;return t.jsxs("div",{className:"mt-1.5",style:{opacity:o?1:.6},children:[t.jsxs("div",{className:"relative",children:[t.jsx("input",{ref:f,value:i,disabled:!o,onChange:N=>{a(N.target.value),y(null),x(null),c(!0)},onFocus:()=>{i.trim()&&!m&&c(!0)},onBlur:()=>{window.setTimeout(()=>c(!1),120)},onKeyDown:D,placeholder:o?"Link to… type an element ID or name":"Connect to the dev server to author relationships","aria-label":"Link this element to another","aria-expanded":l,"aria-controls":"memo-quick-add-matches","aria-activedescendant":l&&P?`memo-quick-add-${P}`:void 0,role:"combobox",autoComplete:"off",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:j.xs,background:"#FFFFFF",border:`1px solid ${m?Nn:_n}`,color:"#374151"}}),l&&i.trim()&&t.jsxs("div",{id:"memo-quick-add-matches",ref:w,role:"listbox",className:"absolute left-0 right-0 z-20 mt-1 rounded overflow-y-auto",style:{maxHeight:240,background:"#FFFFFF",border:`1px solid ${_n}`,boxShadow:"0 8px 24px rgba(15,23,42,0.14)"},children:[A.length===0?t.jsxs("div",{className:"px-2 py-2",style:{fontSize:j.xs,color:"#9CA3AF"},children:["No element matches “",i.trim(),"”."]}):C.map(N=>t.jsxs("div",{children:[t.jsx(sl,{kind:N.kind,layer:N.layer,count:N.elements.length}),N.elements.map(L=>t.jsx(il,{element:L,active:L.id===P,onSelect:()=>b(L)},L.id))]},N.kind)),h.length===Ut&&t.jsxs("div",{className:"px-2 py-1",style:{fontSize:"10px",color:"#9CA3AF"},children:["Showing the first ",Ut," matches — keep typing to narrow."]})]})]}),m&&t.jsx(ol,{element:e,target:m,options:T,selected:S,registries:n,onSelect:x}),m&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[t.jsx("button",{onClick:()=>{O&&(s(O),R())},disabled:!O||!o,className:"px-2 py-0.5 rounded",style:{fontSize:j.xs,fontWeight:600,border:"none",background:O&&o?Nn:"#E5E5E0",color:O&&o?"#FFFFFF":"#9CA3AF",cursor:O&&o?"pointer":"not-allowed"},children:"Create link"}),t.jsx("button",{onClick:R,className:"px-2 py-0.5 rounded",style:{fontSize:j.xs,background:"#F0F0ED",color:"#374151",border:"none",cursor:"pointer"},children:"Cancel"})]})]})}function ol({element:e,target:r,options:n,selected:o,registries:s,onSelect:i}){const a=s.relationships.filter(l=>!l.isAbstract&&!n.some(c=>c.definition.name===l.name)).length;return n.length===0?t.jsx("div",{className:"mt-1.5 px-2 py-1.5 rounded",style:{background:"#FFFBEB",border:"1px solid #FDE68A"},children:t.jsxs("div",{style:{fontSize:j.xs,color:"#92400E"},children:["The ontology defines no relationship between a ",e.kind," and a ",r.kind,"."]})}):t.jsxs("div",{className:"mt-1.5",children:[t.jsx("div",{className:"mb-1",style:{fontSize:"10px",fontWeight:600,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.04em"},children:"Relationship"}),t.jsx("div",{style:{maxHeight:160,overflowY:"auto"},children:n.map(l=>{const c=(o==null?void 0:o.definition.name)===l.definition.name&&(o==null?void 0:o.direction)===l.direction,d=bs(l.definition);return t.jsxs("button",{onClick:()=>i(l),className:"w-full text-left px-2 py-1 rounded",style:{background:c?"#2DD4A818":"transparent",border:"none",cursor:"pointer",display:"block"},onMouseEnter:u=>{c||(u.currentTarget.style.background="#F7F7F5")},onMouseLeave:u=>{c||(u.currentTarget.style.background="transparent")},children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{style:{fontSize:j.xs,fontWeight:500,color:"#1a1a1a"},children:l.definition.label}),d&&t.jsx("span",{className:"px-1 rounded",style:{fontSize:"9px",background:"#FEF3C7",color:"#92400E"},title:"Joins any two elements. Prefer a relation that carries the meaning.",children:"fallback"})]}),t.jsx("div",{className:"truncate",style:{fontSize:"10px",color:"#9CA3AF"},children:l.direction==="outgoing"?`${e.name} → ${r.name}`:`${r.name} → ${e.name}`})]},`${l.definition.name}-${l.direction}`)})}),a>0&&t.jsxs("div",{className:"mt-0.5",style:{fontSize:"10px",color:"#9CA3AF"},children:[a," other relationship type",a>1?"s are":" is"," defined but cannot join a ",e.kind," and a ",r.kind,"."]})]})}function sl({kind:e,layer:r,count:n}){const o=ne[r]||"#666";return t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{background:"#FAFAF8",borderBottom:"1px solid #F0F0ED",position:"sticky",top:0},children:[t.jsx("span",{className:"w-2 h-2 flex-shrink-0",style:{background:o,borderRadius:2}}),t.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:"#6B7280"},children:e}),t.jsx("span",{className:"ml-auto",style:{fontSize:"10px",color:"#D1D5DB"},children:n})]})}function il({element:e,active:r,onSelect:n}){return t.jsxs("div",{id:`memo-quick-add-${e.id}`,role:"option","aria-selected":r,"data-active":r,onMouseDown:o=>{o.preventDefault(),n()},className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer",style:{background:r?"#2DD4A818":"transparent"},children:[t.jsx("span",{className:"truncate",style:{fontSize:j.xs,color:"#1a1a1a"},children:e.name||e.id}),t.jsx("span",{className:"ml-auto flex-shrink-0 font-mono truncate",style:{fontSize:"10px",color:"#9CA3AF",maxWidth:110},title:e.id,children:e.shortId??e.id})]})}const al={text:"14px",heading:"13px",meta:"12px",valuePadding:"9px 12px",fieldGap:"10px",sectionPadding:"0 0 18px 0",radius:"10px",twoColumnAttributes:!0},ll={text:"12px",heading:"12px",meta:"11px",valuePadding:"4px 7px",fieldGap:"5px",sectionPadding:"0 0 10px 0",radius:"7px",twoColumnAttributes:!1};function Fe(e){return e==="page"?al:ll}const dl={kind:"editable"},cl={id:"The model identifier. It is referenced by relationships and views, so it is not editable here.",name:"The element name in SysML. Renaming touches every reference, so do it in the source file."};function ul(e){const r=cl[e];return r?{kind:"identity",reason:r}:dl}function zd(e){return{kind:"derived",reason:`"${e}" is derived from the SysML source when the model is built.`}}function Dr(e){return e.kind==="editable"}function Ar(e){switch(e.kind){case"editable":return"Click to edit";case"identity":return"Identifier — not editable here";case"derived":return"Derived from source — not editable"}}function pl({title:e,count:r,actions:n,density:o,defaultOpen:s=!0,collapsible:i=!0,children:a}){const[l,c]=p.useState(s),d=Fe(o),u=o==="page",m=i?l:!0;return t.jsxs("section",{style:{padding:u?"16px 18px":d.sectionPadding,border:u?"1px solid rgba(60,60,67,0.12)":"none",borderBottom:u?"1px solid rgba(60,60,67,0.12)":`1px solid ${g.borderLight}`,borderRadius:u?14:0,background:u?g.surface:"transparent",boxShadow:u?"0 1px 2px rgba(15,23,42,0.04)":"none",marginBottom:u?14:0},children:[t.jsxs("header",{className:"flex items-center gap-2",style:{cursor:i?"pointer":"default",padding:u?"0 0 10px 0":"6px 10px",borderRadius:u?0:"6px",margin:u?0:"2px 4px"},onClick:i?()=>c(y=>!y):void 0,onMouseEnter:y=>{!u&&i&&(y.currentTarget.style.background=g.surfaceAlt)},onMouseLeave:y=>{u||(y.currentTarget.style.background="transparent")},children:[t.jsx("h3",{style:{flex:1,margin:0,fontSize:d.heading,fontWeight:u?700:500,color:u?g.primary:"#374151",letterSpacing:0,textTransform:"none"},children:e}),typeof r=="number"&&t.jsx("span",{style:{fontSize:d.meta,color:g.faint},children:r}),n&&t.jsx("span",{onClick:y=>y.stopPropagation(),children:n}),i&&t.jsx("span",{style:{color:"#D1D5DB",fontSize:d.meta},children:m?"▾":"▸"})]}),m&&t.jsx("div",{style:{padding:u?0:"0 14px 8px"},children:a})]})}function ml({value:e,editability:r,density:n,mono:o}){const s=Fe(n),i=r.kind==="editable"?"":r.reason;return t.jsxs("div",{title:i||Ar(r),style:{display:"flex",alignItems:"center",gap:6,padding:s.valuePadding,borderRadius:s.radius,background:g.surfaceAlt,border:"1px solid transparent",color:g.muted,fontSize:s.text,fontFamily:o?"ui-monospace, SFMono-Regular, Menlo, monospace":"inherit",cursor:"default",minWidth:0},children:[t.jsx("span",{className:"truncate",style:{flex:1},children:e||t.jsx("span",{style:{color:g.faint,fontStyle:"italic"},children:"none"})}),t.jsx("span",{"aria-hidden":!0,style:{fontSize:s.meta,color:"#C7CBD1",flexShrink:0},children:"🔒"})]})}function On({value:e,onSave:r,density:n,multiline:o,placeholder:s,autoFocus:i,compact:a=!1}){const[l,c]=p.useState(!1),[d,u]=p.useState(!1),[m,y]=p.useState(e),S=Fe(n),x=p.useRef(!1);p.useEffect(()=>{y(e)},[e]);const f=p.useCallback(()=>{x.current||(x.current=!0,c(!1),m!==e&&r(m))},[m,e,r]),w=p.useCallback(C=>{C.key==="Enter"&&!o&&(C.preventDefault(),f()),C.key==="Escape"&&(x.current=!0,y(e),c(!1))},[f,o,e]),h=()=>{x.current=!1,y(e),c(!0)};if(l){const C={value:m,autoFocus:!0,onChange:A=>y(A.target.value),onBlur:f,onKeyDown:w,placeholder:s,style:{width:"100%",padding:a?"5px 8px":S.valuePadding,borderRadius:a?"6px":S.radius,border:`1px solid ${g.accent}`,boxShadow:`0 0 0 3px ${g.accent}25`,background:g.surface,color:g.primary,fontSize:S.text,fontFamily:"inherit",outline:"none",...o?{minHeight:n==="page"?"110px":"54px",resize:"vertical",lineHeight:1.6}:{}}};return o?t.jsx("textarea",{...C}):t.jsx("input",{type:"text",...C})}return t.jsxs("div",{role:"button",tabIndex:0,title:"Click to edit",onClick:h,onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),h())},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{display:"flex",alignItems:"flex-start",gap:6,padding:a?"5px 8px":S.valuePadding,borderRadius:a?"6px":S.radius,background:a?d?"#F0FDF9":g.surfaceAlt:g.surface,border:a?`1px solid ${d?g.accent:"transparent"}`:`1px solid ${d?g.accent:g.border}`,boxShadow:d&&!a?`0 0 0 3px ${g.accent}20`:"none",color:e?g.primary:g.faint,fontSize:S.text,cursor:"text",transition:"border-color 150ms ease, box-shadow 150ms ease",lineHeight:o?1.6:1.4,whiteSpace:o?"pre-wrap":"nowrap",overflow:"hidden",minWidth:0},children:[t.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:e||(s??"Click to add…")}),t.jsx("span",{"aria-hidden":!0,style:{flexShrink:0,fontSize:S.meta,color:d?g.accent:"#C7CBD1",transition:"color 150ms ease"},children:"✎"})]})}function Ld({label:e,editability:r,density:n,children:o}){const s=Fe(n);return t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{className:"flex items-center gap-1.5",style:{marginBottom:4,fontSize:s.meta,color:g.muted},children:[t.jsx("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:e}),t.jsx("span",{className:"sr-only",children:Ar(r)}),!Dr(r)&&t.jsx("span",{title:r.kind==="editable"?"":r.reason,style:{fontSize:"10px",padding:"0 4px",borderRadius:4,background:g.surfaceAlt,color:g.faint,border:`1px solid ${g.border}`},children:r.kind==="identity"?"identifier":"derived"})]}),o]})}function Bd({density:e}){const r=Fe(e);return t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",style:{fontSize:r.meta,color:g.faint},children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{style:{color:g.accent},children:"✎"})," editable here"]}),t.jsx("span",{children:"Identity and source metadata are read-only"})]})}function fl(e,r,n,o){var c;const s=new Map,i=(d,u)=>{var S;const m=u==="outgoing"?d.targetId:d.sourceId,y=s.get(m)??{id:m,element:n.elements[m],links:[]};y.links.push({relationship:d,direction:u,label:((S=Zt(d.type,o))==null?void 0:S.label)??d.type}),s.set(m,y)};e.forEach(d=>i(d,"outgoing")),r.forEach(d=>i(d,"incoming"));const a=new Map;for(const d of s.values()){const u=((c=d.element)==null?void 0:c.layer)||"other";a.set(u,[...a.get(u)??[],d])}const l=d=>{const u=Ue.indexOf(d);return u<0?Number.MAX_SAFE_INTEGER:u};return[...a.entries()].map(([d,u])=>({layer:d,elements:u.sort((m,y)=>{var S,x;return(((S=m.element)==null?void 0:S.name)??m.id).localeCompare(((x=y.element)==null?void 0:x.name)??y.id)})})).sort((d,u)=>l(d.layer)-l(u.layer)||d.layer.localeCompare(u.layer))}function hl({element:e,model:r,registries:n,outgoing:o,incoming:s,density:i,onNavigate:a}){const[l,c]=p.useState(""),d=p.useMemo(()=>fl(o,s,r,n),[o,s,r,n]),u=l.trim().toLowerCase(),m=p.useMemo(()=>d.map(S=>({...S,elements:S.elements.filter(x=>{var f,w,h;return!u||[(f=x.element)==null?void 0:f.name,(w=x.element)==null?void 0:w.kind,(h=x.element)==null?void 0:h.shortId,x.id,S.layer,...x.links.map(C=>C.label)].filter(Boolean).join(" ").toLowerCase().includes(u)})})).filter(S=>S.elements.length>0),[d,u]),y=d.reduce((S,x)=>S+x.elements.length,0);return t.jsxs("div",{style:{border:i==="page"?"none":`1px solid ${g.border}`,borderRadius:12,background:i==="page"?"transparent":g.surfaceAlt,padding:i==="page"?0:10},children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",style:{marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{color:g.primary,fontSize:13,fontWeight:700},children:"Linked elements"}),t.jsxs("div",{style:{color:g.muted,fontSize:11},children:[y," element",y===1?"":"s"," across ",d.length," layer",d.length===1?"":"s"]})]}),y>6&&t.jsx("input",{value:l,onChange:S=>c(S.target.value),placeholder:"Filter linked elements…","aria-label":"Filter linked elements",style:{marginLeft:"auto",width:240,padding:"6px 9px",borderRadius:7,border:`1px solid ${g.border}`,background:g.surface,color:g.primary,fontSize:12,outline:"none"}})]}),y===0&&t.jsx("div",{style:{color:g.faint,fontSize:12},children:"No linked elements."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:m.map(S=>{const x=ne[S.layer]||g.muted;return t.jsxs("section",{style:{padding:i==="page"?"11px 12px":8,background:x+"0D",border:`1px solid ${x}25`,borderRadius:i==="page"?11:8},children:[t.jsxs("div",{className:"flex items-center gap-2",style:{marginBottom:8},children:[t.jsx("span",{style:{width:9,height:9,borderRadius:3,background:x}}),t.jsx("strong",{style:{color:g.primary,fontSize:12},children:Xe[S.layer]??S.layer}),t.jsx("span",{style:{color:g.faint,fontSize:11},children:S.elements.length})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:i==="page"?"repeat(auto-fill, 264px)":"1fr",justifyContent:"start",gap:7},children:S.elements.map(f=>t.jsx(gl,{linked:f,color:x,onNavigate:a},f.id))})]},S.layer)})})]})}function gl({linked:e,color:r,onNavigate:n}){var i,a,l;const[o,s]=p.useState(!1);return t.jsx("button",{onClick:()=>n(e.id),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),className:"text-left",title:`Open ${((i=e.element)==null?void 0:i.name)??e.id}`,style:{padding:"10px 11px",borderRadius:10,background:g.surface,border:`1px solid ${o?r+"90":"rgba(60,60,67,0.12)"}`,cursor:"pointer",minWidth:0,width:"100%",maxWidth:264,boxShadow:o?"0 2px 8px rgba(15,23,42,0.08)":"none"},children:t.jsxs("div",{style:{minWidth:0},children:[e.links.map(c=>t.jsxs("div",{style:{color:c.direction==="outgoing"?"#2563EB":"#059669",fontSize:10,fontWeight:600,marginBottom:2},children:[c.label," ",c.direction==="outgoing"?"to":"from"]},c.relationship.id)),t.jsx("strong",{className:"truncate",style:{display:"block",color:g.primary,fontSize:13},children:((a=e.element)==null?void 0:a.name)??e.id}),t.jsx("div",{style:{color:g.muted,fontSize:10,marginTop:2},children:((l=e.element)==null?void 0:l.kind)??"Unknown element type"})]})})}function yl({element:e,outgoing:r,incoming:n,density:o}){const s=E(D=>D.model),i=E(D=>D.connected),a=E(D=>D.selectElement),l=E(D=>D.selectedDiagramId),c=E(D=>D.pendingRelationships),d=E(D=>D.createRelationship),u=E(D=>D.deleteRelationship),m=E(D=>D.dismissPendingRelationship),y=E(D=>D.addElementToDiagram),[S,x]=p.useState(!1),[f,w]=p.useState(null),[h,C]=p.useState(null),A=p.useMemo(()=>gr(s),[s]);p.useEffect(()=>{w(null),C(null),x(!1)},[e.id]);const b=c.filter(D=>D.sourceId===e.id||D.targetId===e.id),R=r.length+n.length,T=p.useCallback(async D=>{var ee;w(null);const P=await d({...D,selectedElementId:e.id,diagramId:l??void 0});if(!P.success){w({kind:"error",message:P.error??"The relationship could not be created."});return}const F=D.sourceId===e.id?D.targetId:D.sourceId,N=vt(s,l),L=(ee=P.diagnostics)==null?void 0:ee.find(Q=>Q.code==="REL-005"),Z=!!N&&!!N.elementIds&&N.elementIds.length>0&&!N.elementIds.includes(F);w({kind:"success",message:`Relationship created in ${P.sourceFile??"the model"}.`,profileMessage:L==null?void 0:L.message,offerAddToView:Z&&!L&&l?{elementId:F,diagramId:l}:void 0})},[d,e.id,l,s]),O=p.useCallback(async D=>{C(null);const P=await u(D);w(P.success?{kind:"success",message:`Relationship removed from ${P.sourceFile??"the model"}.`}:{kind:"error",message:P.error??"The relationship could not be deleted."})},[u]);return s?t.jsx(t.Fragment,{children:t.jsxs(pl,{title:"Relationships",count:R,density:o,collapsible:o==="panel",actions:R>0?t.jsx("button",{onClick:()=>x(D=>!D),style:{padding:"2px 9px",borderRadius:"6px",background:S?g.accent:g.surfaceAlt,color:S?"#FFFFFF":"#374151",border:`1px solid ${S?g.accent:g.border}`,cursor:"pointer",fontSize:j.xs,fontWeight:500},title:S?"Collapse the expanded relationship view":"Show every relationship, grouped by direction and type",children:S?"▴ Collapse":"⤢ Expand"}):void 0,children:[t.jsx("div",{style:{marginBottom:o==="page"?14:8,maxWidth:o==="page"?720:void 0},children:t.jsx(rl,{element:e,model:s,registries:A,enabled:i,onCreate:T})}),S?t.jsx("div",{style:{marginBottom:12},children:t.jsx(hl,{element:e,model:s,registries:A,outgoing:r,incoming:n,density:o,onNavigate:a})}):t.jsxs(t.Fragment,{children:[R===0&&b.length===0&&t.jsx("div",{style:{fontSize:Fe(o).meta,color:g.faint,padding:"2px 0 6px"},children:"No relationships yet — add the first one below."}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:o==="page"?"repeat(auto-fill, 280px)":"1fr",justifyContent:"start",gap:8},children:[r.map(D=>t.jsx(Pn,{relationship:D,direction:"outgoing",model:s,registries:A,density:o,confirming:h===D.id,onNavigate:()=>a(D.targetId),onRequestDelete:()=>C(D.id),onCancelDelete:()=>C(null),onConfirmDelete:()=>O(D.id),deletable:i},D.id)),n.map(D=>t.jsx(Pn,{relationship:D,direction:"incoming",model:s,registries:A,density:o,confirming:h===D.id,onNavigate:()=>a(D.sourceId),onRequestDelete:()=>C(D.id),onCancelDelete:()=>C(null),onConfirmDelete:()=>O(D.id),deletable:i},D.id))]}),b.map(D=>t.jsx(bl,{pending:D,model:s,onDismiss:()=>m(D.pendingId)},D.pendingId))]}),f&&t.jsx(xl,{status:f,onAddToView:()=>{f.offerAddToView&&(y(f.offerAddToView.diagramId,f.offerAddToView.elementId),w({kind:"success",message:"Element added to this view."}))},onDismiss:()=>w(null),model:s})]})}):null}function xl({status:e,onAddToView:r,onDismiss:n,model:o}){var a;const s=e.kind==="success",i=e.offerAddToView?((a=o.elements[e.offerAddToView.elementId])==null?void 0:a.name)??e.offerAddToView.elementId:null;return t.jsxs("div",{className:"text-xs p-2 rounded-lg mt-2",style:{background:s?"#F0FDF4":"#FEF2F2",border:`1px solid ${s?"#BBF7D0":"#FECACA"}`,color:s?"#166534":"#DC2626"},children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx("span",{className:"flex-1",children:e.message}),t.jsx("button",{onClick:n,style:{background:"none",border:"none",cursor:"pointer",color:"inherit",lineHeight:1},"aria-label":"Dismiss",children:"×"})]}),e.profileMessage&&t.jsx("div",{className:"mt-1",style:{color:"#92400E"},children:"Relationship created in the model, but this view profile does not display this relationship type."}),e.offerAddToView&&t.jsxs("button",{onClick:r,className:"mt-1.5 px-2 py-0.5 rounded",style:{background:"#FFFFFF",border:"1px solid #BBF7D0",color:"#166534",cursor:"pointer",fontSize:j.xs},children:["Relationship created. Add ",i," to this view?"]})]})}function Pn({relationship:e,direction:r,model:n,registries:o,deletable:s,density:i,confirming:a,onNavigate:l,onRequestDelete:c,onCancelDelete:d,onConfirmDelete:u}){const m=r==="outgoing"?e.targetId:e.sourceId,y=n.elements[m],S=y&&ne[y.layer]||"#666",x=y?Xe[y.layer]??y.layer.replace(/_/g," "):"Unknown layer",f=Zt(e.type,o),[w,h]=p.useState(!1),C=Fe(i),A=s&&e.named===!0;return t.jsxs("div",{style:{border:`1px solid ${S}35`,borderRadius:i==="page"?8:6,background:S+"0D",overflow:"hidden",width:"100%",maxWidth:i==="page"?280:void 0},children:[t.jsxs("div",{className:"flex items-start gap-2",style:{padding:i==="page"?"9px 10px":"7px 8px",fontSize:C.text},children:[t.jsxs("button",{onClick:l,className:"text-left",style:{display:"block",flex:1,minWidth:0,background:"none",border:"none",cursor:"pointer",padding:0},title:`Go to ${(y==null?void 0:y.name)??m}`,children:[t.jsx("div",{style:{color:S,fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em"},children:x}),t.jsxs("div",{style:{color:r==="outgoing"?"#2563EB":"#059669",fontSize:C.meta,fontWeight:600,marginTop:4},children:[(f==null?void 0:f.label)??e.type," ",r==="outgoing"?"to":"from"]}),t.jsx("strong",{className:"truncate",style:{display:"block",color:g.primary,fontSize:C.text,fontWeight:650,marginTop:2},children:(y==null?void 0:y.name)??m}),(y==null?void 0:y.kind)&&t.jsx("div",{style:{color:g.muted,fontSize:"10px",marginTop:2},children:y.kind})]}),t.jsx("button",{onClick:()=>h(b=>!b),style:{background:"none",border:"none",cursor:"pointer",color:g.faint,padding:2},"aria-label":w?"Hide relationship details":"Show relationship details",children:w?"▾":"▸"})]}),w&&t.jsxs("div",{className:"px-3 pb-2 space-y-1",style:{fontSize:"10px",color:"#6B7280",borderTop:`1px solid ${g.borderLight}`,paddingTop:7},children:[t.jsx(ct,{label:"Kind",value:(y==null?void 0:y.kind)??"—",valueColor:S}),t.jsx(ct,{label:"Roles",value:`${e.sourceEnd||(f==null?void 0:f.sourceEnd.name)||"source"} → ${e.targetEnd||(f==null?void 0:f.targetEnd.name)||"target"}`}),t.jsx(ct,{label:"ID",value:e.id,mono:!0}),t.jsx(ct,{label:"Source",value:e.file||"—",mono:!0}),!e.named&&t.jsx("div",{style:{color:"#D97706"},children:"Anonymous connection — name it in SysML to allow deletion from here."}),A&&!a&&t.jsx("button",{onClick:c,className:"px-1.5 py-0.5 rounded",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA",cursor:"pointer",fontSize:"10px"},children:"Remove relationship"}),a&&t.jsxs("div",{className:"p-1.5 rounded",style:{background:"#FEF2F2",border:"1px solid #FECACA"},children:[t.jsxs("div",{style:{color:"#DC2626"},children:["Remove ",(f==null?void 0:f.label)??e.type," to ",(y==null?void 0:y.name)??m,"? Both elements are kept."]}),t.jsxs("div",{className:"flex gap-1 mt-1",children:[t.jsx("button",{onClick:u,className:"px-1.5 py-0.5 rounded",style:{background:"#DC2626",color:"#FFFFFF",border:"none",cursor:"pointer",fontSize:"10px"},children:"Remove"}),t.jsx("button",{onClick:d,className:"px-1.5 py-0.5 rounded",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer",fontSize:"10px"},children:"Cancel"})]})]})]})]})}function ct({label:e,value:r,mono:n,valueColor:o}){return t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("span",{style:{minWidth:48,color:"#9CA3AF"},children:e}),t.jsx("span",{className:`truncate ${n?"font-mono":""}`,style:{color:o??"#374151"},title:r,children:r})]})}function bl({pending:e,model:r,onDismiss:n}){const o=e.direction==="outgoing"?e.targetId:e.sourceId,s=r.elements[o],i=e.status==="failed";return t.jsxs("div",{className:"flex items-center gap-1.5 ml-2 rounded",style:{padding:"4px 8px",fontSize:j.xs,background:i?"#FEF2F2":"#F9FAFB",color:i?"#DC2626":"#6B7280",fontStyle:i?"normal":"italic"},children:[t.jsx("span",{children:e.direction==="outgoing"?"→":"←"}),t.jsx("span",{className:"px-1 py-0.5 rounded flex-shrink-0",style:{background:"#E5E7EB",color:"#6B7280",fontSize:j.xs},children:e.label}),t.jsx("span",{className:"truncate flex-1",children:(s==null?void 0:s.name)??o}),i?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",style:{fontSize:"10px",maxWidth:90},title:e.error,children:e.error}),t.jsx("button",{onClick:n,style:{background:"none",border:"none",cursor:"pointer",color:"inherit"},"aria-label":"Dismiss failed relationship",children:"×"})]}):t.jsx("span",{style:{fontSize:"10px"},children:"saving…"})]})}const ut="panel";function ie({title:e,count:r,defaultOpen:n=!0,actions:o,children:s}){const[i,a]=p.useState(n);return t.jsxs("div",{style:{borderBottom:"1px solid #EDEDEA"},children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 cursor-pointer transition-colors",style:{borderRadius:"6px",margin:"2px 4px"},onMouseEnter:l=>l.currentTarget.style.background="#F0F0ED",onMouseLeave:l=>l.currentTarget.style.background="transparent",onClick:()=>a(l=>!l),children:[t.jsx("span",{className:"font-medium flex-1 text-xs",style:{color:"#374151"},children:e}),o&&t.jsx("span",{onClick:l=>l.stopPropagation(),children:o}),typeof r=="number"&&t.jsx("span",{className:"text-xs",style:{color:"#9CA3AF"},children:r}),t.jsx("span",{style:{color:"#D1D5DB"},children:i?"▾":"▸"})]}),i&&t.jsx("div",{className:"px-4 pb-3",children:s})]})}function vl({label:e,kind:r,kindColor:n,onClick:o,arrow:s,typeBadge:i,typeColor:a,selected:l}){return t.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer transition-colors ml-2",style:{borderRadius:"6px",padding:"4px 8px",background:l?"#2DD4A818":"transparent",color:l?"#1B3A4B":"#374151",fontWeight:l?500:400,fontSize:j.xs},onMouseEnter:c=>{l||(c.currentTarget.style.background="#F0F0ED")},onMouseLeave:c=>{l||(c.currentTarget.style.background="transparent")},onClick:o,children:[s&&t.jsx("span",{style:{color:"#9CA3AF"},children:s}),i&&t.jsx("span",{className:"px-1 py-0.5 rounded",style:{background:(a||"#2563EB")+"18",color:a||"#2563EB",fontSize:j.xs},children:i}),t.jsx("span",{className:"truncate",children:e}),r&&t.jsx("span",{className:"ml-auto flex-shrink-0 px-1 py-0.5 rounded",style:{background:(n||"#666")+"15",color:n||"#666",fontSize:j.badge},children:r})]})}function wl(){const e=E(a=>a.model),r=E(a=>a.activeView),n=r.type==="diagram"?r.diagramId:null,o=vt(e,n);if(!o)return null;const s=Re[o.diagramType],i={borderBottom:"1px solid #EDEDEA"};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"p-4",style:{...i,borderLeft:`3px solid ${(s==null?void 0:s.color)||"#6B7280"}`},children:[t.jsx("div",{className:"text-sm font-semibold truncate",style:{color:"#1a1a1a"},children:o.name}),t.jsxs("div",{className:"flex items-center gap-2 text-xs mt-1.5",children:[s&&t.jsx("span",{className:"px-2 py-0.5 rounded-md font-medium",style:{background:s.color+"18",color:s.color},children:s.code}),t.jsx("span",{style:{color:"#6B7280"},children:(s==null?void 0:s.fullName)||o.diagramType})]}),o.auto&&t.jsx("div",{className:"text-xs mt-1",style:{color:"#6B7280"},children:"Auto-generated"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.description&&t.jsx(ie,{title:"Description",defaultOpen:!0,children:t.jsx("div",{className:"text-xs leading-relaxed",style:{color:"#374151"},children:o.description})}),t.jsx(ie,{title:"Details",defaultOpen:!0,children:t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex text-xs",children:[t.jsx("span",{className:"min-w-[80px]",style:{color:"#6B7280"},children:"ID"}),t.jsx("span",{className:"truncate font-mono",style:{color:"#1a1a1a",fontSize:j.xs},children:o.id})]}),t.jsxs("div",{className:"flex text-xs",children:[t.jsx("span",{className:"min-w-[80px]",style:{color:"#6B7280"},children:"Viewpoint"}),t.jsx("span",{style:{color:"#1a1a1a"},children:o.viewpointId})]}),t.jsxs("div",{className:"flex text-xs",children:[t.jsx("span",{className:"min-w-[80px]",style:{color:"#6B7280"},children:"Type"}),t.jsx("span",{style:{color:"#1a1a1a"},children:o.diagramType})]})]})}),o.properties&&Object.keys(o.properties).length>0&&t.jsx(ie,{title:"Properties",count:Object.keys(o.properties).length,children:t.jsx("div",{className:"space-y-1.5",children:Object.entries(o.properties).map(([a,l])=>t.jsxs("div",{className:"flex text-xs",children:[t.jsx("span",{className:"min-w-[80px]",style:{color:"#6B7280"},children:a}),t.jsx("span",{className:"truncate",style:{color:"#1a1a1a"},children:l})]},a))})}),o.elementIds&&o.elementIds.length>0&&t.jsx(ie,{title:"Scoped Elements",count:o.elementIds.length,defaultOpen:!1,children:t.jsx("div",{className:"text-xs",style:{color:"#6B7280"},children:o.elementIds.join(", ")})}),o.relationshipTypes&&o.relationshipTypes.length>0&&t.jsx(ie,{title:"Relationship Types",count:o.relationshipTypes.length,children:t.jsx("div",{className:"flex flex-wrap gap-1",children:o.relationshipTypes.map(a=>t.jsx("span",{className:"px-1.5 py-0.5 rounded text-xs",style:{background:"#EFF6FF",color:"#2563EB",fontSize:j.xs},children:a},a))})})]})]})}const Sl=4e3;function kl({elementId:e}){const r=E(a=>a.model),n=E(a=>a.lastSourceChange),[o,s]=p.useState(null),i=p.useMemo(()=>ti(r,e),[r,e]);return p.useEffect(()=>{if(!ni(n,i))return;s(n.at);const a=setTimeout(()=>s(null),Sl);return()=>clearTimeout(a)},[n==null?void 0:n.seq]),p.useEffect(()=>{s(null)},[e]),o?t.jsx("span",{title:"A source file this element depends on changed; the model was rebuilt",className:"px-1.5 rounded",style:{fontSize:j.badge,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0"},children:"↻ Updated"}):null}function El(){var C,A;const e=E(b=>b.model),r=E(b=>b.selectedElementId),n=E(b=>b.validation),o=E(b=>b.selectElement),s=E(b=>b.updateElementField),i=E(b=>b.updateElementAttribute),a=E(b=>b.applyEdit),[l,c]=p.useState(!1);p.useEffect(()=>{c(!1)},[r]),p.useEffect(()=>{if(!r)return;const b=R=>{(R.metaKey||R.ctrlKey)&&R.key==="s"&&(R.preventDefault(),a(r),c(!1))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[r,a]);const d=p.useMemo(()=>r&&e?ei(e,r):[],[e,r]);if(!r||!e)return null;const u=e.elements[r];if(!u)return null;const m=d.filter(b=>b.sourceId===r),y=d.filter(b=>b.targetId===r),S=ne[u.layer]||"#666",x=(n==null?void 0:n.violations.filter(b=>b.elementId===r))||[],f=Object.entries(u.attributes).filter(([b])=>b!=="name"&&b!=="id"),w=b=>{s(r,"doc",b),a(r)},h=(b,R)=>{i(r,b,R),a(r)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"p-4",style:{borderBottom:"1px solid #EDEDEA",borderLeft:`3px solid ${S}`},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2.5 h-2.5 flex-shrink-0",style:{background:S,borderRadius:"3px"}}),t.jsx("span",{className:"text-sm font-semibold truncate",style:{color:"#1a1a1a"},children:u.name})]}),t.jsx("div",{className:"flex items-center gap-2 text-xs",children:t.jsx("span",{className:"px-2 py-0.5 rounded-md font-medium",style:{background:S+"18",color:S},children:u.kind})}),t.jsxs("div",{className:"text-xs mt-1.5 capitalize",style:{color:"#6B7280"},children:[u.layer," layer"]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx(ie,{title:"Description",defaultOpen:!0,children:t.jsx("div",{className:"text-xs leading-relaxed",children:t.jsx(On,{value:u.doc||"",onSave:w,density:ut,multiline:!0,placeholder:"Click to add a description…"})})}),u.parameters&&u.parameters.length>0&&t.jsx(ie,{title:"Parameters",count:u.parameters.length,children:t.jsx("div",{className:"space-y-1.5",children:u.parameters.map(b=>t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"px-1.5 py-0.5 rounded font-mono",style:{fontSize:"10px",background:b.direction==="in"?"#EFF6FF":b.direction==="out"?"#FFF7ED":"#F0FDF4",color:b.direction==="in"?"#2563EB":b.direction==="out"?"#EA580C":"#16A34A"},children:b.direction}),t.jsx("span",{style:{color:"#374151",fontWeight:500},children:b.name}),t.jsx("span",{style:{color:"#6B7280"},children:":"}),t.jsx("span",{style:{color:"#6B7280"},children:b.type})]},b.name))})}),u.allocatedTo&&t.jsx(ie,{title:"Allocated To",defaultOpen:!0,children:t.jsx(vl,{label:((C=e.elements[u.allocatedTo])==null?void 0:C.name)||u.allocatedTo,kind:(A=e.elements[u.allocatedTo])==null?void 0:A.kind,kindColor:"#E67E22",arrow:"→",onClick:()=>o(u.allocatedTo)})}),f.length>0&&t.jsx(ie,{title:"Attributes",count:f.length,defaultOpen:!0,children:t.jsx("div",{className:"space-y-1.5",children:f.map(([b,R])=>{const T=ul(b);return t.jsxs("div",{className:"flex text-xs items-start gap-1.5",children:[t.jsx("span",{className:"min-w-[80px] pt-0.5",style:{color:"#6B7280"},children:b}),t.jsx("div",{style:{flex:1,minWidth:0},children:Dr(T)?t.jsx(On,{value:String(R??""),onSave:O=>h(b,O),density:ut,placeholder:"Click to set…"}):t.jsx(ml,{value:String(R??""),editability:T,density:ut,mono:!0})})]},b)})})}),t.jsx(yl,{element:u,outgoing:m,incoming:y,density:ut}),x.length>0&&t.jsx(ie,{title:"Guidance",count:x.length,defaultOpen:!0,children:t.jsx("div",{className:"space-y-2",children:x.map((b,R)=>t.jsxs("div",{className:"text-xs p-2.5 rounded-lg",style:{background:b.severity==="error"?"#FEF2F2":b.severity==="warning"?"#FFFBEB":"#EFF6FF",border:`1px solid ${b.severity==="error"?"#FECACA":b.severity==="warning"?"#FDE68A":"#BFDBFE"}`},children:[t.jsx("div",{style:{color:b.severity==="error"?"#DC2626":b.severity==="warning"?"#D97706":"#2563EB"},children:b.description}),t.jsxs("div",{className:"mt-0.5",style:{color:"#6B7280"},children:["[",b.ruleId,"]"]})]},`${b.ruleId}-${R}`))})}),x.length===0&&t.jsx("div",{className:"p-4",children:t.jsxs("div",{className:"text-xs flex items-center gap-1",style:{color:"#10B981"},children:[t.jsx("span",{children:"✓"})," All rules satisfied"]})}),u.file&&t.jsx(ie,{title:"Source",defaultOpen:!1,actions:t.jsx(kl,{elementId:r}),children:t.jsxs("button",{className:"flex items-center gap-1.5 text-xs w-full text-left rounded px-1 py-0.5 transition-colors",style:{color:"#2563EB",background:"transparent",border:"none",cursor:"pointer",wordBreak:"break-all"},onMouseEnter:b=>{b.currentTarget.style.background="#EFF6FF"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{navigator.clipboard.writeText(u.file).catch(()=>{})},title:"Click to copy path",children:[t.jsx("span",{style:{flexShrink:0},children:"⟨/⟩"}),t.jsx("span",{className:"font-mono truncate",children:u.file}),t.jsx("span",{style:{flexShrink:0,color:"#9CA3AF",fontSize:"9px"},children:"copy"})]})})]})]})}function Cl(){const e=E(d=>d.model),r=E(d=>d.selectedRelationshipId);if(!e||!r)return null;const n=e.relationships.find(d=>d.id===r);if(!n)return null;const o=e.elements[n.sourceId],s=e.elements[n.targetId],i=n.type==="flow",a=n.flowItem,l=a&&/energy|power|voltage|current/i.test(a)?"Energy":a&&/material|fluid|gas|batch/i.test(a)?"Material":i?"Data":"Control",c=l==="Energy"?"#D97706":l==="Material"?"#16A34A":l==="Data"?"#3498DB":"#4B5563";return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"p-4",style:{borderBottom:"1px solid #EDEDEA",borderLeft:`3px solid ${c}`},children:[t.jsx("div",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Connection"}),t.jsxs("div",{className:"mt-1 text-xs",style:{color:"#6B7280"},children:[(o==null?void 0:o.name)??n.sourceId," → ",(s==null?void 0:s.name)??n.targetId]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-xs font-medium",style:{background:c+"18",color:c},children:[l," flow"]}),t.jsx("span",{className:"px-2 py-0.5 rounded-md text-xs font-medium",style:{background:"#F3F4F6",color:"#374151"},children:n.type})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx(ie,{title:"Involved item",defaultOpen:!0,children:t.jsx("div",{className:"text-xs",style:{color:"#374151"},children:a??"No transported item is modeled for this connection."})}),t.jsx(ie,{title:"Endpoints",defaultOpen:!0,children:t.jsxs("div",{className:"space-y-2 text-xs",children:[t.jsxs("div",{children:[t.jsx("span",{style:{color:"#6B7280"},children:"Source"}),t.jsx("div",{style:{color:"#1a1a1a",fontWeight:500},children:(o==null?void 0:o.name)??n.sourceId})]}),t.jsxs("div",{children:[t.jsx("span",{style:{color:"#6B7280"},children:"Target"}),t.jsx("div",{style:{color:"#1a1a1a",fontWeight:500},children:(s==null?void 0:s.name)??n.targetId})]})]})}),t.jsx(ie,{title:"Traceability",defaultOpen:!1,children:t.jsx("div",{className:"text-xs",style:{color:"#6B7280"},children:n.file||"Model relationship"})})]})]})}function jl(){const e=E(l=>l.selectedElementId),r=E(l=>l.activeView),n=E(l=>l.selectedRelationshipId),o=E(l=>l.propertiesPanelCollapsed),s=E(l=>l.togglePropertiesPanel);if(o)return t.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 cursor-pointer",style:{width:"40px",background:"#FAFAF8",borderLeft:"1px solid #E5E5E0"},onClick:s,title:"Expand properties",children:[t.jsx("div",{className:"flex items-center justify-center mt-2",style:{color:"#6B7280",fontSize:"20px",width:"32px",height:"32px",borderRadius:"6px"},children:"◂"}),t.jsx("div",{style:{writingMode:"vertical-rl",textOrientation:"mixed",color:"#6B7280",fontSize:"12px",fontWeight:600,letterSpacing:"0.1em"},children:"Properties"})]});const i=r.type==="diagram"&&!e&&!n,a=!!e;return t.jsxs("div",{className:"flex flex-col overflow-hidden flex-shrink-0",style:{width:"300px",background:"#FAFAF8",borderLeft:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid #EDEDEA"},children:[t.jsx("span",{className:"text-xs font-medium",style:{color:"#6B7280"},children:"Properties"}),t.jsx("button",{onClick:s,className:"flex items-center justify-center",style:{color:"#6B7280",fontSize:"20px",lineHeight:1,width:"32px",height:"32px",borderRadius:"6px"},onMouseEnter:l=>l.currentTarget.style.color="#374151",onMouseLeave:l=>l.currentTarget.style.color="#6B7280",title:"Collapse properties","aria-label":"Collapse properties",children:"▸"})]}),n?t.jsx(Cl,{}):a?t.jsx(El,{}):i?t.jsx(wl,{}):t.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:t.jsx("span",{className:"text-xs text-center",style:{color:"#6B7280"},children:"Select an element or diagram to view properties"})})]})}function It(e=g.border){return{borderTop:`1px solid ${e}`}}function Dl({placeholder:e,value:r,onChange:n}){return t.jsx("input",{type:"text",value:r,placeholder:e,onChange:o=>n(o.target.value),className:"flex-1 px-2 py-1 rounded focus:outline-none",style:{background:"#F7F7F5",border:"1px solid #E5E5E0",color:g.primary,fontSize:j.xs,minWidth:0}})}function Al({values:e}){const r=[...new Set(e.filter(Boolean))];return r.length===0?t.jsx("span",{style:{color:g.faint,fontSize:"12px"},children:"—"}):r.length===1?t.jsx("span",{style:{color:g.muted,fontSize:"12px"},children:r[0]}):t.jsxs("span",{style:{color:"#F59E0B",fontSize:"12px"},children:[r.length," different values"]})}function Rl(){const e=E(f=>f.model),r=E(f=>f.selectedElementIds),n=E(f=>f.clearElementSelection),o=E(f=>f.bulkUpdateAttributes),s=p.useMemo(()=>[...r],[r]),i=p.useMemo(()=>s.map(f=>e==null?void 0:e.elements[f]).filter(Boolean),[s,e]),a=p.useMemo(()=>{if(i.length===0)return[];const f="_",w=i.map(C=>new Set(Object.keys(C.attributes).filter(A=>!A.startsWith(f))));return[...w[0]].filter(C=>w.every(A=>A.has(C))).sort()},[i]),l=p.useMemo(()=>{const f={};for(const w of a)f[w]=i.map(h=>h.attributes[w]??"");return f},[i,a]),c=p.useMemo(()=>[...new Set(i.map(f=>f.kind))].sort(),[i]),[d,u]=p.useState({}),m=p.useCallback((f,w)=>{u(h=>({...h,[f]:w}))},[]),y=Object.values(d).some(f=>f!==""),S=p.useCallback(()=>{const f=Object.fromEntries(Object.entries(d).filter(([,w])=>w!==""));Object.keys(f).length!==0&&(o(s,f),u({}))},[d,s,o]),x=p.useCallback(()=>{u({})},[]);return i.length<2?null:t.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:"280px",background:g.surface,borderLeft:`1px solid ${g.border}`,fontSize:j.xs},children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",style:{borderBottom:`1px solid ${g.border}`},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold",style:{color:g.primary,fontSize:j.sm},children:"Bulk Edit"}),t.jsxs("div",{style:{color:g.muted,fontSize:"12px",marginTop:"2px"},children:[s.length," elements selected"]})]}),t.jsx("button",{onClick:n,className:"px-2 py-1 rounded",style:{color:g.muted,background:"#F0F0ED",fontSize:"12px"},title:"Clear selection",children:"✕ Clear"})]}),t.jsxs("div",{className:"px-4 py-3 flex-shrink-0",style:It(),children:[t.jsx("div",{style:{color:g.muted,fontSize:"12px",fontWeight:600,marginBottom:"6px",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Selection"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:c.map(f=>t.jsx("span",{className:"px-2 py-0.5 rounded-full",style:{background:"#EEF2FF",color:"#4F46E5",fontSize:"12px",fontWeight:500},children:f},f))}),t.jsxs("div",{style:{color:g.faint,fontSize:"12px",marginTop:"6px"},children:[i.map(f=>f.name).slice(0,5).join(", "),i.length>5&&` +${i.length-5} more`]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3",style:It(),children:[t.jsxs("div",{style:{color:g.muted,fontSize:"12px",fontWeight:600,marginBottom:"8px",textTransform:"uppercase",letterSpacing:"0.5px"},children:["Common Attributes",a.length>0&&t.jsxs("span",{style:{color:g.faint,fontWeight:400,marginLeft:"4px"},children:["(",a.length,")"]})]}),a.length===0?t.jsx("div",{style:{color:g.faint,fontSize:"12px"},children:"No common attributes across selected elements."}):t.jsx("div",{className:"space-y-3",children:a.map(f=>t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{color:g.secondary,fontSize:"12px",fontWeight:500},children:f}),t.jsx(Al,{values:l[f]})]}),t.jsx(Dl,{placeholder:`Set for all ${s.length} elements…`,value:d[f]??"",onChange:w=>m(f,w)})]},f))})]}),a.length>0&&t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 flex-shrink-0",style:It(),children:[t.jsx("button",{onClick:x,disabled:!y,className:"flex-1 py-1.5 rounded",style:{fontSize:j.xs,fontWeight:500,color:y?g.secondary:g.faint,background:y?"#F0F0ED":"#F7F7F5",cursor:y?"pointer":"default"},children:"Reset"}),t.jsxs("button",{onClick:S,disabled:!y,className:"flex-1 py-1.5 rounded font-semibold",style:{fontSize:j.xs,color:"#FFFFFF",background:y?"#2DD4A8":"#A7F3D0",cursor:y?"pointer":"default"},children:["Apply to ",s.length]})]})]})}const zn="memo-gapbar-pulse";if(typeof document<"u"&&!document.getElementById(zn)){const e=document.createElement("style");e.id=zn,e.textContent=`
3269
- @keyframes memo-pulse-red {
3270
- 0%, 100% { opacity: 1; }
3271
- 50% { opacity: 0.35; }
3272
- }
3273
- `,document.head.appendChild(e)}const pt={error:{color:"#DC2626",bg:"#FEF2F2",icon:"✖"},warning:{color:"#D97706",bg:"#FFFBEB",icon:"⚠"},info:{color:"#2563EB",bg:"#EFF6FF",icon:"ℹ"}};function Fl(){const e=E(F=>F.validation),r=E(F=>F.analysisIssues),n=E(F=>F.selectElement),o=E(F=>F.model),s=E(F=>F.completeness),i=E(F=>F.gapBarExpanded),a=E(F=>F.toggleGapBar),l=E(F=>F.gapBarHeight),c=E(F=>F.setGapBarHeight),[d,u]=p.useState("problems"),m=p.useRef(!1),y=p.useRef(0),S=p.useRef(0),x=o==null?void 0:o.metadata,f=o?Object.keys(o.elements).length:0,w=x!=null&&x.gitUser?t.jsxs(t.Fragment,{children:["@",x.gitUser,x.gitBranch&&t.jsxs(t.Fragment,{children:[" · ",x.gitBranch]}),x.gitCommitShort&&t.jsx("span",{style:{marginLeft:"4px",fontFamily:"monospace",fontSize:j.badge},children:x.gitCommitShort})]}):null,h=(e==null?void 0:e.violations.filter(F=>F.severity==="error"))??[],C=(e==null?void 0:e.violations.filter(F=>F.severity==="warning"))??[],A=(e==null?void 0:e.violations.length)??0,b=r.filter(F=>F.severity==="warning").length,R=A>0||r.length>0,T=!!s,O=R&&T,D=(s==null?void 0:s.layers.filter(F=>F.totalElements>0))??[],P=p.useCallback(F=>{F.preventDefault(),m.current=!0,y.current=F.clientY,S.current=l;const N=Z=>{if(!m.current)return;const ee=y.current-Z.clientY;c(S.current+ee)},L=()=>{m.current=!1,document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",L)},[l,c]);return t.jsxs("div",{style:{background:g.surface,borderTop:`1px solid ${g.border}`,flexShrink:0},children:[i&&t.jsx("div",{style:{height:"4px",cursor:"row-resize",background:"transparent",flexShrink:0},onMouseDown:P,onMouseEnter:F=>{F.currentTarget.style.background=g.accent+"40"},onMouseLeave:F=>{F.currentTarget.style.background="transparent"}}),t.jsxs("div",{className:"flex items-center px-4 gap-3 cursor-pointer select-none",style:{height:"32px",fontSize:j.sm},onClick:a,children:[t.jsx("span",{style:{color:g.faint,fontSize:"10px",transition:"transform 150ms ease",transform:i?"rotate(0deg)":"rotate(-90deg)",display:"inline-block"},children:"▼"}),t.jsx("span",{style:{color:g.secondary,fontWeight:600,fontSize:j.xs},children:"Problems"}),h.length>0&&t.jsxs("span",{className:"flex items-center gap-1",style:{color:"#DC2626",fontSize:j.xs},children:[t.jsx("span",{style:{fontSize:"10px"},children:"✖"})," ",h.length]}),C.length>0&&t.jsxs("span",{className:"flex items-center gap-1",style:{color:"#D97706",fontSize:j.xs},children:[t.jsx("span",{style:{fontSize:"10px"},children:"⚠"})," ",C.length]}),b>0&&t.jsxs("span",{className:"flex items-center gap-1",style:{color:"#D97706",fontSize:j.xs},children:[t.jsx("span",{style:{fontSize:"9px",opacity:.7},children:"DSM"}),t.jsx("span",{style:{fontSize:"10px"},children:"⚠"})," ",b]}),!R&&e&&t.jsx("span",{style:{color:"#10B981",fontSize:j.xs},children:"✓ No problems"}),!e&&t.jsx("span",{style:{color:g.faint,fontSize:j.xs},children:"Waiting for validation…"}),T&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{width:"1px",height:"14px",background:g.border,flexShrink:0}}),t.jsx("span",{style:{color:g.secondary,fontWeight:600,fontSize:j.xs},children:"Completeness"}),t.jsxs("span",{style:{color:s.overall>=80?"#10B981":s.overall>=50?"#D97706":"#DC2626",fontSize:j.xs,fontWeight:600},children:[s.overall,"%"]}),t.jsx("div",{className:"flex items-center gap-0.5",children:D.map(F=>{const N=F.percentage<40;return t.jsx("div",{title:`${Xe[F.layerId]||F.layerLabel}: ${F.percentage}%`,style:{width:8,height:8,borderRadius:"2px",background:F.layerColor,opacity:Math.max(F.percentage/100,.12),flexShrink:0,animation:N?"memo-pulse-red 1.4s ease-in-out infinite":"none",cursor:"default"}},F.layerId)})})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-1",style:{fontSize:j.xs},children:[e&&t.jsxs("span",{style:{color:g.faint},children:[e.rulesEvaluated," rules | ",e.rulesPassed," passed |"," "]}),t.jsxs("strong",{style:{color:g.secondary,fontWeight:700},children:[f," elements"]}),o&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:g.faint},children:" · "}),t.jsxs("strong",{style:{color:g.secondary,fontWeight:700},children:[o.relationships.length," rels"]})]}),w&&t.jsxs("span",{style:{color:g.faint},children:[" | ",w]})]})]}),i&&t.jsxs("div",{style:{borderTop:`1px solid ${g.borderLight}`},children:[O&&t.jsx("div",{className:"flex",style:{borderBottom:`1px solid ${g.border}`,background:"#FAFAF8"},children:["problems","completeness"].map(F=>t.jsx("button",{onClick:N=>{N.stopPropagation(),u(F)},className:"px-4 py-1.5 font-medium transition-colors",style:{fontSize:j.xs,borderBottom:d===F?`2px solid ${g.accent}`:"2px solid transparent",color:d===F?g.accentDark:g.faint,background:"transparent"},children:F==="problems"?`Problems (${A+r.length})`:`Completeness ${s.overall}%`},F))}),(d==="problems"||!O)&&t.jsx("div",{className:"overflow-y-auto",style:{maxHeight:`${l}px`},children:R?t.jsxs(t.Fragment,{children:[A>0&&(e==null?void 0:e.violations.map((F,N)=>{const L=pt[F.severity]||pt.info;return t.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 cursor-pointer transition-colors",style:{color:L.color,fontSize:j.xs},onMouseEnter:Z=>Z.currentTarget.style.background=L.bg,onMouseLeave:Z=>Z.currentTarget.style.background="transparent",onClick:()=>n(F.elementId),children:[t.jsx("span",{children:L.icon}),t.jsxs("span",{style:{color:g.faint},children:["[",F.ruleId,"]"]}),t.jsxs("span",{className:"font-medium",children:[F.elementKind,"/",F.elementName]}),t.jsx("span",{className:"truncate flex-1",style:{color:g.muted},children:F.description})]},`${F.ruleId}-${F.elementId}-${N}`)})),r.length>0&&t.jsxs(t.Fragment,{children:[A>0&&t.jsx("div",{style:{padding:"4px 16px",fontSize:"10px",fontWeight:600,color:g.faint,background:g.surfaceAlt,borderTop:`1px solid ${g.border}`,textTransform:"uppercase",letterSpacing:"0.06em"},children:"DSM Analysis"}),r.map(F=>{const N=pt[F.severity]||pt.info;return t.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 cursor-pointer transition-colors",style:{color:N.color,fontSize:j.xs},onMouseEnter:L=>L.currentTarget.style.background=N.bg,onMouseLeave:L=>L.currentTarget.style.background="transparent",onClick:()=>n(F.elementId),children:[t.jsx("span",{children:N.icon}),t.jsxs("span",{style:{color:g.faint},children:["[",F.source,"]"]}),t.jsx("span",{className:"font-medium",children:F.elementName}),t.jsx("span",{className:"truncate flex-1",style:{color:g.muted},children:F.message}),F.tag&&t.jsx("span",{style:{flexShrink:0,fontSize:"9px",padding:"1px 5px",borderRadius:"4px",background:"#E5E7EB",color:"#374151"},children:F.tag})]},F.id)})]})]}):t.jsx("div",{className:"px-4 py-3",style:{color:g.faint,fontSize:j.xs},children:e?"✓ No problems found":"Waiting for validation…"})}),(d==="completeness"||!O)&&T&&t.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:`${l}px`},children:[t.jsxs("div",{className:"px-4 py-2 flex items-center gap-3",style:{borderBottom:`1px solid ${g.borderLight}`},children:[t.jsxs("span",{style:{fontWeight:700,fontSize:"18px",color:s.overall>=80?"#10B981":s.overall>=50?"#D97706":"#DC2626"},children:[s.overall,"%"]}),t.jsx("div",{className:"flex-1 flex items-center gap-0.5",style:{height:"8px"},children:D.map(F=>{const N=Math.max(F.totalElements/s.totalElements*100,2);return t.jsx("div",{style:{width:`${N}%`,height:"100%",background:F.layerColor+"30",borderRadius:"4px",overflow:"hidden"},children:t.jsx("div",{style:{width:`${F.percentage}%`,height:"100%",background:F.layerColor,borderRadius:"4px"}})},F.layerId)})}),t.jsxs("span",{style:{color:g.faint,fontSize:j.xs},children:[s.completeElements,"/",s.totalElements]})]}),t.jsx("div",{className:"px-4 py-2 grid gap-1.5",style:{gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))"},children:D.map(F=>t.jsxs("div",{className:"flex items-center gap-2",style:{fontSize:j.xs},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:F.layerColor}}),t.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:Xe[F.layerId]||F.layerLabel}),t.jsxs("span",{style:{color:"#6B7280"},children:[F.percentage,"%"]}),t.jsxs("span",{style:{color:"#9CA3AF"},children:["(",F.completeElements,"/",F.totalElements,")"]})]},F.layerId))})]})]})]})}function Tl(){const[e,r]=p.useState(!1),[n,o]=p.useState(""),[s,i]=p.useState(0),a=p.useRef(null),l=E(w=>w.model),c=E(w=>w.selectElement),d=E(w=>w.setActiveView),u=E(w=>w.selectViewpoint),m=E(w=>w.setExplorerTab);p.useEffect(()=>{const w=h=>{(h.metaKey||h.ctrlKey)&&h.key==="k"&&(h.preventDefault(),r(C=>!C),o(""),i(0)),h.key==="Escape"&&e&&r(!1)};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]),p.useEffect(()=>{e&&setTimeout(()=>{var w;return(w=a.current)==null?void 0:w.focus()},50)},[e]);const y=p.useMemo(()=>{const w=[];if(w.push({id:"tool:dsm",label:"DSM",sublabel:"Design Structure Matrix",kind:"tool",action:()=>d({type:"dsm"})},{id:"tool:traceability",label:"Traceability Matrix",sublabel:"N×N trace matrix with presets",kind:"tool",action:()=>d({type:"traceability"})},{id:"tool:ontology",label:"Ontology",sublabel:"Ontology Viewer",kind:"tool",action:()=>d({type:"ontology"})}),!l)return w;for(const h of l.diagrams??[]){const C=Re[h.diagramType];w.push({id:`diag:${h.id}`,label:h.name,sublabel:(C==null?void 0:C.fullName)||h.diagramType,kind:"diagram",color:C==null?void 0:C.color,action:()=>{d({type:"diagram",diagramId:h.id}),u(h.viewpointId==="__model"?null:h.viewpointId),m("views")}})}for(const h of l.viewpoints??[])w.push({id:`vp:${h.id}`,label:h.label,sublabel:"Viewpoint",kind:"viewpoint",action:()=>{u(h.id),m("views")}});for(const h of Object.values(l.elements))w.push({id:`el:${h.id}`,label:h.name,sublabel:`${h.kind} · ${h.layer}`,kind:"element",color:ne[h.layer],action:()=>{c(h.id),m("model")}});return w},[l,d,c,u,m]),S=p.useMemo(()=>{if(!n)return y.slice(0,20);const w=n.toLowerCase();return y.filter(h=>{var C;return h.label.toLowerCase().includes(w)||((C=h.sublabel)==null?void 0:C.toLowerCase().includes(w))}).slice(0,20)},[y,n]);p.useEffect(()=>{i(0)},[S]);const x=p.useCallback(w=>{w.key==="ArrowDown"&&(w.preventDefault(),i(h=>Math.min(h+1,S.length-1))),w.key==="ArrowUp"&&(w.preventDefault(),i(h=>Math.max(h-1,0))),w.key==="Enter"&&S[s]&&(S[s].action(),r(!1))},[S,s]);if(!e)return null;const f={element:"○",diagram:"▦",tool:"⚙",viewpoint:"◉"};return t.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-24",style:{background:"rgba(0,0,0,0.4)"},onClick:()=>r(!1),children:t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{width:"520px",maxHeight:"400px",background:"#FFFFFF",boxShadow:"0 16px 48px rgba(0,0,0,0.2)"},onClick:w=>w.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",style:{borderBottom:"1px solid #E5E5E0"},children:[t.jsx("span",{style:{color:"#9CA3AF",fontSize:"14px"},children:"⌕"}),t.jsx("input",{ref:a,type:"text",placeholder:"Search elements, diagrams, tools...",value:n,onChange:w=>o(w.target.value),onKeyDown:x,className:"flex-1 text-sm focus:outline-none",style:{color:"#1a1a1a",background:"transparent"}}),t.jsx("kbd",{className:"px-1.5 py-0.5 rounded text-xs",style:{background:"#F0F0ED",color:"#9CA3AF",fontSize:"10px"},children:"ESC"})]}),t.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:"340px"},children:[S.length===0&&t.jsx("div",{className:"px-4 py-6 text-center text-xs",style:{color:"#9CA3AF"},children:"No results found"}),S.map((w,h)=>t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 cursor-pointer",style:{background:h===s?"#F0F0ED":"transparent"},onMouseEnter:()=>i(h),onClick:()=>{w.action(),r(!1)},children:[t.jsx("span",{style:{color:w.color||"#9CA3AF",fontSize:"12px"},children:f[w.kind]||"○"}),t.jsx("span",{className:"text-sm truncate",style:{color:"#1a1a1a"},children:w.label}),w.sublabel&&t.jsx("span",{className:"text-xs truncate ml-auto",style:{color:"#9CA3AF"},children:w.sublabel})]},w.id))]}),t.jsx("div",{className:"px-4 py-2 flex items-center gap-3",style:{borderTop:"1px solid #E5E5E0",background:"#FAFAF8"},children:t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:["↑↓"," navigate · ","↵"," select · esc close"]})})]})})}function Il(e){const r=e.trim().split(/\r?\n/).filter(Boolean);if(r.length<2)return{headers:[],rows:[]};const o=r[0].includes(" ")?" ":",",s=l=>l.split(o).map(c=>c.replace(/^"(.*)"$/,"$1").replace(/""/g,'"').trim()),i=s(r[0]),a=r.slice(1).map(l=>{const c=s(l),d={};return i.forEach((u,m)=>{d[u]=c[m]??""}),d});return{headers:i,rows:a}}const Ln=["id","name","kind","construct","doc","— skip —"];function _l(){const e=E(v=>v.bulkImportOpen),r=E(v=>v.setBulkImportOpen),n=E(v=>v.importResult),o=E(v=>v.clearImportResult),s=E(v=>v.model),i=p.useRef(null),[a,l]=p.useState("input"),[c,d]=p.useState(""),[u,m]=p.useState(null),[y,S]=p.useState("bulk_import"),[x,f]=p.useState(""),[w,h]=p.useState([]),[C,A]=p.useState([]),[b,R]=p.useState([]),[T,O]=p.useState([]),[D,P]=p.useState([]),[F,N]=p.useState([]),[L,Z]=p.useState(""),[ee,Q]=p.useState(!1);_r.useMemo(()=>s?Array.from(new Set(Object.values(s.elements).map(v=>v.kind))).sort():[],[s]),p.useEffect(()=>{e||(l("input"),d(""),m(null),S("bulk_import"),f(""),h([]),A([]),R([]),O([]),P([]),N([]),Z(""),Q(!1),o())},[e,o]),p.useEffect(()=>{n&&Q(!1)},[n]);const _=p.useCallback(()=>{r(!1)},[r]),W=p.useCallback(v=>{var q;const k=(q=v.target.files)==null?void 0:q[0];if(!k)return;const I=new FileReader;I.onload=$=>{var se;const J=(se=$.target)==null?void 0:se.result;d(J),f("");const z=k.name.replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9_]/g,"_");z&&S(z)},I.readAsText(k)},[]),K=p.useCallback(()=>{if(!c.trim()){f("Paste CSV data or upload a file first.");return}const{headers:v,rows:k}=Il(c);if(v.length===0){f("Could not parse headers. Make sure the first row contains column names.");return}if(k.length===0){f("No data rows found after the header row.");return}h(v),A(k),R(Ds(v,u??void 0)),f(""),l("mapping")},[c,u]),B=p.useCallback(()=>{const v=u==null?void 0:u.defaultKind,k=Rs(C,b,{},v);Z(k.csv),N(k.warnings);const I=k.csv.trim().split(`
3274
- `);if(I.length<2){P(["No rows to preview after applying mappings."]),O([]),l("preview");return}const q=I[0].split(",").map(z=>z.replace(/^"|"$/g,"").trim()),$=[],J=[];I.slice(1,21).forEach((z,se)=>{const ve=z.split(",").map(V=>V.replace(/^"|"$/g,"").trim()),ce={rowIndex:se+1,id:"",name:"",kind:"",doc:""};q.forEach((V,H)=>{ce[V]=ve[H]??""}),ce.id||J.push(`Row ${se+2}: missing id`),ce.name||J.push(`Row ${se+2}: missing name`),ce.kind||J.push(`Row ${se+2}: missing kind`),$.push(ce)}),O($),P(J),l("preview")},[C,b,u]),U=p.useCallback(()=>{L&&(Q(!0),o(),Ys({elementsCsv:L,packageName:y||"bulk_import"}))},[L,y,o]),re=p.useCallback((v,k)=>{R(I=>I.map((q,$)=>$===v?{...q,targetAttribute:k}:q))},[]);if(!e)return null;const fe={input:"1 · Input",mapping:"2 · Map columns",preview:"3 · Preview & Import"},be=["input","mapping","preview"],Y=be.indexOf(a);return t.jsx("div",{ref:i,className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.35)"},onMouseDown:v=>{v.target===i.current&&_()},children:t.jsxs("div",{className:"flex flex-col rounded-2xl overflow-hidden",style:{width:680,maxHeight:"90vh",background:"#FFFFFF",boxShadow:"0 24px 64px rgba(0,0,0,0.18)",border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{background:"linear-gradient(135deg, #1B3A4B, #2D6A7A)",flexShrink:0},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{fontSize:"15px",fontWeight:700,color:"#2DD4A8",margin:0},children:"Bulk Import Elements"}),t.jsx("p",{style:{fontSize:"12px",color:"rgba(255,255,255,0.6)",margin:"2px 0 0"},children:"Import from CSV, Excel paste, or requirements spreadsheet"})]}),t.jsx("button",{onClick:_,style:Nl,children:"✕"})]}),t.jsx("div",{className:"flex",style:{borderBottom:"1px solid #F0F0EC",background:"#FAFAF8",flexShrink:0},children:be.map((v,k)=>t.jsx("div",{className:"flex-1 flex items-center justify-center py-2.5",style:{fontSize:j.xs,fontWeight:k===Y?700:400,color:k===Y?"#1B3A4B":k<Y?"#2D6A7A":"#9CA3AF",borderBottom:k===Y?"2px solid #2D6A7A":"2px solid transparent"},children:fe[v]},v))}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5",style:{minHeight:0},children:[a==="input"&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{style:_t,children:"Artifact type (recipe preset)"}),t.jsxs("select",{value:(u==null?void 0:u.id)??"",onChange:v=>{const k=gn.find(I=>I.id===v.target.value)??null;m(k)},style:Nt,children:[t.jsx("option",{value:"",children:"— Custom / no preset —"}),gn.map(v=>t.jsx("option",{value:v.id,children:v.name},v.id))]}),u&&t.jsx("p",{style:{fontSize:j.xs,color:"#6B7280",marginTop:4},children:u.description})]}),t.jsxs("div",{children:[t.jsxs("label",{style:_t,children:["Package name ",t.jsx("span",{style:{color:"#9CA3AF",fontWeight:400},children:"(for the generated .sysml file)"})]}),t.jsx("input",{type:"text",value:y,onChange:v=>S(v.target.value.replace(/[^a-zA-Z0-9_]/g,"_")),style:Nt,placeholder:"bulk_import"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:_t,children:["CSV data ",t.jsx("span",{style:{color:"#E74C3C"},children:"*"})]}),t.jsx("textarea",{value:c,onChange:v=>{d(v.target.value),f("")},placeholder:`Paste CSV or tab-separated data here.
3275
- First row must be the header.
3276
-
3277
- Example:
3278
- id,name,kind,doc
3279
- req_001,System shall be safe,Requirement,Safety requirement`,rows:10,style:{...Nt,resize:"vertical",fontFamily:"monospace",fontSize:"12px",lineHeight:"1.5"}}),x&&t.jsx("p",{style:{fontSize:j.xs,color:"#E74C3C",marginTop:4},children:x})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{style:{fontSize:j.xs,color:"#6B7280"},children:"or upload a file:"}),t.jsxs("label",{style:{cursor:"pointer",padding:"4px 12px",borderRadius:6,background:"#F3F4F6",border:"1px solid #E5E5E0",fontSize:j.xs,color:"#374151"},children:["Browse…",t.jsx("input",{type:"file",accept:".csv,.tsv,.txt",style:{display:"none"},onChange:W})]}),c&&t.jsxs("span",{style:{fontSize:j.xs,color:"#6B7280"},children:[c.split(`
3280
- `).length," line(s) loaded"]})]})]}),a==="mapping"&&t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("p",{style:{fontSize:j.xs,color:"#6B7280",margin:0},children:["Map each source column to a MEMO attribute. ",t.jsx("strong",{children:"id"}),", ",t.jsx("strong",{children:"name"}),", and ",t.jsx("strong",{children:"kind"})," are required. Unrecognised columns are passed through as dynamic attributes."]}),t.jsxs("div",{style:{border:"1px solid #E5E5E0",borderRadius:8,overflow:"hidden"},children:[t.jsxs("div",{className:"flex",style:{background:"#F8F8F5",padding:"8px 12px",borderBottom:"1px solid #E5E5E0"},children:[t.jsx("span",{style:{flex:1,fontSize:j.xs,fontWeight:600,color:"#374151"},children:"Source column"}),t.jsx("span",{style:{flex:1,fontSize:j.xs,fontWeight:600,color:"#374151"},children:"Maps to"}),t.jsx("span",{style:{width:80,fontSize:j.xs,fontWeight:600,color:"#374151"},children:"Transform"})]}),b.map((v,k)=>{const I=["id","name","kind"].includes(v.targetAttribute),q=!v.targetAttribute,$=b.filter((z,se)=>se!==k&&["id","name","kind","doc","construct"].includes(z.targetAttribute)).map(z=>z.targetAttribute),J=Ln.filter(z=>z==="— skip —"||!$.includes(z)||z===v.targetAttribute);return t.jsxs("div",{className:"flex items-center",style:{padding:"6px 12px",borderBottom:k<b.length-1?"1px solid #F0F0EC":"none",background:I?"#F0FDF4":"transparent"},children:[t.jsx("div",{style:{flex:1,fontSize:j.xs,color:"#374151",fontFamily:"monospace"},children:v.sourceColumn}),t.jsx("div",{style:{flex:1,paddingRight:8},children:t.jsxs("select",{value:v.targetAttribute||"",onChange:z=>re(k,z.target.value==="— skip —"?"":z.target.value),style:{width:"100%",fontSize:j.xs,padding:"3px 6px",borderRadius:5,border:`1px solid ${q?"#E5E5E0":I?"#22C55E":"#E5E5E0"}`,background:q?"#F9FAFB":"#FFFFFF",color:q?"#9CA3AF":"#1a1a1a"},children:[J.map(z=>t.jsx("option",{value:z,children:z},z)),v.targetAttribute&&!Ln.includes(v.targetAttribute)&&t.jsx("option",{value:v.targetAttribute,children:v.targetAttribute})]})}),t.jsx("div",{style:{width:80,fontSize:"10px",color:"#9CA3AF"},children:v.transform??"—"})]},k)})]}),C.length>0&&t.jsxs("details",{children:[t.jsxs("summary",{style:{fontSize:j.xs,color:"#6B7280",cursor:"pointer",marginTop:4},children:["Show raw data sample (",Math.min(C.length,3)," of ",C.length," rows)"]}),t.jsx("div",{style:{marginTop:6,overflowX:"auto"},children:t.jsxs("table",{style:{fontSize:"10px",borderCollapse:"collapse",width:"100%"},children:[t.jsx("thead",{children:t.jsx("tr",{children:w.map(v=>t.jsx("th",{style:Ie,children:v},v))})}),t.jsx("tbody",{children:C.slice(0,3).map((v,k)=>t.jsx("tr",{children:w.map(I=>t.jsx("td",{style:He,children:v[I]??""},I))},k))})]})})]})]}),a==="preview"&&t.jsxs("div",{className:"flex flex-col gap-4",children:[D.length>0&&t.jsxs("div",{style:{background:"#FEF2F2",border:"1px solid #FECACA",borderRadius:8,padding:"10px 14px"},children:[t.jsxs("p",{style:{fontSize:j.xs,fontWeight:700,color:"#DC2626",margin:"0 0 4px"},children:[D.length," validation error(s) — rows with missing required fields will be skipped"]}),D.slice(0,5).map((v,k)=>t.jsx("p",{style:{fontSize:"11px",color:"#DC2626",margin:"1px 0"},children:v},k)),D.length>5&&t.jsxs("p",{style:{fontSize:"11px",color:"#DC2626",margin:"2px 0 0"},children:["+",D.length-5," more…"]})]}),F.length>0&&t.jsxs("div",{style:{background:"#FFFBEB",border:"1px solid #FDE68A",borderRadius:8,padding:"10px 14px"},children:[t.jsxs("p",{style:{fontSize:j.xs,fontWeight:700,color:"#D97706",margin:"0 0 4px"},children:[F.length," warning(s)"]}),F.slice(0,3).map((v,k)=>t.jsx("p",{style:{fontSize:"11px",color:"#D97706",margin:"1px 0"},children:v},k))]}),n&&t.jsxs("div",{style:{background:n.success?"#F0FDF4":"#FEF2F2",border:`1px solid ${n.success?"#86EFAC":"#FECACA"}`,borderRadius:8,padding:"12px 14px"},children:[t.jsx("p",{style:{fontSize:j.xs,fontWeight:700,margin:"0 0 4px",color:n.success?"#16A34A":"#DC2626"},children:n.success?`Import complete — ${n.elementsImported} element(s) written to ${n.generatedFile??"model"}`:"Import failed"}),n.errors.map((v,k)=>t.jsx("p",{style:{fontSize:"11px",color:"#DC2626",margin:"1px 0"},children:v},k)),n.warnings.slice(0,3).map((v,k)=>t.jsx("p",{style:{fontSize:"11px",color:"#D97706",margin:"1px 0"},children:v},k))]}),T.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{style:{fontSize:j.xs,color:"#6B7280",margin:0},children:["Showing first ",T.length," of ",C.length," row(s)",C.length>T.length&&` (+${C.length-T.length} more will be imported)`]}),t.jsx("div",{style:{overflowX:"auto",borderRadius:8,border:"1px solid #E5E5E0"},children:t.jsxs("table",{style:{fontSize:"11px",borderCollapse:"collapse",width:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#F8F8F5"},children:[t.jsx("th",{style:Ie,children:"#"}),t.jsx("th",{style:Ie,children:"id"}),t.jsx("th",{style:Ie,children:"name"}),t.jsx("th",{style:Ie,children:"kind"}),t.jsx("th",{style:Ie,children:"doc"})]})}),t.jsx("tbody",{children:T.map(v=>{const k=!v.id||!v.name||!v.kind;return t.jsxs("tr",{style:{background:k?"#FEF9F9":"transparent"},children:[t.jsx("td",{style:qn,children:v.rowIndex}),t.jsx("td",{style:{...qn,color:v.id?"#1a1a1a":"#DC2626"},children:v.id||"⚠ missing"}),t.jsx("td",{style:{...He,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(v.name||"—")}),t.jsx("td",{style:{...He,color:v.kind?"#1B3A4B":"#DC2626"},children:v.kind||"⚠ missing"}),t.jsx("td",{style:{...He,maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#6B7280"},children:String(v.doc||"—")})]},v.rowIndex)})})]})})]}),T.length===0&&D.length===0&&t.jsx("p",{style:{fontSize:j.xs,color:"#9CA3AF",textAlign:"center",padding:"24px 0"},children:"No rows to preview."})]})]}),t.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:"1px solid #F0F0EC",background:"#FAFAF8",flexShrink:0},children:[t.jsx("div",{className:"flex gap-2",children:a!=="input"&&!n&&t.jsx("button",{onClick:()=>l(be[Y-1]),style:Bn,children:"← Back"})}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("button",{onClick:_,style:Bn,children:n!=null&&n.success?"Done":"Cancel"}),!n&&t.jsxs(t.Fragment,{children:[a==="input"&&t.jsx("button",{onClick:K,style:Mt,children:"Next →"}),a==="mapping"&&t.jsx("button",{onClick:B,style:Mt,children:"Preview →"}),a==="preview"&&t.jsx("button",{onClick:U,disabled:ee||T.length===0,style:{...Mt,opacity:ee||T.length===0?.5:1,cursor:ee||T.length===0?"not-allowed":"pointer"},children:ee?"Importing…":`Import ${C.length} element(s)`})]})]})]})]})})}const _t={display:"block",fontSize:j.xs,fontWeight:600,color:"#374151",marginBottom:6},Nt={width:"100%",padding:"7px 10px",borderRadius:8,border:"1px solid #E5E5E0",fontSize:j.sm,color:"#1a1a1a",background:"#FAFAF8",boxSizing:"border-box"},Nl={background:"rgba(255,255,255,0.12)",border:"none",borderRadius:8,color:"rgba(255,255,255,0.8)",cursor:"pointer",padding:"6px 10px",fontSize:"14px"},Mt={padding:"7px 18px",borderRadius:8,background:"#1B3A4B",border:"none",color:"#FFFFFF",fontSize:j.xs,fontWeight:600,cursor:"pointer"},Bn={padding:"7px 14px",borderRadius:8,background:"transparent",border:"1px solid #E5E5E0",color:"#374151",fontSize:j.xs,cursor:"pointer"},Ie={padding:"5px 8px",textAlign:"left",fontWeight:600,fontSize:"10px",color:"#6B7280",borderBottom:"1px solid #E5E5E0",whiteSpace:"nowrap"},He={padding:"4px 8px",fontSize:"11px",color:"#1a1a1a",borderBottom:"1px solid #F5F5F2"},qn={...He,fontFamily:"monospace",fontSize:"10px",color:"#6B7280"};function Ml(){var l,c,d;const e=E(u=>u.activeView),r=E(u=>u.model),n=E(u=>u.selectedElementId),o=E(u=>u.selectElement),s=E(u=>u.setActiveView),i=Se(),a=[];switch(e.type){case"diagram":{const u=vt(r,e.diagramId);if(u){const m=u.viewpointId==="__model"?"Unassigned Views":((c=(l=r==null?void 0:r.viewpoints)==null?void 0:l.find(w=>w.id===u.viewpointId))==null?void 0:c.label)||u.viewpointId,y=(d=r==null?void 0:r.viewpoints)==null?void 0:d.find(w=>w.id===u.viewpointId);a.push({label:y?`${y.id} · ${m}`:m});const S=u.viewKind?ki[u.viewKind]:void 0,x=Re[u.diagramType],f=(S==null?void 0:S.label)??(x==null?void 0:x.code)??u.diagramType;a.push({label:`${u.id} · ${f}: ${u.name}`})}break}case"element-detail":{const u=e.elementId,m=r==null?void 0:r.elements[u];if(m){const y=m.shortId??m.id,S=y.split("-")[0];a.push({label:"Catalog",onClick:()=>i("/catalog")}),a.push({label:S,onClick:()=>i(`/catalog/${S}`)}),a.push({label:`${y} ${m.name}`})}break}case"dsm":a.push({label:"Tools"}),a.push({label:"DSM"});break;case"traceability":a.push({label:"Tools"}),a.push({label:"Traceability Matrix"});break;case"ontology":a.push({label:"Tools"}),a.push({label:"Ontology"});break}if(n&&r&&e.type!=="element-detail"){const u=r.elements[n];u&&a.push({label:u.name,onClick:()=>o(u.id)})}return a.length===0?null:t.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5",style:{background:"#FAFAF8",borderBottom:"1px solid #E5E5E0"},children:[t.jsx("button",{className:"text-xs px-1 py-0.5 rounded transition-colors",style:{color:"#9CA3AF"},onMouseEnter:u=>{u.currentTarget.style.color="#374151",u.currentTarget.style.background="#F0F0ED"},onMouseLeave:u=>{u.currentTarget.style.color="#9CA3AF",u.currentTarget.style.background="transparent"},onClick:()=>s({type:"welcome"}),title:"Home",children:"⌂"}),a.map((u,m)=>t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs",style:{color:"#D1D5DB"},children:"/"}),u.onClick?t.jsx("button",{className:"text-xs px-1 py-0.5 rounded transition-colors",style:{color:"#374151"},onMouseEnter:y=>y.currentTarget.style.background="#F0F0ED",onMouseLeave:y=>y.currentTarget.style.background="transparent",onClick:u.onClick,children:u.label}):t.jsx("span",{className:"text-xs",style:{color:m===a.length-1?"#374151":"#9CA3AF"},children:u.label})]},m)),t.jsx("div",{className:"flex-1"}),t.jsxs("kbd",{className:"px-1.5 py-0.5 rounded text-xs",style:{background:"#F0F0ED",color:"#9CA3AF",fontSize:"9px"},children:["⌘","K"]})]})}const Vn="memo-onboarding-completed",$e=[{title:"Welcome to MEMO Architect",description:"MEMO is a model-based systems engineering tool for medical devices. You'll land on the Dashboard — it shows your model health and suggests the next action. Let's take a quick tour.",target:"center",position:"center"},{title:"Model Explorer",description:"Browse your model elements organized by architecture layer. Switch to Views tab to see diagrams grouped by viewpoint.",target:"left panel",position:"left"},{title:"Unified Canvas",description:"The center area renders your selected view — diagrams, action flows, DSM matrices, and more.",target:"center canvas",position:"center"},{title:"Properties Panel",description:"View and edit element properties, relationships, and attributes. Select any element to see its details.",target:"right panel",position:"right"},{title:"Tools Menu",description:"Access analysis tools from the toolbar: DSM, Trace Matrix, Action Flow, Ontology, Scenarios, Diff, Compliance, and Stats.",target:"toolbar",position:"center"},{title:"Command Palette",description:"Press Cmd+K (or Ctrl+K) to quickly search elements, diagrams, viewpoints, and tools.",target:"keyboard shortcut",position:"center"},{title:"Working Sets",description:"Save and restore your workspace layout using the Sets tab in the Explorer panel. Great for switching between review contexts.",target:"explorer sets tab",position:"left"},{title:"You're all set!",description:"Start from the Dashboard — it shows your model status and suggests the next step. Use the Workflow Wizard (Tools menu) for a guided path through requirements, risk, and verification.",target:"center",position:"center"}];function Ol(){const[e,r]=p.useState(!1),[n,o]=p.useState(0);p.useEffect(()=>{try{if(!localStorage.getItem(Vn)){const y=setTimeout(()=>r(!0),800);return()=>clearTimeout(y)}}catch{}},[]);const s=p.useCallback(()=>{r(!1);try{localStorage.setItem(Vn,"true")}catch{}},[]),i=p.useCallback(()=>{n>=$e.length-1?s():o(n+1)},[n,s]),a=p.useCallback(()=>{n>0&&o(n-1)},[n]);if(!e)return null;const l=$e[n],c=n===$e.length-1,d=n===0,u=()=>{switch(l.position){case"left":return{left:"300px",top:"50%",transform:"translateY(-50%)"};case"right":return{right:"300px",top:"50%",transform:"translateY(-50%)"};case"bottom":return{left:"50%",bottom:"80px",transform:"translateX(-50%)"};case"center":default:return{left:"50%",top:"50%",transform:"translate(-50%, -50%)"}}};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.4)",backdropFilter:"blur(2px)"},onClick:s}),t.jsxs("div",{className:"fixed z-50 rounded-xl p-5 max-w-sm",style:{...u(),background:"#FFFFFF",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",border:"1px solid #E5E5E0"},onClick:m=>m.stopPropagation(),children:[t.jsx("div",{className:"flex items-center gap-1 mb-3",children:$e.map((m,y)=>t.jsx("div",{className:"h-1 rounded-full transition-all",style:{width:y===n?"20px":"8px",background:y===n?"#2DD4A8":y<n?"#2DD4A880":"#E5E5E0"}},y))}),t.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"#1B3A4B"},children:l.title}),t.jsx("p",{className:"text-xs leading-relaxed mb-4",style:{color:"#6B7280"},children:l.description}),t.jsxs("div",{className:"flex items-center gap-2",children:[!d&&t.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs rounded-lg",style:{background:"#F3F4F6",color:"#6B7280"},children:"Back"}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:s,className:"px-3 py-1.5 text-xs rounded-lg",style:{color:"#9CA3AF"},children:"Skip tour"}),t.jsx("button",{onClick:i,className:"px-4 py-1.5 text-xs font-medium rounded-lg",style:{background:"#2DD4A8",color:"#FFFFFF"},children:c?"Get started":"Next"})]}),t.jsxs("div",{className:"text-center mt-2",style:{color:"#D1D5DB",fontSize:"10px"},children:[n+1," of ",$e.length]})]})]})}function Pl(){const e=E(n=>n.restartRequired);if(!e)return null;const r=e.reason==="ontology-selection-changed"?"Ontology selection changed":"Ontology source changed";return t.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(15, 23, 42, 0.85)",backdropFilter:"blur(4px)"},children:t.jsxs("div",{style:{background:"#1E293B",border:"1px solid #F59E0B",borderRadius:"12px",padding:"32px 40px",maxWidth:"480px",width:"90%",textAlign:"center",color:"#F8FAFC",boxShadow:"0 25px 50px rgba(0,0,0,0.5)"},children:[t.jsx("div",{style:{fontSize:"2rem",marginBottom:"12px"},children:"⚠️"}),t.jsx("div",{style:{fontSize:"1.1rem",fontWeight:600,marginBottom:"8px",color:"#F59E0B"},children:"Restart Required"}),t.jsx("div",{style:{fontSize:"0.875rem",color:"#CBD5E1",marginBottom:"4px"},children:r}),t.jsx("div",{style:{fontSize:"0.75rem",color:"#94A3B8",marginBottom:"24px",fontFamily:"monospace"},children:e.changedFile}),t.jsx("div",{style:{fontSize:"0.875rem",color:"#E2E8F0",marginBottom:"24px",lineHeight:1.6},children:e.instruction}),t.jsx("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:t.jsx("button",{onClick:()=>window.location.reload(),style:{background:"#F59E0B",color:"#0F172A",border:"none",borderRadius:"6px",padding:"8px 20px",fontWeight:600,fontSize:"0.875rem",cursor:"pointer"},children:"Reload page"})})]})})}const Wn={Hazard:"HZD",HazardousEvent:"HZD-EVT",HazardousSituation:"HZD-SIT",Risk:"RISK",RiskControlMeasure:"RISK-CTL",MitigationMeasure:"MIT",ResidualRisk:"RRISK",StakeholderRequirement:"STK-REQ",Requirement:"REQ",SoftwareSpecification:"SW-SPEC",InterfaceRequirement:"REQ",PerformanceRequirement:"PERF-REQ",SafetyRequirement:"SAF-REQ",RegulatoryRequirement:"REG-REQ",FunctionalRequirement:"REQ",NonFunctionalRequirement:"NFR",SystemComponent:"SYS-COMP",SoftwareComponent:"SW-COMP",HardwareComponent:"HW-COMP",Subsystem:"SUBSYS",Module:"MOD",Interface:"IF",Port:"PORT",Action:"ACT",ActionDefinition:"ACT-DEF",UseCase:"UC",Stakeholder:"STK",OperationalScenario:"OPS",Mission:"MSNS",Capability:"CAP",DesignInput:"DI",DesignOutput:"DO",VerificationActivity:"VER",ValidationActivity:"VAL",TestCase:"TC",Item:"ITM",Part:"PART"};function zl(e){return e.length<=3?e.toUpperCase():(e[0]+e.slice(1).replace(/[aeiouAEIOU]/g,"")).slice(0,3).toUpperCase()}function Ll(e){if(Wn[e])return Wn[e];const r=e.replace(/([A-Z])/g," $1").trim().split(" ").filter(Boolean);return r.length===0?"EL":r.map(zl).join("-")}function Bl(e){return e.split("-")[0]}function ql(e){return`/catalog/${e.split("-")[0]}/${e}`}function Vl(e){return`/catalog/${e}`}function Wl(e,r){return`/diagrams/${e.toLowerCase().replace(/\s+/g,"-")}/${encodeURIComponent(r)}`}function $l(){const e=E(s=>s.model),r=Se(),n=p.useMemo(()=>{if(!e)return[];const s={};for(const i of Object.values(e.elements)){const a=Ll(i.kind),l=Bl(a);s[l]||(s[l]={count:0,kinds:new Set,layer:i.layer}),s[l].count++,s[l].kinds.add(i.kind)}return Object.entries(s).sort((i,a)=>a[1].count-i[1].count)},[e]);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("p",{style:{color:g.muted,fontSize:j.sm},children:"Loading…"})});const o=Object.keys(e.elements).length;return t.jsxs("div",{style:{flex:1,overflow:"auto",background:"#F7F7F5",padding:"32px 40px"},children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:700,color:g.primary,marginBottom:"4px",marginTop:0},children:"Catalog"}),t.jsxs("p",{style:{color:g.muted,fontSize:j.sm,marginTop:0,marginBottom:"24px"},children:[o," elements across ",n.length," families"]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"},children:n.map(([s,i])=>{const a=ne[i.layer]??"#9CA3AF";return t.jsx(Ul,{family:s,count:i.count,kinds:i.kinds,color:a,onClick:()=>r(Vl(s))},s)})})]})}function Ul({family:e,count:r,kinds:n,color:o,onClick:s}){return t.jsxs("div",{onClick:s,style:{background:g.surface,border:`1px solid ${g.border}`,borderRadius:"10px",padding:"16px",cursor:"pointer",transition:"box-shadow 0.15s, border-color 0.15s",borderTop:`3px solid ${o}`},onMouseEnter:i=>{i.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)",i.currentTarget.style.borderTopColor=o},onMouseLeave:i=>{i.currentTarget.style.boxShadow="none"},children:[t.jsx("div",{style:{fontWeight:700,fontSize:"15px",color:g.primary,marginBottom:"4px"},children:e}),t.jsx("div",{style:{fontSize:"22px",fontWeight:800,color:o,lineHeight:1,marginBottom:"6px"},children:r}),t.jsxs("div",{style:{fontSize:"11px",color:g.muted,lineHeight:"1.5"},children:[Array.from(n).slice(0,3).join(", "),n.size>3&&` +${n.size-3} more`]})]})}function Hl(){var s;const e=E(i=>i.model),r=Se(),n=p.useMemo(()=>{var y;const i=(e==null?void 0:e.diagrams)??[],a=new Map,l=new Map(((e==null?void 0:e.viewpoints)??[]).map(S=>{var x;return[S.id,(x=S.declaredLayers)!=null&&x.length?S.declaredLayers:S.visibleLayers??[]]}));for(const S of i){const x=S.viewpointIds;for(const f of x!=null&&x.length?x:[S.viewpointId]){const w=(y=e==null?void 0:e.viewpoints)==null?void 0:y.find(A=>A.id===f),h=w?f:me,C=a.get(h);C?C.items.push(S):a.set(h,{id:h,label:(w==null?void 0:w.label)??"Uncategorized",items:[S]})}}const c=Er([...a.values()].filter(S=>S.id!==me).map(S=>({...S,declaredLayers:l.get(S.id)??[]}))),d=Cr(c.map(S=>S.label)),u=c.map((S,x)=>({...S,label:d[x],items:[...S.items].sort((f,w)=>f.name.localeCompare(w.name))})),m=a.get(me);return m?[...u,{...m,items:[...m.items].sort((S,x)=>S.name.localeCompare(x.name))}]:u},[e]);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("p",{style:{color:g.muted,fontSize:j.sm},children:"Loading…"})});const o=((s=e.diagrams)==null?void 0:s.length)??0;return t.jsxs("div",{style:{flex:1,overflow:"auto",background:"#F7F7F5",padding:"32px 40px"},children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:700,color:g.primary,marginBottom:"4px",marginTop:0},children:"Viewpoints"}),t.jsxs("p",{style:{color:g.muted,fontSize:j.sm,marginTop:0,marginBottom:"24px"},children:[o," model ",o===1?"view":"views"," across ",n.length," ",n.length===1?"viewpoint":"viewpoints"]}),o===0&&t.jsx("p",{style:{color:g.muted,fontSize:j.sm},children:"This model defines no model views yet."}),n.map(i=>t.jsxs("section",{style:{marginBottom:"28px"},children:[t.jsxs("h2",{style:{fontSize:"11px",fontWeight:700,color:g.muted,textTransform:"uppercase",letterSpacing:"0.06em",margin:"0 0 10px 0"},children:[i.label,t.jsx("code",{style:{marginLeft:8,color:g.faint,textTransform:"none"},children:i.id===me?"no viewpoint":i.id}),t.jsx("span",{style:{marginLeft:8,fontWeight:400},children:i.items.length})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:"12px"},children:i.items.map(a=>t.jsx(Kl,{diagram:a,onClick:()=>r(Wl(a.diagramType,a.id))},a.id))})]},i.id))]})}function Kl({diagram:e,onClick:r}){var i;const n=Re[e.diagramType],o=(n==null?void 0:n.color)??"#6B7280",s=((i=e.elementIds)==null?void 0:i.length)??0;return t.jsxs("div",{onClick:r,role:"button",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r())},style:{background:g.surface,border:`1px solid ${g.border}`,borderRadius:"10px",padding:"14px 16px",cursor:"pointer",transition:"box-shadow 0.15s",borderTop:`3px solid ${o}`},onMouseEnter:a=>{a.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)"},onMouseLeave:a=>{a.currentTarget.style.boxShadow="none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[n&&t.jsx("span",{style:{background:o+"18",color:o,borderRadius:4,padding:"1px 5px",fontSize:"10px",fontWeight:700},children:n.code}),e.auto&&t.jsx("span",{style:{fontSize:"10px",color:g.muted},children:"auto"})]}),t.jsx("div",{style:{fontWeight:600,fontSize:"14px",color:g.primary,marginBottom:4},children:e.name}),t.jsx("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"10px",color:g.faint,marginBottom:4},children:e.id}),t.jsxs("div",{style:{fontSize:"11px",color:g.muted,lineHeight:1.5},children:[(n==null?void 0:n.fullName)??e.diagramType,s>0&&` · ${s} element${s===1?"":"s"}`]})]})}function Gl({family:e}){const r=E(c=>c.model),n=Se(),[o,s]=p.useState(""),i=p.useMemo(()=>r?Object.values(r.elements).filter(c=>{const d=c.shortId??"";return d.startsWith(e+"-")||d.startsWith(e+" ")}):[],[r,e]),a=p.useMemo(()=>{if(!o.trim())return i;const c=o.toLowerCase();return i.filter(d=>d.name.toLowerCase().includes(c)||(d.shortId??"").toLowerCase().includes(c)||d.kind.toLowerCase().includes(c))},[i,o]),l=p.useMemo(()=>{const c={};for(const d of i)c[d.kind]=(c[d.kind]??0)+1;return c},[i]);return r?i.length===0?t.jsx(Ot,{family:e,children:t.jsxs("p",{style:{color:g.muted,fontSize:j.sm},children:["No elements found with family prefix ",t.jsx("code",{children:e}),"."]})}):t.jsxs(Ot,{family:e,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:Object.entries(l).map(([c,d])=>{const u=ne[c]??"#9CA3AF";return t.jsxs("span",{style:{fontSize:j.xs,padding:"2px 8px",borderRadius:"12px",background:u+"20",color:u,border:`1px solid ${u}40`,fontWeight:500},children:[c," · ",d]},c)})}),t.jsx("input",{type:"search",placeholder:`Search ${i.length} elements…`,value:o,onChange:c=>s(c.target.value),style:{width:"100%",boxSizing:"border-box",padding:"7px 12px",fontSize:j.sm,border:`1px solid ${g.border}`,borderRadius:"6px",background:g.surface,color:g.primary,outline:"none",marginBottom:"12px"}}),t.jsxs("div",{style:{background:g.surface,border:`1px solid ${g.border}`,borderRadius:"8px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"140px 1fr 120px 120px",padding:"8px 16px",background:g.surfaceAlt,borderBottom:`1px solid ${g.border}`,fontSize:j.xs,fontWeight:600,color:g.muted,gap:"12px"},children:[t.jsx("span",{children:"ID"}),t.jsx("span",{children:"Name"}),t.jsx("span",{children:"Kind"}),t.jsx("span",{children:"Layer"})]}),a.length===0?t.jsxs("div",{style:{padding:"24px 16px",color:g.muted,fontSize:j.sm,textAlign:"center"},children:['No results for "',o,'"']}):a.map((c,d)=>t.jsx(Yl,{element:c,zebra:d%2===1,onClick:()=>n(ql(c.shortId??c.id))},c.id))]}),t.jsxs("p",{style:{color:g.faint,fontSize:"11px",marginTop:"8px"},children:[a.length," of ",i.length," elements shown"]})]}):t.jsx(Ot,{family:e,children:t.jsx("p",{style:{color:g.muted,fontSize:j.sm},children:"Loading model…"})})}function Yl({element:e,zebra:r,onClick:n}){const o=ne[e.layer]??"#9CA3AF";return t.jsxs("div",{onClick:n,style:{display:"grid",gridTemplateColumns:"140px 1fr 120px 120px",padding:"10px 16px",gap:"12px",background:r?"#FAFAF8":g.surface,cursor:"pointer",borderBottom:`1px solid ${g.borderLight}`,alignItems:"center",transition:"background 0.1s"},onMouseEnter:s=>s.currentTarget.style.background="#F0FDF4",onMouseLeave:s=>s.currentTarget.style.background=r?"#FAFAF8":g.surface,children:[t.jsx("code",{style:{fontSize:"11px",color:"#2DD4A8",fontWeight:600,fontFamily:"monospace"},children:e.shortId??e.id}),t.jsx("span",{style:{fontSize:j.sm,color:g.primary,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx("span",{style:{fontSize:j.xs,color:g.secondary},children:e.kind}),t.jsx("span",{style:{fontSize:"11px",color:o,fontWeight:500,background:o+"15",padding:"2px 6px",borderRadius:"4px",width:"fit-content"},children:e.layer})]})}function Ot({family:e,children:r}){const n=Se();return t.jsxs("div",{style:{flex:1,overflow:"auto",background:"#F7F7F5",padding:"32px 40px"},children:[t.jsxs("nav",{style:{fontSize:j.xs,color:g.muted,marginBottom:"20px"},children:[t.jsx("button",{onClick:()=>n("/catalog"),style:{background:"none",border:"none",color:"#2DD4A8",cursor:"pointer",padding:0,fontSize:j.xs},children:"Catalog"})," / ",t.jsx("span",{style:{color:g.primary,fontWeight:600},children:e})]}),t.jsx("h1",{style:{fontSize:"20px",fontWeight:700,color:g.primary,marginBottom:"6px",marginTop:0},children:e}),r]})}const Jl=p.lazy(()=>te(()=>import("./DiagramEditor-CJ7OG2IC.js"),__vite__mapDeps([3,1,2])).then(e=>({default:e.DiagramEditor}))),Xl=p.lazy(()=>te(()=>import("./DSMView-DGheBwZ0.js"),__vite__mapDeps([4,1,2])).then(e=>({default:e.DSMView}))),Ql=p.lazy(()=>te(()=>import("./OntologyViewer-BIpJC66j.js"),__vite__mapDeps([5,1,2])).then(e=>({default:e.OntologyViewer}))),Zl=p.lazy(()=>te(()=>import("./TraceabilityMatrix-CHZHFucA.js"),__vite__mapDeps([6,1,2])).then(e=>({default:e.TraceabilityMatrix}))),ed=p.lazy(()=>te(()=>import("./ScenarioEditor-JQ3huCnz.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.ScenarioEditor}))),td=p.lazy(()=>te(()=>import("./ModelDiff-BbqIoesG.js"),__vite__mapDeps([7,1,2])).then(e=>({default:e.ModelDiff}))),nd=p.lazy(()=>te(()=>import("./ComplianceWizard-k98NZ2ec.js"),__vite__mapDeps([8,1,2])).then(e=>({default:e.ComplianceWizard}))),rd=p.lazy(()=>te(()=>import("./StatisticsDashboard-B8BduIDz.js"),__vite__mapDeps([9,1,2])).then(e=>({default:e.StatisticsDashboard}))),od=p.lazy(()=>te(()=>import("./DhfDashboard-B9V_n7kg.js"),__vite__mapDeps([10,1,2])).then(e=>({default:e.DhfDashboard}))),sd=p.lazy(()=>te(()=>import("./DhfWorkbench-TOnZkdUU.js"),__vite__mapDeps([11,1,2])).then(e=>({default:e.DhfWorkbench}))),id=p.lazy(()=>te(()=>import("./AiWorkspace-DS79vBOT.js"),__vite__mapDeps([12,1,2])).then(e=>({default:e.AiWorkspace}))),Rr=p.lazy(()=>te(()=>import("./ElementDetailView-CDcm1rvf.js"),__vite__mapDeps([13,1,2])).then(e=>({default:e.ElementDetailView}))),le=p.lazy(()=>te(()=>import("./Dashboard-BRUQvUFK.js"),__vite__mapDeps([14,1,2])).then(e=>({default:e.Dashboard}))),ad=p.lazy(()=>te(()=>import("./ReviewDashboard-DKoExM8K.js"),__vite__mapDeps([15,1,2])).then(e=>({default:e.ReviewDashboard}))),ld=p.lazy(()=>te(()=>import("./WorkflowWizard-7--f9OH2.js"),__vite__mapDeps([16,1,2])).then(e=>({default:e.WorkflowWizard}))),dd=p.lazy(()=>te(()=>import("./TabularView-BXfFSluC.js"),__vite__mapDeps([17,1,2])).then(e=>({default:e.TabularView}))),cd=p.lazy(()=>te(()=>import("./ImportView-CyMm-tSP.js"),__vite__mapDeps([18,1,2])).then(e=>({default:e.ImportView}))),ud=p.lazy(()=>te(()=>import("./AnalysisWorkspace-D_u4shRY.js"),__vite__mapDeps([19,1,2])).then(e=>({default:e.AnalysisWorkspace})));function _e(){const e=E(s=>s.activeView);E(s=>s.selectedViewpointId);const r=E(s=>s.selectedDiagramId),n=E(s=>s.selectDiagram);p.useEffect(()=>{e.type==="diagram"&&r!==e.diagramId&&n(e.diagramId)},[e,r,n]);const o=()=>{switch(e.type){case"diagram":return t.jsx(Jl,{diagramId:e.diagramId});case"dsm":return oe("model-tools")?t.jsx(Xl,{}):t.jsx(le,{});case"traceability":return oe("model-tools")?t.jsx(Zl,{}):t.jsx(le,{});case"tabular":return t.jsx(dd,{});case"ontology":case"ontology-detail":return oe("ontology")?t.jsx(Ql,{}):t.jsx(le,{});case"scenario-editor":return t.jsx(ed,{});case"model-diff":return oe("model-tools")?t.jsx(td,{}):t.jsx(le,{});case"compliance-wizard":return oe("model-tools")?t.jsx(nd,{}):t.jsx(le,{});case"statistics":return oe("model-tools")?t.jsx(rd,{}):t.jsx(le,{});case"dhf-dashboard":case"dhf-document":return t.jsx(sd,{});case"dhf-dashboard-legacy":return t.jsx(od,{});case"ai":case"ask":case"sysml-generator":return oe("ai-tools")?t.jsx(id,{}):t.jsx(le,{});case"element-detail":return t.jsx(Rr,{});case"dashboard":return t.jsx(le,{});case"review-dashboard":return oe("model-tools")?t.jsx(ad,{}):t.jsx(le,{});case"workflow-wizard":return oe("model-tools")?t.jsx(ld,{}):t.jsx(le,{});case"import":return oe("import")?t.jsx(cd,{}):t.jsx(le,{});case"analysis":return oe("analysis")?t.jsx(ud,{}):t.jsx(le,{});case"welcome":default:return t.jsx($n,{})}};return(e.type==="welcome"||e.type==="dashboard")&&e.type==="welcome"?t.jsx($n,{}):t.jsx(p.Suspense,{fallback:t.jsx(Fr,{}),children:o()})}function Fr(){return t.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:t.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[t.jsx("img",{src:"/logo.png",alt:"MEMO Logo",style:{width:"180px",marginBottom:"24px",opacity:.4,filter:"grayscale(1)"},className:"animate-pulse"}),t.jsx("div",{className:"text-xs mt-2",children:"Loading view..."})]})})}const gt="linear-gradient(135deg, #EEF7F3 0%, #EAF2F8 55%, #F2EEF8 100%)";function $n(){var c;const e=E(d=>d.model),r=E(d=>d.setActiveView),n=E(d=>d.selectElement),o=E(d=>d.setExplorerTab),s=((c=e==null?void 0:e.diagrams)==null?void 0:c.length)??0,i=e?Object.keys(e.elements).length:0,a=p.useMemo(()=>{if(!e)return[];const d=new Map;for(const u of Object.values(e.elements))d.has(u.kind)||d.set(u.kind,u);return Array.from(d.values()).slice(0,8)},[e]);function l(d){n(d),r({type:"element-detail",elementId:d})}return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center overflow-auto",style:{background:gt,padding:"48px 40px"},children:[t.jsx("img",{src:"/logo.png",alt:"MEMO Logo",style:{width:"520px",maxWidth:"80vw",maxHeight:"40vh",objectFit:"contain",marginBottom:"-36px",opacity:.97}}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px",marginTop:0},children:"MEMO Architect"}),t.jsx("p",{style:{fontSize:"14px",color:"#4B6E80",marginTop:0,marginBottom:"24px",maxWidth:"480px",textAlign:"center",lineHeight:"1.6"},children:"SysML-based medical device architecture tool, aligned with ISO 14971 and IEC 62304."}),i>0&&t.jsxs("div",{className:"flex items-center gap-4 mb-6",style:{fontSize:"13px",color:"#4B6E80"},children:[t.jsxs("span",{children:[t.jsx("strong",{style:{color:"#1B3A4B"},children:i})," elements"]}),t.jsx("span",{style:{color:"#CBD5DB"},children:"·"}),t.jsxs("span",{children:[t.jsx("strong",{style:{color:"#1B3A4B"},children:s})," diagrams"]}),(e==null?void 0:e.relationships)&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"#CBD5DB"},children:"·"}),t.jsxs("span",{children:[t.jsx("strong",{style:{color:"#1B3A4B"},children:e.relationships.length})," relationships"]})]})]}),t.jsxs("div",{className:"flex gap-3 mb-8",children:[t.jsx("button",{onClick:()=>o("model"),className:"px-5 py-2.5 text-sm font-semibold rounded-lg transition-all",style:{background:"#1B3A4B",color:"#FFFFFF",border:"none",cursor:"pointer"},onMouseEnter:d=>d.currentTarget.style.background="#244D63",onMouseLeave:d=>d.currentTarget.style.background="#1B3A4B",children:"Browse Model"}),s>0&&t.jsxs("button",{onClick:()=>o("views"),className:"px-5 py-2.5 text-sm font-semibold rounded-lg transition-all",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840",cursor:"pointer"},onMouseEnter:d=>d.currentTarget.style.background="#2DD4A830",onMouseLeave:d=>d.currentTarget.style.background="#2DD4A815",children:["View Diagrams (",s,")"]})]}),a.length>0&&t.jsxs("div",{style:{width:"100%",maxWidth:"680px"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#7A9BAA",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"10px"},children:"Quick Browse"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"8px"},children:a.map(d=>t.jsxs("button",{onClick:()=>l(d.id),style:{textAlign:"left",background:"rgba(255,255,255,0.7)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"8px",padding:"10px 12px",cursor:"pointer",transition:"all 0.15s",backdropFilter:"blur(4px)"},onMouseEnter:u=>{u.currentTarget.style.background="rgba(255,255,255,0.95)",u.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.08)",u.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:u=>{u.currentTarget.style.background="rgba(255,255,255,0.7)",u.currentTarget.style.boxShadow="none",u.currentTarget.style.transform="none"},children:[t.jsx("div",{style:{fontSize:"10px",color:"#7A9BAA",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"3px"},children:d.kind}),t.jsx("div",{style:{fontSize:"13px",color:"#1B3A4B",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.name}),d.shortId&&t.jsx("div",{style:{fontSize:"10px",color:"#9CB8C5",marginTop:"2px",fontFamily:"monospace"},children:d.shortId})]},d.id))})]})]})}function pd(){const e=E(y=>y.connected),r=E(y=>y.model),n=E(y=>y.activeView),o=E(y=>y.selectedElementIds),{pathname:s}=xe(),i=s.startsWith("/catalog"),a=E(y=>y.activeMode),l=E(y=>y.sidebarCollapsed),c=E(y=>y.toggleSidebar),d=E(y=>y.toggleGapBar);p.useEffect(()=>{const y=S=>{(S.metaKey||S.ctrlKey)&&S.shiftKey&&S.key==="P"&&(S.preventDefault(),d())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[d]);const u=n.type!=="dsm"&&n.type!=="ai"&&n.type!=="ask"&&n.type!=="sysml-generator"&&n.type!=="analysis";p.useEffect(()=>{u&&l&&c()},[n.type]),p.useEffect(()=>{Ps()||mr()},[]);const m=r?Object.keys(r.elements).length:0;return e?r?m===0?t.jsxs("div",{className:"flex flex-col h-screen",style:{background:gt,color:"#1a1a1a"},children:[t.jsx(it,{}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center max-w-lg",style:{lineHeight:"1.7"},children:[t.jsx("img",{src:"/logo.png",alt:"MEMO Logo",style:{width:"380px",maxWidth:"80vw",display:"block",margin:"0 auto -20px auto",opacity:.35,filter:"grayscale(1)"}}),t.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1B3A4B",marginBottom:"8px"},children:"Your model is empty"}),t.jsxs("p",{style:{fontSize:"14px",color:"#4B6E80",marginBottom:"20px"},children:["Connected successfully — but no ",t.jsx("code",{children:".sysml"})," elements found yet."]}),t.jsxs("div",{style:{textAlign:"left",background:"rgba(255,255,255,0.65)",borderRadius:"10px",padding:"16px 20px",fontSize:"13px",border:"1px solid rgba(255,255,255,0.9)"},children:[t.jsx("p",{style:{fontWeight:600,marginBottom:"8px",color:"#1B3A4B"},children:"Get started:"}),t.jsxs("ol",{style:{paddingLeft:"18px",margin:0,color:"#4B6E80"},children:[t.jsxs("li",{style:{marginBottom:"6px"},children:["Create a ",t.jsx("code",{children:".sysml"})," file in your ",t.jsx("code",{children:"model/"})," directory"]}),t.jsxs("li",{style:{marginBottom:"6px"},children:["Import from CSV: ",t.jsx("code",{children:"pnpm memo import template elements"})]}),t.jsxs("li",{children:["Scaffold a new project: ",t.jsx("code",{children:"pnpm memo init my-device"})]})]})]})]})})]}):t.jsxs("div",{className:"flex flex-col h-screen",style:{background:"#F7F7F5",color:"#1a1a1a"},children:[t.jsx(gd,{}),t.jsx(it,{}),t.jsx(wi,{}),t.jsx(Ml,{}),t.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[u&&t.jsx(el,{}),t.jsx("div",{className:"flex-1 flex flex-col",style:{minWidth:0},children:t.jsxs(No,{children:[t.jsx(pe,{path:"/catalog",element:t.jsx($l,{})}),t.jsx(pe,{path:"/catalog/:family",element:t.jsx(md,{})}),t.jsx(pe,{path:"/catalog/:family/:shortId",element:t.jsx(fd,{})}),t.jsx(pe,{path:"/diagrams",element:t.jsx(Hl,{})}),t.jsx(pe,{path:"/diagrams/:diagramType/:diagramId",element:t.jsx(hd,{})}),li().map(y=>t.jsx(pe,{path:y,element:t.jsx(_e,{})},y)),t.jsx(pe,{path:"/ontology/:packageName",element:t.jsx(_e,{})}),t.jsx(pe,{path:"/ontology/:packageName/:layerId",element:t.jsx(_e,{})}),t.jsx(pe,{path:"/dhf/:docId",element:t.jsx(_e,{})}),t.jsx(pe,{path:"*",element:t.jsx(_e,{})})]})}),n.type!=="element-detail"&&n.type!=="scenario-editor"&&n.type!=="ontology"&&n.type!=="ontology-detail"&&n.type!=="ai"&&n.type!=="ask"&&n.type!=="sysml-generator"&&n.type!=="analysis"&&!i&&a!=="dhf"&&a!=="ontology"&&(o.size>=2?t.jsx(Rl,{}):t.jsx(jl,{}))]}),t.jsx(Fl,{}),t.jsx(Tl,{}),t.jsx(_l,{}),t.jsx(Ol,{}),t.jsx(Pl,{})]}):t.jsxs("div",{className:"flex flex-col h-screen",style:{background:gt,color:"#1a1a1a"},children:[t.jsx(it,{}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx("img",{src:"/logo.png",alt:"MEMO Logo",style:{width:"360px",maxWidth:"80vw",display:"block",margin:"0 auto -20px auto",opacity:.45,filter:"grayscale(1)"},className:"animate-pulse"}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px"},children:"MEMO Architect"}),t.jsx("p",{style:{color:"#6B7280",fontSize:"14px"},children:"Loading model data…"})]})})]}):t.jsxs("div",{className:"flex flex-col h-screen",style:{background:gt,color:"#1a1a1a"},children:[t.jsx(it,{}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center max-w-md",children:[t.jsx("img",{src:"/logo.png",alt:"MEMO Logo",style:{width:"360px",maxWidth:"80vw",display:"block",margin:"0 auto -20px auto",opacity:.45,filter:"grayscale(1)"},className:"animate-pulse"}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"#1B3A4B",marginBottom:"8px"},children:"MEMO Architect"}),t.jsx("p",{style:{color:"#6B7280",fontSize:"14px",marginBottom:"20px"},children:"Connecting to dev server…"}),t.jsxs("div",{style:{color:"#6B7280",fontSize:"13px",lineHeight:"1.6",textAlign:"left",background:"rgba(255,255,255,0.6)",borderRadius:"10px",padding:"16px 20px",border:"1px solid rgba(255,255,255,0.9)"},children:[t.jsx("p",{style:{fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Start the MEMO dev server:"}),t.jsx("code",{style:{display:"block",margin:"0 0 12px",padding:"8px 14px",background:"#1B3A4B",color:"#2DD4A8",borderRadius:"6px",fontFamily:"monospace",fontSize:"13px"},children:"pnpm architect -- dev --port 3000"}),t.jsx("p",{style:{color:"#9CA3AF",marginBottom:"8px"},children:"Or try the example project:"}),t.jsx("code",{style:{display:"block",padding:"8px 14px",background:"#1B3A4B",color:"#2DD4A8",borderRadius:"6px",fontFamily:"monospace",fontSize:"13px"},children:"pnpm example:dev"})]})]})})]})}function md(){const{family:e=""}=Gt();return t.jsx(Gl,{family:e.toUpperCase()})}function fd(){const{shortId:e=""}=Gt(),r=E(s=>s.model),n=E(s=>s.setActiveView),o=E(s=>s.selectElement);return p.useEffect(()=>{if(!r)return;const s=Object.values(r.elements).find(i=>(i.shortId??i.id)===e);s&&(o(s.id),n({type:"element-detail",elementId:s.id}))},[e,r,n,o]),t.jsx(p.Suspense,{fallback:t.jsx(Fr,{}),children:t.jsx(Rr,{})})}function hd(){const{diagramId:e=""}=Gt(),r=E(s=>s.model),n=E(s=>s.selectDiagram),o=E(s=>s.setActiveView);return p.useEffect(()=>{var i;if(!r)return;const s=(i=r.diagrams)==null?void 0:i.find(a=>a.id===e||a.id.toLowerCase()===e.toLowerCase());s&&(n(s.id),o({type:"diagram",diagramId:s.id}))},[e,r,n,o]),t.jsx(_e,{})}function gd(){const e=E(d=>d.activeView),r=E(d=>d.model),n=E(d=>d.setActiveView),o=E(d=>d.setActiveMode),s=Se(),i=xe(),a=xo(),l=p.useRef(!1),c=p.useRef(!1);return p.useEffect(()=>{const d=!l.current;if(l.current=!0,!d&&a!=="POP")return;const u=ii(i.pathname,i.search);(u==null?void 0:u.type)==="scenario-editor"&&o("scenario"),u&&JSON.stringify(u)!==JSON.stringify(e)&&(c.current=!0,n(u))},[i.pathname,i.search,a]),p.useEffect(()=>{var u;if(!l.current)return;if(c.current){c.current=!1;return}if(e.type==="welcome"&&i.pathname!=="/"||ai(i.pathname)&&!(e.type==="diagram"||e.type==="element-detail"))return;let d=null;if(e.type==="element-detail"&&r){const m=r.elements[e.elementId];if(m){const y=m.shortId??m.id;d=`/catalog/${y.split("-")[0]}/${y}`}}else if(e.type==="diagram"&&r){const m=(u=r.diagrams)==null?void 0:u.find(y=>y.id===e.diagramId);m&&(d=`/diagrams/${oi(m.diagramType)}/${encodeURIComponent(m.id)}`)}else d=si(e);d&&i.pathname+i.search!==d&&s(d,{replace:!1})},[e,r]),null}Mr.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(os,{children:t.jsx(pd,{})})}));export{gr as A,Cd as B,g as C,Re as D,Ni as E,j as F,wn as G,Md as H,Pd as I,ws as J,Sd as K,Ue as L,Ed as M,kd as N,pl as P,Od as R,_d as S,ki as V,te as _,Id as a,wd as b,bd as c,Td as d,Xe as e,ne as f,vt as g,ei as h,Te as i,Rn as j,Fd as k,vd as l,Ad as m,jd as n,Dd as o,Rd as p,Bd as q,Ei as r,ni as s,On as t,E as u,yl as v,Ld as w,ml as x,zd as y,Nd as z};