@mcp-graph-workflow/mcp-graph 3.0.0 → 4.1.0

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 (114) hide show
  1. package/README.md +14 -4
  2. package/dist/api/middleware/validate.d.ts.map +1 -1
  3. package/dist/api/middleware/validate.js.map +1 -1
  4. package/dist/api/router.d.ts +1 -2
  5. package/dist/api/router.d.ts.map +1 -1
  6. package/dist/api/router.js.map +1 -1
  7. package/dist/api/routes/edges.js.map +1 -1
  8. package/dist/api/routes/import.d.ts.map +1 -1
  9. package/dist/api/routes/import.js +4 -1
  10. package/dist/api/routes/import.js.map +1 -1
  11. package/dist/api/routes/integrations.js.map +1 -1
  12. package/dist/api/routes/rag.js.map +1 -1
  13. package/dist/cli/commands/import-cmd.d.ts.map +1 -1
  14. package/dist/cli/commands/import-cmd.js +6 -3
  15. package/dist/cli/commands/import-cmd.js.map +1 -1
  16. package/dist/cli/commands/index-cmd.d.ts.map +1 -1
  17. package/dist/cli/commands/index-cmd.js +11 -7
  18. package/dist/cli/commands/index-cmd.js.map +1 -1
  19. package/dist/cli/commands/init.d.ts.map +1 -1
  20. package/dist/cli/commands/init.js +6 -3
  21. package/dist/cli/commands/init.js.map +1 -1
  22. package/dist/cli/commands/serve.js +2 -1
  23. package/dist/cli/commands/serve.js.map +1 -1
  24. package/dist/cli/commands/stats.d.ts.map +1 -1
  25. package/dist/cli/commands/stats.js +13 -9
  26. package/dist/cli/commands/stats.js.map +1 -1
  27. package/dist/cli/index.js +7 -2
  28. package/dist/cli/index.js.map +1 -1
  29. package/dist/core/capture/web-capture.d.ts.map +1 -1
  30. package/dist/core/capture/web-capture.js +5 -4
  31. package/dist/core/capture/web-capture.js.map +1 -1
  32. package/dist/core/context/context-assembler.d.ts.map +1 -1
  33. package/dist/core/context/context-assembler.js.map +1 -1
  34. package/dist/core/context/rag-context.d.ts.map +1 -1
  35. package/dist/core/context/rag-context.js.map +1 -1
  36. package/dist/core/importer/prd-to-graph.d.ts.map +1 -1
  37. package/dist/core/importer/prd-to-graph.js +1 -2
  38. package/dist/core/importer/prd-to-graph.js.map +1 -1
  39. package/dist/core/insights/bottleneck-detector.d.ts.map +1 -1
  40. package/dist/core/parser/file-reader.d.ts.map +1 -1
  41. package/dist/core/parser/file-reader.js +2 -1
  42. package/dist/core/parser/file-reader.js.map +1 -1
  43. package/dist/core/planner/lifecycle-phase.js +1 -1
  44. package/dist/core/planner/lifecycle-phase.js.map +1 -1
  45. package/dist/core/rag/embedding-store.d.ts.map +1 -1
  46. package/dist/core/rag/embedding-store.js.map +1 -1
  47. package/dist/core/rag/serena-indexer.js +1 -1
  48. package/dist/core/rag/serena-indexer.js.map +1 -1
  49. package/dist/core/search/fts-search.js +1 -1
  50. package/dist/core/search/fts-search.js.map +1 -1
  51. package/dist/core/store/sqlite-store.d.ts.map +1 -1
  52. package/dist/core/store/sqlite-store.js.map +1 -1
  53. package/dist/mcp/init-project.js +2 -2
  54. package/dist/mcp/init-project.js.map +1 -1
  55. package/dist/mcp/tools/update-node.js.map +1 -1
  56. package/package.json +10 -3
  57. package/dist/web/dashboard/dist/assets/benchmark-tab-BTKW3REK.js +0 -1
  58. package/dist/web/dashboard/dist/assets/benchmark-tab-BhbUvjLM.js +0 -1
  59. package/dist/web/dashboard/dist/assets/benchmark-tab-D64Ala80.js +0 -1
  60. package/dist/web/dashboard/dist/assets/benchmark-tab-DJ7HyF-u.js +0 -1
  61. package/dist/web/dashboard/dist/assets/benchmark-tab-DVyzQZ2d.js +0 -1
  62. package/dist/web/dashboard/dist/assets/benchmark-tab-XUH7yQNv.js +0 -1
  63. package/dist/web/dashboard/dist/assets/benchmark-tab-ZfJu1pxc.js +0 -1
  64. package/dist/web/dashboard/dist/assets/gitnexus-tab-BFHEXsJm.js +0 -312
  65. package/dist/web/dashboard/dist/assets/gitnexus-tab-Bbp91fom.js +0 -312
  66. package/dist/web/dashboard/dist/assets/gitnexus-tab-C3fPSzYi.js +0 -312
  67. package/dist/web/dashboard/dist/assets/gitnexus-tab-Cd0k8qk3.js +0 -312
  68. package/dist/web/dashboard/dist/assets/gitnexus-tab-Cuc-KSII.js +0 -312
  69. package/dist/web/dashboard/dist/assets/gitnexus-tab-DEwJXSnD.js +0 -312
  70. package/dist/web/dashboard/dist/assets/gitnexus-tab-DOD7xwmm.js +0 -312
  71. package/dist/web/dashboard/dist/assets/graph-tab-AD7csRcc.js +0 -1
  72. package/dist/web/dashboard/dist/assets/graph-tab-BKyDCyHH.js +0 -1
  73. package/dist/web/dashboard/dist/assets/graph-tab-D0F0WJES.js +0 -1
  74. package/dist/web/dashboard/dist/assets/graph-tab-DA16nThT.js +0 -1
  75. package/dist/web/dashboard/dist/assets/graph-tab-DJknUhrl.js +0 -1
  76. package/dist/web/dashboard/dist/assets/graph-tab-DRPfelKw.js +0 -1
  77. package/dist/web/dashboard/dist/assets/graph-tab-lJ2rPS4Z.js +0 -1
  78. package/dist/web/dashboard/dist/assets/graph-utils-BN7tt0ZS.js +0 -23
  79. package/dist/web/dashboard/dist/assets/graph-utils-BTV1KGUM.js +0 -23
  80. package/dist/web/dashboard/dist/assets/graph-utils-BkfAOVJ9.js +0 -23
  81. package/dist/web/dashboard/dist/assets/graph-utils-Bo7cD1sx.js +0 -23
  82. package/dist/web/dashboard/dist/assets/graph-utils-CI4znRl5.js +0 -23
  83. package/dist/web/dashboard/dist/assets/graph-utils-DrCx5m7q.js +0 -23
  84. package/dist/web/dashboard/dist/assets/graph-utils-KQmzMFXM.js +0 -23
  85. package/dist/web/dashboard/dist/assets/index-BGMP3W6f.css +0 -1
  86. package/dist/web/dashboard/dist/assets/index-BVXu3x9W.js +0 -53
  87. package/dist/web/dashboard/dist/assets/index-B_T9j86O.js +0 -53
  88. package/dist/web/dashboard/dist/assets/index-Bga9WW2A.css +0 -1
  89. package/dist/web/dashboard/dist/assets/index-BonF71I0.js +0 -53
  90. package/dist/web/dashboard/dist/assets/index-CSyjxREL.js +0 -53
  91. package/dist/web/dashboard/dist/assets/index-CbUKe2Fv.js +0 -53
  92. package/dist/web/dashboard/dist/assets/index-DzM6oBA3.js +0 -53
  93. package/dist/web/dashboard/dist/assets/index-IK005MzD.js +0 -53
  94. package/dist/web/dashboard/dist/assets/insights-tab-B9R3HsMU.js +0 -1
  95. package/dist/web/dashboard/dist/assets/insights-tab-BO_cxLyV.js +0 -1
  96. package/dist/web/dashboard/dist/assets/insights-tab-Brn6IMfQ.js +0 -1
  97. package/dist/web/dashboard/dist/assets/insights-tab-C6x-aJ8p.js +0 -1
  98. package/dist/web/dashboard/dist/assets/insights-tab-CapL1jP-.js +0 -1
  99. package/dist/web/dashboard/dist/assets/insights-tab-CeWM6zgV.js +0 -1
  100. package/dist/web/dashboard/dist/assets/insights-tab-xQj5e61M.js +0 -1
  101. package/dist/web/dashboard/dist/assets/prd-backlog-tab-0oOO63rA.js +0 -1
  102. package/dist/web/dashboard/dist/assets/prd-backlog-tab-BcWoplsM.js +0 -1
  103. package/dist/web/dashboard/dist/assets/prd-backlog-tab-Bjj5KccG.js +0 -1
  104. package/dist/web/dashboard/dist/assets/prd-backlog-tab-C7cKQyup.js +0 -1
  105. package/dist/web/dashboard/dist/assets/prd-backlog-tab-CT4ja7Ay.js +0 -1
  106. package/dist/web/dashboard/dist/assets/prd-backlog-tab-CmPHHBDQ.js +0 -1
  107. package/dist/web/dashboard/dist/assets/prd-backlog-tab-_jmBe3MU.js +0 -1
  108. package/dist/web/dashboard/dist/assets/serena-tab-BVyBTaHC.js +0 -1
  109. package/dist/web/dashboard/dist/assets/serena-tab-CVI1GGRk.js +0 -1
  110. package/dist/web/dashboard/dist/assets/serena-tab-D1ki2NjT.js +0 -1
  111. package/dist/web/dashboard/dist/assets/serena-tab-DRrRfjpO.js +0 -1
  112. package/dist/web/dashboard/dist/assets/serena-tab-DvYbwR4Z.js +0 -1
  113. package/dist/web/dashboard/dist/assets/serena-tab-L6isY0iT.js +0 -1
  114. package/dist/web/dashboard/dist/assets/serena-tab-ba2n0AOh.js +0 -1
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-CSyjxREL.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-KQmzMFXM.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-B_T9j86O.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-Bo7cD1sx.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-BVXu3x9W.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-BTV1KGUM.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-DzM6oBA3.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-CI4znRl5.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-BonF71I0.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-BN7tt0ZS.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-IK005MzD.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-DrCx5m7q.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};
@@ -1 +0,0 @@
1
- import{r as t,j as e,a as X}from"./index-CbUKe2Fv.js";import{u as ee,a as se,f as M,t as te,s as re,b as ae,c as oe,i as le,W as ne,d as ce,B as de,C as ie,N as xe}from"./graph-utils-BkfAOVJ9.js";import{A as ue,S as L,a as pe,N as _,E as me}from"./constants-BIEJOBya.js";const be=t.memo(function({statuses:p,types:y,direction:m,onStatusToggle:N,onTypeToggle:h,onDirectionChange:f,onClear:b,showFullGraph:n,totalNodeCount:c,onShowFullGraphChange:v}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)] text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Status:"}),ue.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p.has(a),onChange:()=>N(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:L[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Type:"}),pe.map(a=>e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y.has(a),onChange:()=>h(a),className:"w-3 h-3"}),e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:_[a]}}),e.jsx("span",{children:a.replace("_"," ")})]},a))]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-[var(--color-text-muted)]",children:"Layout:"}),e.jsxs("select",{value:m,onChange:a=>f(a.target.value),className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-1 py-0.5 text-xs",children:[e.jsx("option",{value:"TB",children:"Top → Down"}),e.jsx("option",{value:"LR",children:"Left → Right"})]})]}),e.jsx("div",{className:"w-px h-4 bg-[var(--color-border)]"}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>v(!n),className:"w-3 h-3"}),e.jsxs("span",{children:["Show all nodes (",c,")"]})]}),n&&c>200&&e.jsx("span",{className:"text-[var(--color-warning)] font-medium",children:"Large graph — may be slow"}),e.jsx("button",{onClick:b,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] underline",children:"Clear"})]})}),E=50,he=t.memo(function({nodes:p,onNodeClick:y}){const[m,N]=t.useState("priority"),[h,f]=t.useState("asc"),[b,n]=t.useState(""),[c,v]=t.useState(0),a=t.useMemo(()=>{if(!b)return p;const s=b.toLowerCase();return p.filter(u=>u.title.toLowerCase().includes(s)||u.type.toLowerCase().includes(s)||u.status.toLowerCase().includes(s)||(u.sprint||"").toLowerCase().includes(s))},[p,b]),g=t.useMemo(()=>[...a].sort((s,u)=>{const C=s[m]??"",w=u[m]??"",S=typeof C=="number"?C-w:String(C).localeCompare(String(w));return h==="asc"?S:-S}),[a,m,h]),i=Math.max(1,Math.ceil(g.length/E)),j=t.useMemo(()=>g.slice(c*E,(c+1)*E),[g,c]),l=s=>{m===s?f(u=>u==="asc"?"desc":"asc"):(N(s),f("asc"))},k=[{key:"title",label:"Title"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"priority",label:"Priority"},{key:"xpSize",label:"Size"},{key:"sprint",label:"Sprint"}];return e.jsxs("div",{className:"border-t border-[var(--color-border)]",children:[e.jsx("div",{className:"px-4 py-2 bg-[var(--color-bg-secondary)]",children:e.jsx("input",{type:"text",placeholder:"Search nodes...",value:b,onChange:s=>n(s.target.value),className:"w-full max-w-xs px-2 py-1 text-sm border border-[var(--color-border)] rounded bg-[var(--color-bg)]"})}),e.jsx("div",{className:"overflow-x-auto max-h-64",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[var(--color-bg-tertiary)]",children:k.map(s=>e.jsxs("th",{onClick:()=>l(s.key),className:"px-3 py-1.5 text-left text-xs font-medium text-[var(--color-text-muted)] cursor-pointer hover:text-[var(--color-text)]",children:[s.label,m===s.key&&(h==="asc"?" ↑":" ↓")]},s.key))})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-4 text-center text-[var(--color-text-muted)]",children:"No nodes found"})}):j.map(s=>e.jsxs("tr",{onClick:()=>y(s),className:"border-t border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] cursor-pointer",children:[e.jsx("td",{className:"px-3 py-1.5 max-w-[200px] truncate",children:s.title}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:`${_[s.type]}20`,color:_[s.type]},children:s.type})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${L[s.status]}20`,color:L[s.status]},children:s.status.replace("_"," ")})}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.priority}),e.jsx("td",{className:"px-3 py-1.5 text-center",children:s.xpSize||"-"}),e.jsx("td",{className:"px-3 py-1.5",children:s.sprint||"-"})]},s.id))})]})}),i>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border)] text-xs text-[var(--color-text-muted)]",children:[e.jsxs("span",{children:[g.length," nodes"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{disabled:c===0,onClick:()=>v(s=>Math.max(0,s-1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Prev"}),e.jsxs("span",{children:[c+1,"/",i]}),e.jsx("button",{disabled:c>=i-1,onClick:()=>v(s=>Math.min(i-1,s+1)),className:"px-2 py-0.5 rounded border border-[var(--color-border)] disabled:opacity-30",children:"Next"})]})]})]})}),fe=["depends_on","blocks","parent_of","child_of","related_to","priority_over","implements","derived_from"];function ge({fromId:o,toId:p,fromTitle:y,toTitle:m,onCreated:N,onCancel:h}){const[f,b]=t.useState("depends_on"),[n,c]=t.useState(""),[v,a]=t.useState(!1),[g,i]=t.useState(null),j=t.useCallback(async()=>{a(!0),i(null);try{await X.createEdge({from:o,to:p,relationType:f,reason:n.trim()||void 0}),N()}catch(l){i(l instanceof Error?l.message:"Failed to create edge")}finally{a(!1)}},[o,p,f,n,N]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-[var(--color-bg)] border border-[var(--color-border)] rounded-lg shadow-xl w-96 p-4",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"Create Relationship"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"From"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:y??o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"To"}),e.jsx("div",{className:"text-xs bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded truncate",children:m??p})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Relation Type"}),e.jsx("select",{value:f,onChange:l=>b(l.target.value),className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]",children:fe.map(l=>{const k=me[l];return e.jsx("option",{value:l,children:k.label},l)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-[var(--color-text-muted)] block mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:n,onChange:l=>c(l.target.value),placeholder:"Why this relationship exists...",className:"w-full text-xs px-2 py-1.5 rounded bg-[var(--color-bg-tertiary)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})]}),g&&e.jsx("div",{className:"text-xs text-[var(--color-danger)] bg-[var(--color-bg-tertiary)] px-2 py-1.5 rounded",children:g})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:h,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-bg-tertiary)] hover:bg-[var(--color-border)] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:v,className:"text-xs px-3 py-1.5 rounded bg-[var(--color-accent)] text-white font-medium disabled:opacity-50 hover:opacity-90 transition-opacity",children:v?"Creating...":"Create"})]})]})})}const ve={workflowNode:ce},ye={workflowEdge:ne},Ne={hideAttribution:!0};function je({graph:o}){var P,F;const[p,y,m]=ee([]),[N,h,f]=se([]),[b,n]=t.useState(null),[c,v]=t.useState("TB"),[a,g]=t.useState(new Set),[i,j]=t.useState(new Set),[l,k]=t.useState(!1),[s,u]=t.useState(null),C=t.useDeferredValue(a),w=t.useDeferredValue(i),S=t.useDeferredValue(c),D=t.useRef(null),R=t.useCallback((r,x,d)=>{const q=M(o.nodes,l),I=te(q,{statuses:r,types:x}),T=I.map(Q=>Q.id);if(re(D.current,T)&&d===S)return;D.current=T;const H=new Set(T),J=ae(o.edges,H),A=oe(I,J,d);y(A.nodes),h(A.edges)},[o,y,h,S,l]);t.useEffect(()=>{R(C,w,S)},[o,R,C,w,S]);const z=t.useCallback((r,x)=>{n(x.data.sourceNode)},[]),O=t.useCallback(r=>{n(r)},[]),G=t.useCallback(r=>{const x=o.nodes.find(d=>d.id===r);x&&n(x)},[o.nodes]),W=t.useCallback(r=>{r.source&&r.target&&r.source!==r.target&&u({fromId:r.source,toId:r.target})},[]),B=t.useCallback(()=>{u(null)},[]),V=t.useCallback(r=>{g(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Y=t.useCallback(r=>{j(x=>{const d=new Set(x);return d.has(r)?d.delete(r):d.add(r),d})},[]),Z=t.useCallback(()=>{g(new Set),j(new Set)},[]),K=t.useMemo(()=>M(o.nodes,l).filter(x=>!(a.size&&!a.has(x.status)||i.size&&!i.has(x.type))),[o.nodes,a,i,l]),U=s?(P=o.nodes.find(r=>r.id===s.fromId))==null?void 0:P.title:void 0,$=s?(F=o.nodes.find(r=>r.id===s.toId))==null?void 0:F.title:void 0;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(be,{statuses:a,types:i,direction:c,onStatusToggle:V,onTypeToggle:Y,onDirectionChange:v,onClear:Z,showFullGraph:l,totalNodeCount:o.nodes.length,onShowFullGraphChange:k}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 relative",children:o.nodes.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No nodes in graph"}),e.jsx("p",{className:"text-sm",children:"Import a PRD to get started"})]})}):e.jsxs(le,{nodes:p,edges:N,onNodesChange:m,onEdgesChange:f,onNodeClick:z,onConnect:W,nodeTypes:ve,edgeTypes:ye,nodesDraggable:!1,nodesConnectable:!0,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Ne,children:[e.jsx(de,{gap:16,size:1}),e.jsx(ie,{showInteractive:!1})]})}),b&&e.jsx(xe,{node:b,edges:o.edges,allNodes:o.nodes,onClose:()=>n(null),onNodeNavigate:G})]}),e.jsx(he,{nodes:K,onNodeClick:O}),s&&e.jsx(ge,{fromId:s.fromId,toId:s.toId,fromTitle:U,toTitle:$,onCreated:B,onCancel:()=>u(null)})]})}function Te({graph:o}){return e.jsx("div",{className:"h-full",children:e.jsx(je,{graph:o})})}export{Te as GraphTab};