@memoarchitect/architect 0.7.2 → 0.8.26

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 (71) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{AiWorkspace-Bu9TlIWg.js → AiWorkspace-Z3BbnmaP.js} +1 -1
  3. package/dist/assets/{AnalysisWorkspace-CodmoI-v.js → AnalysisWorkspace-DjaUOo7U.js} +1 -1
  4. package/dist/assets/{ComplianceWizard-CTihkUi-.js → ComplianceWizard-DKxZ1z25.js} +1 -1
  5. package/dist/assets/DSMView-DJhmrXYm.js +5 -0
  6. package/dist/assets/Dashboard-CYT7KjqU.js +1 -0
  7. package/dist/assets/DhfDashboard-DacdOtkU.js +1 -0
  8. package/dist/assets/DhfWorkbench-CIhopT8J.js +69 -0
  9. package/dist/assets/DiagramCanvas-CLE_nv7Y.js +4 -0
  10. package/dist/assets/{DiagramEditor-UJDHcAUF.js → DiagramEditor-puQuE8gB.js} +2 -2
  11. package/dist/assets/DiagramToolbarControls-XMGLx08e.js +1 -0
  12. package/dist/assets/{ElementDetailView-10U0rr33.js → ElementDetailView-D5XvAL_i.js} +1 -1
  13. package/dist/assets/ExplorerTreeRow-DUmcEsqf.js +3 -0
  14. package/dist/assets/{ImportView-D8svP04Q.js → ImportView-9y1nhQS4.js} +1 -1
  15. package/dist/assets/{LayerGrid-DEe0Ryz-.js → LayerGrid-bhFpOIbe.js} +1 -1
  16. package/dist/assets/{LayerTable-CN_b2rDr.js → LayerTable-RuswZVUI.js} +1 -1
  17. package/dist/assets/{MaxGraphCanvas-bo8oPBct.js → MaxGraphCanvas-D3BXQK2y.js} +1 -1
  18. package/dist/assets/{ModelDiff-xe95oVua.js → ModelDiff-Cl2dhlk3.js} +1 -1
  19. package/dist/assets/{OntologyDecompositionDiagram-BL9R8bdB.js → OntologyDecompositionDiagram-aONGngg4.js} +1 -1
  20. package/dist/assets/{OntologyViewer-CtqNkkCn.js → OntologyViewer-VOrKTRuQ.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-DL0N8Vmk.js → RelationshipOverlay-B3AN-bM-.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-BoJ0aUXe.js → RelationshipsSection-DggeGBKP.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-DeTge2oC.js → ReviewDashboard--LMXZ3F4.js} +1 -1
  24. package/dist/assets/{ScenarioEditor-FAEYTHgP.js → ScenarioEditor-bB4iBbgO.js} +1 -1
  25. package/dist/assets/{StatisticsDashboard-BAZRqIPN.js → StatisticsDashboard-iXimfU20.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-BBfup_Ni.js → SysmlCodeEditor-i0BHj3of.js} +117 -117
  27. package/dist/assets/{TabularView-I4LjHhoH.js → TabularView-DnIfq-TB.js} +1 -1
  28. package/dist/assets/TraceabilityMatrix-eilGn6Sr.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-Cs1ivqzc.js +1 -0
  30. package/dist/assets/{WorkflowWizard-VwpEHt3R.js → WorkflowWizard-C7jI6C59.js} +1 -1
  31. package/dist/assets/index-CG-gfw-s.js +4067 -0
  32. package/dist/assets/index-DXB4CKwW.css +1 -0
  33. package/dist/assets/{index.es-ClbJxlAQ.js → index.es-DABt8CUc.js} +1 -1
  34. package/dist/assets/{jspdf.es.min-DZ68BGxk.js → jspdf.es.min-G-Vwo9yG.js} +3 -3
  35. package/dist/assets/{layout-providers-Dr743WlP.js → layout-providers-BSDYNZu0.js} +1 -1
  36. package/dist/assets/notation-scene-DLZms6VR.js +1 -0
  37. package/dist/assets/{reactflow-s7jmJtXx.js → reactflow-C9OlmOYw.js} +1 -1
  38. package/dist/assets/xlsx-CkFp8p6R.js +105 -0
  39. package/dist/index.html +3 -3
  40. package/dist-standalone/index.html +5504 -0
  41. package/lib/__tests__/standalone-distribution.test.d.ts +2 -0
  42. package/lib/__tests__/standalone-distribution.test.d.ts.map +1 -0
  43. package/lib/__tests__/standalone-distribution.test.js +51 -0
  44. package/lib/__tests__/standalone-distribution.test.js.map +1 -0
  45. package/lib/__tests__/supervised-child-args.test.js +21 -1
  46. package/lib/__tests__/supervised-child-args.test.js.map +1 -1
  47. package/lib/commands/build.d.ts.map +1 -1
  48. package/lib/commands/build.js +15 -18
  49. package/lib/commands/build.js.map +1 -1
  50. package/lib/commands/dev.d.ts +14 -0
  51. package/lib/commands/dev.d.ts.map +1 -1
  52. package/lib/commands/dev.js +40 -1
  53. package/lib/commands/dev.js.map +1 -1
  54. package/lib/feature-grants.d.ts.map +1 -1
  55. package/lib/feature-grants.js +3 -1
  56. package/lib/feature-grants.js.map +1 -1
  57. package/package.json +10 -6
  58. package/dist/assets/DSMView-BiC845df.js +0 -1
  59. package/dist/assets/Dashboard-CgnNLhKq.js +0 -1
  60. package/dist/assets/DhfDashboard-w-dJoJHU.js +0 -1
  61. package/dist/assets/DhfWorkbench-o6B_MT-0.js +0 -69
  62. package/dist/assets/DiagramCanvas-CqGqDbgT.js +0 -3
  63. package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +0 -1
  64. package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +0 -3
  65. package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +0 -3
  66. package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +0 -1
  67. package/dist/assets/editor.worker-DyuDvpVp.js +0 -26
  68. package/dist/assets/element-options-B7AgTB8R.js +0 -3
  69. package/dist/assets/index-BWMNo4wW.css +0 -1
  70. package/dist/assets/index-Bij8Q4Kg.js +0 -45
  71. package/dist/assets/notation-scene-DT8LpWVK.js +0 -1
@@ -1,69 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bij8Q4Kg.js","assets/reactflow-s7jmJtXx.js","assets/zustand-CrhqMOHB.js","assets/index-BWMNo4wW.css"])))=>i.map(i=>d[i]);
2
- import{u as w,p as te,M as oe,_ as ne}from"./index-Bij8Q4Kg.js";import{j as e}from"./reactflow-s7jmJtXx.js";import{a as x}from"./zustand-CrhqMOHB.js";const re=/<div class="memo-doc-diagram" data-diagram-id="([^"]*)"><\/div>/;function m(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function H(t,r){const n=t.split(`
3
- `).map(o=>o.trim()).filter(Boolean);return n.length===0?`<tr><td colspan="4" style="color:#9CA3AF;font-style:italic">No ${r.toLowerCase()}s defined</td></tr>`:n.map(o=>{const[i="",d=""]=o.split("|").map(a=>a.trim());return`<tr><td>${m(i)}</td><td>${m(d||r)}</td><td style="color:#9CA3AF">—</td><td style="color:#9CA3AF">—</td></tr>`}).join("")}function ie(t){const r=t.authors.trim().length>0,n=t.approvers.trim().length>0,o="<thead><tr><th>Name</th><th>Role</th><th>Signature</th><th>Date</th></tr></thead>";return`
4
- <h2>Authors</h2>
5
- <table>${o}<tbody>${H(t.authors,"Author")}</tbody></table>
6
- ${r?"":'<p style="font-size:11px;color:#dc2626">⚠ No authors set — open Document Properties to add authors.</p>'}
7
- <h2>Approvers</h2>
8
- <table>${o}<tbody>${H(t.approvers,"Approver")}</tbody></table>
9
- ${n?"":'<p style="font-size:11px;color:#dc2626">⚠ No approvers set — open Document Properties to add approvers.</p>'}`}function se(t){const r=[],n=/^(#{2,4})\s+(.+)$/gm;let o;for(;(o=n.exec(t))!==null;){const i=(o[1].length-2)*18;r.push(`<div style="margin-left:${i}px">${m(o[2].trim())}</div>`)}return r.length===0?"":`<h2>Table of Contents</h2><div class="memo-doc-toc">${r.join("")}</div>`}function le(t,r,n,o,i){t=t.replace(/\{\{include:shared\/snippets\/approval-block\.md\}\}/g,()=>ie(o)),t=t.replace(/\{\{include:([^}]+)\}\}/g,(a,l)=>`<span class="directive-placeholder">[Snippet: ${m(l)} — rendered on export]</span>`);const d={company:n.company,product:n.product,device_type:n.deviceType,version:n.version,phase:n.phase};return t=t.replace(/\{\{project\.([^}]+)\}\}/g,(a,l)=>{const p=d[l];return p&&p.trim()?m(p):`<span class="directive-error">⚠ {{project.${m(l)}}} — not set</span>`}),t=t.replace(/\{\{ref:([^.}]+)(?:\.(\w+))?\}\}/g,(a,l,p)=>{if(!r)return`<code>${m(l)}</code>`;const h=r.elements[l];return h?m(!p||p==="name"?h.name:String(h[p]??h.name)):`<em>[${m(l)} not found]</em>`}),t=t.replace(/\{\{diagram:([^}]+)\}\}/g,(a,l)=>i.diagrams==="note"?`<p><strong>[Diagram: ${m(l.trim())}]</strong> <em>— view in MEMO Architect</em></p>`:`<div class="memo-doc-diagram" data-diagram-id="${m(l.trim())}"></div>`),t=t.replace(/\{\{toc\}\}/g,()=>i.resolveToc?se(t):'<span class="directive-placeholder">[TOC — generated on export]</span>'),t=t.replace(/\{\{glossary\}\}/g,'<span class="directive-placeholder">[Glossary — generated on export]</span>'),t=t.replace(/\{\{[^}]+\}\}/g,a=>`<span class="directive-placeholder">${m(a)}</span>`),t=t.replace(/```memo-query\r?\n([\s\S]*?)```/g,(a,l)=>{const p=l.split(`
10
- `).filter(Boolean),h=v=>(p.find(E=>E.startsWith(v))??"").replace(v,"").trim(),c=h("kind:")||"?",S=h("display:")||"table",u=h("empty:").replace(/^['"]|['"]$/g,"")||"No results found.",j=h("label:")||c;if(!r)return`<div class="query-preview">⟳ <em>memo-query: ${m(c)} (${m(S)})</em></div>`;const g=c.startsWith("[")||c.startsWith("-")?c.replace(/[\[\]]/g,"").split(/[,\n]/).map(v=>v.replace("-","").trim()).filter(Boolean):[c],f=Object.values(r.elements).filter(v=>g.includes(v.kind));if(f.length===0)return`<div class="query-preview empty"><em>${m(u)}</em></div>`;if(S==="count")return`<div class="query-preview count"><strong>${f.length}</strong><span>${m(j)}</span></div>`;const b=["name","kind","layer"],y=b.map(v=>`<th>${v}</th>`).join(""),B=f.slice(0,10).map(v=>`<tr>${b.map(R=>`<td>${m(String(v[R]??"—"))}</td>`).join("")}</tr>`).join(""),C=f.length>10?`<tr><td colspan="${b.length}" style="color:#9CA3AF;font-size:11px">…and ${f.length-10} more</td></tr>`:"";return`<div class="query-preview"><table><thead><tr>${y}</tr></thead><tbody>${B}${C}</tbody></table></div>`}),t=t.replace(/```memo-script\r?\n([\s\S]*?)```/g,'<div class="query-preview script"><em>memo-script — executed on export</em></div>'),t}function F(t){return t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/_([^_]+)_/g,"<em>$1</em>").replace(/`([^`]+)`/g,(r,n)=>`<code>${m(n)}</code>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>')}const L=/^\|\s*:?-{2,}.*\|$/;function de(t){const r=[],n=t.split(/\r?\n/);let o=0,i=[];const d=()=>{i.length>0&&(r.push(`<p>${F(i.join(" "))}</p>`),i=[])};for(;o<n.length;){const a=n[o],l=a.trim();if(l===""){d(),o++;continue}if(l.startsWith("<")){d(),r.push(a),o++;continue}if(l.match(/^```(\w[\w-]*)?/)){d();const u=[];for(o++;o<n.length&&!n[o].trim().startsWith("```");)u.push(n[o]),o++;o++,r.push(`<pre><code>${m(u.join(`
11
- `))}</code></pre>`);continue}const h=l.match(/^(#{1,6})\s+(.+)$/);if(h){d();const u=h[1].length;r.push(`<h${u}>${F(h[2])}</h${u}>`),o++;continue}if(/^(-{3,}|\*{3,})$/.test(l)){d(),r.push("<hr>"),o++;continue}if(l.startsWith("> ")||l===">"){d();const u=[];for(;o<n.length&&(n[o].trim().startsWith("> ")||n[o].trim()===">");)u.push(n[o].trim().replace(/^>\s?/,"")),o++;r.push(`<blockquote>${F(u.join(" "))}</blockquote>`);continue}if(l.startsWith("|")&&l.endsWith("|")){d();const u=[];for(;o<n.length&&n[o].trim().startsWith("|")&&n[o].trim().endsWith("|");)u.push(n[o].trim()),o++;const j=y=>y.slice(1,-1).split("|").map(B=>B.trim()),g=u.length>1&&L.test(u[1]),f=g?u.slice(2):u;let b="<table>";g&&(b+=`<thead><tr>${j(u[0]).map(y=>`<th>${F(y)}</th>`).join("")}</tr></thead>`),b+=`<tbody>${f.filter(y=>!L.test(y)).map(y=>`<tr>${j(y).map(B=>`<td>${F(B)}</td>`).join("")}</tr>`).join("")}</tbody></table>`,r.push(b);continue}const c=/^[-*]\s+/.test(l),S=/^\d+\.\s+/.test(l);if(c||S){d();const u=c?"ul":"ol",j=c?/^[-*]\s+/:/^\d+\.\s+/,g=[];for(;o<n.length;){const f=n[o].trim();if(j.test(f))g.push(f.replace(j,"")),o++;else if(f!==""&&/^\s{2,}/.test(n[o])&&g.length>0)g[g.length-1]+=` ${f}`,o++;else break}r.push(`<${u}>${g.map(f=>`<li>${F(f)}</li>`).join("")}</${u}>`);continue}i.push(l),o++}return d(),r.join(`
12
- `)}function Y(t,r,n,o,i={}){const d=t.replace(/^---[\s\S]*?---\r?\n/,""),a=le(d,r,n,o,i);return de(a)}const ae="#2DD4A8";function K(t){const r=t.primaryColor||"#1B3A4B",n=ae,o=t.compactMode?.9:1,i=d=>`${Math.round(d*o)}px`;return`
13
- .memo-doc{font-size:${i(14)};line-height:1.7;color:#1B3A4B;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
14
- .memo-doc h1{font-size:${i(22)};font-weight:700;color:${r};border-bottom:2px solid ${n};padding-bottom:8px;margin:0 0 20px}
15
- .memo-doc h2{font-size:${i(17)};font-weight:700;color:${r};margin:28px 0 12px}
16
- .memo-doc h3{font-size:${i(14)};font-weight:600;color:#374151;margin:20px 0 8px}
17
- .memo-doc h4{font-size:${i(13)};font-weight:600;color:#6B7280;margin:12px 0 6px}
18
- .memo-doc h5,.memo-doc h6{font-size:${i(12)};font-weight:600;color:#6B7280;margin:10px 0 5px}
19
- .memo-doc p{margin:8px 0}
20
- .memo-doc ul,.memo-doc ol{margin:8px 0;padding-left:24px}
21
- .memo-doc li{margin:3px 0}
22
- .memo-doc table{border-collapse:collapse;width:100%;margin:12px 0;font-size:${i(12)}}
23
- .memo-doc th,.memo-doc td{border:1px solid #e5e7eb;padding:6px 10px;text-align:left;vertical-align:top}
24
- .memo-doc th{background:#f3f4f6;font-weight:600}
25
- .memo-doc code{background:#f3f4f6;padding:1px 5px;border-radius:3px;font-family:monospace;font-size:${i(12)}}
26
- .memo-doc pre{background:#1e293b;color:#e2e8f0;padding:14px;border-radius:6px;overflow-x:auto}
27
- .memo-doc pre code{background:none;color:inherit;padding:0}
28
- .memo-doc blockquote{border-left:3px solid ${n};margin:12px 0;padding:6px 14px;background:#f0fdf9;font-style:italic;color:#374151}
29
- .memo-doc hr{border:none;border-top:1px solid #e5e7eb;margin:24px 0}
30
- .memo-doc a{color:${r};text-decoration:underline}
31
- .memo-doc .directive-placeholder{color:#8B5CF6;font-style:normal;font-size:${i(12)};background:#F5F3FF;padding:1px 5px;border-radius:3px;display:inline-block}
32
- .memo-doc .directive-error{color:#DC2626;font-size:${i(12)};background:#FEF2F2;border:1px solid #FECACA;padding:1px 6px;border-radius:3px;display:inline-block;font-family:monospace}
33
- .memo-doc .query-preview{background:#f8fafc;border:1px solid #e2e8f0;border-radius:6px;padding:10px 14px;margin:10px 0;font-size:${i(12)}}
34
- .memo-doc .query-preview.empty{color:#9CA3AF}
35
- .memo-doc .query-preview.count{display:flex;align-items:baseline;gap:6px}
36
- .memo-doc .query-preview.count strong{font-size:${i(24)};color:#2563eb;font-weight:700}
37
- .memo-doc .query-preview.count span{font-size:${i(13)};color:#6B7280}
38
- .memo-doc .query-preview.script{color:#7c3aed;font-style:italic}
39
- @media print {
40
- .memo-doc{font-size:11pt;color:#000}
41
- .memo-doc .query-preview{border:1px solid #ccc;background:#fff}
42
- .memo-doc .directive-placeholder,.memo-doc .directive-error{background:#fff;border:1px dashed #999;color:#555}
43
- .memo-doc h2{break-after:avoid}
44
- .memo-doc table{break-inside:avoid}
45
- }`}const ce=`
46
- body{margin:0;padding:40px;background:#fff}
47
- .memo-doc{max-width:800px;margin:0 auto}
48
- @media print{body{padding:0}}
49
- `,pe=`
50
- @page WordSection1{size:8.5in 11.0in;margin:1.0in;mso-header-margin:0.5in;mso-footer-margin:0.5in;mso-footer:f1}
51
- div.WordSection1{page:WordSection1}
52
- p.MsoFooter{font-size:9pt;color:#6B7280}
53
- `;function I(t,r){return`<!--[if supportFields]><span style="mso-element:field-begin"></span><span> ${t} </span><span style="mso-element:field-separator"></span><![endif]-->${r}<!--[if supportFields]><span style="mso-element:field-end"></span><![endif]-->`}const ue=`<h2>Table of Contents</h2><p>${I('TOC \\o "1-3" \\h \\z \\u','<span style="color:#6B7280"><i>Right-click here and choose "Update Field" (or press F9) to generate the table of contents.</i></span>')}</p>`,me=`<div style="mso-element:footer" id="f1"><p class="MsoFooter" align="center" style="text-align:center">Page ${I("PAGE","1")} of ${I("NUMPAGES","1")}</p></div>`;function T(t,r,n,o={}){let i=Y(t.content,r,n,t,{resolveToc:!0,diagrams:"note"});o.word&&(i=i.replace(/<h2>Table of Contents<\/h2><div class="memo-doc-toc">[\s\S]*?<\/div>/,ue));const d=o.word?`<div class="WordSection1"><div class="memo-doc">${i}</div></div>
54
- ${me}`:`<div class="memo-doc">${i}</div>`;return`<!DOCTYPE html>
55
- <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word">
56
- <head>
57
- <meta charset="utf-8">
58
- <title>${N(t.id)} — ${N(t.title)}</title>
59
- ${o.word?'<meta name="ProgId" content="Word.Document"><!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View></w:WordDocument></xml><![endif]-->':""}
60
- <style>${K(n)}${ce}${o.word?pe:""}</style>
61
- </head>
62
- <body>${d}</body>
63
- </html>`}function N(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M(t,r,n){const o=new Blob([r],{type:n}),i=URL.createObjectURL(o),d=document.createElement("a");d.href=i,d.download=t,d.click(),URL.revokeObjectURL(i)}function xe(t,r,n){M(`${t.id}.html`,T(t,r,n),"text/html;charset=utf-8")}function he(t,r,n){M(`${t.id}.doc`,T(t,r,n,{word:!0}),"application/msword")}function fe(t){M(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function ge(t,r,n){const o=window.open("","_blank");o&&(o.document.write(T(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const U=x.lazy(()=>ne(()=>import("./index-Bij8Q4Kg.js").then(t=>t.Y),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.DhfSettingsPanel}))),V=[{id:"q-hazards",label:"Hazard Table",description:"All hazards in the risk layer",category:"query",code:'```memo-query\nkind: Hazard\ndisplay: table\ncolumns: name, layer, doc\nsort: name\nempty: "No hazards defined."\n```'},{id:"q-hazardous-situations",label:"Hazardous Situations",description:"All hazardous situations",category:"query",code:"```memo-query\nkind: HazardousSituation\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-risk-controls",label:"Risk Controls",description:"All risk control measures",category:"query",code:"```memo-query\nkind: RiskControlMeasure\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-requirements",label:"Requirements",description:"All system requirements",category:"query",code:"```memo-query\nkind: Requirement\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-soup",label:"SOUP List",description:"All SOUP components",category:"query",code:"```memo-query\nkind: SOUPComponent\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-sw-items",label:"Software Items",description:"All software items",category:"query",code:"```memo-query\nkind: SoftwareItem\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-test-cases",label:"Test Cases",description:"All test cases",category:"query",code:"```memo-query\nkind: TestCase\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-hazard-count",label:"Hazard Count (metric)",description:"Metric badge with hazard count",category:"query",code:"```memo-query\nkind: Hazard\ndisplay: count\nlabel: Total hazards\n```"},{id:"s-unmitigated",label:"Unmitigated Hazards",description:"Hazards without risk controls",category:"script",code:"```memo-script\nconst hazards = query({ kind: 'Hazard' });\nconst unmitigated = hazards.filter(h => h.mitigatedBy?.length === 0);\nif (unmitigated.length === 0) return 'All hazards have associated risk controls.';\nreturn table(unmitigated, ['name', 'layer', 'doc']);\n```"},{id:"s-coverage",label:"Requirements Coverage",description:"Requirements with/without test cases",category:"script",code:"```memo-script\nconst reqs = query({ kind: 'Requirement' });\nconst covered = reqs.filter(r => r.verifiedBy?.length > 0);\nreturn count(covered, `covered of ${reqs.length} requirements`);\n```"},{id:"i-doc-header",label:"Document Control Header",description:"Standard doc control table",category:"include",code:"{{include:shared/snippets/document-control-header.md}}"},{id:"i-approval",label:"Approval Block",description:"Reviewer/approver signature table",category:"include",code:"{{include:shared/snippets/approval-block.md}}"},{id:"i-revision",label:"Revision History",description:"Revision history table",category:"include",code:"{{include:shared/snippets/revision-history-table.md}}"},{id:"i-references",label:"References Section",description:"Normative references block",category:"include",code:"{{include:shared/snippets/references-section.md}}"},{id:"d-toc",label:"Table of Contents",description:"Auto-generated TOC (on export)",category:"directive",code:"{{toc}}"},{id:"d-glossary",label:"Glossary",description:"Auto-generated glossary (on export)",category:"directive",code:"{{glossary}}"}],J={query:"#2563eb",script:"#7c3aed",include:"#0891b2",directive:"#6B7280"},Q={query:"Query",script:"Script",include:"Snippet",directive:"Directive"};function $e(){const t=w(s=>s.model),r=w(s=>s.activeView),n=w(s=>s.dhfDocuments),o=w(s=>s.updateDhfDocumentContent),i=w(s=>s.updateDhfDocumentMeta),d=w(s=>s.llmAvailable),a=w(s=>s.registerLlmRequest),l=w(s=>s.dhfSettings),[p,h]=x.useState("split"),c=x.useRef(null),[S,u]=x.useState(!1),[j,g]=x.useState(null),[f,b]=x.useState(!1),[y,B]=x.useState(!1),[C,v]=x.useState(!1),[E,R]=x.useState("all"),X=x.useCallback(async(s,A)=>{u(!0),g(null);const z=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`,q=A.split("/").pop()??A;try{const $=await new Promise((W,D)=>{a(z,W,D),te(z,q),setTimeout(()=>D(new Error("Request timed out after 120 seconds.")),12e4)});o(s,$.markdown)}catch($){g(($==null?void 0:$.message)??"Unknown error")}finally{u(!1)}},[a,o]),Z=x.useCallback(s=>{if(!c.current)return;const A=c.current,z=A.selectionStart,q=A.selectionEnd,$=`
64
-
65
- ${s.code}
66
-
67
- `,W=A.value.slice(0,z)+$+A.value.slice(q),D=r.type==="dhf-document"?r.docId:null;D&&o(D,W),requestAnimationFrame(()=>{A.focus();const P=z+$.length;A.setSelectionRange(P,P)})},[r,o]),_=r.type==="dhf-document"?r.docId:null,k=_?n.find(s=>s.id===_):null,O=x.useMemo(()=>{const s=[];return l.company||s.push("company"),l.product||s.push("product"),s},[l]);if(!k)return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",background:"#F7F7F5",color:"#9CA3AF",gap:"12px"},children:[e.jsx(oe,{size:190}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"#6B7280",marginBottom:"6px"},children:"No document selected"}),e.jsxs("div",{style:{fontSize:"12px",color:"#9CA3AF",maxWidth:"280px",lineHeight:"1.6"},children:["Use ",e.jsx("strong",{children:"+ New Document"})," in the explorer to create one, then click it to open."]})]}),e.jsxs("button",{onClick:()=>b(!0),style:{marginTop:"8px",padding:"7px 16px",borderRadius:"6px",border:"1px solid #E5E7EB",background:"#fff",fontSize:"12px",color:"#6B7280",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(G,{size:13})," DHF Settings"]})]}),f&&e.jsx(x.Suspense,{fallback:null,children:e.jsx(U,{onClose:()=>b(!1)})})]});const ee=E==="all"?V:V.filter(s=>s.category===E);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{style:{height:"40px",display:"flex",alignItems:"center",gap:"6px",padding:"0 12px",borderBottom:"1px solid #e5e7eb",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"baseline",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:700,color:"#6B7280",fontFamily:"monospace"},children:k.id}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:k.title})]}),e.jsxs("button",{onClick:()=>v(s=>!s),title:"Document properties (authors, approvers)",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:C?"#6366F1":"#E5E7EB",background:C?"#EEF2FF":"#fff",color:C?"#4338CA":"#6B7280",fontSize:"11px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Authors"]}),e.jsxs("button",{onClick:()=>B(s=>!s),title:"Scriptlets & snippets library",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:y?"#2DD4A8":"#E5E7EB",background:y?"#F0FDF9":"#fff",color:y?"#065F46":"#6B7280",fontSize:"11px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]}),"Snippets"]}),e.jsxs("button",{onClick:()=>X(k.id,k.templateId),disabled:!d||S,title:d?"Use AI to draft empty sections from model data":"Set ANTHROPIC_API_KEY or OPENAI_API_KEY to enable AI drafting",style:{padding:"3px 10px",borderRadius:"6px",border:"none",background:d?"#2DD4A815":"#f3f4f6",color:d?"#065F46":"#9CA3AF",fontSize:"11px",fontWeight:600,cursor:d&&!S?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"4px",opacity:S?.6:1},children:[e.jsx("span",{children:"✦"}),S?"Drafting…":"Draft with AI"]}),e.jsx(ye,{doc:k,model:t,settings:l}),e.jsx("div",{style:{display:"flex",gap:"2px",background:"#f3f4f6",borderRadius:"6px",padding:"2px"},children:["edit","split","preview"].map(s=>e.jsx("button",{onClick:()=>h(s),style:{padding:"3px 10px",borderRadius:"4px",border:"none",fontSize:"11px",fontWeight:500,cursor:"pointer",background:p===s?"#fff":"transparent",color:p===s?"#1B3A4B":"#6B7280",boxShadow:p===s?"0 1px 2px rgba(0,0,0,0.08)":"none"},children:s.charAt(0).toUpperCase()+s.slice(1)},s))}),e.jsx("button",{onClick:()=>b(!0),title:"DHF global settings",style:{padding:"4px",borderRadius:"6px",border:"1px solid #E5E7EB",background:"#fff",cursor:"pointer",color:"#6B7280",display:"flex",alignItems:"center"},children:e.jsx(G,{size:14})})]}),j&&e.jsxs("div",{style:{padding:"6px 16px",background:"#fef2f2",borderBottom:"1px solid #fecaca",fontSize:"12px",color:"#dc2626",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[e.jsxs("span",{children:["AI draft failed: ",j]}),e.jsx("button",{onClick:()=>g(null),style:{background:"none",border:"none",color:"#dc2626",cursor:"pointer",fontSize:"14px"},children:"✕"})]}),O.length>0&&e.jsxs("div",{style:{padding:"5px 16px",background:"#FFFBEB",borderBottom:"1px solid #FDE68A",fontSize:"11px",color:"#92400E",display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("span",{children:["Project settings incomplete — ",e.jsx("strong",{children:O.join(", ")})," not set. ",e.jsx("code",{style:{background:"#FEF3C7",padding:"0 3px",borderRadius:"2px"},children:"{{project.*}}"})," will show as errors in preview."]}),e.jsx("button",{onClick:()=>b(!0),style:{background:"none",border:"none",color:"#92400E",cursor:"pointer",fontWeight:700,fontSize:"11px",padding:0,textDecoration:"underline"},children:"Configure"})]}),C&&e.jsx(be,{doc:k,onUpdate:s=>i(k.id,s)}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(p==="edit"||p==="split")&&e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:p==="split"?"1px solid #e5e7eb":"none"},children:e.jsx("textarea",{ref:c,value:k.content,onChange:s=>o(k.id,s.target.value),spellCheck:!1,style:{flex:1,padding:"20px",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",fontSize:"13px",lineHeight:"1.7",border:"none",outline:"none",resize:"none",background:"#fafafa",color:"#1B3A4B",tabSize:2},placeholder:"Start writing your DHF document here..."})}),(p==="preview"||p==="split")&&e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px 32px",background:"#fff"},children:e.jsx(ke,{content:k.content,model:t,settings:l,doc:k})}),y&&e.jsxs("div",{style:{width:"260px",borderLeft:"1px solid #E5E7EB",display:"flex",flexDirection:"column",background:"#FAFAFA",flexShrink:0,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 12px",borderBottom:"1px solid #E5E7EB",flexShrink:0},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#1B3A4B",marginBottom:"8px"},children:"Scriptlets & Snippets"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:["all","query","script","include","directive"].map(s=>e.jsx("button",{onClick:()=>R(s),style:{padding:"2px 8px",borderRadius:"10px",border:"none",fontSize:"10px",fontWeight:600,cursor:"pointer",background:E===s?s==="all"?"#1B3A4B":J[s]:"#E5E7EB",color:E===s?"#fff":"#6B7280"},children:s==="all"?"All":Q[s]},s))})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:[ee.map(s=>e.jsx(ve,{snippet:s,onInsert:()=>Z(s)},s.id)),e.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",padding:"8px 4px",lineHeight:"1.5"},children:["Custom scriptlets can be added to ",e.jsx("code",{style:{background:"#E5E7EB",padding:"1px 3px",borderRadius:"2px"},children:"shared/snippets/"}),"."]})]})]})]})]}),f&&e.jsx(x.Suspense,{fallback:null,children:e.jsx(U,{onClose:()=>b(!1)})})]})}function ye({doc:t,model:r,settings:n}){const[o,i]=x.useState(!1),d=[{label:"Word (.doc)",hint:"Opens in Word / Pages",run:()=>he(t,r,n)},{label:"PDF",hint:"Via the print dialog",run:()=>ge(t,r,n)},{label:"HTML",hint:"Standalone web page",run:()=>xe(t,r,n)},{label:"Markdown",hint:"Raw document source",run:()=>fe(t)}];return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>i(a=>!a),title:"Export this document",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:o?"#1B3A4B":"#E5E7EB",background:o?"#F1F5F9":"#fff",color:"#1B3A4B",fontSize:"11px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Export"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9997},onClick:()=>i(!1)}),e.jsx("div",{style:{position:"absolute",top:"28px",right:0,zIndex:9998,background:"#fff",borderRadius:"8px",border:"1px solid #E5E7EB",boxShadow:"0 8px 24px rgba(0,0,0,0.12)",padding:"4px 0",minWidth:"200px"},children:d.map(a=>e.jsxs("button",{onClick:()=>{i(!1),a.run()},style:{display:"flex",flexDirection:"column",width:"100%",padding:"7px 14px",background:"none",border:"none",textAlign:"left",cursor:"pointer"},onMouseEnter:l=>l.currentTarget.style.background="#F3F4F6",onMouseLeave:l=>l.currentTarget.style.background="none",children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#1B3A4B"},children:a.label}),e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:a.hint})]},a.label))})]})]})}function be({doc:t,onUpdate:r}){return e.jsxs("div",{style:{borderBottom:"1px solid #E5E7EB",background:"#F9FAFB",padding:"10px 16px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",flexShrink:0},children:[e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:"10px",fontWeight:700,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.05em",display:"block",marginBottom:"4px"},children:["Authors ",e.jsx("span",{style:{color:"#9CA3AF",textTransform:"none",fontWeight:400},children:"(Name | Role, one per line)"})]}),e.jsx("textarea",{value:t.authors,onChange:n=>r({authors:n.target.value}),placeholder:`Jane Smith | Lead Engineer
68
- Bob Jones | Quality Assurance`,rows:3,style:{width:"100%",padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",resize:"none",fontFamily:"inherit",background:"#fff",outline:"none",boxSizing:"border-box",lineHeight:"1.5"}})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:"10px",fontWeight:700,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.05em",display:"block",marginBottom:"4px"},children:["Approvers ",e.jsx("span",{style:{color:"#9CA3AF",textTransform:"none",fontWeight:400},children:"(Name | Role, one per line)"})]}),e.jsx("textarea",{value:t.approvers,onChange:n=>r({approvers:n.target.value}),placeholder:`Alice Brown | Regulatory Affairs
69
- Dr. Carol White | Clinical Safety`,rows:3,style:{width:"100%",padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",resize:"none",fontFamily:"inherit",background:"#fff",outline:"none",boxSizing:"border-box",lineHeight:"1.5"}})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",fontSize:"11px",color:"#9CA3AF",marginTop:"-4px"},children:["These populate ",e.jsx("code",{style:{background:"#E5E7EB",padding:"0 3px",borderRadius:"2px"},children:"{{include:shared/snippets/approval-block.md}}"})," in the preview and exported document."]})]})}function ve({snippet:t,onInsert:r}){const[n,o]=x.useState(!1),i=J[t.category];return e.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{padding:"8px 10px",borderRadius:"6px",marginBottom:"4px",border:`1px solid ${n?i+"60":"#E5E7EB"}`,background:n?i+"08":"#fff",cursor:"default"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{fontSize:"9px",fontWeight:700,padding:"1px 5px",borderRadius:"3px",background:i+"18",color:i},children:Q[t.category]}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#1B3A4B",flex:1},children:t.label})]}),e.jsx("div",{style:{fontSize:"11px",color:"#6B7280",marginBottom:"6px",lineHeight:"1.4"},children:t.description}),e.jsx("button",{onClick:r,style:{padding:"3px 10px",borderRadius:"4px",border:"none",background:i,color:"#fff",fontSize:"10px",fontWeight:600,cursor:"pointer",opacity:n?1:.7},children:"Insert"})]})}function G({size:t}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function ke({content:t,model:r,settings:n,doc:o}){const i=x.useMemo(()=>Y(t,r,n,o),[t,r,n,o]),d=x.useMemo(()=>K(n),[n]),a=x.useMemo(()=>i.split(new RegExp(re,"g")),[i]);return e.jsxs("div",{className:"memo-doc",children:[e.jsx("style",{children:d}),a.map((l,p)=>p%2===0?e.jsx("div",{dangerouslySetInnerHTML:{__html:l}},p):e.jsx(je,{diagramRef:l,model:r},p))]})}function je({diagramRef:t,model:r}){var h;const n=w(c=>c.setActiveView),o=w(c=>c.selectDiagram),i=c=>c.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/view$/,""),d=i(t),a=(r==null?void 0:r.diagrams)??[],l=a.find(c=>c.id===t)??a.find(c=>i(c.id)===d||i(c.name)===d)??a.find(c=>d.length>=6&&(i(c.name).includes(d)||i(c.id).includes(d)));if(!l)return e.jsxs("div",{style:{margin:"10px 0",padding:"10px 14px",borderRadius:"6px",border:"1px dashed #FCA5A5",background:"#FEF2F2",fontSize:"12px",color:"#DC2626"},children:["⚠ Diagram ",e.jsx("code",{style:{background:"#FEE2E2",padding:"0 4px",borderRadius:"3px"},children:t})," not found in the model — check the id in ",e.jsx("code",{style:{background:"#FEE2E2",padding:"0 4px",borderRadius:"3px"},children:"{{diagram:…}}"}),"."]});const p=()=>{o(l.id),n({type:"diagram",diagramId:l.id})};return e.jsx("div",{style:{margin:"10px 0",borderRadius:"8px",border:"1px solid #E2E8F0",background:"#F8FAFC",overflow:"hidden"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px"},children:[e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"#2DD4A8",strokeWidth:"1.8",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"8.5",y:"16",width:"7",height:"5",rx:"1"}),e.jsx("path",{d:"M6.5 8v4h11V8M12 12v4"})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:l.name}),e.jsxs("div",{style:{fontSize:"11px",color:"#6B7280"},children:[l.viewKind||l.diagramType,(h=l.elementIds)!=null&&h.length?` · ${l.elementIds.length} elements`:""]})]}),e.jsx("button",{onClick:p,style:{padding:"5px 12px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"Open diagram →"})]})})}export{$e as DhfWorkbench};