@memoarchitect/architect 0.4.6 → 0.6.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 (58) hide show
  1. package/README.md +44 -3
  2. package/dist/assets/AskPanel-Dqc6aaqg.js +1 -0
  3. package/dist/assets/ComplianceWizard-Bi9PLmJH.js +1 -0
  4. package/dist/assets/{DSMView-B4IEz19F.js → DSMView-DbC_fUKT.js} +1 -1
  5. package/dist/assets/{Dashboard-DNRzU1Hk.js → Dashboard-6Dgma4kY.js} +1 -1
  6. package/dist/assets/DhfDashboard-BPXIYJnw.js +1 -0
  7. package/dist/assets/{DhfSettingsPanel-C89T0dv7.js → DhfSettingsPanel-jQ5mh_50.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-4gHayn-l.js → DhfWorkbench-CgFdQIts.js} +3 -3
  9. package/dist/assets/DiagramCanvas-CIfN1ybl.js +1 -0
  10. package/dist/assets/DiagramEditor-Y4sSx9nO.js +4 -0
  11. package/dist/assets/ElementDetailView-B946aM3p.js +2 -0
  12. package/dist/assets/{ImportView-t1dIoZF5.js → ImportView-HCDzL9Xx.js} +1 -1
  13. package/dist/assets/{LayerGrid-fSGvqSEj.js → LayerGrid-DSxAFwPk.js} +1 -1
  14. package/dist/assets/{LayerTable-D8QCFY1b.js → LayerTable-C5VBpm6T.js} +2 -2
  15. package/dist/assets/{MaxGraphCanvas-DYs6MPuP.js → MaxGraphCanvas-B7tAFvDf.js} +6 -6
  16. package/dist/assets/{ModelDiff-CLFqnELG.js → ModelDiff-MM5NKKXK.js} +1 -1
  17. package/dist/assets/OntologyDecompositionDiagram-CAzu3z_q.js +1 -0
  18. package/dist/assets/{OntologyViewer-72jTw72H.js → OntologyViewer-C5ik2Kmi.js} +2 -2
  19. package/dist/assets/{RelationshipOverlay-BDrBRSPP.js → RelationshipOverlay-DSzjs5U7.js} +1 -1
  20. package/dist/assets/{RelationshipsSection-D1-tuVYo.js → RelationshipsSection-2CEoiF6o.js} +1 -1
  21. package/dist/assets/{ReviewDashboard-BVOe2I5w.js → ReviewDashboard-DwlsAVBa.js} +1 -1
  22. package/dist/assets/ScenarioEditor-BRWvcD2f.js +3 -0
  23. package/dist/assets/{StatisticsDashboard-Dn6lsnKe.js → StatisticsDashboard-C67W4pb0.js} +1 -1
  24. package/dist/assets/{SysmlCodeEditor-BLcw6hdp.js → SysmlCodeEditor-CGOcUFE7.js} +1 -1
  25. package/dist/assets/SysmlGenerator-BwRhtec-.js +1 -0
  26. package/dist/assets/{TabularView-B99xy3H3.js → TabularView-CTQgMG25.js} +1 -1
  27. package/dist/assets/TraceabilityMatrix-Bw5ej-So.js +1 -0
  28. package/dist/assets/{WorkflowWizard-C38DZKOe.js → WorkflowWizard-BwGWzMkE.js} +1 -1
  29. package/dist/assets/index-D0i9ua6F.js +3277 -0
  30. package/dist/assets/index-DPzXL4uF.css +1 -0
  31. package/dist/assets/{layout-providers-BAUgp0nu.js → layout-providers-BFnfta4Z.js} +13 -13
  32. package/dist/assets/layout-selection-BTId1JyG.js +1 -0
  33. package/dist/assets/{reactflow-WKyu73tD.js → reactflow-CX-HDacK.js} +1 -1
  34. package/dist/index.html +3 -3
  35. package/lib/bin/memo-architect.js +39 -3
  36. package/lib/bin/memo-architect.js.map +1 -1
  37. package/lib/commands/dev.d.ts.map +1 -1
  38. package/lib/commands/dev.js +9 -0
  39. package/lib/commands/dev.js.map +1 -1
  40. package/lib/commands/example.d.ts +16 -0
  41. package/lib/commands/example.d.ts.map +1 -0
  42. package/lib/commands/example.js +143 -0
  43. package/lib/commands/example.js.map +1 -0
  44. package/package.json +5 -4
  45. package/dist/assets/AskPanel-D9_AKyYt.js +0 -1
  46. package/dist/assets/ComplianceWizard-BNvT_ic6.js +0 -1
  47. package/dist/assets/DhfDashboard-DguH-rDT.js +0 -1
  48. package/dist/assets/DiagramCanvas-BgfO0AtP.js +0 -1
  49. package/dist/assets/DiagramEditor-CEr6iqBf.js +0 -4
  50. package/dist/assets/DiagramSurface-B_lfUNzV.js +0 -2
  51. package/dist/assets/ElementDetailView-AclSjurg.js +0 -2
  52. package/dist/assets/OntologyDecompositionDiagram-cpmTTMRH.js +0 -1
  53. package/dist/assets/ScenarioEditor-CvOkiRC6.js +0 -3
  54. package/dist/assets/SysmlGenerator-CfBQWovl.js +0 -1
  55. package/dist/assets/TraceabilityMatrix-BAJb0X7G.js +0 -1
  56. package/dist/assets/index-CgRwea72.js +0 -3277
  57. package/dist/assets/index-CnFhl4_e.css +0 -1
  58. package/dist/assets/layout-selection-BQ2WuAEB.js +0 -1
@@ -1,2 +0,0 @@
1
- import{j as e}from"./reactflow-WKyu73tD.js";import{a as v}from"./zustand-qbFpP9Up.js";import{u as d,e as B,C as t,F as n,d as A,K,S as z}from"./index-CgRwea72.js";const R=new Set(["Scenario","UseCase","UserActivity"]);function W(i){return i?i.split(`
2
- `).filter(o=>o.trim()).map((o,c)=>{const p=o.match(/^\d+\.\s*(.*)/);return{index:c,text:p?p[1].trim():o.trim()}}):[]}function V({element:i,layerColor:o}){const c=v.useMemo(()=>W(i.doc||""),[i.doc]),[p,u]=v.useState(!1),S=d(r=>r.updateElementField),f=d(r=>r.applyEdit),y=d(r=>r.pendingEdits).get(i.id),l=(y==null?void 0:y.doc)??i.doc??"";if(c.length===0&&!p)return e.jsx("div",{className:"rounded-lg p-4 cursor-pointer text-center",style:{background:o+"08",border:`1px dashed ${o}40`,color:t.faint,fontSize:n.sm},onClick:()=>u(!0),children:"No steps defined. Click to add scenario steps (one per line, numbered)."});if(p){const r=()=>{f(i.id),u(!1)};return e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:n.xs,color:t.faint,marginBottom:"6px"},children:["Enter numbered steps, one per line: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx("textarea",{value:l,onChange:b=>S(i.id,"doc",b.target.value),className:"w-full rounded-lg p-3 focus:outline-none",style:{border:`1px solid ${t.accent}`,background:t.surface,color:t.primary,fontSize:n.sm,minHeight:"120px",resize:"vertical",fontFamily:"monospace",lineHeight:1.7},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:r,className:"px-3 py-1.5 rounded-md font-medium",style:{background:t.accent,color:t.accentDark,fontSize:n.xs},children:"Save"}),e.jsx("button",{onClick:()=>u(!1),className:"px-3 py-1.5 rounded-md",style:{color:t.muted,fontSize:n.xs,border:`1px solid ${t.border}`},children:"Cancel"})]})]})}return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>u(!0),style:{position:"absolute",top:0,right:0,fontSize:n.xs,color:t.faint,padding:"2px 8px",border:`1px solid ${t.border}`,borderRadius:"6px",background:t.surface,cursor:"pointer"},onMouseEnter:r=>r.currentTarget.style.borderColor=t.accent,onMouseLeave:r=>r.currentTarget.style.borderColor=t.border,children:"Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0,paddingTop:"4px"},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:n.xs,fontWeight:700,background:o,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),c.map((r,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx("div",{style:{width:"2px",height:"20px",background:o+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${o}80`}})}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:t.surface,border:`1px solid ${o}30`,borderRadius:"8px",padding:"10px 14px",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("span",{style:{flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:o+"18",color:o,fontSize:n.xs,fontWeight:700},children:b+1}),e.jsx("span",{style:{fontSize:n.sm,color:t.primary,lineHeight:1.5,paddingTop:"3px"},children:r.text})]})]},b)),e.jsx("div",{style:{width:"2px",height:"20px",background:o+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${o}80`}})}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:n.xs,fontWeight:700,background:o+"20",color:o,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${o}40`},children:"End"})]})]})}function X(){const i=d(s=>s.activeView),o=d(s=>s.model),c=d(s=>s.validation),p=d(s=>s.selectElement),u=d(s=>s.updateElementField),S=d(s=>s.updateElementAttribute),f=d(s=>s.cancelEdit),x=d(s=>s.applyEdit),y=d(s=>s.pendingEdits),l=i.type==="element-detail"?i.elementId:null,r=l&&o?o.elements[l]:null,[b,w]=v.useState(!1),[L,k]=v.useState(null),m=v.useMemo(()=>{if(!o||!l)return{incoming:[],outgoing:[]};const s=B(o,l);return{incoming:s.filter(a=>a.targetId===l),outgoing:s.filter(a=>a.sourceId===l)}},[o,l]),E=v.useMemo(()=>!c||!l?[]:c.violations.filter(s=>s.elementId===l),[c,l]);if(!r||!l)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:t.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:t.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:n.md},children:"Select an element to view details"})]})});const C=A[r.layer]||t.muted,h=K[r.kind],j=y.get(l),F=(j==null?void 0:j.doc)??r.doc??"",O=y.has(l),T=()=>{x(l),w(!1),k(null)},D=s=>{if(!o)return s;const a=o.elements[s];return a?a.name:s};return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:t.surfaceAlt},children:e.jsxs("div",{style:{maxWidth:"900px",margin:"0 auto",padding:"32px 40px"},children:[e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-2 py-1 rounded font-semibold",style:{background:C+"18",color:C,fontSize:n.sm},children:r.kind}),e.jsx("span",{className:"px-2 py-1 rounded",style:{background:((h==null?void 0:h.color)||t.muted)+"12",color:(h==null?void 0:h.color)||t.muted,fontSize:n.xs},children:r.layer}),h&&e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:h.label})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:t.primary,lineHeight:1.3},children:r.name}),e.jsx("p",{className:"mt-1",style:{color:t.faint,fontSize:n.xs,fontFamily:"monospace"},children:r.id})]}),O&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>f(l),className:"px-4 py-2 rounded-lg font-medium transition-all",style:{background:t.surface,color:t.muted,fontSize:n.sm,border:`1px solid ${t.border}`},onMouseEnter:s=>s.currentTarget.style.borderColor=t.accent,onMouseLeave:s=>s.currentTarget.style.borderColor=t.border,children:"Cancel"}),e.jsx("button",{onClick:T,className:"px-4 py-2 rounded-lg font-medium transition-all",style:{background:t.accent,color:t.accentDark,fontSize:n.sm,boxShadow:z.sm},onMouseEnter:s=>s.currentTarget.style.boxShadow=z.md,onMouseLeave:s=>s.currentTarget.style.boxShadow=z.sm,children:"Save Changes"})]})]}),E.length>0&&e.jsxs("div",{className:"rounded-lg mb-6 overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2"},children:[e.jsxs("div",{className:"px-4 py-2 font-medium",style:{color:"#DC2626",fontSize:n.sm,borderBottom:"1px solid #FEE2E2"},children:[E.length," violation",E.length!==1?"s":""]}),E.map((s,a)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:n.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:t.faint},children:["[",s.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:s.description})]},a))]}),R.has(r.kind)&&e.jsx(N,{title:"Flow",children:e.jsx(V,{element:r,layerColor:C})}),!R.has(r.kind)&&e.jsx(N,{title:"Description",children:b?e.jsxs("div",{children:[e.jsx("textarea",{value:F,onChange:s=>u(l,"doc",s.target.value),className:"w-full rounded-lg p-3 focus:outline-none focus:ring-2",style:{border:`1px solid ${t.border}`,background:t.surface,color:t.primary,fontSize:n.md,minHeight:"120px",resize:"vertical",fontFamily:"inherit",lineHeight:1.6,"--tw-ring-color":t.accent},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:T,className:"px-3 py-1.5 rounded-md font-medium",style:{background:t.accent,color:t.accentDark,fontSize:n.xs},children:"Save"}),e.jsx("button",{onClick:()=>w(!1),className:"px-3 py-1.5 rounded-md",style:{color:t.muted,fontSize:n.xs,border:`1px solid ${t.border}`},children:"Cancel"})]})]}):e.jsx("div",{className:"rounded-lg p-4 cursor-pointer transition-all",style:{background:t.surface,border:`1px solid ${t.border}`,minHeight:"60px",color:F?t.primary:t.faint,fontSize:n.md,lineHeight:1.6},onClick:()=>w(!0),onMouseEnter:s=>s.currentTarget.style.borderColor=t.accent,onMouseLeave:s=>s.currentTarget.style.borderColor=t.border,title:"Click to edit",children:F||"Click to add a description..."})}),e.jsx(N,{title:"Attributes",children:e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${t.border}`,background:t.surface},children:e.jsxs("table",{className:"w-full",style:{fontSize:n.sm},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${t.border}`,background:t.surfaceAlt},children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:t.secondary,width:"35%"},children:"Key"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:t.secondary},children:"Value"})]})}),e.jsxs("tbody",{children:[Object.entries(r.attributes).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:2,className:"px-4 py-3 text-center",style:{color:t.faint},children:"No attributes"})}),Object.entries(r.attributes).map(([s,a])=>{var I;const $=((I=j==null?void 0:j.attributes)==null?void 0:I[s])??a,H=L===s;return e.jsxs("tr",{style:{borderBottom:`1px solid ${t.borderLight}`},children:[e.jsx("td",{className:"px-4 py-2",style:{color:t.secondary,fontFamily:"monospace",fontSize:n.xs},children:s}),e.jsx("td",{className:"px-4 py-2",children:H?e.jsx("input",{type:"text",value:$,onChange:g=>S(l,s,g.target.value),onBlur:()=>k(null),onKeyDown:g=>{g.key==="Enter"&&k(null)},className:"w-full px-2 py-1 rounded focus:outline-none",style:{border:`1px solid ${t.accent}`,color:t.primary,fontSize:n.sm},autoFocus:!0}):e.jsx("span",{className:"cursor-pointer block px-2 py-1 rounded",style:{color:t.primary},onClick:()=>k(s),onMouseEnter:g=>g.currentTarget.style.background=t.surfaceAlt,onMouseLeave:g=>g.currentTarget.style.background="transparent",title:"Click to edit",children:$||e.jsx("span",{style:{color:t.faint},children:"—"})})})]},s)})]})]})})}),(m.outgoing.length>0||m.incoming.length>0)&&e.jsxs(N,{title:"Relationships",children:[m.outgoing.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h4",{className:"font-medium mb-2",style:{color:t.secondary,fontSize:n.sm},children:["Outgoing (",m.outgoing.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.outgoing.map((s,a)=>e.jsx(M,{rel:s,direction:"out",resolveName:D,onNavigate:p},a))})]}),m.incoming.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",style:{color:t.secondary,fontSize:n.sm},children:["Incoming (",m.incoming.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.incoming.map((s,a)=>e.jsx(M,{rel:s,direction:"in",resolveName:D,onNavigate:p},a))})]})]}),r.file&&e.jsx(N,{title:"Source",children:e.jsx("div",{className:"rounded-lg px-4 py-3",style:{background:t.surface,border:`1px solid ${t.border}`,fontSize:n.xs,fontFamily:"monospace",color:t.secondary},children:r.file})})]})})}function N({title:i,children:o}){return e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold mb-3",style:{color:t.primary,fontSize:n.lg,letterSpacing:"-0.01em"},children:i}),o]})}function M({rel:i,direction:o,resolveName:c,onNavigate:p}){const u=o==="out"?i.targetId:i.sourceId,S=c(u),f=A[i.type]||t.accent;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer transition-all",style:{background:t.surface,border:`1px solid ${t.border}`,fontSize:n.sm},onClick:()=>p(u),onMouseEnter:x=>{x.currentTarget.style.borderColor=t.accent,x.currentTarget.style.boxShadow=z.sm},onMouseLeave:x=>{x.currentTarget.style.borderColor=t.border,x.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:o==="out"?"→":"←"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded font-medium",style:{background:f+"15",color:f,fontSize:n.badge},children:i.type}),e.jsx("span",{className:"flex-1 truncate font-medium",style:{color:t.accentDark},children:S}),e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:"›"})]})}export{X as ElementDetailView};
@@ -1 +0,0 @@
1
- import{j as e,H as C,P as k,R as D,u as S,i as O,f as R,g as T}from"./reactflow-WKyu73tD.js";import{a as p}from"./zustand-qbFpP9Up.js";/* empty css */import{r as I}from"./layout-providers-BAUgp0nu.js";import{d as L,u as h,t as P,v as M,w as z}from"./index-CgRwea72.js";import"./elk-B75IRfCd.js";import"web-worker";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memo/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,V=180;async function K(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:V})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await I(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function U(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return K(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(T,{showInteractive:!1})]})}),t&&e.jsx(Z,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const Z=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function ne(){return e.jsx(D,{children:e.jsx(U,{})})}export{ne as OntologyDecompositionDiagram,ne as default};
@@ -1,3 +0,0 @@
1
- import{j as s}from"./reactflow-WKyu73tD.js";import{a}from"./zustand-qbFpP9Up.js";import{u as j,e as U,f as $,d as F,h as z}from"./index-CgRwea72.js";function w(d){return d?d.split(`
2
- `).filter(o=>o.trim()).map((o,p)=>{const h=o.match(/^\d+\.\s*(.*)/);return{index:p,text:h?h[1]:o}}):[]}function _(d){return d.map((m,o)=>`${o+1}. ${m.text}`).join(`
3
- `)}function q(){const d=j(e=>e.model),m=j(e=>e.selectElement),o=j(e=>e.selectedElementId),[p,h]=a.useState(""),[r,u]=a.useState(null),[y,k]=a.useState(""),[b,v]=a.useState(null),[g,N]=a.useState(""),f=a.useMemo(()=>d?Object.values(d.elements).filter(e=>e.kind==="Scenario"||e.kind==="UseCase"||e.kind==="UserActivity"):[],[d]),E=a.useMemo(()=>{if(!p)return f;const e=p.toLowerCase();return f.filter(t=>t.name.toLowerCase().includes(e)||t.kind.toLowerCase().includes(e))},[f,p]),C=a.useMemo(()=>{const e=new Map;for(const t of E)e.has(t.kind)||e.set(t.kind,[]),e.get(t.kind).push(t);return[...e.entries()].sort((t,n)=>t[0].localeCompare(n[0]))},[E]),c=o&&d?d.elements[o]:null,A=a.useMemo(()=>U(d,o||""),[d,o]),i=a.useMemo(()=>r||(c?w(c.doc||""):[]),[c,r]),M=a.useCallback(()=>{c&&u(w(c.doc||""))},[c]),B=a.useCallback(()=>{if(!c||!r)return;const e=_(r);$({...c,doc:e}),u(null)},[c,r]),S=a.useCallback(()=>{if(!y.trim())return;const e=[...r||i,{index:i.length,text:y.trim()}];u(e),k("")},[y,r,i]),L=a.useCallback(e=>{const t=(r||i).filter((n,l)=>l!==e);u(t)},[r,i]),D=a.useCallback((e,t)=>{const n=[...r||i],l=e+t;l<0||l>=n.length||([n[e],n[l]]=[n[l],n[e]],u(n))},[r,i]),T=a.useCallback((e,t)=>{const n=[...r||i];n[e]={...n[e],text:t},u(n)},[r,i]),R=a.useMemo(()=>{if(!d||!g)return[];const e=g.toLowerCase();return Object.values(d.elements).filter(t=>t.id!==o&&t.name.toLowerCase().includes(e)).slice(0,10)},[d,g,o]),[I,O]=a.useState(new Set),G=e=>{O(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsxs("div",{className:"w-72 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[s.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:s.jsx("input",{type:"text",placeholder:`Search ${f.length} scenarios...`,value:p,onChange:e=>h(e.target.value),className:"w-full px-3 py-2 text-sm rounded-lg focus:outline-none",style:{background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#1a1a1a"}})}),s.jsxs("div",{className:"flex-1 overflow-y-auto text-xs py-1",children:[C.map(([e,t])=>{const n=I.has(e);return s.jsxs("div",{className:"mb-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 cursor-pointer",style:{borderRadius:"6px",margin:"0 4px"},onMouseEnter:l=>l.currentTarget.style.background="#F0F0ED",onMouseLeave:l=>l.currentTarget.style.background="transparent",onClick:()=>G(e),children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:F.functional,borderRadius:"3px"}}),s.jsx("span",{className:"font-medium flex-1",style:{color:"#374151"},children:e}),s.jsx("span",{style:{color:"#9CA3AF"},children:t.length}),s.jsx("span",{style:{color:"#D1D5DB"},children:n?"▸":"▾"})]}),!n&&t.map(l=>s.jsx("div",{className:"px-3 py-1 ml-6 cursor-pointer flex items-center gap-1.5",style:{borderRadius:"6px",background:o===l.id?"#2DD4A818":"transparent",color:o===l.id?"#1B3A4B":"#374151",fontWeight:o===l.id?500:400},onMouseEnter:x=>{o!==l.id&&(x.currentTarget.style.background="#F0F0ED")},onMouseLeave:x=>{o!==l.id&&(x.currentTarget.style.background="transparent")},onClick:()=>{m(l.id),u(null)},children:s.jsx("span",{className:"truncate",children:l.name})},l.id))]},e)}),C.length===0&&s.jsx("div",{className:"px-4 py-8 text-center",style:{color:"#9CA3AF"},children:"No scenarios found."})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:[!c&&s.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"▶"}),s.jsx("div",{className:"text-sm",children:"Select a scenario to edit steps and link elements"})]})}),c&&s.jsxs("div",{className:"max-w-2xl",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold",style:{color:"#1a1a1a"},children:c.name}),s.jsx("span",{className:"px-2 py-0.5 text-xs rounded-md font-medium",style:{background:"#E67E2218",color:"#E67E22"},children:c.kind})]}),s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:"Steps"}),!r&&s.jsx("button",{onClick:M,className:"px-2 py-0.5 text-xs rounded",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"Edit"}),r&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:B,className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Save"}),s.jsx("button",{onClick:()=>u(null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:"Cancel"})]})]}),s.jsx("div",{className:"space-y-1",children:i.map((e,t)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[s.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium",style:{background:"#2DD4A815",color:"#1B3A4B"},children:t+1}),r?s.jsx("input",{type:"text",value:e.text,onChange:n=>T(t,n.target.value),className:"flex-1 text-sm px-2 py-1 rounded focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#374151"}}):s.jsx("span",{className:"flex-1 text-sm",style:{color:"#374151"},children:e.text}),r&&s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>D(t,-1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move up",children:"▲"}),s.jsx("button",{onClick:()=>D(t,1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move down",children:"▼"}),s.jsx("button",{onClick:()=>L(t),className:"px-1 text-xs",style:{color:"#E74C3C"},title:"Remove",children:"✕"})]})]},t))}),r&&s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("input",{type:"text",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>e.key==="Enter"&&S(),placeholder:"Add a step...",className:"flex-1 text-sm px-3 py-2 rounded-lg focus:outline-none",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",color:"#374151"}}),s.jsx("button",{onClick:S,className:"px-3 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"+ Add"})]}),i.length===0&&!r&&s.jsx("div",{className:"text-xs p-3 rounded-lg",style:{background:"#F3F4F6",color:"#9CA3AF"},children:"No steps defined. Click Edit to add scenario steps."})]}),s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:["Linked Elements (",A.length,")"]}),s.jsx("button",{onClick:()=>v(b===null?0:null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#4A90D915",color:"#4A90D9",border:"1px solid #4A90D940"},children:b!==null?"Done":"+ Link"})]}),b!==null&&s.jsxs("div",{className:"mb-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #4A90D940"},children:[s.jsx("input",{type:"text",value:g,onChange:e=>N(e.target.value),placeholder:"Search elements to link...",className:"w-full text-sm px-2 py-1 rounded focus:outline-none mb-1",style:{border:"1px solid #E5E5E0",color:"#374151"}}),R.map(e=>s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs rounded cursor-pointer",onMouseEnter:t=>t.currentTarget.style.background="#F0F0ED",onMouseLeave:t=>t.currentTarget.style.background="transparent",onClick:()=>{z(c.id,e.id,"traceTo"),N(""),v(null)},children:[s.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:F[e.layer]||"#95A5A6"}}),s.jsx("span",{style:{color:"#374151"},children:e.name}),s.jsx("span",{style:{color:"#9CA3AF"},children:e.kind})]},e.id))]}),s.jsx("div",{className:"space-y-1",children:A.map(e=>{const t=e.sourceId===c.id?e.targetId:e.sourceId,n=d.elements[t],l=e.sourceId===c.id?"→":"←";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:x=>x.currentTarget.style.background="#F0F0ED",onMouseLeave:x=>x.currentTarget.style.background="#FFFFFF",onClick:()=>m(t),children:[s.jsx("span",{style:{color:"#9CA3AF"},children:l}),s.jsx("span",{className:"font-medium",style:{color:"#2563EB"},children:e.type}),s.jsx("span",{style:{color:"#374151"},children:(n==null?void 0:n.name)||t}),n&&s.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded text-xs",style:{background:(F[n.layer]||"#95A5A6")+"18",color:F[n.layer]||"#95A5A6"},children:n.kind})]},e.id)})})]}),s.jsx("div",{className:"text-xs",style:{color:"#D1D5DB"},children:c.file})]})]})]})}export{q as ScenarioEditor};
@@ -1 +0,0 @@
1
- import{j as e}from"./reactflow-WKyu73tD.js";import{a as s}from"./zustand-qbFpP9Up.js";import{u as a,k as C}from"./index-CgRwea72.js";const A=["Add a PressureSensor component with a USB interface and a power port.","Create a hazard: AlarmFailure that causes patient harm in ICU setting.","Define a software item InfusionController with a requirement for dose limit checking.","Add a RiskControl that mitigates OverInfusion by adding a flow rate sensor."];function F(){const r=a(o=>o.llmAvailable),v=a(o=>o.llmProvider),S=a(o=>o.llmModel),f=a(o=>o.registerLlmRequest),[l,p]=s.useState(""),[n,g]=s.useState(!1),[t,c]=s.useState(null),[u,m]=s.useState(null),[y,x]=s.useState(!1),h=s.useCallback(async o=>{if(!o.trim()||n)return;g(!0),c(null),m(null),x(!1);const i=`gen-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const d=await new Promise((E,b)=>{f(i,E,b),C(i,o.trim()),setTimeout(()=>b(new Error("Request timed out after 60 seconds.")),6e4)});c(d)}catch(d){m((d==null?void 0:d.message)??"Unknown error")}finally{g(!1)}},[n,f]),j=()=>{t!=null&&t.sysml&&navigator.clipboard.writeText(t.sysml).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"14px 20px 10px",borderBottom:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:"⟨/⟩"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"SysML Generator"}),e.jsx("div",{style:{fontSize:"11px",color:r?"#059669":"#dc2626",marginTop:"1px"},children:r?`${v??"LLM"} · ${S??"unknown model"} · natural language → SysML v2`:"No LLM provider — set ANTHROPIC_API_KEY or OPENAI_API_KEY"})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{fontSize:"12px",fontWeight:600,color:"#374151",display:"block",marginBottom:"6px"},children:"Describe what to generate"}),e.jsx("textarea",{value:l,onChange:o=>p(o.target.value),disabled:!r||n,rows:4,placeholder:"Describe the element(s) to generate in plain English…",style:{width:"100%",padding:"10px 12px",border:"1px solid #E5E5E0",borderRadius:"8px",fontSize:"13px",resize:"vertical",fontFamily:"inherit",outline:"none",background:"#fff",color:"#1B3A4B",lineHeight:"1.5",boxSizing:"border-box",opacity:r?1:.5},onFocus:o=>{o.target.style.borderColor="#2DD4A8"},onBlur:o=>{o.target.style.borderColor="#E5E5E0"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),h(l))}}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:"Cmd+Enter to generate"}),e.jsx("button",{onClick:()=>h(l),disabled:!r||n||!l.trim(),style:{padding:"6px 16px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",opacity:!r||!l.trim()?.4:1},children:n?"Generating…":"Generate SysML"})]})]}),!t&&!n&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"8px"},children:"Examples"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"5px"},children:A.map(o=>e.jsx("button",{onClick:()=>{p(o)},disabled:!r,style:{textAlign:"left",padding:"7px 11px",borderRadius:"6px",background:"#fff",border:"1px solid #E5E5E0",fontSize:"12px",color:"#374151",cursor:"pointer",opacity:r?1:.5},onMouseEnter:i=>{r&&(i.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:i=>{i.currentTarget.style.borderColor="#E5E5E0"},children:o},o))})]}),n&&e.jsxs("div",{style:{background:"#fff",border:"1px solid #E5E5E0",borderRadius:"10px",padding:"20px",textAlign:"center",color:"#9CA3AF",fontSize:"13px"},children:[e.jsx("div",{style:{marginBottom:"8px",fontSize:"20px"},children:"⟨/⟩"}),"Generating SysML v2…"]}),u&&e.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"12px",color:"#dc2626",fontSize:"13px"},children:[e.jsx("strong",{children:"Error:"})," ",u]}),t&&!n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs("div",{style:{background:"#F0FDF9",border:"1px solid #A7F3D0",borderRadius:"8px",padding:"12px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#065F46",marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Explanation"}),e.jsx("p",{style:{fontSize:"13px",color:"#1B3A4B",margin:0,lineHeight:"1.6"},children:t.explanation}),t.suggestedFile&&e.jsxs("div",{style:{marginTop:"8px",fontSize:"11px",color:"#6B7280"},children:["Suggested file: ",e.jsx("code",{style:{background:"#D1FAE5",padding:"1px 5px",borderRadius:"3px"},children:t.suggestedFile})]})]}),e.jsxs("div",{style:{background:"#1e293b",borderRadius:"10px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 14px",borderBottom:"1px solid #334155"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#94a3b8",fontWeight:600},children:"SysML v2"}),e.jsx("button",{onClick:j,style:{padding:"3px 10px",borderRadius:"4px",border:"none",background:y?"#059669":"#334155",color:"#fff",fontSize:"11px",cursor:"pointer",fontWeight:500},children:y?"Copied!":"Copy"})]}),e.jsx("pre",{style:{margin:0,padding:"14px 16px",fontSize:"12px",lineHeight:"1.6",color:"#e2e8f0",overflowX:"auto",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:e.jsx("code",{children:t.sysml})})]}),e.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",padding:"4px 0"},children:["Review the generated SysML before saving. Copy it into your project's ",e.jsx("code",{children:".sysml"})," files. The dev server will pick up the changes automatically."]}),e.jsx("button",{onClick:()=>{c(null),p("")},style:{padding:"6px 14px",borderRadius:"6px",border:"1px solid #E5E5E0",background:"#fff",color:"#374151",fontSize:"12px",cursor:"pointer",alignSelf:"flex-start"},children:"Generate another"})]})]})]})}export{F as SysmlGenerator};
@@ -1 +0,0 @@
1
- import{j as s}from"./reactflow-WKyu73tD.js";import{a as p}from"./zustand-qbFpP9Up.js";import{u as j,d as w}from"./index-CgRwea72.js";const F=[{id:"risk-control",label:"ISO 14971: Risk → Control",description:"Hazards and hazardous situations traced to risk controls",rowKinds:["Hazard","HazardousSituation"],colKinds:["RiskControl","SafetyGoal"],relationshipTypes:["mitigates","traceTo","causes","leadsTo"]},{id:"req-test",label:"IEC 62304: Requirement → Test",description:"Software requirements traced to verification tests",rowKinds:["Requirement","Requirement","Requirement"],colKinds:["Test"],relationshipTypes:["verify","satisfy","traceTo"]},{id:"req-function",label:"Requirement → Function",description:"Requirements traced to system/component functions",rowKinds:["Requirement","Requirement","Requirement"],colKinds:["Function","Function"],relationshipTypes:["satisfy","traceTo","allocateTo"]},{id:"function-component",label:"Function → Component",description:"Functions allocated to logical/physical components",rowKinds:["Function","Function"],colKinds:["System","Subsystem","Component","LogicalComponent","SoftwareComponent","PhysicalComponent"],relationshipTypes:["allocateTo","traceTo","composedOf"]},{id:"all",label:"All Elements",description:"Full N×N matrix of all elements and relationships",rowKinds:[],colKinds:[],relationshipTypes:[]}];function N({cell:n,onClick:m}){if(!n||n.rels.length===0)return s.jsx("td",{className:"border",style:{borderColor:"#E5E5E0",width:"28px",height:"28px"}});const u=[...new Set(n.rels.map(f=>f.type))],h=n.rels.length>1?"#2DD4A830":"#2DD4A818";return s.jsx("td",{className:"border text-center cursor-pointer",style:{borderColor:"#E5E5E0",background:h,width:"28px",height:"28px"},title:u.join(", "),onClick:m,children:s.jsx("span",{className:"text-xs font-semibold",style:{color:"#1B3A4B",fontSize:"10px"},children:n.rels.length})})}function K(){const n=j(e=>e.model),m=j(e=>e.selectElement),[u,h]=p.useState("risk-control"),[f,g]=p.useState(null),[v,E]=p.useState(null),d=F.find(e=>e.id===u)||F[0],{rows:c,cols:x,matrix:y}=p.useMemo(()=>{if(!n)return{rows:[],cols:[],matrix:new Map};const e=Object.values(n.elements);let i,r;if(d.rowKinds.length===0&&d.colKinds.length===0)i=e,r=e;else{const t=new Set(d.rowKinds),o=new Set(d.colKinds);i=e.filter(l=>t.has(l.kind)),r=e.filter(l=>o.has(l.kind))}i.sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name)),r.sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name));const a=new Map,k=d.relationshipTypes.length>0?new Set(d.relationshipTypes):null,C=new Set(i.map(t=>t.id)),S=new Set(r.map(t=>t.id));for(const t of n.relationships)if(!(k&&!k.has(t.type))){if(C.has(t.sourceId)&&S.has(t.targetId)){const o=`${t.sourceId}:${t.targetId}`,l=a.get(o);l?l.rels.push(t):a.set(o,{rels:[t]})}if(C.has(t.targetId)&&S.has(t.sourceId)){const o=`${t.targetId}:${t.sourceId}`,l=a.get(o);l?l.rels.push(t):a.set(o,{rels:[t]})}}return{rows:i,cols:r,matrix:a}},[n,d]),b=p.useMemo(()=>{const e=new Set;for(const[i]of y){const r=i.split(":")[0];e.add(r)}return e.size},[y]);return n?s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#FAFAF8"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0",background:"#FFFFFF"},children:[s.jsx("span",{className:"text-xs font-medium",style:{color:"#6B7280"},children:"Preset:"}),F.map(e=>s.jsx("button",{onClick:()=>h(e.id),className:"px-2 py-1 text-xs rounded-md transition-colors",style:u===e.id?{background:"#2DD4A818",color:"#1B3A4B",fontWeight:600}:{color:"#6B7280"},title:e.description,children:e.label},e.id)),s.jsx("div",{className:"flex-1"}),s.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[c.length," rows × ",x.length," cols · ",b,"/",c.length," traced (",c.length>0?Math.round(b/c.length*100):0,"%)"]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:c.length===0||x.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-xs",style:{color:"#9CA3AF"},children:"No elements match the selected preset. Try a different preset or add more model elements."}):s.jsxs("table",{className:"border-collapse text-xs",style:{borderColor:"#E5E5E0"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"border px-2 py-1 sticky left-0 z-10",style:{borderColor:"#E5E5E0",background:"#FFFFFF",minWidth:"140px"}}),x.map(e=>(w[e.layer],s.jsx("th",{className:"border px-1 py-1",style:{borderColor:"#E5E5E0",background:v===e.id?"#F0F0ED":"#FFFFFF",writingMode:"vertical-rl",textOrientation:"mixed",maxWidth:"28px",fontSize:"10px",color:"#374151",cursor:"pointer"},onMouseEnter:()=>E(e.id),onMouseLeave:()=>E(null),onClick:()=>m(e.id),title:`${e.name} (${e.kind})`,children:s.jsx("span",{className:"truncate",style:{maxHeight:"100px",display:"block",overflow:"hidden"},children:e.name})},e.id)))]})}),s.jsx("tbody",{children:c.map(e=>{const i=w[e.layer]||"#6B7280";return s.jsxs("tr",{children:[s.jsx("td",{className:"border px-2 py-1 sticky left-0 z-10 cursor-pointer truncate",style:{borderColor:"#E5E5E0",background:f===e.id?"#F0F0ED":"#FFFFFF",maxWidth:"180px",fontSize:"11px",color:"#374151",borderLeft:`3px solid ${i}`},onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(null),onClick:()=>m(e.id),title:`${e.name} (${e.kind})`,children:e.name}),x.map(r=>{const a=y.get(`${e.id}:${r.id}`)||null;return s.jsx(N,{cell:a,onClick:a?()=>m(e.id):void 0},r.id)})]},e.id)})})]})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-xs",style:{color:"#9CA3AF"},children:"No model loaded"})}export{K as TraceabilityMatrix};