@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.
- package/README.md +26 -4
- package/dist/assets/AiWorkspace-Bu9TlIWg.js +7 -0
- package/dist/assets/AnalysisWorkspace-CodmoI-v.js +39 -0
- package/dist/assets/{ComplianceWizard-k98NZ2ec.js → ComplianceWizard-CTihkUi-.js} +1 -1
- package/dist/assets/DSMView-BiC845df.js +1 -0
- package/dist/assets/Dashboard-CgnNLhKq.js +1 -0
- package/dist/assets/{DhfDashboard-B9V_n7kg.js → DhfDashboard-w-dJoJHU.js} +1 -1
- package/dist/assets/{DhfWorkbench-TOnZkdUU.js → DhfWorkbench-o6B_MT-0.js} +15 -15
- package/dist/assets/DiagramCanvas-CqGqDbgT.js +3 -0
- package/dist/assets/DiagramEditor-UJDHcAUF.js +4 -0
- package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +1 -0
- package/dist/assets/ElementDetailView-10U0rr33.js +2 -0
- package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +3 -0
- package/dist/assets/{ImportView-CyMm-tSP.js → ImportView-D8svP04Q.js} +1 -1
- package/dist/assets/{LayerGrid-DNPZYTsD.js → LayerGrid-DEe0Ryz-.js} +1 -1
- package/dist/assets/{LayerTable-DhOq1DHo.js → LayerTable-CN_b2rDr.js} +2 -2
- package/dist/assets/{MaxGraphCanvas-DqKU1PTY.js → MaxGraphCanvas-bo8oPBct.js} +6 -6
- package/dist/assets/{ModelDiff-BbqIoesG.js → ModelDiff-xe95oVua.js} +1 -1
- package/dist/assets/OntologyDecompositionDiagram-BL9R8bdB.js +1 -0
- package/dist/assets/{OntologyViewer-BIpJC66j.js → OntologyViewer-CtqNkkCn.js} +2 -2
- package/dist/assets/{RelationshipOverlay-B9bqt4zl.js → RelationshipOverlay-DL0N8Vmk.js} +1 -1
- package/dist/assets/{RelationshipsSection-DttMvF2i.js → RelationshipsSection-BoJ0aUXe.js} +1 -1
- package/dist/assets/{ReviewDashboard-DKoExM8K.js → ReviewDashboard-DeTge2oC.js} +1 -1
- package/dist/assets/ScenarioEditor-FAEYTHgP.js +3 -0
- package/dist/assets/{StatisticsDashboard-B8BduIDz.js → StatisticsDashboard-BAZRqIPN.js} +1 -1
- package/dist/assets/{SysmlCodeEditor-Die2RUsz.js → SysmlCodeEditor-BBfup_Ni.js} +1 -1
- package/dist/assets/TabularView-I4LjHhoH.js +1 -0
- package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +3 -0
- package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +1 -0
- package/dist/assets/{WorkflowWizard-7--f9OH2.js → WorkflowWizard-VwpEHt3R.js} +1 -1
- package/dist/assets/element-options-B7AgTB8R.js +3 -0
- package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
- package/dist/assets/index-BWMNo4wW.css +1 -0
- package/dist/assets/index-Bij8Q4Kg.js +45 -0
- package/dist/assets/index.es-ClbJxlAQ.js +18 -0
- package/dist/assets/jspdf.es.min-DZ68BGxk.js +170 -0
- package/dist/assets/notation-scene-DT8LpWVK.js +1 -0
- package/dist/assets/purify.es-DP5U8-sc.js +3 -0
- package/dist/assets/{reactflow-CsCqNKB-.js → reactflow-s7jmJtXx.js} +5 -5
- package/dist/index.html +3 -3
- package/lib/__tests__/compiler-bundling.test.d.ts +2 -0
- package/lib/__tests__/compiler-bundling.test.d.ts.map +1 -0
- package/lib/__tests__/compiler-bundling.test.js +32 -0
- package/lib/__tests__/compiler-bundling.test.js.map +1 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts +2 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts.map +1 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.js +22 -0
- package/lib/__tests__/standard-sysml-diagrams-smoke.test.js.map +1 -0
- package/lib/__tests__/supervised-child-args.test.d.ts +2 -0
- package/lib/__tests__/supervised-child-args.test.d.ts.map +1 -0
- package/lib/__tests__/supervised-child-args.test.js +35 -0
- package/lib/__tests__/supervised-child-args.test.js.map +1 -0
- package/lib/bin/memo-architect.js +30 -4
- package/lib/bin/memo-architect.js.map +1 -1
- package/lib/commands/dev.d.ts +18 -2
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +56 -8
- package/lib/commands/dev.js.map +1 -1
- package/lib/commands/example.d.ts +1 -0
- package/lib/commands/example.d.ts.map +1 -1
- package/lib/commands/example.js +2 -0
- package/lib/commands/example.js.map +1 -1
- package/package.json +11 -5
- package/dist/assets/AiWorkspace-DS79vBOT.js +0 -3
- package/dist/assets/AnalysisWorkspace-D_u4shRY.js +0 -39
- package/dist/assets/DSMView-DGheBwZ0.js +0 -1
- package/dist/assets/Dashboard-BRUQvUFK.js +0 -1
- package/dist/assets/DhfSettingsPanel-B8aLsWn6.js +0 -1
- package/dist/assets/DiagramCanvas-B9d4aLKt.js +0 -1
- package/dist/assets/DiagramEditor-CJ7OG2IC.js +0 -4
- package/dist/assets/ElementDetailView-CDcm1rvf.js +0 -2
- package/dist/assets/OntologyDecompositionDiagram-DkxTe2C_.js +0 -1
- package/dist/assets/ScenarioEditor-JQ3huCnz.js +0 -3
- package/dist/assets/TabularView-BXfFSluC.js +0 -1
- package/dist/assets/TraceabilityMatrix-CHZHFucA.js +0 -1
- package/dist/assets/index-CVW92JY7.js +0 -3280
- package/dist/assets/index-Y1UZTZg-.css +0 -1
- package/dist/assets/layout-selection-ClQ295Xc.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/
|
|
2
|
-
import{u as w,
|
|
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
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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
4
|
<h2>Authors</h2>
|
|
5
5
|
<table>${o}<tbody>${H(t.authors,"Author")}</tbody></table>
|
|
6
6
|
${r?"":'<p style="font-size:11px;color:#dc2626">⚠ No authors set — open Document Properties to add authors.</p>'}
|
|
7
7
|
<h2>Approvers</h2>
|
|
8
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
|
|
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.",
|
|
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
|
|
12
|
-
`)}function Y(t,r,n,o,i={}){const d=t.replace(/^---[\s\S]*?---\r?\n/,""),a=
|
|
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
13
|
.memo-doc{font-size:${i(14)};line-height:1.7;color:#1B3A4B;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
|
|
14
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
15
|
.memo-doc h2{font-size:${i(17)};font-weight:700;color:${r};margin:28px 0 12px}
|
|
@@ -42,28 +42,28 @@ ${n?"":'<p style="font-size:11px;color:#dc2626">⚠ No approvers set — open Do
|
|
|
42
42
|
.memo-doc .directive-placeholder,.memo-doc .directive-error{background:#fff;border:1px dashed #999;color:#555}
|
|
43
43
|
.memo-doc h2{break-after:avoid}
|
|
44
44
|
.memo-doc table{break-inside:avoid}
|
|
45
|
-
}`}const
|
|
45
|
+
}`}const ce=`
|
|
46
46
|
body{margin:0;padding:40px;background:#fff}
|
|
47
47
|
.memo-doc{max-width:800px;margin:0 auto}
|
|
48
48
|
@media print{body{padding:0}}
|
|
49
|
-
`,
|
|
49
|
+
`,pe=`
|
|
50
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
51
|
div.WordSection1{page:WordSection1}
|
|
52
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
|
|
54
|
-
${
|
|
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
55
|
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word">
|
|
56
56
|
<head>
|
|
57
57
|
<meta charset="utf-8">
|
|
58
58
|
<title>${N(t.id)} — ${N(t.title)}</title>
|
|
59
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)}${
|
|
60
|
+
<style>${K(n)}${ce}${o.word?pe:""}</style>
|
|
61
61
|
</head>
|
|
62
62
|
<body>${d}</body>
|
|
63
|
-
</html>`}function N(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function
|
|
63
|
+
</html>`}function N(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}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
64
|
|
|
65
65
|
${s.code}
|
|
66
66
|
|
|
67
|
-
`,W=A.value.slice(0,z)+B+A.value.slice(q),D=r.type==="dhf-document"?r.docId:null;D&&o(D,W),requestAnimationFrame(()=>{A.focus();const P=z+B.length;A.setSelectionRange(P,P)})},[r,o]),M=r.type==="dhf-document"?r.docId:null,j=M?n.find(s=>s.id===M):null,O=x.useMemo(()=>{const s=[];return l.company||s.push("company"),l.product||s.push("product"),s},[l]);if(!j)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.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#D1D5DB",strokeWidth:"1.5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}),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:j.id}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:j.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:()=>$(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(j.id,j.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(ge,{doc:j,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})})]}),k&&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: ",k]}),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(ye,{doc:j,onUpdate:s=>i(j.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:j.content,onChange:s=>o(j.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(ve,{content:j.content,model:t,settings:l,doc:j})}),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(be,{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 ge({doc:t,model:r,settings:n}){const[o,i]=x.useState(!1),d=[{label:"Word (.doc)",hint:"Opens in Word / Pages",run:()=>xe(t,r,n)},{label:"PDF",hint:"Via the print dialog",run:()=>fe(t,r,n)},{label:"HTML",hint:"Standalone web page",run:()=>me(t,r,n)},{label:"Markdown",hint:"Raw document source",run:()=>he(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 ye({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
|
|
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
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
|
|
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};
|