@memoarchitect/architect 0.6.5 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +45 -4
  2. package/dist/assets/AiWorkspace-Bu9TlIWg.js +7 -0
  3. package/dist/assets/AnalysisWorkspace-CodmoI-v.js +39 -0
  4. package/dist/assets/{ComplianceWizard-DWolzleI.js → ComplianceWizard-CTihkUi-.js} +1 -1
  5. package/dist/assets/DSMView-BiC845df.js +1 -0
  6. package/dist/assets/Dashboard-CgnNLhKq.js +1 -0
  7. package/dist/assets/{DhfDashboard-D9JxRAbD.js → DhfDashboard-w-dJoJHU.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-BQv2WQ9o.js → DhfWorkbench-o6B_MT-0.js} +15 -15
  9. package/dist/assets/DiagramCanvas-CqGqDbgT.js +3 -0
  10. package/dist/assets/DiagramEditor-UJDHcAUF.js +4 -0
  11. package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +1 -0
  12. package/dist/assets/ElementDetailView-10U0rr33.js +2 -0
  13. package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +3 -0
  14. package/dist/assets/{ImportView-33dFwj6A.js → ImportView-D8svP04Q.js} +1 -1
  15. package/dist/assets/{LayerGrid-B3MBWswK.js → LayerGrid-DEe0Ryz-.js} +1 -1
  16. package/dist/assets/{LayerTable-DyIzIt5M.js → LayerTable-CN_b2rDr.js} +2 -2
  17. package/dist/assets/{MaxGraphCanvas-BS5wYazZ.js → MaxGraphCanvas-bo8oPBct.js} +6 -6
  18. package/dist/assets/{ModelDiff-BoFREnpg.js → ModelDiff-xe95oVua.js} +1 -1
  19. package/dist/assets/{OntologyDecompositionDiagram-IG1gj1c3.js → OntologyDecompositionDiagram-BL9R8bdB.js} +1 -1
  20. package/dist/assets/{OntologyViewer-CQTEg-GI.js → OntologyViewer-CtqNkkCn.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-B9bqt4zl.js → RelationshipOverlay-DL0N8Vmk.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-DttMvF2i.js → RelationshipsSection-BoJ0aUXe.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-BJ_smBGS.js → ReviewDashboard-DeTge2oC.js} +1 -1
  24. package/dist/assets/ScenarioEditor-FAEYTHgP.js +3 -0
  25. package/dist/assets/{StatisticsDashboard-CBYJGUPH.js → StatisticsDashboard-BAZRqIPN.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-Die2RUsz.js → SysmlCodeEditor-BBfup_Ni.js} +1 -1
  27. package/dist/assets/TabularView-I4LjHhoH.js +1 -0
  28. package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +1 -0
  30. package/dist/assets/{WorkflowWizard-CbkDyd1W.js → WorkflowWizard-VwpEHt3R.js} +1 -1
  31. package/dist/assets/element-options-B7AgTB8R.js +3 -0
  32. package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
  33. package/dist/assets/index-BWMNo4wW.css +1 -0
  34. package/dist/assets/index-Bij8Q4Kg.js +45 -0
  35. package/dist/assets/index.es-ClbJxlAQ.js +18 -0
  36. package/dist/assets/jspdf.es.min-DZ68BGxk.js +170 -0
  37. package/dist/assets/notation-scene-DT8LpWVK.js +1 -0
  38. package/dist/assets/purify.es-DP5U8-sc.js +3 -0
  39. package/dist/assets/{reactflow-CsCqNKB-.js → reactflow-s7jmJtXx.js} +5 -5
  40. package/dist/index.html +3 -3
  41. package/lib/__tests__/compiler-bundling.test.d.ts +2 -0
  42. package/lib/__tests__/compiler-bundling.test.d.ts.map +1 -0
  43. package/lib/__tests__/compiler-bundling.test.js +32 -0
  44. package/lib/__tests__/compiler-bundling.test.js.map +1 -0
  45. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts +2 -0
  46. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts.map +1 -0
  47. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js +22 -0
  48. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js.map +1 -0
  49. package/lib/__tests__/supervised-child-args.test.d.ts +2 -0
  50. package/lib/__tests__/supervised-child-args.test.d.ts.map +1 -0
  51. package/lib/__tests__/supervised-child-args.test.js +35 -0
  52. package/lib/__tests__/supervised-child-args.test.js.map +1 -0
  53. package/lib/bin/memo-architect.js +30 -4
  54. package/lib/bin/memo-architect.js.map +1 -1
  55. package/lib/commands/dev.d.ts +18 -2
  56. package/lib/commands/dev.d.ts.map +1 -1
  57. package/lib/commands/dev.js +56 -8
  58. package/lib/commands/dev.js.map +1 -1
  59. package/lib/commands/example.d.ts +1 -0
  60. package/lib/commands/example.d.ts.map +1 -1
  61. package/lib/commands/example.js +2 -0
  62. package/lib/commands/example.js.map +1 -1
  63. package/lib/feature-grants.d.ts.map +1 -1
  64. package/lib/feature-grants.js +2 -2
  65. package/lib/feature-grants.js.map +1 -1
  66. package/package.json +12 -6
  67. package/dist/assets/AiWorkspace-DHZ6a9HJ.js +0 -3
  68. package/dist/assets/DSMView-TdC3EADB.js +0 -1
  69. package/dist/assets/Dashboard-DBfAOCJv.js +0 -1
  70. package/dist/assets/DhfSettingsPanel-Firov0IF.js +0 -1
  71. package/dist/assets/DiagramCanvas-BfwO8YE5.js +0 -1
  72. package/dist/assets/DiagramEditor-Cp9ORYoN.js +0 -4
  73. package/dist/assets/ElementDetailView-DOrG8v7V.js +0 -2
  74. package/dist/assets/ScenarioEditor-D06nbX4h.js +0 -3
  75. package/dist/assets/TabularView-BLzDtgmK.js +0 -1
  76. package/dist/assets/TraceabilityMatrix-DbL_FkAC.js +0 -1
  77. package/dist/assets/index-B8HDzVLs.css +0 -1
  78. package/dist/assets/index-D0vtjNjX.js +0 -3280
  79. package/dist/assets/layout-selection-DIQaaOIC.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{j as e}from"./reactflow-s7jmJtXx.js";import{a as E}from"./zustand-CrhqMOHB.js";import{u as h,k as C,C as i,F as a,h as V,x as D,P as z,y as F,R as f,z as P,A as U,B as S,G as u}from"./index-Bij8Q4Kg.js";const r="page",_=new Set(["Scenario","UseCase","UserActivity"]);function H(p){return p?p.split(`
2
+ `).filter(o=>o.trim()).map((o,d)=>{const m=o.match(/^\d+\.\s*(.*)/);return{index:d,text:m?m[1].trim():o.trim()}}):[]}function Y({element:p,layerColor:o,onSave:d}){const m=E.useMemo(()=>H(p.doc||""),[p.doc]),[w,y]=E.useState(!1);return w||m.length===0?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:a.xs,color:i.faint,marginBottom:6,marginTop:0},children:["One step per line, numbered: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx(F,{value:p.doc||"",onSave:x=>{d(x),y(!1)},density:r,multiline:!0,placeholder:"Click to add scenario steps…"})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>y(!0),style:{position:"absolute",top:0,right:0,fontSize:a.xs,color:i.muted,padding:"2px 9px",border:`1px solid ${i.border}`,borderRadius:"6px",background:i.surface,cursor:"pointer"},onMouseEnter:x=>{x.currentTarget.style.borderColor=i.accent},onMouseLeave:x=>{x.currentTarget.style.borderColor=i.border},children:"✎ Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:a.xs,fontWeight:700,background:o,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),m.map((x,s)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx(M,{color:o}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:i.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:a.xs,fontWeight:700},children:s+1}),e.jsx("span",{style:{fontSize:a.sm,color:i.primary,lineHeight:1.5,paddingTop:"3px"},children:x.text})]})]},s)),e.jsx(M,{color:o}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:a.xs,fontWeight:700,background:o+"20",color:o,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${o}40`},children:"End"})]})]})}function M({color:p}){return e.jsx("div",{style:{width:"2px",height:"20px",background:p+"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 ${p}80`}})})}function q({elementId:p}={}){var N,$,B,L;const o=h(t=>t.activeView),d=h(t=>t.model),m=h(t=>t.validation),w=h(t=>t.updateElementField),y=h(t=>t.updateElementAttribute),x=h(t=>t.applyEdit),s=p??(o.type==="element-detail"?o.elementId:null),n=s&&d?d.elements[s]:null,R=E.useMemo(()=>{if(!d||!s)return{incoming:[],outgoing:[]};const t=C(d,s);return{incoming:t.filter(c=>c.targetId===s),outgoing:t.filter(c=>c.sourceId===s)}},[d,s]),b=E.useMemo(()=>!m||!s?[]:m.violations.filter(t=>t.elementId===s),[m,s]);if(!n||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:i.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:i.faint,marginTop:"-48px"},children:[e.jsxs("div",{style:{position:"relative",width:"280px",maxWidth:"60vw",margin:"0 auto -32px"},children:[e.jsx("img",{src:"/logo.png",alt:"MEMO",style:{width:"100%",display:"block",opacity:.5,mixBlendMode:"multiply"}}),e.jsx("span",{style:{position:"absolute",left:"59%",top:"60%",color:"#8B949E",fontSize:"19px",fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap"},children:"Architect"})]}),e.jsx("p",{style:{fontSize:a.md,margin:0},children:"Select an element to view details"})]})});const j=V[n.layer]||i.muted,l=(N=n.provenance)==null?void 0:N.declaration,k=(l==null?void 0:l.writable)!==!1,g=($=d==null?void 0:d.registries)==null?void 0:$.kinds.find(t=>t.name===n.kind),T=((B=g==null?void 0:g.namespace)==null?void 0:B[1])??((L=g==null?void 0:g.namespace)==null?void 0:L[0]),O=(t,c)=>{w(s,t,c),x(s)},I=(t,c)=>{y(s,t,c),x(s)},v=Object.entries(n.attributes).filter(([t])=>t!=="id"&&t!=="name"),A=_.has(n.kind);return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"#EEF4F7"},children:e.jsxs("div",{style:{maxWidth:"1040px",margin:"0 auto",padding:"20px 28px 48px"},children:[e.jsxs("header",{style:{background:i.surface,border:"1px solid rgba(60,60,67,0.12)",borderLeft:`4px solid ${j}`,borderRadius:"16px",padding:"14px 18px",marginBottom:16,boxShadow:"0 1px 3px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",style:{marginBottom:8},children:[e.jsx("span",{className:"px-2 py-0.5 rounded-md font-semibold",style:{background:j+"18",color:j,fontSize:a.xs},children:n.kind}),e.jsx("span",{className:"px-2 py-0.5 rounded-md",style:{background:i.surfaceAlt,color:i.muted,fontSize:a.xs},children:n.layer}),T&&e.jsx("span",{style:{color:i.faint,fontSize:a.xs},children:T.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}),n.shortId&&e.jsx("span",{style:{marginLeft:"auto",color:i.faint,fontSize:a.xs,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:n.shortId})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:i.primary,lineHeight:1.2,margin:0},children:n.name}),e.jsx("div",{style:{marginTop:9,paddingTop:8,borderTop:`1px solid ${i.borderLight}`},children:e.jsx(D,{density:r})})]}),b.length>0&&e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2",marginBottom:20},children:[e.jsxs("div",{className:"px-4 py-2 font-semibold",style:{color:"#DC2626",fontSize:a.sm,borderBottom:"1px solid #FEE2E2"},children:[b.length," violation",b.length!==1?"s":""]}),b.map((t,c)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:a.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:i.faint},children:["[",t.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:t.description})]},c))]}),e.jsx(z,{title:A?"Flow":"Description",density:r,collapsible:!1,children:A&&k?e.jsx(Y,{element:n,layerColor:j,onSave:t=>O("doc",t)}):k?e.jsx(F,{value:n.attributes.description||"",onSave:t=>I("description",t),density:r,multiline:!0,placeholder:"Click to add a description…"}):e.jsx(f,{value:n.attributes.description||n.doc||"",editability:{kind:"derived",reason:`This ${(l==null?void 0:l.origin)??"library"} declaration is read-only.`},density:r})}),e.jsxs(z,{title:"Attributes",count:v.length,density:r,collapsible:!1,children:[v.length===0&&e.jsx("p",{style:{fontSize:a.sm,color:i.faint,margin:0},children:"This element defines no attributes."}),v.length>0&&e.jsx("div",{style:{borderTop:`1px solid ${i.border}`,maxWidth:900},children:v.map(([t,c])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 24%) minmax(0, 1fr)",gap:16,alignItems:"center",padding:"7px 0",borderBottom:`1px solid ${i.borderLight}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{color:i.secondary,fontSize:a.sm,fontWeight:600},children:t}),e.jsx("div",{style:{color:i.faint,fontSize:"10px"},children:"Editable"})]}),k?e.jsx(F,{value:String(c??""),onSave:W=>I(t,W),density:r,placeholder:"Add value…",compact:!0}):e.jsx(f,{value:String(c??""),editability:{kind:"derived",reason:`This ${(l==null?void 0:l.origin)??"library"} declaration is read-only.`},density:r})]},t))})]}),e.jsx(P,{element:n,outgoing:R.outgoing,incoming:R.incoming,density:r}),e.jsx("div",{style:{background:i.surface,borderRadius:12,marginBottom:16},children:e.jsx(U,{subject:n})}),e.jsx(z,{title:"Origin",density:r,collapsible:!1,children:e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(S,{label:"SysML source file",editability:u("file"),density:r,children:e.jsx(f,{value:n.file??"—",editability:u("file"),density:r,mono:!0})}),l&&e.jsxs(e.Fragment,{children:[e.jsx(S,{label:"Origin",editability:u("origin"),density:r,children:e.jsx(f,{value:l.origin,editability:u("origin"),density:r})}),e.jsx(S,{label:"Package",editability:u("package"),density:r,children:e.jsx(f,{value:`${l.packageName}${l.packageVersion?` v${l.packageVersion}`:""}`,editability:u("package"),density:r})}),e.jsx(S,{label:"Access",editability:u("access"),density:r,children:e.jsx(f,{value:l.writable?"Editable project content":"Read-only reusable content",editability:u("access"),density:r})})]})]})})]})})}export{q as ElementDetailView};
@@ -0,0 +1,3 @@
1
+ import{j as s}from"./reactflow-s7jmJtXx.js";import{a as F}from"./zustand-CrhqMOHB.js";import{u as ne,F as M}from"./index-Bij8Q4Kg.js";const ce=new Set(["overlay","transient"]);function V(t){if(!t)return"";const o=t.lastIndexOf("::");return o>=0?t.slice(o+2):t}function $(t){if(t===void 0||t==="")return;const o=Number(t);return Number.isFinite(o)?o:void 0}function ie(t){const o=t.attributes??{},g=$(o["bounds.x"]),d=$(o["bounds.y"]),c=$(o["bounds.width"]),a=$(o["bounds.height"]);if(!(g===void 0||d===void 0||c===void 0||a===void 0))return{x:g,y:d,width:c,height:a}}function le(t,o){return{x:t.x+o.x*t.width,y:t.y+o.y*t.height,width:o.width*t.width,height:o.height*t.height}}function G(t,o){const g=new Map;for(const d of t){if(d.type.toLowerCase()!==o)continue;const c=g.get(d.sourceId)??[];c.push(d.targetId),g.set(d.sourceId,c)}return g}function ue(t,o={}){var x,r,w;const g=Object.values(t.elements??{}),d=new Map(g.map(f=>[f.id,f])),c=t.relationships??[],a=g.filter(f=>f.kind==="ScreenCapture"),u=o.captureId?a.find(f=>f.id===o.captureId):a[0];if(!u)return{nodes:[],emptyReason:"No ScreenCapture in this view."};const E=G(c,"capturesscreen"),S=(E.get(u.id)??[])[0],j=S?d.get(S):void 0;if(!j)return{capture:u,nodes:[],emptyReason:`"${u.name}" is not linked to a screen by CapturesScreen.`};const z=G(c,"composes"),C=G(c,"navigatesto"),v={x:0,y:0,width:1,height:1},k=[],R=new Set,h=new Set([...E.values()].flat()),l=(f,O,D,P)=>{if(R.has(f.id))return;R.add(f.id);const p=f.attributes??{},W=V(p.detectionMethod),N=(z.get(f.id)??[]).filter(U=>{const y=d.get(U);return!!y&&y.kind==="UIElement"&&!!ie(y)});if(k.push({element:f,rect:O,depth:D,childIds:N,parentId:P,formKind:V(p.formKind),disclosureKind:V(p.disclosureKind)||"inline",boundaryColor:p.boundaryColor||void 0,boundaryOpacity:Math.max(0,Math.min(1,$(p.boundaryOpacity)??.12)),unconfirmed:W==="automatic"&&!(p.confirmedBy??"").trim(),detectionConfidence:$(p.detectionConfidence),navigatesToId:(C.get(f.id)??[])[0]}),!(f.id!==j.id&&h.has(f.id)))for(const U of N){const y=d.get(U);l(y,le(O,ie(y)),D+1,f.id)}};return l(j,v,0),{capture:u,screen:j,imageUri:pe((x=u.attributes)==null?void 0:x.imageUri),pixelWidth:$((r=u.attributes)==null?void 0:r.pixelWidth),pixelHeight:$((w=u.attributes)==null?void 0:w.pixelHeight),nodes:k}}function pe(t){if(t)return t.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`/${t}`}function xe(t){return Object.values(t.elements??{}).filter(o=>o.kind==="ScreenCapture")}function K(t,o){const d=(t.relationships??[]).find(c=>c.type.toLowerCase()==="capturesscreen"&&c.targetId===o);if(d)return(t.elements??{})[d.sourceId]??Object.values(t.elements??{}).find(c=>c.id===d.sourceId)}function ye(t,o,g){const d=new Map((t.relationships??[]).filter(u=>u.type.toLowerCase()==="composes").map(u=>[u.targetId,u.sourceId])),c=new Set;let a=d.get(g);for(;a&&a!==o&&!c.has(a);){c.add(a);const u=K(t,a);if(u)return u;a=d.get(a)}return K(t,o)}function _(t){return ce.has(t.disclosureKind)}const he={screen:"#1B3A4B",panel:"#2DD4A8",dialog:"#A855F7",field:"#E4572E",button:"#A855F7",selector:"#F59E0B",table:"#3B82F6",chart:"#3B82F6",decoration:"#9CA3AF"},ge=t=>t.boundaryColor||he[t.formKind]||"#6B7280",X=(t,o=0,g=1)=>Math.max(o,Math.min(g,t));function Fe({diagram:t,model:o,captureId:g,viewpointFilter:d,editable:c=!1,drawMode:a=!1,newElementDefaultName:u="New UIElement",onCreateBounds:E,onBoundsChange:S,proposals:j=[],onAcceptProposal:z,onRejectProposal:C}){var Z;const v=ne(e=>e.inspectElement),k=ne(e=>e.selectedElementId),[R,h]=F.useState([]),[l,x]=F.useState(null),[r,w]=F.useState(null),[f,O]=F.useState(null),D=F.useRef(null),P=R[R.length-1]??g;F.useEffect(()=>h([]),[g]),F.useEffect(()=>{a||w(e=>(e==null?void 0:e.kind)==="create"?null:e)},[a]);const p=F.useMemo(()=>ue(o,{captureId:P}),[o,P]),W=F.useMemo(()=>d?p.nodes.filter(e=>d(e.element)):p.nodes,[p.nodes,d]),N=W.find(e=>e.element.id===k),y=W.find(e=>e.element.id===f)??N,oe=new Set((y==null?void 0:y.childIds)??[]),q=F.useCallback(e=>{const i=e.navigatesToId??e.element.id,n=K(o,i);(n==null?void 0:n.id)!==P&&n&&h(m=>[...m,n.id])},[o,P]);if(!p.nodes.length)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:s.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[s.jsx("h3",{style:{fontSize:M.lg,fontWeight:600,color:"#374151",marginBottom:8},children:t.name}),s.jsx("p",{style:{fontSize:M.md,color:"#9CA3AF",lineHeight:1.6},children:p.emptyReason??"Nothing to lay out in this view."})]})});const re=[...W].sort((e,i)=>{const n=_(e)?1:0,m=_(i)?1:0;return n-m||e.depth-i.depth}),se=p.pixelWidth&&p.pixelHeight?p.pixelHeight/p.pixelWidth:.625,L=(e,i)=>{var m;const n=(m=D.current)==null?void 0:m.getBoundingClientRect();return n?{x:X((e-n.left)/n.width),y:X((i-n.top)/n.height)}:{x:0,y:0}},B=e=>{if(e.kind==="draw")return{x:Math.min(e.startX,e.currentX),y:Math.min(e.startY,e.currentY),width:Math.abs(e.currentX-e.startX),height:Math.abs(e.currentY-e.startY)};const i=e.currentX-e.startX,n=e.currentY-e.startY;return e.kind==="move"?{...e.baseRect,x:X(e.baseRect.x+i,0,1-e.baseRect.width),y:X(e.baseRect.y+n,0,1-e.baseRect.height)}:{...e.baseRect,width:X(e.baseRect.width+i,.01,1-e.baseRect.x),height:X(e.baseRect.height+n,.01,1-e.baseRect.y)}},ae=(e,i)=>{var m;const n=e.parentId?(m=p.nodes.find(Y=>Y.element.id===e.parentId))==null?void 0:m.rect:void 0;return n?{x:(i.x-n.x)/n.width,y:(i.y-n.y)/n.height,width:i.width/n.width,height:i.height/n.height}:i},de=()=>{if(!l)return;const e=B(l);l.kind==="draw"?e.width>=.01&&e.height>=.01&&w({kind:"create",rect:e,name:u}):(Math.abs(l.currentX-l.startX)>=.002||Math.abs(l.currentY-l.startY)>=.002)&&w(l.node?{kind:"edit",node:l.node,rect:e}:{kind:"create",rect:e,name:(r==null?void 0:r.kind)==="create"?r.name:u}),x(null)},J=(e,i,n)=>{var Y;e.stopPropagation();const m=L(e.clientX,e.clientY);(Y=D.current)==null||Y.setPointerCapture(e.pointerId),x({kind:i,node:n.kind==="edit"?n.node:void 0,baseRect:n.rect,startX:m.x,startY:m.y,currentX:m.x,currentY:m.y})},Q=()=>{if(r){if(r.kind==="create"){const e=r.name.trim();if(!e)return;E==null||E(r.rect,e)}else S==null||S(r.node.element.id,ae(r.node,r.rect));w(null)}};return s.jsxs("div",{className:"flex-1 flex flex-col overflow-auto",style:{background:"#F7F7F5"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:[s.jsx("span",{style:{fontSize:M.sm,fontWeight:600,color:"#374151"},children:(Z=p.screen)==null?void 0:Z.name}),R.length>0&&s.jsx("button",{onClick:()=>h(e=>e.slice(0,-1)),style:{fontSize:M.xs,padding:"2px 8px",marginLeft:"auto",border:"1px solid #E5E5E0",borderRadius:6,background:"#FFFFFF",color:"#374151",cursor:"pointer"},children:"← Back"})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{ref:D,role:"application","aria-label":"Screen region canvas",onPointerDown:e=>{if(!c||!a||r||e.target!==e.currentTarget)return;const i=L(e.clientX,e.clientY);e.currentTarget.setPointerCapture(e.pointerId),x({kind:"draw",startX:i.x,startY:i.y,currentX:i.x,currentY:i.y})},onPointerMove:e=>{if(!l)return;const i=L(e.clientX,e.clientY);x(n=>n?{...n,currentX:i.x,currentY:i.y}:null)},onPointerUp:de,onPointerCancel:()=>x(null),style:{position:"relative",width:"100%",maxWidth:900,paddingBottom:`${se*100}%`,margin:"0 auto",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:8,backgroundImage:p.imageUri?`url(${p.imageUri})`:void 0,backgroundSize:"contain",backgroundRepeat:"no-repeat",cursor:a&&!r?"crosshair":"default"},children:[!p.imageUri&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{fontSize:M.xs,color:"#9CA3AF"},children:"No image at this capture’s imageUri — boxes shown without a backdrop"}),!a&&re.map(e=>{const i=e.element.id===k,n=e.element.id===f,m=e.element.id===(y==null?void 0:y.element.id),Y=oe.has(e.element.id),H=!!y&&!m&&!Y,A=ge(e),ee=K(o,e.navigatesToId??e.element.id),te=!!ee&&ee.id!==P;return s.jsxs("div",{onClick:b=>{b.stopPropagation(),v(e.element.id)},onDoubleClick:b=>{b.stopPropagation(),q(e)},onMouseEnter:()=>O(e.element.id),onMouseLeave:()=>O(b=>b===e.element.id?null:b),onPointerDown:b=>{var T;if(!c||a||r||e.depth===0)return;b.stopPropagation(),v(e.element.id);const I=L(b.clientX,b.clientY);(T=D.current)==null||T.setPointerCapture(b.pointerId),x({kind:"move",node:e,baseRect:e.rect,startX:I.x,startY:I.y,currentX:I.x,currentY:I.y})},title:`${e.element.name} · ${e.formKind}${te?" · double-click to open":""}`,style:{position:"absolute",left:`${e.rect.x*100}%`,top:`${e.rect.y*100}%`,width:`${e.rect.width*100}%`,height:`${e.rect.height*100}%`,border:`${i||n?2:1}px ${e.unconfirmed?"dashed":"solid"} ${H?"#9CA3AF":A}`,borderRadius:3,background:H?"#6B728012":`color-mix(in srgb, ${A} ${Math.round(Math.min(1,e.boundaryOpacity+(n?.12:i?.06:0))*100)}%, transparent)`,boxShadow:_(e)?"0 2px 10px rgba(0,0,0,0.18)":void 0,opacity:H?.18:1,pointerEvents:a?"none":"auto",cursor:c&&i?"move":"pointer",transition:"opacity 120ms ease, border-width 120ms ease"},children:[(i||!N)&&e.depth>0&&s.jsxs("span",{style:{position:"absolute",top:-2,left:2,transform:"translateY(-100%)",fontSize:9,fontWeight:600,color:A,background:"#FFFFFFDD",padding:"0 3px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none"},children:[e.element.name,e.unconfirmed&&e.detectionConfidence!==void 0&&` · ${Math.round(e.detectionConfidence*100)}%?`]}),te&&s.jsx("button",{type:"button","aria-label":`Open ${e.element.name}`,onClick:b=>{b.stopPropagation(),q(e)},style:{position:"absolute",top:3,right:3,zIndex:3,width:22,height:22,borderRadius:5,border:`1px solid ${A}`,background:"#FFFFFFE8",color:A,fontSize:13,lineHeight:"18px",cursor:"pointer",opacity:H?.25:1},title:`Open nested region ${e.element.name}`,children:"↗"}),c&&i&&e.depth>0&&s.jsx("span",{onPointerDown:b=>{var T;b.stopPropagation();const I=L(b.clientX,b.clientY);(T=D.current)==null||T.setPointerCapture(b.pointerId),x({kind:"resize",node:e,baseRect:e.rect,startX:I.x,startY:I.y,currentX:I.x,currentY:I.y})},title:"Drag to resize",style:{position:"absolute",width:10,height:10,right:-5,bottom:-5,borderRadius:2,background:A,border:"1px solid #FFFFFF",cursor:"nwse-resize"}})]},e.element.id)}),!a&&j.filter(e=>e.status==="pending").map((e,i)=>s.jsx("div",{title:`Detected boundary · ${Math.round(e.confidence*100)}% confidence`,style:{position:"absolute",zIndex:20+i,left:`${e.bounds.x*100}%`,top:`${e.bounds.y*100}%`,width:`${e.bounds.width*100}%`,height:`${e.bounds.height*100}%`,border:"2px dashed #2563EB",borderRadius:3,background:"#2563EB12",pointerEvents:"none"},children:s.jsxs("span",{style:{position:"absolute",top:2,right:2,display:"inline-flex",gap:3,pointerEvents:"auto",background:"#FFFFFFEE",padding:2,borderRadius:5,boxShadow:"0 1px 4px rgba(0,0,0,0.16)"},children:[s.jsx("button",{type:"button","aria-label":`Accept detected region ${e.id}`,onPointerDown:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),z==null||z(e.id)},title:"Accept region",style:{width:22,height:20,border:0,borderRadius:4,background:"#DCFCE7",color:"#15803D",cursor:"pointer"},children:"✓"}),s.jsx("button",{type:"button","aria-label":`Reject detected region ${e.id}`,onPointerDown:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),C==null||C(e.id)},title:"Reject region",style:{width:22,height:20,border:0,borderRadius:4,background:"#FEE2E2",color:"#DC2626",cursor:"pointer"},children:"×"})]})},e.id)),l&&s.jsx("div",{style:{position:"absolute",left:`${B(l).x*100}%`,top:`${B(l).y*100}%`,width:`${B(l).width*100}%`,height:`${B(l).height*100}%`,border:"2px dashed #0F766E",background:"#2DD4A81A",pointerEvents:"none"}}),r&&!l&&s.jsxs("div",{"aria-label":r.kind==="create"?"New region boundary draft":"Edited region boundary draft",onPointerDown:e=>J(e,"move",r),style:{position:"absolute",zIndex:80,left:`${r.rect.x*100}%`,top:`${r.rect.y*100}%`,width:`${r.rect.width*100}%`,height:`${r.rect.height*100}%`,border:"2px dashed #0F766E",borderRadius:3,background:"#2DD4A824",cursor:"move",boxShadow:"0 0 0 1px #FFFFFF99"},children:[s.jsxs("span",{style:{position:"absolute",top:4,left:4,display:"flex",gap:4,padding:3,borderRadius:6,background:"#FFFFFFF2",boxShadow:"0 1px 5px rgba(15,23,42,0.18)"},children:[r.kind==="create"&&s.jsx("input",{autoFocus:!0,"aria-label":"New UIElement name",placeholder:"UIElement name",value:r.name,onPointerDown:e=>e.stopPropagation(),onFocus:e=>e.currentTarget.select(),onChange:e=>w(i=>(i==null?void 0:i.kind)==="create"?{...i,name:e.target.value}:i),onKeyDown:e=>{e.key==="Enter"&&Q(),e.key==="Escape"&&w(null)},style:{width:150,border:"1px solid #CBD5E1",borderRadius:4,padding:"3px 6px",color:"#1F2937",fontSize:10}}),s.jsx("button",{type:"button",disabled:r.kind==="create"&&!r.name.trim(),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),Q()},"aria-label":"Confirm region boundary",title:"Save this boundary",style:{border:0,borderRadius:4,padding:"3px 7px",background:"#DCFCE7",color:"#15803D",cursor:r.kind==="create"&&!r.name.trim()?"not-allowed":"pointer",opacity:r.kind==="create"&&!r.name.trim()?.5:1,fontSize:10,fontWeight:700},children:"✓ Confirm"}),s.jsx("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),w(null)},"aria-label":"Cancel region boundary",title:"Discard this boundary change",style:{border:0,borderRadius:4,padding:"3px 7px",background:"#FEE2E2",color:"#DC2626",cursor:"pointer",fontSize:10,fontWeight:700},children:"× Cancel"})]}),s.jsx("span",{"aria-label":"Resize region boundary draft",onPointerDown:e=>J(e,"resize",r),title:"Drag to resize before confirming",style:{position:"absolute",width:12,height:12,right:-6,bottom:-6,borderRadius:2,background:"#0F766E",border:"2px solid #FFFFFF",cursor:"nwse-resize"}})]}),a&&!l&&!r&&s.jsx("div",{style:{position:"absolute",zIndex:70,left:8,top:8,padding:"5px 8px",borderRadius:6,pointerEvents:"none",background:"#0F766EEB",color:"#FFFFFF",fontSize:10,fontWeight:650},children:"Click and drag to define a region"})]})})]})}function ve({id:t,label:o,depth:g,hasChildren:d,expanded:c,selected:a,badge:u,badgeColor:E="#0F766E",count:S,title:j,onClick:z,onDelete:C}){const[v,k]=F.useState(null),R=F.useRef(null);return F.useEffect(()=>{if(!v)return;const h=x=>{var r;(r=R.current)!=null&&r.contains(x.target)||k(null)},l=x=>{x.key==="Escape"&&k(null)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",l)}},[v]),s.jsxs("div",{role:"none",children:[s.jsxs("button",{type:"button",role:"treeitem","aria-selected":a,"aria-expanded":d?c:void 0,"data-tree-id":t,onClick:z,onContextMenu:C?h=>{h.preventDefault(),h.stopPropagation(),k({x:h.clientX,y:h.clientY})}:void 0,title:j,className:"flex items-center gap-1.5 w-full text-left",style:{minHeight:28,padding:"4px 8px",paddingLeft:8+g*18,border:0,borderRadius:6,cursor:"pointer",background:a?"#2DD4A818":"transparent",color:a?"#0F766E":"#374151"},onMouseEnter:h=>{a||(h.currentTarget.style.background="#F0F0ED")},onMouseLeave:h=>{h.currentTarget.style.background=a?"#2DD4A818":"transparent"},children:[s.jsx("span",{"aria-hidden":!0,style:{width:12,textAlign:"center",flexShrink:0,fontSize:9,color:"#9CA3AF",transform:c?"rotate(90deg)":"none",transition:"transform 120ms ease",visibility:d?"visible":"hidden"},children:"▶"}),u&&s.jsx("span",{style:{minWidth:27,height:17,padding:"0 4px",borderRadius:4,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:`${E}18`,color:E,fontSize:9,fontWeight:800},children:u}),s.jsx("span",{className:"truncate",style:{flex:1,fontSize:M.xs,fontWeight:d?650:500},children:o}),S!==void 0&&s.jsx("span",{style:{color:"#9CA3AF",fontSize:9},children:S})]}),v&&C&&s.jsx("div",{ref:R,role:"menu",className:"fixed z-50 rounded-lg overflow-hidden py-1",style:{left:v.x,top:v.y,minWidth:180,background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:s.jsx("button",{type:"button",role:"menuitem",onClick:async()=>{if(k(null),!window.confirm(`Delete “${o}”?
2
+
3
+ All incoming and outgoing relationships will also be deleted. This cannot be undone.`))return;const h=await C();h.success||window.alert(h.error??"The element could not be deleted.")},style:{width:"100%",border:0,padding:"8px 12px",textAlign:"left",cursor:"pointer",background:"#FFFFFF",color:"#DC2626",fontSize:12,fontWeight:600},children:"Delete element…"})})]})}export{ve as E,Fe as S,K as a,ye as b,ue as c,xe as l};
@@ -1 +1 @@
1
- import{j as e}from"./reactflow-CsCqNKB-.js";import{u as n}from"./index-D0vtjNjX.js";import"./zustand-CrhqMOHB.js";function p(){const i=n(t=>t.setBulkImportOpen),s=n(t=>t.connected),a=[{icon:"📄",title:"Import Elements from CSV",description:"Import model elements from a CSV or tab-separated file. Supports column mapping, artifact type presets, and batch preview before committing.",action:()=>i(!0),requiresConnection:!0}];return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"40px 48px",background:"linear-gradient(135deg, #F0F4F7 0%, #E8EFF3 100%)",minHeight:0},children:e.jsxs("div",{style:{maxWidth:720,margin:"0 auto"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#1B3A4B",marginBottom:6},children:"Import"}),e.jsx("p",{style:{fontSize:"14px",color:"#6B7280",marginBottom:36},children:"Bring data into your model from external sources."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:a.map(t=>{const r=t.requiresConnection&&!s;return e.jsxs("button",{onClick:r?void 0:t.action,disabled:r,style:{display:"flex",alignItems:"flex-start",gap:20,padding:"20px 24px",borderRadius:12,textAlign:"left",background:r?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.75)",border:`1px solid ${r?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.95)"}`,boxShadow:r?"none":"0 2px 8px rgba(0,0,0,0.06)",cursor:r?"not-allowed":"pointer",transition:"all 0.15s",opacity:r?.55:1},onMouseEnter:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.95)",o.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",o.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.75)",o.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)",o.currentTarget.style.transform="none")},children:[e.jsx("div",{style:{fontSize:28,lineHeight:1,flexShrink:0,marginTop:2},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"#1B3A4B",marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:"13px",color:"#6B7280",lineHeight:1.55},children:t.description}),r&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:8},children:"Connect to the dev server to use this import."})]})]},t.title)})})]})})}export{p as ImportView};
1
+ import{j as e}from"./reactflow-s7jmJtXx.js";import{u as n}from"./index-Bij8Q4Kg.js";import"./zustand-CrhqMOHB.js";function p(){const i=n(t=>t.setBulkImportOpen),s=n(t=>t.connected),a=[{icon:"📄",title:"Import Elements from CSV",description:"Import model elements from a CSV or tab-separated file. Supports column mapping, artifact type presets, and batch preview before committing.",action:()=>i(!0),requiresConnection:!0}];return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"40px 48px",background:"linear-gradient(135deg, #F0F4F7 0%, #E8EFF3 100%)",minHeight:0},children:e.jsxs("div",{style:{maxWidth:720,margin:"0 auto"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#1B3A4B",marginBottom:6},children:"Import"}),e.jsx("p",{style:{fontSize:"14px",color:"#6B7280",marginBottom:36},children:"Bring data into your model from external sources."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:a.map(t=>{const r=t.requiresConnection&&!s;return e.jsxs("button",{onClick:r?void 0:t.action,disabled:r,style:{display:"flex",alignItems:"flex-start",gap:20,padding:"20px 24px",borderRadius:12,textAlign:"left",background:r?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.75)",border:`1px solid ${r?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.95)"}`,boxShadow:r?"none":"0 2px 8px rgba(0,0,0,0.06)",cursor:r?"not-allowed":"pointer",transition:"all 0.15s",opacity:r?.55:1},onMouseEnter:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.95)",o.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",o.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.75)",o.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)",o.currentTarget.style.transform="none")},children:[e.jsx("div",{style:{fontSize:28,lineHeight:1,flexShrink:0,marginTop:2},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"#1B3A4B",marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:"13px",color:"#6B7280",lineHeight:1.55},children:t.description}),r&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:8},children:"Connect to the dev server to use this import."})]})]},t.title)})})]})})}export{p as ImportView};
@@ -1 +1 @@
1
- import{j as t}from"./reactflow-CsCqNKB-.js";import{a as f}from"./zustand-CrhqMOHB.js";import{L as M}from"./index-D0vtjNjX.js";const $={"purpose-operational":{bg:"#f0f7ff",header:"#cce5ff",text:"#1e40af",border:"#93c5fd"},requirements:{bg:"#f0f6ff",header:"#dae8fc",text:"#1d4ed8",border:"#93c5fd"},architecture:{bg:"#f0faf0",header:"#d5e8d4",text:"#166534",border:"#86efac"},risk:{bg:"#fff5f5",header:"#f8cecc",text:"#991b1b",border:"#fca5a5"},"vv-evidence":{bg:"#faf5ff",header:"#e1d5e7",text:"#6b21a8",border:"#c4b5fd"},"dhf-outputs":{bg:"#fffbeb",header:"#fff2cc",text:"#92400e",border:"#fcd34d"},other:{bg:"#f9fafb",header:"#f3f4f6",text:"#374151",border:"#d1d5db"}},F=[{id:"purpose-operational",label:"Purpose & Operational",abbr:"PUR",layerIds:["purpose","business","operational"]},{id:"requirements",label:"Requirements",abbr:"REQ",layerIds:["requirements"]},{id:"architecture",label:"Architecture",abbr:"ARCH",layerIds:["functional","behavior","logical","physical","software","interfaces","ui"],subGroups:[{label:"Functional",layerIds:["functional","behavior"]},{label:"Logical",layerIds:["logical"]},{label:"Physical",layerIds:["physical"]},{label:"Software",layerIds:["software"]},{label:"Interfaces",layerIds:["interfaces","ui"]}]},{id:"risk",label:"Risk",abbr:"RISK",layerIds:["risk","safety","cybersecurity"]},{id:"vv-evidence",label:"V&V & Evidence",abbr:"V&V",layerIds:["verification","analysis"]},{id:"dhf-outputs",label:"DHF Outputs",abbr:"DHF",layerIds:["design-control","qms","software-lifecycle","operations","clinical","privacy"]}],A=Object.fromEntries(M.map((n,r)=>[n,r]));function O(n){return[...n].sort((r,d)=>(A[r.id]??99)-(A[d.id]??99))}function T(n){return[...n].sort((r,d)=>{const a=r.derivesFrom?1:0,x=d.derivesFrom?1:0;return a!==x?a-x:r.name.localeCompare(d.name)})}function B({kind:n,layerColor:r,domainBg:d,selected:a,onClick:x,onContextMenu:N,isFlashing:p,flashTick:R}){const[b,g]=f.useState(!1),[v,j]=f.useState(!1);f.useEffect(()=>{if(!p)return;j(!0);const w=setTimeout(()=>j(!1),700);return()=>clearTimeout(w)},[p,R]);const m=a?`${r}18`:b?`${r}0C`:"#ffffff",I=a?r:"transparent",k=r;return t.jsxs("button",{"data-kind":n.name,onClick:x,onContextMenu:N,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"text-left transition-all",style:{width:"130px",minHeight:"55px",background:m,border:`1px solid ${I}`,borderLeft:`3px solid ${k}`,borderRadius:"6px",padding:"6px 8px",cursor:"pointer",transform:v?"scale(1.04)":"scale(1)",boxShadow:v?`0 0 0 2px ${r}, 0 0 12px ${r}60`:a?`0 0 0 1px ${r}40`:b?"0 1px 3px rgba(0,0,0,0.08)":"none",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{fontSize:"9px",fontFamily:"monospace",color:r,opacity:.8,textTransform:"uppercase",letterSpacing:"0.02em",lineHeight:1},children:n.construct.replace("part def","pd").replace("connection def","cd").replace("attribute def","ad")}),n.instanceCount>0&&t.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:`${r}15`,borderRadius:"8px",padding:"0 4px",lineHeight:"14px"},children:n.instanceCount})]}),t.jsx("div",{style:{fontSize:"11px",fontWeight:n.derivesFrom?400:600,color:a?r:"#1F2937",lineHeight:1.3,wordBreak:"break-word"},children:n.name}),n.derivesFrom&&t.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:"2px",lineHeight:1},children:["↳ ",n.derivesFrom]})]})}function z({layers:n,selectedKind:r,onKindClick:d,activeLayerId:a,flashKindName:x,flashTick:N}){const p=f.useRef({}),[R,b]=f.useState(null),[g,v]=f.useState(()=>new Set(F.map(e=>e.id).concat(["other"])));if(f.useEffect(()=>{if(!a)return;const e=p.current[a];if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),b(a);const o=setTimeout(()=>b(null),1200);return()=>clearTimeout(o)}},[a]),n.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12",style:{color:"#9CA3AF"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl mb-2",children:"⬡"}),t.jsx("div",{className:"text-xs",children:"No layers found in this ontology"})]})});const j=new Set(F.flatMap(e=>e.layerIds)),m=O(n.filter(e=>!j.has(e.id)));function I(e,o){e.preventDefault()}function k(e){v(o=>{const s=new Set(o);return s.has(e)?s.delete(e):s.add(e),s})}const w=(e,o,s)=>T(e).map(l=>t.jsx(B,{kind:l,layerColor:o,domainBg:s,selected:r===l.name,onClick:()=>d(r===l.name?null:l.name),onContextMenu:u=>I(u,l.name),isFlashing:x===l.name,flashTick:N},l.name)),C=(e,o)=>{const s=$[e.id]??$.other,L=o.reduce((i,c)=>i+c.kindCount,0),l=L===0,u=g.has(e.id),E=O(o);return t.jsxs("div",{ref:i=>{p.current[e.id]=i},className:"rounded-xl overflow-hidden transition-all",style:{border:`1px solid ${s.border}`,background:s.bg,outline:R===e.id?`2px solid ${s.border}`:"none",outlineOffset:"2px"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 cursor-pointer select-none",style:{background:s.header,borderBottom:u?"none":`1px solid ${s.border}`},onClick:()=>k(e.id),title:u?"Expand":"Collapse",children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:u?"rotate(-90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M4 6L8 10L12 6",stroke:s.text,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s.text,letterSpacing:"0.08em",textTransform:"uppercase",minWidth:"32px",textAlign:"center"},children:e.abbr}),t.jsx("span",{style:{width:"1px",height:"14px",background:`${s.border}`,opacity:.5}}),t.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:s.text},children:e.label}),t.jsx("span",{className:"text-xs",style:{color:s.text,opacity:.7},children:l?"no kinds":`${L} kinds`})]}),!u&&(l?t.jsx("div",{className:"px-4 py-1.5 text-xs italic",style:{color:s.text,opacity:.4},children:"(no elements)"}):t.jsx("div",{className:"p-3 space-y-3",children:e.subGroups?e.subGroups.map(i=>{const c=E.filter(y=>i.layerIds.includes(y.id));if(c.length===0)return null;const h=c.flatMap(y=>y.kinds);if(h.length===0)return null;const S=c[0].color??s.text;return t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium mb-1.5 flex items-center gap-1.5",style:{color:s.text,opacity:.75},ref:y=>{c.forEach(H=>{p.current[H.id]=y})},children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-sm flex-shrink-0",style:{background:S}}),i.label]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w(h,S,s.bg)})]},i.label)}):(()=>{var h;const i=E.flatMap(S=>S.kinds),c=((h=E[0])==null?void 0:h.color)??s.text;return t.jsx("div",{className:"flex flex-wrap gap-2",children:w(i,c,s.bg)})})()}))]},e.id)};return t.jsxs("div",{className:"space-y-3 mb-6",children:[F.map(e=>{const o=n.filter(s=>e.layerIds.includes(s.id));return o.length===0?null:C(e,o)}),m.length>0&&C({id:"other",label:"Other",abbr:"EXT",layerIds:m.map(e=>e.id)},m)]})}export{z as LayerGrid};
1
+ import{j as t}from"./reactflow-s7jmJtXx.js";import{a as f}from"./zustand-CrhqMOHB.js";import{L as M}from"./index-Bij8Q4Kg.js";const $={"purpose-operational":{bg:"#f0f7ff",header:"#cce5ff",text:"#1e40af",border:"#93c5fd"},requirements:{bg:"#f0f6ff",header:"#dae8fc",text:"#1d4ed8",border:"#93c5fd"},architecture:{bg:"#f0faf0",header:"#d5e8d4",text:"#166534",border:"#86efac"},risk:{bg:"#fff5f5",header:"#f8cecc",text:"#991b1b",border:"#fca5a5"},"vv-evidence":{bg:"#faf5ff",header:"#e1d5e7",text:"#6b21a8",border:"#c4b5fd"},"dhf-outputs":{bg:"#fffbeb",header:"#fff2cc",text:"#92400e",border:"#fcd34d"},other:{bg:"#f9fafb",header:"#f3f4f6",text:"#374151",border:"#d1d5db"}},F=[{id:"purpose-operational",label:"Purpose & Operational",abbr:"PUR",layerIds:["purpose","business","operational"]},{id:"requirements",label:"Requirements",abbr:"REQ",layerIds:["requirements"]},{id:"architecture",label:"Architecture",abbr:"ARCH",layerIds:["functional","behavior","logical","physical","software","interfaces","ui"],subGroups:[{label:"Functional",layerIds:["functional","behavior"]},{label:"Logical",layerIds:["logical"]},{label:"Physical",layerIds:["physical"]},{label:"Software",layerIds:["software"]},{label:"Interfaces",layerIds:["interfaces","ui"]}]},{id:"risk",label:"Risk",abbr:"RISK",layerIds:["risk","safety","cybersecurity"]},{id:"vv-evidence",label:"V&V & Evidence",abbr:"V&V",layerIds:["verification","analysis"]},{id:"dhf-outputs",label:"DHF Outputs",abbr:"DHF",layerIds:["design-control","qms","software-lifecycle","operations","clinical","privacy"]}],A=Object.fromEntries(M.map((n,r)=>[n,r]));function O(n){return[...n].sort((r,d)=>(A[r.id]??99)-(A[d.id]??99))}function T(n){return[...n].sort((r,d)=>{const a=r.derivesFrom?1:0,x=d.derivesFrom?1:0;return a!==x?a-x:r.name.localeCompare(d.name)})}function B({kind:n,layerColor:r,domainBg:d,selected:a,onClick:x,onContextMenu:N,isFlashing:p,flashTick:R}){const[b,g]=f.useState(!1),[v,j]=f.useState(!1);f.useEffect(()=>{if(!p)return;j(!0);const w=setTimeout(()=>j(!1),700);return()=>clearTimeout(w)},[p,R]);const m=a?`${r}18`:b?`${r}0C`:"#ffffff",I=a?r:"transparent",k=r;return t.jsxs("button",{"data-kind":n.name,onClick:x,onContextMenu:N,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"text-left transition-all",style:{width:"130px",minHeight:"55px",background:m,border:`1px solid ${I}`,borderLeft:`3px solid ${k}`,borderRadius:"6px",padding:"6px 8px",cursor:"pointer",transform:v?"scale(1.04)":"scale(1)",boxShadow:v?`0 0 0 2px ${r}, 0 0 12px ${r}60`:a?`0 0 0 1px ${r}40`:b?"0 1px 3px rgba(0,0,0,0.08)":"none",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{fontSize:"9px",fontFamily:"monospace",color:r,opacity:.8,textTransform:"uppercase",letterSpacing:"0.02em",lineHeight:1},children:n.construct.replace("part def","pd").replace("connection def","cd").replace("attribute def","ad")}),n.instanceCount>0&&t.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:`${r}15`,borderRadius:"8px",padding:"0 4px",lineHeight:"14px"},children:n.instanceCount})]}),t.jsx("div",{style:{fontSize:"11px",fontWeight:n.derivesFrom?400:600,color:a?r:"#1F2937",lineHeight:1.3,wordBreak:"break-word"},children:n.name}),n.derivesFrom&&t.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:"2px",lineHeight:1},children:["↳ ",n.derivesFrom]})]})}function z({layers:n,selectedKind:r,onKindClick:d,activeLayerId:a,flashKindName:x,flashTick:N}){const p=f.useRef({}),[R,b]=f.useState(null),[g,v]=f.useState(()=>new Set(F.map(e=>e.id).concat(["other"])));if(f.useEffect(()=>{if(!a)return;const e=p.current[a];if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),b(a);const o=setTimeout(()=>b(null),1200);return()=>clearTimeout(o)}},[a]),n.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12",style:{color:"#9CA3AF"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl mb-2",children:"⬡"}),t.jsx("div",{className:"text-xs",children:"No layers found in this ontology"})]})});const j=new Set(F.flatMap(e=>e.layerIds)),m=O(n.filter(e=>!j.has(e.id)));function I(e,o){e.preventDefault()}function k(e){v(o=>{const s=new Set(o);return s.has(e)?s.delete(e):s.add(e),s})}const w=(e,o,s)=>T(e).map(l=>t.jsx(B,{kind:l,layerColor:o,domainBg:s,selected:r===l.name,onClick:()=>d(r===l.name?null:l.name),onContextMenu:u=>I(u,l.name),isFlashing:x===l.name,flashTick:N},l.name)),C=(e,o)=>{const s=$[e.id]??$.other,L=o.reduce((i,c)=>i+c.kindCount,0),l=L===0,u=g.has(e.id),E=O(o);return t.jsxs("div",{ref:i=>{p.current[e.id]=i},className:"rounded-xl overflow-hidden transition-all",style:{border:`1px solid ${s.border}`,background:s.bg,outline:R===e.id?`2px solid ${s.border}`:"none",outlineOffset:"2px"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 cursor-pointer select-none",style:{background:s.header,borderBottom:u?"none":`1px solid ${s.border}`},onClick:()=>k(e.id),title:u?"Expand":"Collapse",children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:u?"rotate(-90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M4 6L8 10L12 6",stroke:s.text,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s.text,letterSpacing:"0.08em",textTransform:"uppercase",minWidth:"32px",textAlign:"center"},children:e.abbr}),t.jsx("span",{style:{width:"1px",height:"14px",background:`${s.border}`,opacity:.5}}),t.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:s.text},children:e.label}),t.jsx("span",{className:"text-xs",style:{color:s.text,opacity:.7},children:l?"no kinds":`${L} kinds`})]}),!u&&(l?t.jsx("div",{className:"px-4 py-1.5 text-xs italic",style:{color:s.text,opacity:.4},children:"(no elements)"}):t.jsx("div",{className:"p-3 space-y-3",children:e.subGroups?e.subGroups.map(i=>{const c=E.filter(y=>i.layerIds.includes(y.id));if(c.length===0)return null;const h=c.flatMap(y=>y.kinds);if(h.length===0)return null;const S=c[0].color??s.text;return t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium mb-1.5 flex items-center gap-1.5",style:{color:s.text,opacity:.75},ref:y=>{c.forEach(H=>{p.current[H.id]=y})},children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-sm flex-shrink-0",style:{background:S}}),i.label]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w(h,S,s.bg)})]},i.label)}):(()=>{var h;const i=E.flatMap(S=>S.kinds),c=((h=E[0])==null?void 0:h.color)??s.text;return t.jsx("div",{className:"flex flex-wrap gap-2",children:w(i,c,s.bg)})})()}))]},e.id)};return t.jsxs("div",{className:"space-y-3 mb-6",children:[F.map(e=>{const o=n.filter(s=>e.layerIds.includes(s.id));return o.length===0?null:C(e,o)}),m.length>0&&C({id:"other",label:"Other",abbr:"EXT",layerIds:m.map(e=>e.id)},m)]})}export{z as LayerGrid};
@@ -1,2 +1,2 @@
1
- import{j as t}from"./reactflow-CsCqNKB-.js";import{a}from"./zustand-CrhqMOHB.js";import{f as A}from"./index-D0vtjNjX.js";function q({layers:p,selectedKind:L,onKindClick:S}){const[F,D]=a.useState("name"),[g,j]=a.useState("asc"),[f,M]=a.useState(""),[c,T]=a.useState(!1),[i,v]=a.useState("all"),[d,E]=a.useState("all"),[B,h]=a.useState(!1),[N,b]=a.useState(!1),y=a.useMemo(()=>p.flatMap(e=>e.kinds.map(s=>({...s,layerLabel:e.label,layerColor:A[e.id]??e.color??"#6B7280"}))),[p]),R=a.useMemo(()=>[...new Set(p.map(e=>e.id))],[p]),K=a.useMemo(()=>[...new Set(y.map(e=>e.construct))],[y]),C=a.useMemo(()=>{let e=y;if(f.trim()){const s=f.toLowerCase();e=e.filter(o=>{var l,r;return o.name.toLowerCase().includes(s)||o.label.toLowerCase().includes(s)||o.layer.toLowerCase().includes(s)||(((l=o.description)==null?void 0:l.toLowerCase().includes(s))??!1)||(((r=o.derivesFrom)==null?void 0:r.toLowerCase().includes(s))??!1)})}return i!=="all"&&(e=e.filter(s=>s.layer===i)),d!=="all"&&(e=e.filter(s=>s.construct===d)),e},[y,f,i,d]),x=a.useMemo(()=>[...C].sort((e,s)=>{var l,r;let o=0;switch(F){case"name":o=e.name.localeCompare(s.name);break;case"layer":o=e.layer.localeCompare(s.layer);break;case"construct":o=e.construct.localeCompare(s.construct);break;case"instanceCount":o=e.instanceCount-s.instanceCount;break;case"derivesFrom":o=(e.derivesFrom??"").localeCompare(s.derivesFrom??"");break;case"derivedByCount":o=(((l=e.derivedBy)==null?void 0:l.length)??0)-(((r=s.derivedBy)==null?void 0:r.length)??0);break}return g==="asc"?o:-o}),[C,F,g]),k=a.useMemo(()=>{if(c)return null;const e=new Map;for(const s of x)e.has(s.layer)||e.set(s.layer,[]),e.get(s.layer).push(s);return e},[x,c]);function u(e){F===e?j(s=>s==="asc"?"desc":"asc"):(D(e),j("asc"))}const z=a.useCallback(()=>{const e=[["Name","Layer","Construct","Instances","Derives From","Derived By","Description"]];for(const n of x)e.push([n.name,n.layer,n.construct,String(n.instanceCount),n.derivesFrom??"",(n.derivedBy??[]).join("; "),n.description??""]);const s=e.map(n=>n.map($=>`"${$.replace(/"/g,'""')}"`).join(",")).join(`
2
- `),o=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="ontology-kinds.csv",r.click(),URL.revokeObjectURL(l)},[x]),m=({k:e})=>t.jsx("span",{style:{fontSize:"10px",color:F===e?"#1B3A4B":"#D1D5DB",marginLeft:"3px"},children:F===e?g==="asc"?"▲":"▼":"⇅"}),w=(e,s)=>{var l,r;const o=L===e.name;return t.jsxs("div",{className:"grid items-center cursor-pointer text-xs",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",padding:"7px 16px",background:o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF",borderLeft:o?`3px solid ${e.layerColor}`:"3px solid transparent",transition:"background 100ms ease"},onClick:()=>S(o?null:e.name),onMouseEnter:n=>{o||(n.currentTarget.style.background="#F0F7FF")},onMouseLeave:n=>{o||(n.currentTarget.style.background=o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF")},children:[t.jsxs("div",{className:"flex items-center gap-2 truncate",children:[t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:e.layerColor}}),t.jsx("span",{style:{color:"#1a1a1a",fontWeight:o?600:400},children:e.name})]}),t.jsx("span",{className:"capitalize",style:{color:"#6B7280"},children:e.layer}),t.jsx("span",{className:"font-mono",style:{color:"#9CA3AF"},children:e.construct}),t.jsx("span",{className:"text-right",style:{color:e.instanceCount>0?"#1B3A4B":"#D1D5DB"},children:e.instanceCount>0?e.instanceCount:"—"}),t.jsx("span",{className:"truncate",style:{color:e.derivesFrom?"#2563EB":"#D1D5DB"},children:e.derivesFrom??"—"}),t.jsx("span",{className:"text-right",style:{color:(((l=e.derivedBy)==null?void 0:l.length)??0)>0?"#374151":"#D1D5DB"},children:(((r=e.derivedBy)==null?void 0:r.length)??0)>0?e.derivedBy.length:"—"})]},`${e.layer}:${e.name}`)};return t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("input",{type:"text",placeholder:"Search kinds...",value:f,onChange:e=>M(e.target.value),className:"px-2.5 py-1.5 text-xs rounded-md flex-1 min-w-[140px]",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none",maxWidth:"240px"},onFocus:e=>e.currentTarget.style.borderColor="#2563EB",onBlur:e=>e.currentTarget.style.borderColor="#E5E7EB"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{h(!B),b(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:i!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Layer: ",i==="all"?"All":i]}),B&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"120px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{v("all"),h(!1)},children:"All"}),R.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 capitalize",style:{color:"#374151"},onClick:()=>{v(e),h(!1)},children:e},e))]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{b(!N),h(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:d!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Construct: ",d==="all"?"All":d]}),N&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"140px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{E("all"),b(!1)},children:"All"}),K.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 font-mono",style:{color:"#374151"},onClick:()=>{E(e),b(!1)},children:e},e))]})]}),t.jsx("button",{onClick:()=>T(!c),className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:c?"#1B3A4B":"#F9FAFB",color:c?"#2DD4A8":"#374151"},children:c?"Grouped":"Flatten"}),t.jsx("button",{onClick:z,className:"px-2.5 py-1.5 text-xs rounded-md ml-auto",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151"},title:"Export as CSV",children:"Export CSV"}),t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[C.length," / ",y.length," kinds"]})]}),t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"grid text-xs font-medium",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",padding:"8px 16px",color:"#6B7280",position:"sticky",top:0,zIndex:5},children:[t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("name"),children:["Kind ",t.jsx(m,{k:"name"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("layer"),children:["Layer ",t.jsx(m,{k:"layer"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("construct"),children:["Construct ",t.jsx(m,{k:"construct"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("instanceCount"),children:["# ",t.jsx(m,{k:"instanceCount"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("derivesFrom"),children:["Derives From ",t.jsx(m,{k:"derivesFrom"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("derivedByCount"),children:["Subs ",t.jsx(m,{k:"derivedByCount"})]})]}),c?x.map((e,s)=>w(e,s)):k&&[...k.entries()].map(([e,s])=>{const o=p.find(r=>r.id===e),l=A[e]??"#6B7280";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-semibold",style:{background:`${l}08`,borderTop:"1px solid #E5E5E0",color:l},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:l}}),(o==null?void 0:o.label)??e,t.jsxs("span",{className:"font-normal",style:{color:"#9CA3AF"},children:["(",s.length,")"]})]}),s.map((r,n)=>w(r,n))]},e)}),x.length===0&&t.jsx("div",{className:"py-8 text-center text-xs",style:{color:"#9CA3AF"},children:"No kinds match the current filters"})]})]})}export{q as LayerTable};
1
+ import{j as t}from"./reactflow-s7jmJtXx.js";import{a}from"./zustand-CrhqMOHB.js";import{h as A}from"./index-Bij8Q4Kg.js";function q({layers:p,selectedKind:L,onKindClick:S}){const[F,D]=a.useState("name"),[g,j]=a.useState("asc"),[h,M]=a.useState(""),[c,T]=a.useState(!1),[i,v]=a.useState("all"),[d,E]=a.useState("all"),[B,f]=a.useState(!1),[N,b]=a.useState(!1),y=a.useMemo(()=>p.flatMap(e=>e.kinds.map(s=>({...s,layerLabel:e.label,layerColor:A[e.id]??e.color??"#6B7280"}))),[p]),R=a.useMemo(()=>[...new Set(p.map(e=>e.id))],[p]),K=a.useMemo(()=>[...new Set(y.map(e=>e.construct))],[y]),C=a.useMemo(()=>{let e=y;if(h.trim()){const s=h.toLowerCase();e=e.filter(o=>{var l,r;return o.name.toLowerCase().includes(s)||o.label.toLowerCase().includes(s)||o.layer.toLowerCase().includes(s)||(((l=o.description)==null?void 0:l.toLowerCase().includes(s))??!1)||(((r=o.derivesFrom)==null?void 0:r.toLowerCase().includes(s))??!1)})}return i!=="all"&&(e=e.filter(s=>s.layer===i)),d!=="all"&&(e=e.filter(s=>s.construct===d)),e},[y,h,i,d]),x=a.useMemo(()=>[...C].sort((e,s)=>{var l,r;let o=0;switch(F){case"name":o=e.name.localeCompare(s.name);break;case"layer":o=e.layer.localeCompare(s.layer);break;case"construct":o=e.construct.localeCompare(s.construct);break;case"instanceCount":o=e.instanceCount-s.instanceCount;break;case"derivesFrom":o=(e.derivesFrom??"").localeCompare(s.derivesFrom??"");break;case"derivedByCount":o=(((l=e.derivedBy)==null?void 0:l.length)??0)-(((r=s.derivedBy)==null?void 0:r.length)??0);break}return g==="asc"?o:-o}),[C,F,g]),k=a.useMemo(()=>{if(c)return null;const e=new Map;for(const s of x)e.has(s.layer)||e.set(s.layer,[]),e.get(s.layer).push(s);return e},[x,c]);function u(e){F===e?j(s=>s==="asc"?"desc":"asc"):(D(e),j("asc"))}const z=a.useCallback(()=>{const e=[["Name","Layer","Construct","Instances","Derives From","Derived By","Description"]];for(const n of x)e.push([n.name,n.layer,n.construct,String(n.instanceCount),n.derivesFrom??"",(n.derivedBy??[]).join("; "),n.description??""]);const s=e.map(n=>n.map($=>`"${$.replace(/"/g,'""')}"`).join(",")).join(`
2
+ `),o=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="ontology-kinds.csv",r.click(),URL.revokeObjectURL(l)},[x]),m=({k:e})=>t.jsx("span",{style:{fontSize:"10px",color:F===e?"#1B3A4B":"#D1D5DB",marginLeft:"3px"},children:F===e?g==="asc"?"▲":"▼":"⇅"}),w=(e,s)=>{var l,r;const o=L===e.name;return t.jsxs("div",{className:"grid items-center cursor-pointer text-xs",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",padding:"7px 16px",background:o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF",borderLeft:o?`3px solid ${e.layerColor}`:"3px solid transparent",transition:"background 100ms ease"},onClick:()=>S(o?null:e.name),onMouseEnter:n=>{o||(n.currentTarget.style.background="#F0F7FF")},onMouseLeave:n=>{o||(n.currentTarget.style.background=o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF")},children:[t.jsxs("div",{className:"flex items-center gap-2 truncate",children:[t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:e.layerColor}}),t.jsx("span",{style:{color:"#1a1a1a",fontWeight:o?600:400},children:e.name})]}),t.jsx("span",{className:"capitalize",style:{color:"#6B7280"},children:e.layer}),t.jsx("span",{className:"font-mono",style:{color:"#9CA3AF"},children:e.construct}),t.jsx("span",{className:"text-right",style:{color:e.instanceCount>0?"#1B3A4B":"#D1D5DB"},children:e.instanceCount>0?e.instanceCount:"—"}),t.jsx("span",{className:"truncate",style:{color:e.derivesFrom?"#2563EB":"#D1D5DB"},children:e.derivesFrom??"—"}),t.jsx("span",{className:"text-right",style:{color:(((l=e.derivedBy)==null?void 0:l.length)??0)>0?"#374151":"#D1D5DB"},children:(((r=e.derivedBy)==null?void 0:r.length)??0)>0?e.derivedBy.length:"—"})]},`${e.layer}:${e.name}`)};return t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("input",{type:"text",placeholder:"Search kinds...",value:h,onChange:e=>M(e.target.value),className:"px-2.5 py-1.5 text-xs rounded-md flex-1 min-w-[140px]",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none",maxWidth:"240px"},onFocus:e=>e.currentTarget.style.borderColor="#2563EB",onBlur:e=>e.currentTarget.style.borderColor="#E5E7EB"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{f(!B),b(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:i!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Layer: ",i==="all"?"All":i]}),B&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"120px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{v("all"),f(!1)},children:"All"}),R.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 capitalize",style:{color:"#374151"},onClick:()=>{v(e),f(!1)},children:e},e))]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{b(!N),f(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:d!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Construct: ",d==="all"?"All":d]}),N&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"140px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{E("all"),b(!1)},children:"All"}),K.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 font-mono",style:{color:"#374151"},onClick:()=>{E(e),b(!1)},children:e},e))]})]}),t.jsx("button",{onClick:()=>T(!c),className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:c?"#1B3A4B":"#F9FAFB",color:c?"#2DD4A8":"#374151"},children:c?"Grouped":"Flatten"}),t.jsx("button",{onClick:z,className:"px-2.5 py-1.5 text-xs rounded-md ml-auto",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151"},title:"Export as CSV",children:"Export CSV"}),t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[C.length," / ",y.length," kinds"]})]}),t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"grid text-xs font-medium",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",padding:"8px 16px",color:"#6B7280",position:"sticky",top:0,zIndex:5},children:[t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("name"),children:["Kind ",t.jsx(m,{k:"name"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("layer"),children:["Layer ",t.jsx(m,{k:"layer"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("construct"),children:["Construct ",t.jsx(m,{k:"construct"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("instanceCount"),children:["# ",t.jsx(m,{k:"instanceCount"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("derivesFrom"),children:["Derives From ",t.jsx(m,{k:"derivesFrom"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("derivedByCount"),children:["Subs ",t.jsx(m,{k:"derivedByCount"})]})]}),c?x.map((e,s)=>w(e,s)):k&&[...k.entries()].map(([e,s])=>{const o=p.find(r=>r.id===e),l=A[e]??"#6B7280";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-semibold",style:{background:`${l}08`,borderTop:"1px solid #E5E5E0",color:l},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:l}}),(o==null?void 0:o.label)??e,t.jsxs("span",{className:"font-normal",style:{color:"#9CA3AF"},children:["(",s.length,")"]})]}),s.map((r,n)=>w(r,n))]},e)}),x.length===0&&t.jsx("div",{className:"py-8 text-center text-xs",style:{color:"#9CA3AF"},children:"No kinds match the current filters"})]})]})}export{q as LayerTable};