trybeacon 0.1.79 → 0.1.81

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 (129) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.next/BUILD_ID +1 -1
  3. package/.next/app-path-routes-manifest.json +15 -15
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +3 -3
  6. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/server/app/_not-found/page.js +2 -2
  16. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/_not-found.html +1 -1
  19. package/.next/server/app/_not-found.rsc +26 -25
  20. package/.next/server/app/_not-found.segments/_full.segment.rsc +26 -25
  21. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_index.segment.rsc +15 -14
  23. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  26. package/.next/server/app/docs/page.js +2 -2
  27. package/.next/server/app/docs/page.js.nft.json +1 -1
  28. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app/docs.html +1 -1
  30. package/.next/server/app/docs.rsc +27 -26
  31. package/.next/server/app/docs.segments/_full.segment.rsc +27 -26
  32. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  33. package/.next/server/app/docs.segments/_index.segment.rsc +15 -14
  34. package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  35. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  36. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  37. package/.next/server/app/help/page.js +2 -2
  38. package/.next/server/app/help/page.js.nft.json +1 -1
  39. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  40. package/.next/server/app/help.html +1 -1
  41. package/.next/server/app/help.rsc +35 -34
  42. package/.next/server/app/help.segments/_full.segment.rsc +35 -34
  43. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  44. package/.next/server/app/help.segments/_index.segment.rsc +15 -14
  45. package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
  46. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
  47. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  48. package/.next/server/app/index.html +1 -1
  49. package/.next/server/app/index.rsc +25 -24
  50. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  51. package/.next/server/app/index.segments/_full.segment.rsc +25 -24
  52. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  53. package/.next/server/app/index.segments/_index.segment.rsc +15 -14
  54. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  55. package/.next/server/app/learn/page.js +4 -4
  56. package/.next/server/app/learn/page.js.nft.json +1 -1
  57. package/.next/server/app/learn/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/map/page.js +2 -2
  59. package/.next/server/app/map/page.js.nft.json +1 -1
  60. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/page.js +2 -2
  62. package/.next/server/app/page.js.nft.json +1 -1
  63. package/.next/server/app/page_client-reference-manifest.js +1 -1
  64. package/.next/server/app/plan/page.js +3 -3
  65. package/.next/server/app/plan/page.js.nft.json +1 -1
  66. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  67. package/.next/server/app/s/[token]/page.js +2 -2
  68. package/.next/server/app/s/[token]/page.js.nft.json +1 -1
  69. package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
  70. package/.next/server/app/settings/page.js +2 -2
  71. package/.next/server/app/settings/page.js.nft.json +1 -1
  72. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app-paths-manifest.json +15 -15
  74. package/.next/server/chunks/{7720.js → 141.js} +4 -4
  75. package/.next/server/chunks/2025.js +1 -1
  76. package/.next/server/chunks/2455.js +1 -0
  77. package/.next/server/chunks/3174.js +1 -1
  78. package/.next/server/chunks/3179.js +1 -0
  79. package/.next/server/chunks/6469.js +2 -2
  80. package/.next/server/middleware-build-manifest.js +1 -1
  81. package/.next/server/pages/404.html +1 -1
  82. package/.next/server/pages/500.html +1 -1
  83. package/.next/server/server-reference-manifest.js +1 -1
  84. package/.next/server/server-reference-manifest.json +1 -1
  85. package/.next/static/chunks/1909-0f500ebe4df09208.js +1 -0
  86. package/.next/static/chunks/{3908-80efc60050779adf.js → 3908-2ba88cd8ba5dfa2e.js} +1 -1
  87. package/.next/static/chunks/{2059-fba06ba63ba64522.js → 4674-31ad596c3e856647.js} +3 -3
  88. package/.next/static/chunks/4752-81a4fc25de32efa2.js +1 -0
  89. package/.next/static/chunks/4853-43350f60d0d9135b.js +1 -0
  90. package/.next/static/chunks/6639-f0b63e1e7d03a20a.js +1 -0
  91. package/.next/static/chunks/9784-880aab43467bf1e0.js +1 -0
  92. package/.next/static/chunks/app/layout-ef1edf5ed5839b01.js +1 -0
  93. package/.next/static/chunks/app/learn/page-6459c292421bec82.js +7 -0
  94. package/.next/static/chunks/app/map/page-602309791f192143.js +1 -0
  95. package/.next/static/chunks/app/page-32a051917fc57795.js +1 -0
  96. package/.next/static/chunks/app/plan/page-920d4fecdd6dde34.js +11 -0
  97. package/.next/static/chunks/app/s/[token]/page-1df7929974ceeb5a.js +1 -0
  98. package/.next/static/chunks/app/settings/page-f128ae102e013087.js +1 -0
  99. package/.next/static/css/9301599114d42898.css +1 -0
  100. package/.next/trace +47 -46
  101. package/.next/trace-build +1 -1
  102. package/dist/bin/beacon.js +16 -15
  103. package/dist/bin/doctor.js +61 -60
  104. package/dist/bin/hook.js +58 -57
  105. package/dist/bin/mcp.js +70 -69
  106. package/dist/bin/plan.js +61 -60
  107. package/dist/bin/uninstall.js +59 -58
  108. package/dist/lib/assets.js +55 -20
  109. package/dist/lib/codex-install.js +62 -61
  110. package/dist/lib/daemon-boot.js +37 -0
  111. package/dist/lib/global-install.js +62 -61
  112. package/package.json +1 -1
  113. package/.next/server/chunks/5295.js +0 -1
  114. package/.next/server/chunks/8569.js +0 -1
  115. package/.next/static/chunks/1909-98243a0473be2aae.js +0 -1
  116. package/.next/static/chunks/4477-cda153702c7812d2.js +0 -1
  117. package/.next/static/chunks/4607-a668ea431c41e60e.js +0 -1
  118. package/.next/static/chunks/4853-0082a1e1b820a293.js +0 -1
  119. package/.next/static/chunks/6302-27c904b9f4b65236.js +0 -1
  120. package/.next/static/chunks/app/layout-e728d45f193e3b95.js +0 -1
  121. package/.next/static/chunks/app/learn/page-14a297c6ff4e54f0.js +0 -7
  122. package/.next/static/chunks/app/map/page-91637b0a29494ee5.js +0 -1
  123. package/.next/static/chunks/app/page-ec00130a7a249f14.js +0 -1
  124. package/.next/static/chunks/app/plan/page-d4651c40e3bd751e.js +0 -11
  125. package/.next/static/chunks/app/s/[token]/page-05344f912a83ed60.js +0 -1
  126. package/.next/static/chunks/app/settings/page-7e86fd456b92c248.js +0 -1
  127. package/.next/static/css/570399103dd72653.css +0 -1
  128. /package/.next/static/{J6oJS9kOgjsQGP4x5VPu6 → ms-hAcPFSz7LxuiDMzzcP}/_buildManifest.js +0 -0
  129. /package/.next/static/{J6oJS9kOgjsQGP4x5VPu6 → ms-hAcPFSz7LxuiDMzzcP}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4853],{44853:(e,t,n)=>{n.d(t,{DbMapClient:()=>ek});var a=n(95155),s=n(12115),o=n(80277),l=n(73321),i=n(81750),r=n(6266);n(53255);var d=n(32133),c=n(81499),m=n(51128),u=n(65738),p=n(9005),h=n(2125),f=n(91337),x=n(18874);let b=(0,s.createContext)(null);function g(){let e=(0,s.useContext)(b);if(!e)throw Error("useDbEdit must be used inside DbEditContext");return e}var y=n(29523),j=n(70221),k=n(95635),w=n(17918);let v={danger:"bg-red-500/15 text-red-300",warn:"bg-amber-500/15 text-amber-300"};function N({badges:e,className:t}){return e.length?(0,a.jsx)("span",{className:(0,f.cn)("flex shrink-0 items-center gap-0.5",t),children:e.map(e=>(0,a.jsx)("span",{title:e.title,className:(0,f.cn)("rounded px-1 text-[8px] font-semibold uppercase tracking-wide",v[e.tone]),children:e.label},e.label))}):null}let C=/pass(word)?|token|secret|api[_-]?key|credential|priv(ate)?[_-]?key|hash|salt/i,T=/auth|login|logout|session|token|password|oauth|sso|credential/i,M="nodrag nopan",S=k.x;function E({onClick:e,title:t}){return(0,a.jsx)("button",{type:"button",title:t,onClick:t=>{t.stopPropagation(),e()},className:(0,f.cn)(M,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover/row:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})}function I({c:e,fkTargets:t}){let n=t?.[e.name];return(0,a.jsx)("span",{title:n?`→ ${n}`:e.type,className:"ml-auto min-w-0 truncate font-mono text-[11px] text-muted-foreground/80",children:n?(0,a.jsxs)(a.Fragment,{children:["→\xa0",n]}):e.type})}let $=(0,s.memo)(function({id:e,data:t,selected:n}){var o;let l,i,r="DRAFT"===t.source,d="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",b="added"===t.diffStatus||"modified"===t.diffStatus,v="added"===t.diffStatus?"new":"modified"===t.diffStatus?"modify":"in plan",T=t.diffChanges?.length?t.diffChanges.join("\n"):"in this plan — no column change",$=r?d:(0,x.qA)(t.domain),A=(o={domain:t.domain,columns:t.columns},l=[],(i=o.columns.filter(e=>C.test(e.name)).map(e=>e.name)).length&&l.push({label:"secrets",tone:"danger",title:`stores credentials: ${i.join(", ")}`}),o.domain&&/auth/i.test(o.domain)&&l.push({label:"auth",tone:"warn",title:"auth-domain table"}),l),P=g(),[z,D]=(0,s.useState)(t.name),[F,R]=(0,s.useState)(t.columns),[O,L]=(0,s.useState)(!1);(0,s.useEffect)(()=>{D(t.name),R(t.columns)},[t.rev]);let K=e=>e.stopPropagation(),B=t=>{R(t),P.patchTable(e,{columns:t})},H=(t.pins??[]).filter(e=>null===e.column),_=e=>(t.pins??[]).filter(t=>t.column===e),Z=function(e,t,n,a=!1,s){return Math.min(312,Math.max(240,Math.round(8*e.length)+90,...t.map(e=>{if(a){let t=s?.[e.name],a=n?.[e.name];return Math.round(7.3*Math.max(6,e.name.length+1)+(a?(a.length+2)*8:t?.kind==="modified"?8*t.detail.length:64))+94}let t=n?.[e.name]?n[e.name].length+2:e.type.length;return Math.round(7.3*e.name.length+6.7*t)+64})))}(t.name,r?F:t.columns,t.fkTargets,r,t.diffColumns),U=(0,f.cn)("relative rounded-xl border bg-[#161618]/95 text-card-foreground shadow-[0_18px_50px_-22px_rgba(0,0,0,0.9)] backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]"),q=(0,y.k)(j.fE);return"full"!==q?(0,a.jsxs)("div",{className:(0,f.cn)(U,"border-white/10 px-3 py-2.5","far"===q&&!P.readOnly&&"!opacity-0"),style:{width:Z},children:[(0,a.jsx)(k.x,{}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{background:$}}),(0,a.jsx)("span",{className:"truncate font-mono text-[15px] font-semibold",children:t.name})]})]}):r?(0,a.jsxs)("div",{className:(0,f.cn)(U,"group/card"),style:{width:Z,borderColor:`${d}59`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-1.5 rounded-t-[11px] px-3 py-2",style:{background:`${d}14`},children:[(0,a.jsx)("input",{value:z,onChange:e=>D(e.target.value),onBlur:()=>{let n=z.trim();n&&n!==t.name&&P.patchTable(e,{name:n})},onKeyDown:e=>{K(e),"Enter"===e.key&&e.currentTarget.blur()},placeholder:"table",className:(0,f.cn)(M,"min-w-0 flex-1 bg-transparent font-mono text-[13px] font-semibold tracking-tight outline-none")}),(0,a.jsx)(N,{badges:A}),(0,a.jsx)("span",{title:T,className:(0,f.cn)("shrink-0 rounded-md border px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em]",!b&&"border-white/15 bg-white/5 text-muted-foreground"),style:b?{background:`${d}1f`,borderColor:`${d}55`,color:d}:void 0,children:v}),(0,a.jsx)("button",{type:"button",onClick:t=>{K(t),O?P.deleteTable(e):L(!0)},onBlur:()=>L(!1),title:"Delete table",className:(0,f.cn)(M,"shrink-0 transition-all",O?"text-red-300":"text-muted-foreground opacity-0 hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(u.A,{className:"size-3"})}),H.length>0?(0,a.jsx)(w.e0,{pins:H,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsxs)("div",{className:"divide-y divide-white/[0.05]",children:[F.map((e,n)=>{let s=_(e.name),o=t.diffColumns?.[e.name],l=o?.kind==="added"?{background:"#7bd38914",boxShadow:"inset 2px 0 0 #7bd389"}:o?.kind==="modified"?{background:"#ffb86b14",boxShadow:"inset 2px 0 0 #ffb86b"}:void 0;return(0,a.jsxs)("div",{style:l,className:"group/row relative flex items-center gap-1.5 px-3 py-[5px] text-[12px]",children:[(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.map((e,t)=>t===n?{...e,isPk:!e.isPk}:e))},title:"Primary key",className:(0,f.cn)(M,"shrink-0",e.isPk?"text-amber-300/90":"text-muted-foreground/40 hover:text-amber-300"),children:(0,a.jsx)(c.A,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.map((e,t)=>t===n?{...e,isFk:!e.isFk}:e))},title:"Foreign key",className:(0,f.cn)(M,"shrink-0",e.isFk?"text-sky-400/80":"text-muted-foreground/40 hover:text-sky-400"),children:(0,a.jsx)(m.A,{className:"size-3"})}),(0,a.jsx)("input",{value:e.name,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,name:e.target.value}:t)),onBlur:()=>B(F),onKeyDown:K,placeholder:"column",style:{width:`${Math.max(6,e.name.length+1)}ch`},className:(0,f.cn)(M,"shrink-0 bg-transparent font-mono outline-none")}),(0,a.jsx)("span",{"aria-hidden":!0,className:"flex-1"}),t.fkTargets?.[e.name]?(0,a.jsxs)("span",{title:`→ ${t.fkTargets[e.name]}`,className:"min-w-0 shrink truncate text-right font-mono text-[11px] text-muted-foreground/80",children:["→\xa0",t.fkTargets[e.name]]}):o?.kind==="modified"?(0,a.jsx)("span",{title:`was changed — ${o.detail}`,className:(0,f.cn)(M,"min-w-0 shrink truncate text-right font-mono text-[11px] font-medium text-[#ffb86b]"),children:o.detail}):(0,a.jsx)("input",{value:e.type,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,type:e.target.value}:t)),onBlur:()=>B(F),onKeyDown:K,placeholder:"type",title:e.type,className:(0,f.cn)(M,"w-16 min-w-0 shrink bg-transparent text-right font-mono text-[11px] outline-none",o?.kind==="added"?"text-[#7bd389]":"text-muted-foreground/80")}),(0,a.jsx)("button",{type:"button",onClick:e=>{K(e),B(F.filter((e,t)=>t!==n))},title:"Remove column",className:(0,f.cn)(M,"shrink-0 text-muted-foreground/40 opacity-0 transition-opacity hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(p.A,{className:"size-3"})}),s.length>0?(0,a.jsx)(w.e0,{pins:s,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},n)}),(0,a.jsxs)("button",{type:"button",onClick:e=>{K(e),B([...F,{name:"",type:"text",isPk:!1,isFk:!1,nullable:!0,note:null}])},className:(0,f.cn)(M,"flex w-full items-center gap-1 px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(h.A,{className:"size-3"})," column"]})]})]}):(0,a.jsxs)("div",{className:U,style:{width:Z,borderColor:`${$}3d`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center justify-between rounded-t-[11px] px-3 py-2",style:{background:`${$}14`},children:[(0,a.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 font-mono text-[13px] font-semibold tracking-tight",children:["INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),(0,a.jsx)("span",{className:"truncate",title:t.name,children:t.name})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5",children:["INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(N,{badges:A}),t.domain&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-[0.14em]",style:{color:$},children:t.domain})]}),H.length>0?(0,a.jsx)(w.e0,{pins:H,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsx)("div",{className:"divide-y divide-white/[0.05]",children:t.columns.map(e=>{let n=_(e.name);return(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-2 px-3 py-[7px] text-[12px]",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 shrink-0 text-amber-300/90"}):e.isFk?(0,a.jsx)(m.A,{className:"size-3 shrink-0 text-sky-400/80"}):(0,a.jsx)("span",{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"shrink-0 whitespace-nowrap font-mono",children:e.name}),(0,a.jsx)(I,{c:e,fkTargets:t.fkTargets}),n.length>0?(0,a.jsx)(w.e0,{pins:n,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(E,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},e.name)})})]})}),A="nodrag nopan",P=["GET","POST","PUT","PATCH","DELETE"],z=(0,s.memo)(function({id:e,data:t,selected:n}){var o;let l,i=x.e6[t.method]??"#8a8a8a",r="DRAFT"===t.source,c="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",m="added"===t.diffStatus?"new":"modified"===t.diffStatus?"changed":"draft",p=t.diffChanges?.length?t.diffChanges.join("\n"):"draft",h=(o={method:t.method,domain:t.domain,path:t.path},l=[],/^delete$/i.test(o.method.trim())&&l.push({label:"DELETE",tone:"danger",title:"destructive: deletes data"}),(o.domain&&/auth/i.test(o.domain)||T.test(o.path))&&l.push({label:"auth",tone:"warn",title:"auth-related endpoint"}),l),b=g(),[v,C]=(0,s.useState)(t.path),[M,S]=(0,s.useState)(!1);(0,s.useEffect)(()=>{C(t.path)},[t.rev]);let E=e=>e.stopPropagation(),I=(0,y.k)(j.fE);return"full"!==I?(0,a.jsxs)("div",{className:(0,f.cn)("relative flex w-[300px] items-center gap-2 rounded-lg border border-white/10 bg-[#161618]/95 px-2.5 py-2 text-card-foreground backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]","far"===I&&!b.readOnly&&"!opacity-0"),children:[(0,a.jsx)(k.x,{}),(0,a.jsx)("span",{className:"shrink-0 font-mono text-[12px] font-bold",style:{color:i},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"truncate font-mono text-[13px]",children:t.path})]}):(0,a.jsxs)("div",{className:(0,f.cn)("group relative flex w-[300px] items-center gap-2 rounded-lg border bg-[#161618]/95 px-2.5 py-1.5 text-card-foreground shadow-[0_12px_36px_-18px_rgba(0,0,0,0.9)] backdrop-blur",r?"border-dashed":"border-white/10",n&&"ring-2 ring-[var(--accent,#f5b942)]"),style:r?{borderColor:`${c}66`,background:`${c}0f`}:void 0,children:[(0,a.jsx)(k.x,{}),"INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:t.method,onChange:t=>b.patchEndpoint(e,{method:t.target.value}),onPointerDown:E,className:(0,f.cn)(A,"shrink-0 rounded bg-transparent text-[10px] font-bold outline-none"),style:{color:i},title:"Method",children:P.map(e=>(0,a.jsx)("option",{value:e,className:"bg-card text-foreground",children:e},e))}),(0,a.jsx)("input",{value:v,title:v,onChange:e=>C(e.target.value),onBlur:()=>{let n=v.trim();n&&n!==t.path&&b.patchEndpoint(e,{path:n})},onKeyDown:e=>{E(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,f.cn)(A,"min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none")}),(0,a.jsx)(N,{badges:h}),(0,a.jsx)("span",{title:p,className:"shrink-0 rounded px-1 py-0.5 text-[8px] font-semibold uppercase",style:{background:`${c}26`,color:c},children:m}),(0,a.jsx)("button",{type:"button",onClick:t=>{E(t),M?b.deleteEndpoint(e):S(!0)},onBlur:()=>S(!1),title:"Delete",className:(0,f.cn)(A,"shrink-0 transition-colors",M?"text-red-300":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(u.A,{className:"size-3"})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-bold",style:{background:`${i}22`,color:i},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"min-w-0 flex-1 break-all font-mono text-[11px] leading-tight [-webkit-box-orient:vertical] [-webkit-line-clamp:2] [display:-webkit-box] overflow-hidden",children:t.path}),"INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[8px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(N,{badges:h}),(0,a.jsx)("button",{type:"button",onClick:t=>{E(t),M?b.deleteRealEndpoint(e):S(!0)},onBlur:()=>S(!1),title:M?"Click again to delete":"Delete endpoint",className:(0,f.cn)(A,"shrink-0 opacity-0 transition-opacity group-hover:opacity-100",M?"text-red-300 opacity-100":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(u.A,{className:"size-3"})})]}),(t.pins?.length??0)>0?(0,a.jsx)(w.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Comment on ${t.method} ${t.path}`,onClick:e=>{E(e),t.onComment?.(`${t.method} ${t.path}`)},className:(0,f.cn)(A,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})]})});var D=n(54698),F=n(82099),R=n(4474);let O=[{id:"claude",label:"Prompt p/ Claude Code",fn:function(e){let t=["Implement this database schema in this project, following its existing stack and conventions:",""];for(let n of e.tables){let e=`Table \`${n.name}\``+(n.domain?` (domain: ${n.domain})`:"")+(n.description?` — ${n.description}`:"");for(let a of(t.push(e),n.columns)){let e=[a.isPk&&"PK",a.isFk&&"FK",!1===a.nullable&&"NOT NULL"].filter(Boolean).join(", ");t.push(` - ${a.name}: ${a.type}`+(e?` [${e}]`:"")+(a.note?` — ${a.note}`:""))}t.push("")}if(e.relations.length){for(let n of(t.push("Foreign keys:"),e.relations))t.push(` - ${n.fromTable}.${n.fromColumn} -> ${n.toTable}.${n.toColumn}`);t.push("")}return t.push("Create the models/migrations using the project's existing ORM and patterns, wire the relationships, and keep table and column names exactly as given."),t.join("\n")}},{id:"dbml",label:"DBML",fn:function(e){let t=[];for(let n of e.tables){for(let e of(t.push(`Table ${n.name} {`),n.columns)){let n=[e.isPk&&"pk",!1===e.nullable&&!e.isPk&&"not null",e.note&&`note: '${e.note.replace(/'/g,"")}'`].filter(Boolean).join(", ");t.push(` ${e.name} ${e.type}`+(n?` [${n}]`:""))}t.push("}","")}for(let n of e.relations)t.push(`Ref: ${n.fromTable}.${n.fromColumn} > ${n.toTable}.${n.toColumn}`);return t.join("\n").trim()}},{id:"sql",label:"SQL DDL",fn:function(e){let t=[];for(let n of e.tables){t.push(`CREATE TABLE ${n.name} (`);let a=n.columns.map(e=>{let t=[` ${e.name} ${e.type}`];return e.isPk?t.push("PRIMARY KEY"):!1===e.nullable&&t.push("NOT NULL"),t.join(" ")}),s=e.relations.filter(e=>e.fromTable===n.name).map(e=>` FOREIGN KEY (${e.fromColumn}) REFERENCES ${e.toTable}(${e.toColumn})`);t.push([...a,...s].join(",\n")),t.push(");","")}return t.join("\n").trim()}}];function L({draftGraph:e}){let[t,n]=(0,s.useState)(null);if(0===e.tables.length)return null;async function o(t){await navigator.clipboard.writeText(t.fn(e)).catch(()=>{}),n(t.id),setTimeout(()=>n(null),1500)}return(0,a.jsxs)("div",{className:"space-y-2 rounded-xl border border-sky-400/20 bg-sky-500/[0.04] p-3",children:[(0,a.jsxs)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-sky-300",children:["Rascunho \xb7 ",e.tables.length," tabelas"]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"copiar:"}),O.map(e=>(0,a.jsx)(R.$,{size:"sm",variant:"outline",className:"h-6 px-2 text-[11px]",onClick:()=>o(e),children:t===e.id?"✓":e.label},e.id))]})]})}function K({selected:e,tables:t,relations:n,endpoints:s,draftGraph:o,onClose:l,commentsContent:i,commentsCount:r=0,activeTab:c,onTabChange:m,onAddComment:u,topOffset:h}){let f,x,b=new Map(t.map(e=>[e.id,e.name])),g=!!i,y=c??"details",j=e?.kind==="table"?t.find(t=>t.id===e.id)?.name??null:e?.kind==="endpoint"&&(x=s.find(t=>t.id===e.id))?`${x.method} ${x.path}`:null;if(e?.kind==="table"){let o=t.find(t=>t.id===e.id);f=o?(0,a.jsx)(H,{table:o,relations:n,endpoints:s,nameById:b}):null}else if(e?.kind==="endpoint"){let t=s.find(t=>t.id===e.id);f=t?(0,a.jsx)(_,{ep:t,nameById:b}):null}else f=(0,a.jsx)(Z,{tables:t,relations:n,endpoints:s});return(0,a.jsxs)(F.b,{className:"absolute right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:h??12,maxHeight:`calc(100% - ${(h??12)+12}px)`},children:[g?(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(B,{active:"details"===y,onClick:()=>m?.("details"),children:"Details"}),(0,a.jsxs)(B,{active:"comments"===y,onClick:()=>m?.("comments"),children:["Comments",r>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:r})]})]}),(0,a.jsx)("button",{onClick:l,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Panel"}),(0,a.jsx)("button",{onClick:l,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:"comments"===y&&g?(0,a.jsx)("div",{className:"p-3",children:i}):(0,a.jsxs)(a.Fragment,{children:[o.tables.length>0&&(0,a.jsx)("div",{className:"border-b border-white/10 p-3.5",children:(0,a.jsx)(L,{draftGraph:o})}),(0,a.jsxs)("div",{className:"p-4",children:[u&&j&&(0,a.jsxs)("button",{type:"button",onClick:()=>u(j),className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:"size-3.5"}),"Comment on this ",e?.kind==="endpoint"?"endpoint":"table"]}),f]})]})})]})}function B({active:e,onClick:t,children:n}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,f.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:n})}function H({table:e,relations:t,endpoints:n,nameById:s}){let o=t.filter(t=>t.fromTableId===e.id),l=t.filter(t=>t.toTableId===e.id),i=n.map(t=>({e:t,u:t.tables.find(t=>t.tableId===e.id)})).filter(e=>e.u);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs uppercase tracking-wide",style:{color:(0,x.qA)(e.domain)},children:e.domain??"table"}),(0,a.jsx)("h2",{className:"font-mono text-lg font-semibold",children:e.name}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(U,{title:`Columns (${e.columns.length})`,children:(0,a.jsx)("ul",{className:"space-y-0.5",children:e.columns.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5 text-xs",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 text-amber-400"}):e.isFk?(0,a.jsx)(m.A,{className:"size-3 text-sky-400"}):(0,a.jsx)("span",{className:"size-3"}),(0,a.jsx)("span",{className:"font-mono",children:e.name}),(0,a.jsxs)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground",children:[e.type,!e.nullable&&" \xb7NN"]})]},e.name))})}),o.length>0&&(0,a.jsx)(U,{title:"References (FK out)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:o.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[e.fromColumn," → ",s.get(e.toTableId),".",e.toColumn]},e.id))})}),l.length>0&&(0,a.jsx)(U,{title:"Referenced by (FK in)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:l.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[s.get(e.fromTableId),".",e.fromColumn]},e.id))})}),i.length>0&&(0,a.jsx)(U,{title:`Used by endpoints (${i.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:i.map(({e,u:t})=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{style:{color:x.e6[e.method]},className:"font-bold",children:e.method}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.path}),(0,a.jsx)("span",{className:"ml-auto",style:{color:x.ru[t.access]},children:t.access})]},e.id))})})]})}function _({ep:e,nameById:t}){return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-bold",style:{background:`${x.e6[e.method]}22`,color:x.e6[e.method]},children:e.method}),(0,a.jsx)("h2",{className:"mt-2 font-mono text-base font-semibold",children:e.path}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(U,{title:`Tables used (${e.tables.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:e.tables.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono",children:t.get(e.tableId)}),(0,a.jsx)("span",{className:"ml-auto",style:{color:x.ru[e.access]},children:e.access})]},e.tableId))})})]})}function Z({tables:e,relations:t,endpoints:n}){return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Database"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Live schema derived from your code. Click a table or endpoint to see details. Drag to rearrange — positions are saved."})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-3 gap-2 text-center",children:[(0,a.jsx)(q,{label:"tables",value:e.length}),(0,a.jsx)(q,{label:"FKs",value:t.length}),(0,a.jsx)(q,{label:"endpoints",value:n.length})]}),(0,a.jsx)(U,{title:"Legend",children:(0,a.jsxs)("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(c.A,{className:"size-3 text-amber-400"})," primary key"]}),(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(m.A,{className:"size-3 text-sky-400"})," foreign key"]}),(0,a.jsx)("li",{children:"— gray line: FK relation between tables"}),(0,a.jsx)("li",{children:"– – dashed line: endpoint uses table (read/write)"})]})})]})}function U({title:e,children:t}){return(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e}),t]})}function q({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] py-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:t}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e})]})}var W=n(56614),G=n(9991),J=n(40654),Q=n(14983),V=n(62311);let X=new Set(["GET","HEAD","OPTIONS"]);var Y=n(44267),ee=n(94014);function et(e){return 36+30*Math.max(0,e)+16}let en="Unattached",ea=e=>(e??"").trim()||"—";function es(e,t){let n=new Map(e.map(e=>[e.id,e.name])),a=new Map;for(let e of t)for(let t of e.uses)n.has(t.tableId)&&a.set(t.tableId,(a.get(t.tableId)??0)+1);return new Map(t.map(e=>[e.id,function(e,t,n){let a=new Map;for(let n of e.uses)t.has(n.tableId)&&a.set(n.tableId,(a.get(n.tableId)??0)+1);let s=null;for(let[e,o]of a){if(null===s){s=e;continue}let l=a.get(s);if(o>l){s=e;continue}if(o<l)continue;let i=n?.get(e)??0,r=n?.get(s)??0;i<r?s=e:i===r&&0>t.get(e).localeCompare(t.get(s))&&(s=e)}return s}(e,n,a)]))}let eo=(e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.id.localeCompare(t.id);var el=n(70947);let ei=e=>e.trim().toLowerCase();var er=n(85618),ed=n(80846),ec=n(17356),em=n(45486),eu=n(15330),ep=n(60976),eh=n(64577),ef=n(24692),ex=n(45437);let eb={dbTable:$,endpoint:z,annotation:w.Sh},eg={deletable:ef.I,annotation:ex.L},ey="beacon:db-draft",ej={proposedAt:0,status:"pending",tables:[],relations:[],endpoints:[]};function ek({tables:e,relations:t,endpoints:n,draft:d,workspaceId:c,embedded:m=!1,diffBase:p,draftRef:h,onEdit:g,controlRef:k,commentsContent:v,commentsCount:N=0,onAddComment:C,annotations:T,onPinClick:M,onUpdateComment:S,onRemoveComment:E,boardAnnotations:I,readOnly:$=!1}){let A=(0,l.useRouter)(),P=e.length+(d?.tables.length??0),z=n.length+(d?.endpoints.length??0),[F,R]=(0,s.useState)(z>0&&(m||0===P)),[O,L]=(0,s.useState)(null),[B,H]=(0,s.useState)(null),[_,Z]=(0,s.useState)(null),[U,q]=(0,s.useState)(!1),[ef,ex]=(0,s.useState)(!1),[ew,ev]=(0,s.useState)("details"),[eN,eC]=(0,s.useState)(!1),[eT,eM]=(0,s.useState)(""),eS=(0,s.useRef)(null),{tool:eE,setTool:eI,flowProps:e$}=(0,o.e)();(0,s.useEffect)(()=>{if(!$)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>eS.current?.fitView({padding:.2,duration:0}))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[$,d,F]),(0,s.useEffect)(()=>{if(k)return k.current={open:()=>{q(!0),ev("details")},close:()=>{q(!1),ev("details")},openComments:()=>{q(!0),ev("comments")}},()=>{k&&(k.current=null)}},[k]);let[eA,eP]=(0,s.useState)(new Set),[ez,eD]=(0,s.useState)("full"),[eF,eR]=(0,s.useState)(new Set),[eO,eL]=(0,s.useState)(new Set),[eK,eB]=(0,s.useState)(()=>({past:[],present:d??ej,future:[],rev:0,edited:!1})),eH=eK.present,e_=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{past:[...t.past,t.present].slice(-100),present:n,future:[],rev:t.rev+1,edited:!0}})},[]),eZ=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{...t,present:n}})},[]),eU=(0,s.useCallback)(()=>eB(e=>e.past.length?{past:e.past.slice(0,-1),present:e.past[e.past.length-1],future:[e.present,...e.future],rev:e.rev+1,edited:!0}:e),[]),eq=(0,s.useCallback)(()=>eB(e=>e.future.length?{past:[...e.past,e.present],present:e.future[0],future:e.future.slice(1),rev:e.rev+1,edited:!0}:e),[]),eW=(0,s.useCallback)(e=>eB(t=>({past:[],present:e,future:[],rev:t.rev+1,edited:!1})),[]),eG=(0,s.useRef)(!1),eJ=d?.proposedAt??0;(0,s.useEffect)(()=>{let e=null;if(eG.current)d&&d.proposedAt!==eH.proposedAt?e=d:!d&&(eH.tables.length>0||eH.endpoints.length>0)&&(e=ej);else{eG.current=!0;let t=null;try{let e=localStorage.getItem(ey);if(e){let n=JSON.parse(e);n.workspaceId===c&&n.doc&&d&&n.doc.proposedAt===d.proposedAt&&(t=n.doc)}}catch{}e=t??d??null}e&&eW(e)},[eJ]),(0,s.useEffect)(()=>{try{eH.tables.length>0||eH.endpoints.length>0?localStorage.setItem(ey,JSON.stringify({workspaceId:c,doc:eH})):localStorage.removeItem(ey)}catch{}},[eH,c]),(0,s.useEffect)(()=>{h&&(h.current=eH)},[h,eH]);let eQ=(0,s.useRef)(!1);(0,s.useEffect)(()=>{eK.edited&&!eQ.current&&(eQ.current=!0,g?.())},[eK.edited,g]);let eV=(0,s.useMemo)(()=>eH.tables.map(e=>({id:e.id,name:e.name,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,columns:e.columns})),[eH]),eX=(0,s.useMemo)(()=>eH.endpoints.map(e=>({id:e.id,method:e.method,path:e.path,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,tables:e.links.map(e=>({tableId:e.tableId,access:e.access}))})),[eH]),eY=(0,s.useMemo)(()=>[...e,...eV],[e,eV]),e0=(0,s.useMemo)(()=>[...n,...eX],[n,eX]),e1=(0,s.useMemo)(()=>(function(e,t,n={}){let a=es(e,t),s=new Map,o=[];for(let e of[...t].sort(eo)){let t=a.get(e.id)??null;if(t){let n=s.get(t);n?n.push(e):s.set(t,[e])}else o.push(e)}let l=e=>{let t=s.get(e.id)?.length??0;return et(e.columnCount)+(t?10+60*t:0)+30},i=Array.from(new Set(e.map(e=>ea(e.domain)))),r=i.filter(e=>"—"!==e).sort(),d=i.includes("—")?[...r,"—"]:r,c=[];for(let t of d){let n=e.filter(e=>ea(e.domain)===t).sort((e,t)=>e.name.localeCompare(t.name)),a=n.reduce((e,t)=>e+l(t),0),s=Math.max(1,Math.min(12,n.length,Math.round(Math.sqrt(a/320)))),o=Array(s).fill(0),i=new Map;for(let e of n){let t=0;for(let e=1;e<s;e++)o[e]<o[t]&&(t=e);i.set(e.id,{x:320*t,y:o[t]}),o[t]+=l(e)}c.push({d:t,w:320*s,h:Math.max(...o,0),tableLocal:i})}let m=(0,ee.Xi)(c.map(e=>({id:e.d,w:e.w,h:e.h})),{gapX:84,gapY:72,viewportAspect:n.viewportAspect,minBandW:960,aspectSlack:1.7}),u=new Map,p=new Map,h=0;for(let t of c){let n=m.get(t.d);for(let a of e.filter(e=>t.tableLocal.has(e.id))){let e=t.tableLocal.get(a.id),o=n.x+e.x,l=n.y+e.y;u.set(a.id,{x:o,y:l}),(s.get(a.id)??[]).forEach((e,t)=>{p.set(e.id,{x:o,y:l+et(a.columnCount)+10+60*t})})}h=Math.max(h,n.y+t.h)}if(o.length){let e=h+72,t=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(o.length/2))));o.forEach((n,a)=>{p.set(n.id,{x:a%t*300,y:e+60*Math.floor(a/t)})})}return{tables:u,endpoints:p}})(eY.map(e=>({id:e.id,name:e.name,domain:e.domain,columnCount:e.columns.length})),[]).tables,[eY]),e5=(0,s.useMemo)(()=>new Map,[]),e2=(0,s.useMemo)(()=>m?function(e,t){let n=new Map(e.map(e=>[ei(e.name),e])),a=new Map;for(let e of t){let t=n.get(ei(e.name));if(!t){a.set(e.id,{status:"added",changes:["new table"],columns:{}});continue}let{changes:s,columns:o}=function(e,t){let n=new Map(e.map(e=>[ei(e.name),e])),a=new Set(t.map(e=>ei(e.name))),s=[],o={};for(let e of t){let t=n.get(ei(e.name));if(!t){s.push(`+ column ${e.name} (${e.type})`),o[e.name]={kind:"added",detail:"new column"};continue}let a=[],l=[];if(ei(t.type)!==ei(e.type)&&(a.push(`type ${t.type}→${e.type}`),l.push(`${t.type}→${e.type}`)),t.isPk!==e.isPk){let t=e.isPk?"now PK":"no longer PK";a.push(t),l.push(t)}if(t.isFk!==e.isFk){let t=e.isFk?"now FK":"no longer FK";a.push(t),l.push(t)}if(t.nullable!==e.nullable){let t=e.nullable?"now nullable":"now required";a.push(t),l.push(t)}a.length&&(s.push(`~ column ${e.name}: ${a.join(", ")}`),o[e.name]={kind:"modified",detail:l.join(" \xb7 ")})}for(let t of e)a.has(ei(t.name))||s.push(`- column ${t.name}`);return{changes:s,columns:o}}(t.columns,e.columns);a.set(e.id,{status:s.length?"modified":"unchanged",changes:s,columns:o})}return a}(p?.tables??e,eV):e5,[m,p,e,eV,e5]),e3=(0,s.useMemo)(()=>m?function(e,t){let n=e=>`${ei(e.method)} ${ei(e.path)}`,a=new Set(e.map(n)),s=new Map;for(let e of t)s.set(e.id,a.has(n(e))?{status:"unchanged",changes:[],columns:{}}:{status:"added",changes:["new endpoint"],columns:{}});return s}(p?.endpoints??n,eX):e5,[m,p,n,eX,e5]),e4=(0,s.useMemo)(()=>[...t,...eH.relations.map(e=>({id:e.id,fromTableId:e.fromTableId,toTableId:e.toTableId,fromColumn:e.fromColumn,toColumn:e.toColumn,label:e.label}))],[t,eH.relations]),e6=(0,s.useMemo)(()=>{let e=new Map;for(let t of e0)for(let n of t.tables)e.set(n.tableId,(e.get(n.tableId)??0)+1);return e},[e0]),e8=(0,s.useMemo)(()=>{let e=new Map;return eY.forEach(t=>e.set(t.id,t.x)),e0.forEach(t=>e.set(t.id,t.x)),e},[eY,e0]),e9=(0,s.useMemo)(()=>{let e=new Map;return eY.forEach(t=>e.set(t.id,t.y)),e0.forEach(t=>e.set(t.id,t.y)),e},[eY,e0]),e7=(0,s.useMemo)(()=>{let e=new Map(eY.map(e=>[e.id,e.name])),t=new Map;for(let n of e4){let a=e.get(n.toTableId);if(!a)continue;let s=t.get(n.fromTableId)??{};s[n.fromColumn]=a,t.set(n.fromTableId,s)}return t},[e4,eY]),te=void 0!==I,[tt,tn]=(0,s.useState)(I??[]);(0,s.useEffect)(()=>{I&&tn(I)},[I]);let ta=(0,s.useMemo)(()=>({tables:eY.map(e=>({id:e.id,name:e.name,columns:e.columns.map(e=>e.name)})),endpoints:e0.map(e=>({id:e.id,method:e.method,path:e.path}))}),[eY,e0]),ts=(0,s.useMemo)(()=>{if(te){let e=new Set([...eY.map(e=>e.id),...e0.map(e=>e.id)]);return tt.filter(t=>e.has(t.targetId)).map((e,t)=>({id:e.id,n:t+1,targetId:e.targetId,column:e.columnName,text:e.body,x:e.x,y:e.y}))}let e=new Map((T??[]).map(e=>[e.id,e.comment]));return(0,D.m)(T??[],ta).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,column:t.column,text:e.get(t.annotationId)??"",x:null,y:null}))},[te,tt,T,ta,eY,e0]),to=(0,s.useMemo)(()=>{let e=new Map;for(let t of ts){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:t.column}),e.set(t.targetId,n)}return e},[ts]),tl=(0,s.useMemo)(()=>new Map(ts.map(e=>[`anno-${e.id}`,e.targetId])),[ts]),ti=(0,s.useCallback)(async e=>{let t=(0,D.m)([{id:"_",excerpt:e}],ta)[0];if(!t)return;let n=await fetch("/api/board-annotations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetKind:t.kind,targetId:t.targetId,columnName:t.column??void 0})});if(n.ok){let e=await n.json();tn(t=>[...t,e])}},[ta]),tr=(0,s.useCallback)((e,t)=>{tn(n=>n.map(n=>n.id===e?{...n,...t}:n)),fetch(`/api/board-annotations/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)})},[]),td=(0,s.useCallback)(e=>{tn(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),tc=te?ti:C,tm=(0,s.useCallback)((e,t)=>{let n=(e8.get(t)??0)-(e8.get(e)??0),a=(e9.get(t)??0)-(e9.get(e)??0);return Math.abs(n)>=Math.abs(a)?n>=0?{sourceHandle:"sr",targetHandle:"tl"}:{sourceHandle:"sl",targetHandle:"tr"}:a>=0?{sourceHandle:"sb",targetHandle:"tt"}:{sourceHandle:"st",targetHandle:"tb"}},[e8,e9]),tu=(0,s.useMemo)(()=>new Set([...eH.tables.map(e=>e.id),...eH.endpoints.map(e=>e.id)]),[eH]),tp=(0,s.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),th=(0,s.useCallback)(()=>{let e=eY.map(e=>({id:e.id,type:"dbTable",position:F?{x:e.x,y:e.y}:e1.get(e.id)??{x:e.x,y:e.y},data:{name:e.name,domain:e.domain,columns:e.columns,usageCount:e6.get(e.id)??0,source:e.source,rev:eK.rev,diffStatus:e2.get(e.id)?.status,diffChanges:e2.get(e.id)?.changes,diffColumns:e2.get(e.id)?.columns,fkTargets:e7.get(e.id),pins:to.get(e.id),onPinClick:M,onComment:tc}})),t=e0.map(e=>({id:e.id,type:"endpoint",position:{x:e.x,y:e.y},data:{method:e.method,path:e.path,domain:e.domain,source:e.source,rev:eK.rev,diffStatus:e3.get(e.id)?.status,diffChanges:e3.get(e.id)?.changes,pins:to.get(e.id),onPinClick:M,onComment:tc}})),n=new Map,a=new Map(eY.map(e=>[e.id,e])),s=new Map(e0.map(e=>[e.id,e]));return[...e,...t,...ts.map(e=>{let t=a.get(e.targetId),o=s.get(e.targetId),l=t?.x??o?.x??0,i=t?.y??o?.y??0,r=t?38+28*t.columns.length:42,d=n.get(e.targetId)??0;return n.set(e.targetId,d+1),{id:`anno-${e.id}`,type:"annotation",position:{x:e.x??l+26,y:e.y??i+r+64+112*d},data:{n:e.n,text:e.text,annotationId:e.id,onClick:te||S?void 0:M,editable:te||!!S,onChangeText:te?(e,t)=>tr(e,{body:t}):S,onDelete:te?td:E}}})]},[eY,e0,F,e1,e6,eK.rev,e2,e3,e7,to,ts,te,M,S,E,tc,tr,td]),[tf,tx,tb]=(0,i.ck)(th()),tg=(0,s.useRef)(F);(0,s.useEffect)(()=>{let e=tg.current!==F;tg.current=F,tx(t=>{let n=new Map(t.map(e=>[e.id,e.position]));return th().map(t=>e&&"dbTable"===t.type?t:{...t,position:n.get(t.id)??t.position})}),e&&requestAnimationFrame(()=>eS.current?.fitView({duration:500,padding:.15,minZoom:.2,maxZoom:.9}))},[th,tx,F]);let ty=(0,s.useCallback)((e,t,n,a)=>{fetch("/api/db/position",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:e,id:t,x:n,y:a})})},[]),tj=(0,s.useCallback)((e,t)=>{var n;let{x:a,y:s}=t.position,o=(n={readOnly:$,nodeId:t.id,isDraft:tu.has(t.id),boardMode:te}).readOnly?"none":n.nodeId.startsWith("anno-")?n.boardMode?"annotation":"none":n.isDraft?"draft":"real";"annotation"===o?tr(t.id.slice(5),{x:a,y:s}):"draft"===o?eZ(e=>e.tables.some(e=>e.id===t.id)?{...e,tables:e.tables.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e.endpoints.some(e=>e.id===t.id)?{...e,endpoints:e.endpoints.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e):"real"===o&&ty("endpoint"===t.type?"endpoint":"table",t.id,a,s)},[$,tu,eZ,ty,te,tr]),tk=(0,s.useMemo)(()=>e4.map(e=>({id:`fk-${e.id}`,source:e.fromTableId,target:e.toTableId,...tm(e.fromTableId,e.toTableId),type:"deletable",label:e.label??void 0,markerEnd:{type:r.TG.ArrowClosed,color:"#6b6b6b"},style:{stroke:"#6b6b6b"}})),[e4,tm]),tw=(0,s.useMemo)(()=>e0.flatMap(e=>e.tables.map(t=>{let n=x.ru[t.access]??"#5a5a5a";return{id:`u-${e.id}-${t.tableId}`,source:e.id,target:t.tableId,...tm(e.id,t.tableId),type:"default",markerEnd:{type:r.TG.ArrowClosed,color:n},style:{stroke:n,strokeDasharray:"4 4",opacity:.7}}})),[e0,tm]),tv=(0,s.useMemo)(()=>F?[...tk,...tw]:tk,[tk,tw,F]),tN=(0,s.useMemo)(()=>ts.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"annotation",selectable:!1,zIndex:30,style:{stroke:w.V5,strokeWidth:1.5,opacity:.9}})),[ts]),tC=O?.id??_,tT=(0,s.useMemo)(()=>{if(B){let e=tv.find(e=>e.id===B);return e?new Set([e.source,e.target]):null}return tC?(0,x.F1)(tC,tv):null},[tC,B,tv]),tM=(0,s.useMemo)(()=>new Map(eY.map(e=>[e.id,{domain:e.domain,source:e.source}])),[eY]),tS=(0,s.useMemo)(()=>new Map(e0.map(e=>[e.id,{method:e.method,source:e.source}])),[e0]),tE=(0,s.useMemo)(()=>{let e=new Set;if(!F)for(let t of tS.keys())e.add(t);for(let[t,n]of tM)!eA.size||n.domain&&eA.has(n.domain)||e.add(t),eF.size&&!eF.has(n.source)&&e.add(t);for(let[t,n]of tS)eO.size&&!eO.has(n.method)&&e.add(t),eF.size&&!eF.has(n.source)&&e.add(t);return e},[F,tM,tS,eA,eF,eO]),tI=eT.trim().length>0,t$=(0,s.useMemo)(()=>{if(!tI)return null;let e=new Set;for(let t of eY)!tE.has(t.id)&&(0,Q.Qk)((0,Q.jF)(t),eT)&&e.add(t.id);for(let t of e0)!tE.has(t.id)&&(0,Q.Qk)((0,Q.sQ)(t),eT)&&e.add(t.id);return e},[eY,e0,tE,eT,tI]),tA=(0,s.useMemo)(()=>tI?[...(0,Q.r2)(eY.filter(e=>!tE.has(e.id)),eT,e=>(0,Q.jF)(e),e=>({id:e.id,label:e.name,sublabel:e.domain??"table",kind:"table"})),...(0,Q.r2)(e0.filter(e=>!tE.has(e.id)),eT,e=>(0,Q.sQ)(e),e=>({id:e.id,label:e.path,sublabel:e.method,kind:"endpoint"}))].slice(0,12):[],[eY,e0,tE,eT,tI]),tP=(0,s.useCallback)(e=>{eM(""),L(tS.has(e)?{id:e,kind:"endpoint"}:{id:e,kind:"table"}),H(null),q(!0),ev("details");let t=eS.current?.getNode(e);if(!t||!eS.current)return;let n=t.measured?.width??220,a=t.measured?.height??80;eS.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:.9,duration:600})},[tS]),tz=t$??tT,tD=(0,s.useMemo)(()=>tf.map(e=>{if(e.id.startsWith("anno-")){let t=tl.get(e.id),n=!!t&&tE.has(t);return!!e.hidden!==n?{...e,hidden:n}:e}let t=tE.has(e.id);if(!tz)return t?{...e,hidden:t}:e;let n=tz.has(e.id),a=t$?Q.Uy:.45;return{...e,hidden:t,style:{...e.style,opacity:n?1:a,boxShadow:n&&t$?Q.RU:e.style?.boxShadow,borderRadius:n&&t$?"dbTable"===e.type?"var(--radius-xl)":"var(--radius-lg)":e.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}),[tf,tE,tz,t$,tl]),tF=(0,s.useMemo)(()=>{let e=new Map(eY.map(e=>[e.id,(e.domain??"").trim()||"—"])),t=es(eY,e0.map(e=>({id:e.id,method:e.method,path:e.path,uses:e.tables.map(e=>({tableId:e.tableId}))})));return new Map(e0.map(n=>{let a=t.get(n.id);return[n.id,a?e.get(a):en]}))},[eY,e0]),tR=(0,s.useMemo)(()=>{let e=[];for(let t of tf)if(!tE.has(t.id))if("dbTable"===t.type){let n=t.data;e.push({id:t.id,group:(n.domain??"").trim()||"—",x:t.position.x,y:t.position.y,w:t.measured?.width??280,h:t.measured?.height??38+28*n.columns.length})}else"endpoint"===t.type&&e.push({id:t.id,group:tF.get(t.id)??en,x:t.position.x,y:t.position.y,w:t.measured?.width??240,h:t.measured?.height??50});return(0,Y.S)(e)},[tf,tE,tF]),tO=(0,s.useMemo)(()=>t$?tv.map(e=>{let t=tE.has(e.source)||tE.has(e.target);return t$.has(e.source)&&t$.has(e.target)?{...e,hidden:t,style:{...e.style,opacity:1}}:{...e,hidden:t,label:void 0,style:{...e.style,opacity:.08}}}):tv.map(e=>{let t=tE.has(e.source)||tE.has(e.target);return tC||B?(B?e.id===B:tC&&(e.source===tC||e.target===tC))?{...e,hidden:t,zIndex:20,style:{...e.style,opacity:1,strokeWidth:2.5}}:{...e,hidden:t,selectable:!1,label:void 0,markerEnd:void 0,style:{...e.style,opacity:.08}}:{...e,hidden:t,label:void 0}}),[tv,tC,B,tE,t$]),tL=(0,s.useMemo)(()=>Array.from(new Set(eY.map(e=>e.domain).filter(e=>!!e))).sort(),[eY]),tK=(0,s.useMemo)(()=>Array.from(new Set([...eY.map(e=>e.source),...e0.map(e=>e.source)])).sort(),[eY,e0]),tB=(0,s.useMemo)(()=>Array.from(new Set(e0.map(e=>e.method))).sort(),[e0]);function tH(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let t_=+!F+eA.size+eF.size+eO.size,tZ=(0,s.useCallback)(()=>{R(!0),eP(new Set),eR(new Set),eL(new Set)},[]),tU=(0,s.useCallback)(e=>{let{source:t,target:n}=e;t&&n&&t!==n&&e_(e=>{if(!(e.tables.some(e=>e.id===n)||tp.has(n)))return e;let a=e.endpoints.find(e=>e.id===t);return a?a.links.some(e=>e.tableId===n)?e:{...e,endpoints:e.endpoints.map(e=>{var a;return e.id===t?{...e,links:[...e.links,{tableId:n,access:(a=e.method,X.has(a.trim().toUpperCase())?"read":"write")}]}:e})}:e.tables.find(e=>e.id===t)?e.relations.some(e=>e.fromTableId===t&&e.toTableId===n)?e:{...e,relations:[...e.relations,{id:crypto.randomUUID(),fromTableId:t,toTableId:n,fromColumn:"fk",toColumn:"id",label:null}]}:e})},[e_,tp]),tq=(0,s.useMemo)(()=>({readOnly:$,patchEndpoint:(e,t)=>e_(n=>({...n,endpoints:n.endpoints.map(n=>n.id===e?{...n,...t}:n)})),deleteEndpoint:e=>e_(t=>({...t,endpoints:t.endpoints.filter(t=>t.id!==e)})),patchTable:(e,t)=>e_(n=>({...n,tables:n.tables.map(n=>n.id===e?{...n,...t}:n)})),deleteTable:e=>e_(t=>({...t,tables:t.tables.filter(t=>t.id!==e),relations:t.relations.filter(t=>t.fromTableId!==e&&t.toTableId!==e),endpoints:t.endpoints.map(t=>({...t,links:t.links.filter(t=>t.tableId!==e)}))})),deleteRealEndpoint:e=>{fetch(`/api/endpoints/${e}`,{method:"DELETE"}).then(e=>{e.ok&&A.refresh()})}}),[$,e_,A]);(0,s.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.target;if(t&&/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))return;let n=e.key.toLowerCase();"z"===n?(e.preventDefault(),e.shiftKey?eq():eU()):"y"===n&&(e.preventDefault(),eq())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eU,eq]);let tW=(0,s.useCallback)(async()=>{eC(!0);try{if((await fetch("/api/draft/approve",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(eH)})).ok){try{localStorage.removeItem(ey)}catch{}eW(ej),A.refresh()}}finally{eC(!1)}},[eH,eW,A]),tG=(0,s.useCallback)(async()=>{eC(!0);try{await fetch("/api/draft",{method:"DELETE"})}catch{}try{localStorage.removeItem(ey)}catch{}eW(ej),A.refresh(),eC(!1)},[eW,A]),tJ=(0,s.useMemo)(()=>{let e;return e=new Map(eH.tables.map(e=>[e.id,e.name])),{tables:eH.tables.map(e=>({name:e.name,domain:e.domain,description:e.description,columns:e.columns.map(e=>({name:e.name,type:e.type,isPk:e.isPk,isFk:e.isFk,nullable:e.nullable,note:e.note}))})),relations:eH.relations.flatMap(t=>{let n=e.get(t.fromTableId),a=e.get(t.toTableId);return n&&a?[{fromTable:n,fromColumn:t.fromColumn,toTable:a,toColumn:t.toColumn,label:t.label}]:[]}),endpoints:eH.endpoints.map(t=>({method:t.method,path:t.path,domain:t.domain,description:t.description,uses:t.links.flatMap(t=>{let n=e.get(t.tableId);return n?[{table:n,access:t.access}]:[]})}))}},[eH]),tQ=eH.tables.length>0||eH.endpoints.length>0,tV=eK.past.length>0,tX=eK.future.length>0;return(0,a.jsx)(b.Provider,{value:tq,children:(0,a.jsxs)("div",{className:(0,f.cn)("canvas-dots relative w-full",m?"h-full":"h-screen",ef&&"rf-panning"),children:[(0,a.jsxs)(i.Gc,{...e$,nodes:tD,edges:"far"===ez?[...tO,...tN].map(e=>({...e,hidden:!0})):[...tO,...tN.map(e=>({...e,hidden:tE.has(e.source)}))],nodeTypes:eb,edgeTypes:eg,nodesConnectable:!$,connectionMode:r.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{eS.current=e},onNodesChange:tb,onMoveStart:()=>ex(!0),onMoveEnd:()=>ex(!1),onConnect:tU,onNodeMouseEnter:(e,t)=>{"annotation"!==t.type&&Z(t.id)},onNodeMouseLeave:()=>Z(null),onNodeClick:(e,t)=>{if("annotation"===t.type){let e=t.data;e.editable||M?.(e.annotationId);return}let n="endpoint"===t.type?"endpoint":"table";L({id:t.id,kind:n}),H(null),q(!0),ev("details")},onEdgeClick:(e,t)=>{H(t.id),L(null)},onPaneClick:()=>{L(null),H(null),q(!1)},onNodeDragStop:tj,onEdgesDelete:e=>{for(let t of e)if(t.id.startsWith("fk-")){let e=t.id.slice(3);fetch(`/api/db/relations/${e}`,{method:"DELETE"})}},onNodesDelete:e=>{for(let t of e)t.id.startsWith("anno-")||tu.has(t.id)||("endpoint"===t.type?fetch(`/api/endpoints/${t.id}`,{method:"DELETE"}):"dbTable"===t.type&&fetch(`/api/db/tables/${t.id}`,{method:"DELETE"}))},deleteKeyCode:$?null:["Backspace","Delete"],colorMode:"dark",fitView:!0,fitViewOptions:{padding:.15,minZoom:.38,maxZoom:.9},minZoom:.15,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,a.jsx)(el.Z,{regions:tR,tone:"category",lod:ez}),(0,a.jsx)(y.J,{onLod:eD,thresholds:j.fE}),(0,a.jsx)(i.H2,{position:"bottom-right",className:"!overflow-hidden !rounded-xl !border !border-white/10 [&_button]:!border-white/10 [&_button]:!bg-card/70 [&_button]:!text-foreground [&_button]:!backdrop-blur"}),!m&&(0,a.jsx)(i.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:"#555"}),(0,a.jsx)(i.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,a.jsx)(o.H,{tool:eE,onChange:eI})}),!m&&(0,a.jsx)(i.Zk,{position:"bottom-center",className:"!mb-4",children:(0,a.jsx)("div",{className:"glass flex items-center rounded-full p-0.5",children:(0,a.jsxs)("button",{type:"button",disabled:eN,title:"Re-arrange the board — domain clusters with endpoints docked under their tables",onClick:async()=>{eC(!0);try{let e=window.innerWidth/window.innerHeight;await fetch("/api/db/arrange",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewportAspect:e})}),A.refresh()}finally{eC(!1)}},className:"flex h-6 items-center gap-1.5 rounded-full px-3 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground disabled:opacity-40",children:[(0,a.jsx)(er.A,{className:"size-3"}),eN?"Arranging…":"Arrange"]})})}),!m&&(0,a.jsx)(i.Zk,{position:"top-right",className:(0,f.cn)("glass rounded-full px-1 py-0.5 transition-[margin] duration-200",U&&"!mr-[332px]"),children:(0,a.jsx)(V.Z,{active:"DATABASE",tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,a.jsxs)(i.Zk,{position:"top-right",className:(0,f.cn)("!mt-14 flex items-center gap-1 transition-[margin] duration-200",U&&"!mr-[332px]",m&&"hidden"),children:[(0,a.jsx)(G.X,{query:eT,onQuery:eM,hits:tA,placeholder:"Find a table, column, endpoint…",onPick:tP,onZoomToMatches:()=>{t$?.size&&eS.current?.fitView({nodes:[...t$].map(e=>({id:e})),duration:600,padding:.2})}}),(0,a.jsx)(J.e,{defaultSelection:"DATABASE"}),(0,a.jsxs)(W.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,f.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||t_>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(ed.A,{className:"size-4"}),t_>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)] px-1 text-[9px] font-semibold text-white",children:t_})]}),children:[(0,a.jsx)(W.r1,{title:"Show",children:(0,a.jsx)(W.vu,{tone:"accent",on:F,onClick:()=>R(e=>!e),children:"endpoints"})}),tL.length>0&&(0,a.jsx)(W.r1,{title:"Domain",children:tL.map(e=>(0,a.jsx)(W.vu,{on:eA.has(e),onClick:()=>tH(e,eP),children:e},e))}),tB.length>0&&(0,a.jsx)(W.r1,{title:"Method",children:tB.map(e=>(0,a.jsx)(W.vu,{on:eO.has(e),onClick:()=>tH(e,eL),children:e},e))}),tK.length>0&&(0,a.jsx)(W.r1,{title:"Source",children:tK.map(e=>(0,a.jsx)(W.vu,{on:eF.has(e),onClick:()=>tH(e,eR),children:e.toLowerCase()},e))}),t_>0&&(0,a.jsx)("button",{type:"button",onClick:tZ,className:"mt-1 w-full rounded-md border border-white/10 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:"clear filters"})]}),(0,a.jsx)(W.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,f.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(ec.A,{className:"size-4"})}),children:(0,a.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"table"}),(0,a.jsx)("span",{children:"a database table \xb7 its columns"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"endpoint"}),(0,a.jsx)("span",{children:"an API route \xb7 reads / writes tables"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#6b6b6b]"}),(0,a.jsx)("span",{children:"foreign key \xb7 drag from a table handle"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#4ea1ff"}}),(0,a.jsx)("span",{children:"endpoint read \xb7 GET / POST / etc"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#ffb86b"}}),(0,a.jsx)("span",{children:"endpoint write"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-dashed border-sky-400/50 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"draft"}),(0,a.jsx)("span",{children:"agent-proposed \xb7 approve to persist"})]})]})}),!U&&(0,a.jsx)("button",{onClick:()=>q(!0),title:"Show panel",className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(em.A,{className:"size-4"})})]}),tQ&&(0,a.jsxs)(i.Zk,{position:"bottom-center",className:"glass flex items-center gap-1 rounded-xl p-1.5",children:[(0,a.jsxs)("button",{onClick:eU,disabled:!tV,title:"Undo (⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(eu.A,{className:"size-3.5"})," undo"]}),(0,a.jsxs)("button",{onClick:eq,disabled:!tX,title:"Redo (⇧⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(ep.A,{className:"size-3.5"})," redo"]}),!m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-1 h-4 w-px bg-white/10"}),(0,a.jsxs)("button",{onClick:tG,disabled:eN,title:"Discard draft",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300 disabled:opacity-40",children:[(0,a.jsx)(u.A,{className:"size-3.5"})," discard"]}),(0,a.jsxs)("button",{onClick:tW,disabled:eN,title:"Approve and persist to the schema",className:"flex items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25 disabled:opacity-40",children:[(0,a.jsx)(eh.A,{className:"size-3.5"})," approve draft"]})]})]})]}),U&&(0,a.jsx)(K,{selected:O,tables:eY,relations:e4,endpoints:e0,draftGraph:tJ,onClose:()=>{q(!1),ev("details")},commentsContent:v,commentsCount:N,activeTab:ew,onTabChange:ev,onAddComment:tc,topOffset:m?64:void 0})]})})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6302],{6302:(e,t,n)=>{n.d(t,{MapClient:()=>tR});var a=n(95155),r=n(12115),s=n(98112),l=n(6266),o=n(81750);n(53255);var i=n(17356),d=n(85618),c=n(2125),u=n(68319),p=n(15480),x=n(24413),m=n(17494),f=n(80846),h=n(45486),g=n(73321),b=n(95635),y=n(17918),j=n(9339);let v=(0,j.createServerReference)("402fe15540d45fb307989a74aae367ce0df74c2722",j.callServer,void 0,j.findSourceMapURL,"acceptSuggestionAction");var w=n(50981),N=n(34306),k=n(49960),C=n(55737),A=n(72974),E=n(83599),S=n(52750),I=n(68426),R=n(48869),M=n(55776),z=n(65377),T=n(71019),D=n(44825),O=n(54154),P=n(19707),$=n(29450),L=n(17082),Y=n(76181),F=n(27700),U=n(12651),H=n(85222),B=n(70299),_=n(22200),X=n(8962),G=n(12363),K=n(32133),Z=n(76721),V=n(84824),W=n(5736),J=n(65738),q=n(40638),Q=n(36483),ee=n(86659),et=n(9751),en=n(86272),ea=n(64577),er=n(9005),es=n(26518),el=n(43137),eo=n(28161),ei=n(12410);let ed=(0,r.createContext)(null);function ec(){let e=(0,r.useContext)(ed);if(!e)throw Error("useNodeEdit must be used inside NodeEditContext");return e}var eu=n(29523),ep=n(13439),ex=n(62678),em=n(95112),ef=n(67357),eh=n(8143),eg=n(58309),eb=n(5497),ey=n(54682),ej=n(56991),ev=n(93492),ew=n(60292),eN=n(91337);function ek({value:e,onChange:t,onBlur:n,autoFocus:s,compact:l,bare:o,className:i,placeholder:d="Description (markdown)… type @ to mention a file, feature, table…",editable:c=!0}){let u=(0,ep.hG)({editable:c,extensions:[...ey.Pu,ex.Or.configure({placeholder:d}),ej.tw.configure({suggestion:{char:"@",items:async({query:e})=>{if(!e.trim())return[];try{let t=await fetch(`/api/mention-search?q=${encodeURIComponent(e)}`,{headers:(0,ew.dh)((0,ew.fk)())});if(!t.ok)return[];return(await t.json()).hits}catch{return[]}},command:({editor:e,range:t,props:n})=>{e.chain().focus().insertContentAt(t,[{type:"mention",attrs:{kind:n.kind,ref:n.ref,label:n.label}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,n=e=>{if(!t||!e)return;let n=e();n&&(t.style.left=`${n.left}px`,t.style.top=`${n.bottom+4}px`)};return{onStart:a=>{e=new ep.NV(eE,{props:a,editor:a.editor}),(t=document.createElement("div")).style.position="fixed",t.style.zIndex="10000",document.body.appendChild(t),t.appendChild(e.element),n(a.clientRect)},onUpdate:t=>{e?.updateProps(t),n(t.clientRect)},onKeyDown:n=>"Escape"===n.event.key?(t?.remove(),!0):e?.ref?.onKeyDown(n)??!1,onExit:()=>{t?.remove(),t=null,e?.destroy(),e=null}}}}})],content:e?(0,ey.Gd)(e):void 0,immediatelyRender:!1,autofocus:!!s&&"end",editorProps:{attributes:{class:(0,eN.cn)("nodrag nopan node-prose focus:outline-none",i)}},onUpdate:({editor:e})=>t((0,ey.Z2)(e.getJSON())),onBlur:()=>n?.()});return((0,r.useEffect)(()=>{u?.setEditable(c)},[u,c]),(0,r.useEffect)(()=>{!u||u.isFocused||(0,ey.Z2)(u.getJSON())!==e&&u.commands.setContent(e?(0,ey.Gd)(e):"")},[u,e]),u)?(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[c&&(0,a.jsx)(eC,{editor:u,compact:l}),(0,a.jsx)(ep.$Z,{editor:u,onKeyDown:e=>e.stopPropagation(),className:(0,eN.cn)("node-editor min-h-[3.5rem] rounded",o?"text-[15px] leading-relaxed":"bg-white/[0.04] px-1.5 py-1 text-xs focus-within:bg-white/[0.08]",l&&"max-h-[24rem] overflow-y-auto")})]}):null}function eC({editor:e,compact:t}){(0,ev.U)(e);let n=()=>e.chain().focus(),r=t?"size-3":"size-3.5";return(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(ev.I,{label:"Bold",active:e.isActive("bold"),onClick:()=>n().toggleBold().run(),children:(0,a.jsx)(em.A,{className:r})}),(0,a.jsx)(ev.I,{label:"Italic",active:e.isActive("italic"),onClick:()=>n().toggleItalic().run(),children:(0,a.jsx)(ef.A,{className:r})}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-3.5 w-px bg-white/10"}),(0,a.jsx)(ev.I,{label:"Checklist",active:e.isActive("taskList"),onClick:()=>n().toggleTaskList().run(),children:(0,a.jsx)(eh.A,{className:r})}),(0,a.jsx)(ev.I,{label:"Bullet list",active:e.isActive("bulletList"),onClick:()=>n().toggleBulletList().run(),children:(0,a.jsx)(eg.A,{className:r})}),(0,a.jsx)(ev.I,{label:"Numbered list",active:e.isActive("orderedList"),onClick:()=>n().toggleOrderedList().run(),children:(0,a.jsx)(eb.A,{className:r})})]})}let eA={file:"\uD83D\uDCC4",folder:"\uD83D\uDCC1",feature:"\uD83E\uDDE9",table:"⛁",endpoint:"⇄",note:"\uD83D\uDDD2"},eE=(0,r.forwardRef)(function({items:e,command:t},n){let[s,l]=(0,r.useState)(0);return((0,r.useEffect)(()=>l(0),[e]),(0,r.useImperativeHandle)(n,()=>({onKeyDown:({event:n})=>"ArrowDown"===n.key?(l(t=>(t+1)%Math.max(e.length,1)),!0):"ArrowUp"===n.key?(l(t=>(t-1+e.length)%Math.max(e.length,1)),!0):"Enter"===n.key&&(e[s]&&t(e[s]),!0)})),e.length)?(0,a.jsx)("div",{className:"glass max-h-72 min-w-56 max-w-80 overflow-y-auto rounded-lg p-1 shadow-xl",children:e.map((e,n)=>(0,a.jsxs)("button",{type:"button",onMouseDown:n=>{n.preventDefault(),t(e)},onMouseEnter:()=>l(n),className:(0,eN.cn)("flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px]",n===s?"bg-white/[0.1] text-foreground":"text-foreground/85 hover:bg-white/[0.05]"),children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"shrink-0 text-[11px] opacity-80",children:eA[e.kind]??"•"}),(0,a.jsx)("span",{className:"truncate",children:e.label}),e.sublabel&&(0,a.jsx)("span",{className:"ml-auto shrink-0 truncate text-[10px] text-muted-foreground/70",children:e.sublabel})]},`${e.kind}:${e.ref}`))}):(0,a.jsx)("div",{className:"glass min-w-56 rounded-lg p-2 text-[11px] text-muted-foreground shadow-xl",children:"No matches"})}),eS=[{v:0,l:"P0 \xb7 critical"},{v:1,l:"P1 \xb7 high"},{v:2,l:"P2 \xb7 medium"},{v:3,l:"P3 \xb7 low"}],eI=["#ff3860","#ff7a45","#fbbf24","#a1a1aa"],eR=[[/AUTH|SECURIT|LOGIN|SESSION|IDENT/,w.A],[/DATA|\bDB\b|DBMAP|SQL|STORAGE|STORE|CACHE|PERSIST/,N.A],[/\bUI\b|FRONT|VIEW|CANVAS|BOARD|DESIGN/,k.A],[/MCP|\bAPI\b|INTEGRAT/,C.A],[/WEBHOOK|HOOK/,A.A],[/INTEL|GRAPH|\bCODE\b|SYMBOL|SEARCH|FIND/,E.A],[/PLAN|ROADMAP|REVIEW/,S.A],[/INFRA|DEVOPS|CLOUD|DEPLOY|MEDIA/,I.A],[/GAM|PLAY/,R.A],[/NOTE|DOC/,M.A],[/QUERY|SEARCH/,z.A],[/BILL|\bPAY|CHECKOUT|SUBSCRIPT|INVOICE/,T.A],[/LAUNCH|RELEASE|SHIP|ROCKET/,D.A],[/INSTALL|SETUP|BOOTSTRAP|INIT/,O.A],[/CONTEXT|LAYER|BUNDLE/,P.A]],eM=[$.A,L.A,Y.A,F.A,U.A,H.A],ez="nodrag nopan";function eT({layer:e,onSave:t,readOnly:n}){let r=(0,eo.jR)(e);return(0,a.jsxs)(es.l6,{value:r??"none",onValueChange:e=>t("none"===e?null:e),disabled:n,children:[(0,a.jsx)(es.bq,{title:"Which side of the stack this lands on",className:(0,eN.cn)(ez,"!h-5 shrink-0 gap-1 rounded !border-0 !bg-white/10 !px-1.5 !py-0 text-[9px] font-semibold uppercase tracking-wide text-zinc-300 [&_svg]:size-2.5 [&>svg]:hidden hover:[&>svg]:block"),children:(0,a.jsx)(es.yv,{children:e=>"none"===e?(0,a.jsx)("span",{className:"text-muted-foreground/70",children:"layer"}):(0,a.jsxs)("span",{className:"flex items-center gap-1",children:["backend"!==e&&(0,a.jsx)(B.A,{className:"size-2.5"}),"frontend"!==e&&(0,a.jsx)(_.A,{className:"size-2.5"}),eo.YG[e]?.short??e]})})}),(0,a.jsxs)(es.gC,{alignItemWithTrigger:!1,children:[(0,a.jsx)(es.eb,{value:"none",children:"— no layer"}),Object.entries(eo.YG).map(([e,t])=>(0,a.jsx)(es.eb,{value:e,children:t.label},e))]})]})}let eD={DONE:"#34d399",IN_PROGRESS:"#38bdf8",PENDING:"#fbbf24",BLOCKED:"#fb923c",CANCELLED:"#71717a",DEPRIORITIZED:"#52525b",KEEP:"#34d399",REBUILD:"#a78bfa",REPLACE:"#fb7185",DROP:"#71717a"};function eO({status:e}){return(0,a.jsx)("span",{"aria-hidden":!0,title:el.nR[e]?.label??e,className:"absolute bottom-2 left-1 top-2 w-[3px] rounded-full",style:{background:eD[e]??"#71717a"}})}function eP({priority:e,rank:t}){let n=eI[e]??eI[3];return(0,a.jsxs)("div",{className:"flex w-5 shrink-0 flex-col items-center gap-1 self-stretch border-r border-white/[0.06] py-1.5",title:eS[e]?.l??"priority",children:[null!=t&&(0,a.jsx)("span",{title:`#${t} in the work order`,className:(0,eN.cn)("flex size-4 shrink-0 items-center justify-center rounded text-[10px] font-bold leading-none",1===t?"bg-emerald-400 text-black":"bg-white/10 text-muted-foreground"),children:t}),(0,a.jsx)("span",{className:"w-[3px] flex-1 rounded-full",style:{background:n,opacity:.9}})]})}function e$({onFocus:e,onExpand:t,onDetails:n,expanded:r,className:s}){return(0,a.jsxs)("div",{className:(0,eN.cn)(ez,"absolute z-20 flex items-center gap-0.5 rounded-lg p-0.5 transition-colors group-hover/nc:border group-hover/nc:border-white/10 group-hover/nc:bg-card/90 group-hover/nc:shadow-lg group-hover/nc:backdrop-blur",s??"right-2 top-2"),children:[(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),e()},title:"Edit description in focus mode",className:"flex w-0 items-center justify-center overflow-hidden rounded p-0 text-muted-foreground opacity-0 transition-all hover:text-[#ff7a45] group-hover/nc:w-6 group-hover/nc:p-0.5 group-hover/nc:opacity-100",children:(0,a.jsx)(X.A,{className:"size-3.5"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),t()},title:r?"Collapse":"Expand in place",className:"flex w-0 items-center justify-center overflow-hidden rounded p-0 text-muted-foreground opacity-0 transition-all hover:text-foreground group-hover/nc:w-6 group-hover/nc:p-0.5 group-hover/nc:opacity-100",children:(0,a.jsx)(G.A,{className:(0,eN.cn)("size-3.5 transition-transform",r&&"rotate-180")})}),(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),n()},title:"Open details side panel",className:"flex w-0 items-center justify-center overflow-hidden rounded p-0 text-muted-foreground opacity-0 transition-all hover:text-[#ff7a45] group-hover/nc:w-6 group-hover/nc:p-0.5 group-hover/nc:opacity-100",children:(0,a.jsx)(h.A,{className:"size-3.5"})})]})}function eL({value:e,label:t,Icon:n,danger:r}){return(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:(0,eN.cn)("text-[13px] font-semibold leading-none tracking-tight tabular-nums",r&&"text-rose-300"),children:e}),(0,a.jsxs)("div",{className:"mt-0.5 flex items-center justify-center gap-0.5 text-[8px] font-medium uppercase tracking-wide text-muted-foreground",children:[(0,a.jsx)(n,{className:"size-2.5"}),t]})]})}function eY({importsIn:e}){let t=e>=16?5:e>=8?4:e>=4?3:e>=2?2:+(e>=1);return(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",title:`${e} external file(s) import this component`,children:[(0,a.jsx)("span",{className:"flex items-center gap-0.5",children:[0,1,2,3,4].map(e=>(0,a.jsx)("span",{className:"size-1 rounded-full bg-sky-400",style:{opacity:e<t?.7:.18}},e))}),e>=8?"core dependency":e>=3?"shared":e>=1?"leaf":"isolated"]})}function eF({nodeId:e}){let t=(0,g.useRouter)(),[n,s]=(0,r.useState)(!1),[l,o]=(0,r.useState)(""),[i,d]=(0,r.useState)(!1),c=()=>{s(!1),o("")},p=async()=>{let n=l.trim();if(n&&!i){d(!0);try{(await fetch("/api/bug-flags",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({nodeId:e,by:"user",note:n})})).ok&&(c(),t.refresh())}finally{d(!1)}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",title:"Flag a bug on this component",onClick:e=>{e.stopPropagation(),s(e=>!e)},className:(0,eN.cn)(ez,"absolute -right-3 top-[calc(50%-28px)] z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground shadow-md transition-all hover:border-rose-400/50 hover:text-rose-300",n?"border-rose-400/50 text-rose-300 opacity-100":"opacity-0 group-hover/nc:opacity-100"),children:(0,a.jsx)(u.A,{className:"size-3"})}),n&&(0,a.jsxs)("div",{onClick:e=>e.stopPropagation(),className:(0,eN.cn)(ez,"absolute -right-2 top-[calc(50%-28px)] z-20 w-60 translate-x-full rounded-xl border border-rose-400/25 bg-[#1c1c1f] p-2 shadow-xl"),children:[(0,a.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide text-rose-300",children:[(0,a.jsx)(u.A,{className:"size-3"})," Flag a bug"]}),(0,a.jsx)("button",{type:"button",title:"Cancel",onClick:c,className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)("span",{className:"block px-1 text-[11px] leading-none",children:"✕"})})]}),(0,a.jsx)("textarea",{autoFocus:!0,rows:2,value:l,placeholder:"What did you find?",onChange:e=>o(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&c(),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),p())},className:"field-sizing-content max-h-40 min-h-12 w-full resize-none rounded-md bg-white/[0.04] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.07]"}),(0,a.jsx)("button",{type:"button",disabled:i||!l.trim(),onClick:()=>void p(),className:"mt-1.5 w-full rounded-md bg-rose-500/15 py-1 text-[11px] font-semibold text-rose-300 transition-colors hover:bg-rose-500/25 disabled:opacity-50",children:i?"Flagging…":"Flag bug"})]})]})}let eU=["border-[#ff3860]/60 shadow-[0_0_0_1px_rgba(255,56,96,0.15)]","border-[#ff7a45]/50","border-amber-400/35","border-border"],eH=(0,r.memo)(function({id:e,data:t,selected:n}){let{categories:s,statuses:l,patch:o,isExpanded:i,toggleExpand:d,openDetailed:c,openFocus:p,removeNode:x,editingTitleId:m,onAskAgent:f,hasFrontend:h,readOnly:g}=ec(),j=i(e),[w,N]=(0,r.useState)(!1),[k,C]=(0,r.useState)(t.title),[A,E]=(0,r.useState)(t.cluster??""),[S,I]=(0,r.useState)(t.plain??"");(0,r.useEffect)(()=>I(t.plain??""),[t.plain]);let R="BUG"===t.kind&&"ROADMAP"===t.view,M="ARCHITECTURE"===t.view,z=M?"border-border":eU[t.priority]??"border-border",T=t.openBugs??0,D="CANCELLED"===t.status||"DROP"===t.status,O="DEPRIORITIZED"===t.status,P="DRAFT"===t.source,$="IN_PROGRESS"===t.status,L="INIT"===t.source&&"ROADMAP"===t.view,Y=t=>{g||o(e,t,!0)},[F,U]=(0,r.useTransition)(),H=(0,eu.k)();if("full"!==H)return(0,a.jsxs)("div",{className:(0,eN.cn)("relative rounded-lg border bg-card px-3 py-2.5 text-card-foreground shadow-sm","w-fit max-w-[296px]",t.isChild?"min-w-56":"min-w-64",R?"border-rose-400/50 bg-rose-500/[0.05]":z,$&&"border-sky-400/60",n&&"ring-2 ring-[var(--accent,#f5b942)]",D&&"opacity-60","far"===H&&!g&&"!opacity-0"),children:[(0,a.jsx)(b.x,{}),(0,a.jsx)(eO,{status:t.status}),(0,a.jsx)("div",{className:"break-words text-[15px] font-semibold leading-snug",children:t.title})]});let B=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b.x,{}),M&&(0,a.jsx)(eF,{nodeId:e}),(t.pins?.length??0)>0?(0,a.jsx)(y.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Annotate ${t.title}`,onClick:e=>{e.stopPropagation(),t.onComment?.(t.title)},className:(0,eN.cn)(ez,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover/nc:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(K.A,{className:"size-3"})})]}),_=(t.childCount??0)>0&&(0,a.jsxs)("button",{type:"button",onClick:n=>{n.stopPropagation(),t.onToggleCollapse?.(e)},title:t.collapsed?`Show ${t.childCount} sub-task${1===t.childCount?"":"s"}`:`Hide ${t.childCount} sub-task${1===t.childCount?"":"s"}`,className:(0,eN.cn)(ez,"mt-0.5 flex shrink-0 items-center gap-0.5 rounded px-1 text-[10px] font-semibold transition-colors",t.collapsed?"bg-white/[0.06] text-foreground hover:bg-white/10":"text-muted-foreground hover:bg-white/5 hover:text-foreground"),children:[t.collapsed?(0,a.jsx)(Z.A,{className:"size-3"}):(0,a.jsx)(G.A,{className:"size-3"}),t.childCount]}),X=(0,a.jsx)(e$,{onFocus:()=>p({id:e,title:t.title||"Untitled",value:S,editable:!g,onCommit:e=>Y({plain:e.trim()||null})}),onExpand:()=>d(e),onDetails:()=>c(e),expanded:j,className:"top-full right-1 mt-1.5 before:absolute before:inset-x-0 before:bottom-full before:h-2.5 before:content-['']"}),eo=(0,a.jsx)("textarea",{rows:1,value:k,readOnly:g,autoFocus:m===e,placeholder:"Title…",onFocus:t=>{m===e&&t.currentTarget.select()},onChange:e=>C(e.target.value),onBlur:()=>{let e=k.trim();e&&e!==t.title&&Y({title:e})},onKeyDown:e=>{e.stopPropagation(),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())},className:(0,eN.cn)(ez,"field-sizing-content w-full resize-none bg-transparent text-sm font-medium leading-snug outline-none placeholder:text-muted-foreground/60",D&&"line-through")}),ed=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{list:`cats-${e}`,value:A,readOnly:g,placeholder:M?"domain":"category",title:M?"Architecture domain — the lane this component lives in":void 0,onChange:e=>E(e.target.value),onBlur:()=>{let e=A.trim()||null;e!==(t.cluster??null)&&Y({cluster:e})},onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&e.currentTarget.blur()},className:(0,eN.cn)(ez,"field-sizing-content min-w-12 max-w-[60%] rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide outline-none focus:brightness-125 [&::-webkit-calendar-picker-indicator]:hidden",(0,ei.a2)(A))}),(0,a.jsx)("datalist",{id:`cats-${e}`,children:s.map(e=>(0,a.jsx)("option",{value:e},e))})]}),ep=(0,a.jsxs)(es.l6,{value:t.status,onValueChange:e=>Y({status:e}),disabled:g,children:[(0,a.jsx)(es.bq,{className:(0,eN.cn)(ez,"!h-5 shrink-0 !gap-0.5 rounded border !px-1.5 !py-0 text-[10px] font-medium [&_svg]:size-3",el.nR[t.status]?.className??"border-white/10"),children:(0,a.jsx)(es.yv,{children:e=>el.nR[e]?.label??e})}),(0,a.jsx)(es.gC,{alignItemWithTrigger:!1,children:l.map(e=>(0,a.jsx)(es.eb,{value:e,children:el.nR[e]?.label??e},e))})]}),ex=(T>0||(t.signals?.untested??0)>0||t.signals?.auth)&&(0,a.jsxs)("div",{className:"mt-1.5 flex w-0 min-w-full flex-wrap items-center gap-1",children:[T>0&&(0,a.jsxs)("span",{title:`${T} open bug flag(s)`,className:"flex items-center gap-1 rounded bg-rose-500/15 px-1 text-[9px] font-semibold uppercase tracking-wide text-rose-300",children:[(0,a.jsx)(u.A,{className:"size-2.5"}),T]}),(t.signals?.untested??0)>0&&(0,a.jsxs)("span",{title:`${t.signals.untested} of ${t.signals.total} attached file(s) have no test importing them`,className:"flex items-center gap-1 rounded bg-amber-500/15 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-300",children:[(0,a.jsx)(V.A,{className:"size-2.5"}),t.signals.untested]}),t.signals?.auth&&(0,a.jsxs)("span",{title:"touches auth-sensitive files",className:"flex items-center gap-1 rounded bg-red-500/15 px-1 text-[9px] font-semibold uppercase tracking-wide text-red-300",children:[(0,a.jsx)(W.A,{className:"size-2.5"})," auth"]})]}),em=j&&(0,a.jsxs)("div",{className:"mt-2 w-0 min-w-full space-y-2 border-t border-white/10 pt-2",children:[(0,a.jsx)(ek,{compact:!0,editable:!g,value:S,onChange:I,onBlur:()=>{let e=S.trim()||null;e!==(t.plain??null)&&Y({plain:e})}}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pr-8",children:[(0,a.jsx)("div",{className:"flex items-center gap-1",children:!M&&(0,a.jsxs)(es.l6,{value:String(t.priority),onValueChange:e=>Y({priority:Number(e)}),disabled:g,children:[(0,a.jsx)(es.bq,{className:(0,eN.cn)(ez,"!h-6 gap-1 rounded border-white/10 !px-1.5 !py-0 text-[10px] [&_svg]:size-3"),children:(0,a.jsx)(es.yv,{children:e=>eS.find(t=>String(t.v)===e)?.l??e})}),(0,a.jsx)(es.gC,{alignItemWithTrigger:!1,children:eS.map(e=>(0,a.jsx)(es.eb,{value:String(e.v),children:e.l},e.v))})]})}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[!g&&(0,a.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),w?x(e):N(!0)},onBlur:()=>N(!1),title:"Delete node",className:(0,eN.cn)(ez,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] transition-colors",w?"bg-red-500/20 text-red-300":"text-muted-foreground hover:bg-white/5 hover:text-red-300"),children:[(0,a.jsx)(J.A,{className:"size-3"}),w&&"Delete?"]}),f&&(0,a.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),f(`${M?"component":"feature"}: ${t.title}`)},title:"Ask the agent a question about this (answered in its next round)",className:(0,eN.cn)(ez,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-sky-300/90 hover:bg-sky-500/15 hover:text-sky-300"),children:[(0,a.jsx)(q.A,{className:"size-3"})," Ask"]})]})]})]});if(M){let e=(0,ei.i3)(t.cluster);return(0,a.jsxs)("div",{className:(0,eN.cn)("group/nc relative rounded-lg border bg-card px-3 py-2.5 text-card-foreground shadow-sm transition","w-fit min-w-60 max-w-72",P?"border-dashed border-sky-400/50 bg-sky-500/[0.06]":"border-border",$&&"border-sky-400/60 shadow-[0_0_0_1px_rgba(56,160,255,0.25)]",n&&"ring-2 ring-[var(--accent,#f5b942)]",D&&"opacity-60",O&&"opacity-70 border-dashed"),children:[B,(0,a.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,a.jsx)("span",{className:"mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg",style:{background:`color-mix(in oklab, ${e} 18%, transparent)`,color:e},children:(0,r.createElement)(function(e){let t=(e??"").toUpperCase();for(let[e,n]of eR)if(e.test(t))return n;if(!t)return eM[0];let n=0;for(let e=0;e<t.length;e++)n=31*n+t.charCodeAt(e)>>>0;return eM[n%eM.length]}(t.cluster),{className:"size-4"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-start gap-1",children:[eo,_]}),(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[ed,h&&(0,a.jsx)(eT,{layer:t.layer,onSave:e=>Y({layer:e}),readOnly:g})]})]}),(0,a.jsx)("div",{className:"shrink-0",children:ep})]}),t.role&&(0,a.jsx)("div",{className:"mt-2 line-clamp-1 text-[10.5px] leading-snug text-muted-foreground",children:t.role}),(0,a.jsxs)("div",{className:"mt-2.5 grid grid-cols-4 gap-1 border-t border-white/[0.07] pt-2",children:[(0,a.jsx)(eL,{value:t.fileCount??0,label:"files",Icon:Q.A}),(0,a.jsx)(eL,{value:t.importsIn??"—",label:"in",Icon:ee.A}),(0,a.jsx)(eL,{value:t.importsOut??"—",label:"out",Icon:et.A}),(0,a.jsx)(eL,{value:T,label:"bug",Icon:u.A,danger:T>0})]}),null!=t.importsIn&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(eY,{importsIn:t.importsIn})}),X,em]})}let ef=t.childCount??0,eh=t.childDone??0;return(0,a.jsxs)("div",{className:(0,eN.cn)("group/nc relative flex rounded-lg border bg-card text-card-foreground shadow-sm transition","w-fit max-w-96",j?"min-w-80":"min-w-64",P?"border-dashed border-sky-400/50 bg-sky-500/[0.06]":L?"border-dashed border-violet-400/60 bg-violet-500/[0.07] shadow-[0_0_0_1px_rgba(167,139,250,0.18)]":z,R&&!P&&"border-rose-400/50 bg-rose-500/[0.05]",$&&"border-sky-400/60 shadow-[0_0_0_1px_rgba(56,160,255,0.25)]",t.isNext&&"border-emerald-400/70 shadow-[0_0_0_2px_rgba(52,211,153,0.35)]",null!=t.workOrderRank&&t.workOrderRank>1&&"border-emerald-400/25",n&&"ring-2 ring-[var(--accent,#f5b942)]",D&&"opacity-60",O&&"opacity-70 border-dashed"),children:[B,X,(0,a.jsx)(eP,{priority:t.priority,rank:t.workOrderRank}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 px-2.5 py-2.5",children:[(0,a.jsxs)("div",{className:"flex w-0 min-w-full items-start gap-1.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1",children:["LINEAR"===t.source&&(t.assigneeAvatarUrl?(0,a.jsx)("img",{src:t.assigneeAvatarUrl,alt:t.assigneeName??"assignee",title:t.assigneeName?`Owner: ${t.assigneeName}`:"Assignee",draggable:!1,className:(0,eN.cn)(ez,"mt-0.5 size-4 shrink-0 rounded-full object-cover ring-1 ring-white/20")}):t.assigneeName?(0,a.jsx)("span",{title:`Owner: ${t.assigneeName}`,className:(0,eN.cn)(ez,"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full bg-white/10 text-[7px] font-semibold uppercase text-muted-foreground ring-1 ring-white/20"),children:t.assigneeName.split(/\s+/).map(e=>e[0]).slice(0,2).join("")}):null),$&&(0,a.jsx)("span",{title:"in progress",className:"mt-1.5 inline-block size-2 shrink-0 animate-pulse rounded-full bg-sky-400"}),t.isCriterion&&!$&&(0,a.jsx)("span",{title:"Success criterion",className:"mt-1.5 inline-block size-1.5 shrink-0 rounded-full bg-[var(--accent,#f5b942)]"}),eo,_]}),(0,a.jsx)("div",{className:"shrink-0",children:ep})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex w-0 min-w-full flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("span",{title:R?"Bug — something to fix":t.isChild?"Sub-task of a feature":"Feature — top-level roadmap item",className:(0,eN.cn)("flex shrink-0 items-center gap-1 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide",R?"bg-rose-500/15 text-rose-300":t.isChild?"bg-zinc-500/15 text-zinc-300":"bg-sky-500/15 text-sky-300"),children:[R&&(0,a.jsx)(u.A,{className:"size-2.5"}),R?"bug":t.isChild?"sub-task":"feature"]}),h&&(0,a.jsx)(eT,{layer:t.layer,onSave:e=>Y({layer:e}),readOnly:g}),L&&(0,a.jsxs)("span",{className:(0,eN.cn)("flex items-center gap-1 rounded bg-violet-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-violet-300",F&&"opacity-50"),children:[(0,a.jsx)(en.A,{className:"size-2.5"})," IA",(0,a.jsx)("button",{type:"button",title:"Accept suggestion — turn it into your own feature",disabled:F,onClick:t=>{t.stopPropagation(),U(async()=>v(e))},className:(0,eN.cn)(ez,"-my-0.5 rounded p-0.5 hover:bg-emerald-500/20 hover:text-emerald-300"),children:(0,a.jsx)(ea.A,{className:"size-2.5"})}),(0,a.jsx)("button",{type:"button",title:"Dismiss suggestion (deletes the card)",disabled:F,onClick:t=>{t.stopPropagation(),x(e)},className:(0,eN.cn)(ez,"-my-0.5 -ml-0.5 rounded p-0.5 hover:bg-red-500/20 hover:text-red-300"),children:(0,a.jsx)(er.A,{className:"size-2.5"})})]}),ed]}),t.role&&(0,a.jsx)("div",{className:(0,eN.cn)("mt-1.5 w-0 min-w-full text-[10px] leading-snug text-muted-foreground",!j&&"line-clamp-1"),children:t.role}),ef>0&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"h-[3px] flex-1 overflow-hidden rounded-full bg-white/[0.08]",title:`${eh}/${ef} sub-tasks done`,children:(0,a.jsx)("span",{className:"block h-full rounded-full bg-sky-400/75",style:{width:`${ef?eh/ef*100:0}%`}})}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",children:[(0,a.jsx)(ea.A,{className:"size-3"}),eh,"/",ef]})]}),ex,em]})]})});var eB=n(54698),e_=n(24692),eX=n(81499),eG=n(51128);let eK=(0,r.memo)(function({data:e}){let[t,n]=(0,r.useState)(!1),s=e.columns??[],l=t?s:s.slice(0,5),o=s.length-l.length,i=e.sample??[];return(0,a.jsxs)("div",{className:"w-[270px] rounded-xl border border-sky-400/25 bg-[#13161b]/95 text-card-foreground shadow-[0_18px_50px_-22px_rgba(0,0,0,0.9)] backdrop-blur",children:[(0,a.jsx)(b.x,{}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 rounded-t-[11px] border-b border-white/[0.06] bg-sky-400/[0.07] px-3 py-2",children:[(0,a.jsx)(N.A,{className:"size-3.5 shrink-0 text-sky-400/80"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[13px] font-semibold tracking-tight",title:e.name,children:e.name}),e.domain&&(0,a.jsx)("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.14em] text-sky-300/70",children:e.domain})]}),e.note&&(0,a.jsx)("div",{className:"border-b border-white/[0.05] px-3 py-1.5 text-[11px] leading-snug text-muted-foreground",children:e.note}),(0,a.jsx)("div",{className:"divide-y divide-white/[0.05]",children:l.map(e=>(0,a.jsxs)("div",{className:"px-3 py-[6px]",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[12px]",children:[e.isPk?(0,a.jsx)(eX.A,{className:"size-3 shrink-0 text-amber-300/90"}):e.isFk?(0,a.jsx)(eG.A,{className:"size-3 shrink-0 text-sky-400/80"}):(0,a.jsx)("span",{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:(0,eN.cn)("shrink-0 whitespace-nowrap font-mono",e.isPk&&"text-amber-200/95"),children:e.name}),(0,a.jsx)("span",{title:e.fkTo?`→ ${e.fkTo}`:e.type,className:"ml-auto min-w-0 truncate font-mono text-[11px] text-muted-foreground/80",children:e.fkTo?(0,a.jsxs)(a.Fragment,{children:["→\xa0",e.fkTo]}):e.type})]}),e.note&&(0,a.jsx)("div",{className:"ml-5 mt-0.5 text-[10.5px] leading-snug text-muted-foreground/70 [overflow-wrap:anywhere]",children:e.note})]},e.name))}),(o>0||i.length>0)&&(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),n(e=>!e)},className:"nodrag nopan flex w-full items-center justify-center gap-1 rounded-b-[11px] border-t border-white/[0.06] px-3 py-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.04] hover:text-foreground",children:t?"Show less":o>0?`+${o} more column${1===o?"":"s"}`:"Show example row"}),t&&i.length>0&&(0,a.jsxs)("div",{className:"nowheel overflow-x-auto border-t border-white/[0.06] px-3 py-2",children:[(0,a.jsx)("div",{className:"mb-1 text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:"example"}),(0,a.jsxs)("table",{className:"border-collapse font-mono text-[10px]",children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{className:"text-muted-foreground/60",children:s.map(e=>(0,a.jsx)("th",{className:"whitespace-nowrap px-1.5 pb-1 text-left font-medium",children:e.name},e.name))})}),(0,a.jsx)("tbody",{children:i.map((e,t)=>(0,a.jsx)("tr",{className:"text-foreground/85",children:s.map(t=>(0,a.jsx)("td",{className:"whitespace-nowrap px-1.5 py-0.5",children:e[t.name]??""},t.name))},t))})]})]})]})});var eZ=n(45437),eV=n(1275),eW=n(82099),eJ=n(47409),eq=n(4474),eQ=n(66616),e0=n(70521),e1=n(74350),e5=n(39658);function e2({className:e,...t}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,eN.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var e3=n(61388);function e4({className:e,...t}){return(0,a.jsx)(e3.b,{"data-slot":"label",className:(0,eN.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}let e6=(0,j.createServerReference)("40f64c8ecb52343d884291d315769053e8e04bdd1a",j.callServer,void 0,j.findSourceMapURL,"createNodeAction"),e7=(0,j.createServerReference)("607027e6540f362f70914cd97e7d909bb16436cb77",j.callServer,void 0,j.findSourceMapURL,"updateNodeAction");function e9({open:e,onOpenChange:t,mode:n,view:s,heading:l,nodeId:o,parentId:i,position:d,defaults:c,hasFrontend:u=!1}){let p=(0,g.useRouter)(),[x,m]=(0,r.useState)(c?.title??""),[f,h]=(0,r.useState)(c?.role??""),[b,y]=(0,r.useState)(c?.plain??""),[j,v]=(0,r.useState)(c?.cluster??""),[w,N]=(0,r.useState)(c?.status??("ARCHITECTURE"===s?"REBUILD":"PENDING")),[k,C]=(0,r.useState)(c?.kind==="BUG"?"BUG":"FEATURE"),[A,E]=(0,r.useState)((0,eo.jR)(c?.layer)??"none"),[S,I]=(0,r.useState)(!1),R="ARCHITECTURE"===s?el.m6:el.yl;async function M(){if(x.trim()){I(!0);try{let e="none"===A?null:A;"create"===n?await e6({view:s,..."ROADMAP"===s?{kind:k}:{},title:x.trim(),role:f.trim()||null,plain:b.trim()||null,cluster:j.trim()||null,...u?{layer:e}:{},parentId:i??null,status:w,x:d?.x??60,y:d?.y??60}):o&&await e7(o,{..."ROADMAP"===s?{kind:k}:{},title:x.trim(),role:f.trim()||null,plain:b.trim()||null,cluster:j.trim()||null,...u?{layer:e}:{},status:w}),t(!1),p.refresh()}finally{I(!1)}}}return(0,a.jsx)(e1.lG,{open:e,onOpenChange:t,children:(0,a.jsxs)(e1.Cf,{children:[(0,a.jsx)(e1.c7,{children:(0,a.jsx)(e1.L3,{children:l})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{htmlFor:"nf-title",children:"Title"}),(0,a.jsx)(e5.p,{id:"nf-title",value:x,autoFocus:!0,onChange:e=>m(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{htmlFor:"nf-role",children:"Role (one line)"}),(0,a.jsx)(e5.p,{id:"nf-role",value:f,onChange:e=>h(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{htmlFor:"nf-plain",children:"Description"}),(0,a.jsx)(e2,{id:"nf-plain",rows:3,value:b,onChange:e=>y(e.target.value)})]}),"ROADMAP"===s&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{children:"Kind"}),(0,a.jsxs)(es.l6,{value:k,onValueChange:e=>null!=e&&C(e),children:[(0,a.jsx)(es.bq,{children:(0,a.jsx)(es.yv,{children:e=>"BUG"===e?"Bug":"Feature"})}),(0,a.jsxs)(es.gC,{children:[(0,a.jsx)(es.eb,{value:"FEATURE",children:"Feature"}),(0,a.jsx)(es.eb,{value:"BUG",children:"Bug"})]})]})]}),u&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{children:"Layer"}),(0,a.jsxs)(es.l6,{value:A,onValueChange:e=>null!=e&&E(e),children:[(0,a.jsx)(es.bq,{children:(0,a.jsx)(es.yv,{children:e=>"none"===e?"—":eo.YG[e]?.label??e})}),(0,a.jsxs)(es.gC,{children:[(0,a.jsx)(es.eb,{value:"none",children:"—"}),Object.keys(eo.YG).map(e=>(0,a.jsx)(es.eb,{value:e,children:eo.YG[e].label},e))]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{children:"Status"}),(0,a.jsxs)(es.l6,{value:w,onValueChange:e=>null!=e&&N(e),children:[(0,a.jsx)(es.bq,{children:(0,a.jsx)(es.yv,{children:e=>el.nR[e]?.label??e})}),(0,a.jsx)(es.gC,{children:R.map(e=>(0,a.jsx)(es.eb,{value:e,children:el.nR[e]?.label??e},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e4,{htmlFor:"nf-cluster",children:"Cluster / lane"}),(0,a.jsx)(e5.p,{id:"nf-cluster",value:j,onChange:e=>v(e.target.value)})]})]})]}),(0,a.jsxs)(e1.Es,{children:[(0,a.jsx)(eq.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(eq.$,{onClick:M,disabled:S||!x.trim(),children:S?"Saving…":"Save"})]})]})})}let e8=(0,j.createServerReference)("40d086a3ecbc97a811c4512e1e515e44145d839e51",j.callServer,void 0,j.findSourceMapURL,"deleteNodeAction"),te=(0,j.createServerReference)("6009e5e9fbb0c54fc4f04dc9835f8b275c24f08aed",j.callServer,void 0,j.findSourceMapURL,"setStatusAction"),tt=(0,j.createServerReference)("40d1c09d888607ff35964ff3a668da02cbeac19494",j.callServer,void 0,j.findSourceMapURL,"cancelAction"),tn=(0,j.createServerReference)("406e88eba3478dfb51872879d723bcf2a25c0ac38b",j.callServer,void 0,j.findSourceMapURL,"deprioritizeAction");function ta({view:e,selected:t,allNodes:n,onClose:r,commentsContent:s,commentsCount:l=0,activeTab:o,onTabChange:i,onAddComment:d,topOffset:c}){let u=!!s,p=o??"details";return(0,a.jsxs)(eW.b,{className:"absolute right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:c??12,maxHeight:`calc(100% - ${(c??12)+12}px)`},children:[u?(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(eQ.E,{active:"details"===p,onClick:()=>i?.("details"),children:"Details"}),(0,a.jsxs)(eQ.E,{active:"comments"===p,onClick:()=>i?.("comments"),children:["Comments",l>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:l})]})]}),(0,a.jsx)("button",{onClick:r,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(er.A,{className:"size-4"})})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Details"}),(0,a.jsx)("button",{onClick:r,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(er.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,a.jsx)("div",{className:"p-3",children:"comments"===p&&u?s:t?(0,a.jsxs)(a.Fragment,{children:[d&&(0,a.jsxs)("button",{type:"button",onClick:()=>d(t.title),className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(K.A,{className:"size-3.5"}),"Comment on this ","ARCHITECTURE"===e?"component":"feature"]}),(0,a.jsx)(tr,{node:t,view:e},t.id)]}):(0,a.jsx)(tl,{view:e,nodes:n})})})]})}function tr({node:e,view:t}){let n=(0,g.useRouter)(),[s,l]=(0,r.useTransition)(),[o,i]=(0,r.useState)(!1),[d,c]=(0,r.useState)(!1),[u,p]=(0,r.useState)(e.plain??"");(0,r.useEffect)(()=>p(e.plain??""),[e.id,e.plain]);let{hasFrontend:x,openFocus:m}=ec(),f=(0,eo.jR)(e.layer),h="ARCHITECTURE"===t?el.m6:el.yl,b=e=>l(async()=>{await e(),n.refresh()});return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:[(0,el.Xf)(e.cluster),x&&f&&(0,a.jsxs)("span",{className:"ml-2 text-zinc-400",children:["\xb7 ",eo.YG[f].label]}),0===e.priority&&(0,a.jsx)("span",{className:"ml-2 text-[#ff7a90]",children:"\xb7 critical path"})]}),(0,a.jsx)("h2",{className:"mt-1 text-lg font-semibold leading-tight",children:e.title})]}),"INIT"===e.source&&"ROADMAP"===t&&(0,a.jsxs)("div",{className:"rounded-lg border border-violet-400/30 bg-violet-500/[0.06] p-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-violet-300",children:[(0,a.jsx)(en.A,{className:"size-3.5"})," AI suggestion"]}),(0,a.jsx)("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:"Suggested direction surfaced when mapping the repo. Accept to turn it into your own feature, or dismiss."}),(0,a.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[(0,a.jsx)(eq.$,{size:"sm",className:"h-7 px-2.5 text-xs",disabled:s,onClick:()=>b(()=>v(e.id)),children:"Accept"}),(0,a.jsx)(eq.$,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs text-muted-foreground",disabled:s,onClick:()=>b(()=>e8(e.id)),children:"Dismiss"})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Status"}),(0,a.jsxs)(es.l6,{value:e.status,onValueChange:t=>null!=t&&b(()=>te(e.id,t)),children:[(0,a.jsx)(es.bq,{className:"h-8",disabled:s,children:(0,a.jsx)(es.yv,{children:e=>el.nR[e]?.label??e})}),(0,a.jsx)(es.gC,{children:h.map(e=>(0,a.jsx)(es.eb,{value:e,children:el.nR[e]?.label??e},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Description"}),(0,a.jsx)("button",{type:"button",title:"Edit in focus mode",onClick:()=>m({id:e.id,title:e.title,value:u,editable:!0,onCommit:t=>{p(t);let n=t.trim()||null;n!==(e.plain??null)&&b(()=>e7(e.id,{plain:n}))}}),className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-white/10 hover:text-[#ff7a45]",children:(0,a.jsx)(X.A,{className:"size-3.5"})})]}),(0,a.jsx)("div",{className:"rounded-md border border-white/5 bg-card/40 px-2.5 py-2 text-sm",children:(0,a.jsx)(ek,{value:u,onChange:p,onBlur:()=>{let t=u.trim()||null;t!==(e.plain??null)&&b(()=>e7(e.id,{plain:t}))}})})]}),"LINEAR"===e.source&&e.sourceRef?(0,a.jsxs)("a",{href:e.sourceRef,target:"_blank",rel:"noreferrer",className:"flex items-center justify-between gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 text-xs font-medium transition-colors hover:border-[var(--accent-2,#ff7a45)] hover:text-[var(--accent-2,#ff7a45)]",children:[(0,a.jsx)("span",{className:"font-mono",children:e.sourceRef.match(/\/issue\/([^/]+)/)?.[1]??"Linear issue"}),(0,a.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:["Open in Linear ",(0,a.jsx)(eV.A,{className:"size-3.5"})]})]}):e.sourceRef?(0,a.jsx)("div",{className:"rounded-md border border-border bg-card px-2 py-1.5 font-mono text-xs text-muted-foreground",children:e.sourceRef}):null,e.files.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Files (",e.files.length,")"]}),(0,a.jsx)(eJ.h,{files:e.files.map(e=>({path:e}))})]}),"ARCHITECTURE"===t&&(0,a.jsx)(ts,{node:e}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[(0,a.jsx)(eq.$,{size:"sm",variant:"outline",onClick:()=>i(!0),children:"Edit"}),(0,a.jsx)(eq.$,{size:"sm",variant:"outline",onClick:()=>c(!0),children:"+ Sub-node"}),(0,a.jsx)(eq.$,{size:"sm",variant:"outline",disabled:s,onClick:()=>b(()=>tt(e.id)),children:"Cancel"}),(0,a.jsx)(eq.$,{size:"sm",variant:"outline",disabled:s,onClick:()=>b(()=>tn(e.id)),children:"Deprioritize"}),(0,a.jsxs)(e0.Lt,{children:[(0,a.jsx)(e0.tv,{render:(0,a.jsx)(eq.$,{size:"sm",variant:"outline",className:"text-red-300",children:"Delete"})}),(0,a.jsxs)(e0.EO,{children:[(0,a.jsxs)(e0.wd,{children:[(0,a.jsxs)(e0.r7,{children:["Delete “",e.title,"”?"]}),(0,a.jsx)(e0.$v,{children:"This removes the node and all its sub-nodes. It can’t be undone."})]}),(0,a.jsxs)(e0.ck,{children:[(0,a.jsx)(e0.Zr,{children:"Cancel"}),(0,a.jsx)(e0.Rx,{onClick:()=>b(()=>e8(e.id)),children:"Delete"})]})]})]})]}),o&&(0,a.jsx)(e9,{open:!0,onOpenChange:i,mode:"edit",view:t,heading:"Edit node",nodeId:e.id,hasFrontend:x,defaults:{title:e.title,role:e.role,plain:e.plain,status:e.status,cluster:e.cluster,kind:e.kind,layer:e.layer}}),d&&(0,a.jsx)(e9,{open:!0,onOpenChange:c,mode:"create",view:t,heading:"New sub-node",parentId:e.id,position:{x:e.x,y:e.y+120},hasFrontend:x,defaults:{cluster:e.cluster,layer:e.layer}})]})}function ts({node:e}){let t=(0,g.useRouter)(),[n,s]=(0,r.useState)(""),[l,o]=(0,r.useState)(!1),i=e.bugFlags.filter(e=>!e.resolved),d=e=>{o(!0),e().then(()=>t.refresh()).finally(()=>o(!1))},c=()=>{let t=n.trim();t&&d(async()=>{(await fetch("/api/bug-flags",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({nodeId:e.id,by:"user",note:t})})).ok&&s("")})};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,a.jsx)(u.A,{className:"size-3.5 text-rose-300"}),"Bug flags",i.length>0&&` (${i.length} open)`]}),e.bugFlags.length>0&&(0,a.jsx)("ul",{className:"space-y-1.5",children:e.bugFlags.map(e=>(0,a.jsxs)("li",{className:(0,eN.cn)("rounded-md border px-2 py-1.5",e.resolved?"border-white/5 bg-card/30 opacity-60":"border-rose-400/25 bg-rose-500/[0.05]"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{title:"agent"===e.by?"Flagged by an agent examining the code":"Flagged by you",className:(0,eN.cn)("rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide","agent"===e.by?"bg-violet-500/15 text-violet-300":"bg-sky-500/15 text-sky-300"),children:"agent"===e.by?"agent":"you"}),(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",disabled:l,onClick:()=>d(()=>fetch(`/api/bug-flags/${e.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({resolved:!e.resolved})})),className:"rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:e.resolved?"Reopen":"Resolve"}),(0,a.jsx)("button",{type:"button",disabled:l,title:"Delete flag",onClick:()=>d(()=>fetch(`/api/bug-flags/${e.id}`,{method:"DELETE"})),className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-white/10 hover:text-red-300",children:(0,a.jsx)(er.A,{className:"size-3"})})]})]}),(0,a.jsx)("p",{className:(0,eN.cn)("mt-1 text-[11.5px] leading-snug",e.resolved&&"line-through"),children:e.note})]},e.id))}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-start gap-1.5",children:[(0,a.jsx)("textarea",{rows:1,value:n,placeholder:"Flag a bug or something worth investigating…",onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),c())},className:"field-sizing-content min-h-7 w-full resize-none rounded-md border border-white/10 bg-white/[0.03] px-2 py-1 text-[11.5px] outline-none placeholder:text-muted-foreground/60 focus:bg-white/[0.06]"}),(0,a.jsx)(eq.$,{size:"sm",variant:"outline",className:"h-7 shrink-0 px-2 text-[11px]",disabled:l||!n.trim(),onClick:c,children:"Flag"})]})]})}function tl({view:e,nodes:t}){let n=t.filter(e=>0===e.priority).length;return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"ROADMAP"===e?"Roadmap":"Architecture"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Click a node for details and actions. Drag to rearrange — positions are saved."})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-2 gap-2 text-center",children:[(0,a.jsx)(to,{label:"nodes",value:t.length}),(0,a.jsx)(to,{label:"critical",value:n})]})]})}function to({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-md border border-border bg-card py-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:t}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e})]})}function ti({payload:e,onDismiss:t}){let[n,s]=(0,r.useState)(""),[l,o]=(0,r.useState)(null);if((e?.id??null)!==l&&(o(e?.id??null),s(e?.value??"")),(0,r.useEffect)(()=>{if(!e)return;let a=a=>{("Escape"===a.key||(a.metaKey||a.ctrlKey)&&"Enter"===a.key)&&(a.preventDefault(),e.onCommit(n),t())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[e,n,t]),!e)return null;let i=()=>{e.onCommit(n),t()};return(0,a.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":`Edit description — ${e.title}`,onMouseDown:e=>{e.target===e.currentTarget&&i()},className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/55 backdrop-blur-[5px] animate-in fade-in duration-150",children:(0,a.jsxs)(eW.b,{className:"flex max-h-[82vh] w-[min(720px,92vw)] flex-col rounded-2xl duration-150 animate-in fade-in zoom-in-95",onMouseDown:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-white/10 px-4 py-3",children:[(0,a.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Description"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:e.title}),(0,a.jsxs)("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:[n.length," chars"]}),(0,a.jsx)("button",{type:"button",onClick:i,title:"Close (Esc)",className:"shrink-0 rounded-lg p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(er.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-[40vh] flex-1 overflow-y-auto px-6 py-5 text-[15px] leading-relaxed",children:(0,a.jsx)(ek,{bare:!0,autoFocus:e.editable,editable:e.editable,value:n,onChange:s})}),(0,a.jsxs)("div",{className:"flex items-center gap-3 border-t border-white/10 px-4 py-2.5 text-[11.5px] text-muted-foreground",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"size-1.5 rounded-full bg-emerald-400"})," Autosaves"]}),(0,a.jsx)("span",{className:"opacity-70",children:"\xb7 Esc to close"}),e.editable&&(0,a.jsxs)("button",{type:"button",onClick:i,className:"ml-auto flex items-center gap-1.5 rounded-lg bg-[#ff7a45] px-3 py-1.5 text-xs font-semibold text-black transition hover:brightness-110",children:[(0,a.jsx)(ea.A,{className:"size-3.5"}),"Save & close"]})]})]})})}var td=n(80277),tc=n(18874),tu=n(62311),tp=n(9991),tx=n(40654),tm=n(14983),tf=n(91157),th=n(56895),tg=n(16607),tb=n(56614),ty=n(98238),tj=n(36849),tv=n(29813),tw=n(44267);function tN(e,t){let n={x:t.x,y:t.y};for(let t=0;t<100&&e.some(e=>200>Math.abs(n.x-e.x)&&150>Math.abs(n.y-e.y));t++)n.y+=150;return n}var tk=n(70947);let tC=[{value:"cluster",label:"Theme"},{value:"status",label:"Status"},{value:"priority",label:"Priority"}],tA=new Set(["title","role","plain","cluster","layer","status","priority"]),tE={roadmapNode:eH,archNode:eH,annotation:y.Sh,lessonTable:eK},tS={deletable:e_.I,annotation:eZ.L},tI={CONTAINS:{stroke:"#7c7c8a"},DEPENDS:{stroke:"#f5b942",dash:"6 4"},RELATES:{stroke:"#8a8a95",dash:"4 4"},REPLACES:{stroke:"#ff6b9d"}};function tR({view:e,nodes:t,edges:n,workOrder:g=[],embedded:b=!1,commentsContent:j,commentsCount:v=0,controlRef:w,onAskAgent:N,onAddComment:k,annotations:C,onPinClick:A,onUpdateComment:E,onRemoveComment:S,boardAnnotations:I,initialArrangedBy:R=null,initialCollapsed:M=[],hasFrontend:z=!1,readOnly:T=!1,firstTapHighlightsOnly:D=!1,minimap:O,staticEdgeLabels:P=!1,tableNodes:$}){let L=g.join(","),Y=(0,r.useMemo)(()=>{let e=new Map;return g.forEach((t,n)=>e.set(t,n+1)),e},[L]),F=g[0]??null,U=(0,r.useMemo)(()=>t.map(e=>({id:e.id,type:"ROADMAP"===e.view?"roadmapNode":"archNode",position:{x:e.x,y:e.y},data:{title:e.title,role:e.role,plain:e.plain,status:e.status,priority:e.priority,cluster:e.cluster,layer:e.layer,view:e.view,kind:e.kind,source:e.source,sourceRef:e.sourceRef,assigneeName:e.assigneeName,assigneeAvatarUrl:e.assigneeAvatarUrl,isCriterion:e.isCriterion,isChild:null!=e.parentId,parentId:e.parentId,signals:e.signals,fileCount:e.files.length,importsIn:e.importsIn,importsOut:e.importsOut,openBugs:e.bugFlags.filter(e=>!e.resolved).length}})),[t]),H=(0,r.useMemo)(()=>{var e;let a;return e=new Set(($??[]).map(e=>e.id)),a=new Set([...t.map(e=>e.id),...e??[]]),[...t.filter(e=>e.parentId&&a.has(e.parentId)).map(e=>({id:`c-${e.id}`,source:e.parentId,sourceHandle:"sb",target:e.id,targetHandle:"tt",type:"smoothstep",style:{stroke:tI.CONTAINS.stroke}})),...n.filter(e=>a.has(e.fromId)&&a.has(e.toId)).map(e=>{let t=tI[e.kind]??tI.RELATES,n="DEPENDS"===e.kind?"depends on":void 0;return{id:e.id,source:e.fromId,sourceHandle:e.sourceHandle??void 0,target:e.toId,targetHandle:e.targetHandle??void 0,label:e.label??n,type:"deletable",markerEnd:{type:l.TG.ArrowClosed,color:t.stroke},style:{stroke:t.stroke,strokeDasharray:t.dash}}})]},[t,n,$]),[B,_]=(0,r.useState)(U),[X,G]=(0,r.useState)(H),[K,Z]=(0,r.useState)(null),[V,W]=(0,r.useState)(null),[J,q]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(!1),[et,en]=(0,r.useState)("details"),{tool:ea,setTool:er,flowProps:es,paneClass:ei}=(0,td.e)(),[ec,ep]=(0,r.useState)(null),[ex,em]=(0,r.useState)(null),[ef,eh]=(0,r.useState)(!1),eg=(0,r.useRef)(!1),eb=(0,r.useRef)("details");(0,r.useEffect)(()=>{eg.current=Q},[Q]),(0,r.useEffect)(()=>{eb.current=et},[et]),(0,r.useEffect)(()=>{if(w)return w.current={open:()=>{if(eg.current){ee(!1),en("details");return}ee(!0),en("details")},close:()=>{ee(!1),en("details")},openComments:()=>{ee(!0),en("comments")}},()=>{w&&(w.current=null)}},[w]);let[ey,ej]=(0,r.useState)(new Set),[ev,ew]=(0,r.useState)(null),[ek,eC]=(0,r.useState)(!1),eA=(0,r.useRef)(null);(0,r.useEffect)(()=>_(U),[U]),(0,r.useEffect)(()=>G(H),[H]),(0,r.useEffect)(()=>{if(!T)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>eA.current?.fitView({padding:.2,duration:0,minZoom:.38,maxZoom:.9}))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[T,U]);let eE=(0,r.useCallback)((e,t,n)=>{_(n=>n.map(n=>n.id===e?{...n,data:{...n.data,...t}}:n)),n&&fetch(`/api/nodes/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(Object.fromEntries(Object.entries(t).filter(([e])=>tA.has(e))))})},[]),eS=(0,r.useMemo)(()=>JSON.stringify(Array.from(new Set(B.map(e=>e.data.cluster).filter(e=>!!e))).sort()),[B]),eI=(0,r.useMemo)(()=>JSON.parse(eS),[eS]),eR=(0,r.useCallback)(e=>ej(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),eM=(0,r.useCallback)(e=>{Z(e),ee(!0),en("details")},[]),ez=(0,r.useCallback)(e=>{_(t=>t.filter(t=>t.id!==e)),Z(t=>t===e?null:t),fetch(`/api/nodes/${e}`,{method:"DELETE"})},[]),eT=(0,r.useCallback)(async(t,n,a="FEATURE")=>{let r=(0,s.sX)(),l="ARCHITECTURE"===e?"REBUILD":"PENDING",o="BUG"===a?"New bug":"New node";_(s=>[...s,{id:r,type:"ROADMAP"===e?"roadmapNode":"archNode",position:{x:t,y:n},data:{title:o,role:null,plain:null,status:l,priority:2,cluster:null,view:e,kind:a,source:"MANUAL",sourceRef:null,isCriterion:!1,isChild:!1,parentId:null,openBugs:0}}]),ej(e=>new Set(e).add(r)),ew(r),Z(r);try{if(!(await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:r,view:e,kind:a,title:o,status:l,x:t,y:n})})).ok)throw Error("create failed")}catch{_(e=>e.filter(e=>e.id!==r)),ej(e=>{let t=new Set(e);return t.delete(r),t}),ew(e=>e===r?null:e),Z(e=>e===r?null:e)}},[e]),eD=(0,r.useCallback)((e,t)=>{if(!ec||!eA.current)return;let n=eA.current.screenToFlowPosition({x:e,y:t});eT(n.x,n.y,ec),ep(null),em(null)},[ec,eT]);(0,r.useEffect)(()=>{if(!ec&&!ek)return;let e=e=>em({x:e.clientX,y:e.clientY}),t=e=>{"Escape"===e.key&&(ep(null),eC(!1),em(null))};return window.addEventListener("mousemove",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("keydown",t)}},[ec,ek]),(0,r.useCallback)(()=>{let e=B.filter(e=>"annotation"!==e.type);return function(e,t,n={}){let a=n.colW??320,r=n.rowH??150,s=n.maxCols??4,l=n.bandGap??90;if(0===e.length){if(0===t.length)return{x:0,y:0};let e=Math.max(...t.map(e=>e.y));return tN(t,{x:0,y:e+r+l})}let o=Math.min(...e.map(e=>e.x)),i=Math.min(...e.map(e=>e.y)),d=e.map(e=>Math.max(0,Math.round((e.x-o)/a))),c=Math.min(s,Math.max(Math.max(...d)+1,Math.ceil(Math.sqrt(e.length+1)))),u=Array(c).fill(i-r);e.forEach((e,t)=>{let n=Math.min(d[t],c-1);u[n]=Math.max(u[n],e.y)});let p=0;for(let e=1;e<c;e++)u[e]<u[p]&&(p=e);return tN(t,{x:o+p*a,y:u[p]+r})}(e.filter(e=>!e.data.parentId&&!(e.data.cluster??"").trim()).map(e=>e.position),e.map(e=>e.position))},[B]);let eO=(0,r.useCallback)(()=>{eC(!1),ep("FEATURE")},[]),eP=(0,r.useCallback)(()=>{eC(!1),ep("BUG")},[]),[e$,eL]=(0,r.useState)(null),eY=(0,r.useCallback)(e=>eL(e),[]),eF=(0,r.useMemo)(()=>({view:e,readOnly:T,categories:eI,statuses:"ARCHITECTURE"===e?el.m6:el.yl,patch:eE,isExpanded:e=>ey.has(e),toggleExpand:eR,openDetailed:eM,openFocus:eY,removeNode:ez,editingTitleId:ev,onAskAgent:N,hasFrontend:z}),[e,T,eI,eE,ey,eR,eM,eY,ez,ev,N,z]),[eU,eH]=(0,r.useState)(R),[e_,eX]=(0,r.useState)(""),[eG,eK]=(0,r.useState)("full"),[eZ,eV]=(0,r.useState)(new Set),[eW,eJ]=(0,r.useState)(new Set),[eq,eQ]=(0,r.useState)(new Set),[e0,e1]=(0,r.useState)(null),e5=(0,r.useMemo)(()=>Array.from(new Set(t.map(e=>e.status))),[t]),e2=(0,r.useMemo)(()=>Array.from(new Set(t.map(e=>e.cluster).filter(e=>!!e))).sort(),[t]),e3=(0,r.useMemo)(()=>Array.from(new Set(t.map(e=>e.priority))).sort((e,t)=>e-t),[t]),e4=(0,r.useCallback)(e=>(!eZ.size||!!eZ.has(e.status))&&(!eW.size||!!e.cluster&&!!eW.has(e.cluster))&&(!eq.size||!!eq.has(e.priority)),[eZ,eW,eq]),e6=eZ.size+eW.size+eq.size+ +!!e0,e7=(0,r.useCallback)(()=>{eV(new Set),eJ(new Set),eQ(new Set),e1(null)},[]),[e9,e8]=(0,r.useState)(()=>new Set(M)),te=(0,r.useCallback)(t=>{e8(n=>{let a=new Set(n);return a.has(t)?a.delete(t):a.add(t),b||fetch("/api/board-layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({board:"ROADMAP"===e?"roadmap":"architecture",collapsed:[...a]})}).catch(()=>{}),a})},[b,e]),tt=(0,r.useMemo)(()=>(function(e){let t=new Map;for(let n of e)n.parentId&&t.set(n.parentId,(t.get(n.parentId)??0)+1);return t})(t),[t]),tn=(0,r.useMemo)(()=>{let e=new Map;for(let n of t)n.parentId&&"DONE"===n.status&&e.set(n.parentId,(e.get(n.parentId)??0)+1);return e},[t]),tr=(0,r.useMemo)(()=>(function(e,t){let n=new Set;if(0===t.size)return n;let a=new Map;for(let t of e){if(!t.parentId)continue;let e=a.get(t.parentId);e?e.push(t.id):a.set(t.parentId,[t.id])}let r=[...t];for(;r.length;){let e=r.pop();for(let t of a.get(e)??[])n.has(t)||(n.add(t),r.push(t))}return n})(t,e9),[t,e9]),ts=(0,r.useMemo)(()=>B.map(e=>({...e,hidden:!e4(e.data)||tr.has(e.id)})),[B,e4,tr]),tl=(0,r.useMemo)(()=>new Set(ts.filter(e=>e.hidden).map(e=>e.id)),[ts]),to=(0,r.useMemo)(()=>X.map(e=>({...e,hidden:tl.has(e.source)||tl.has(e.target)})),[X,tl]),tM=(0,r.useMemo)(()=>{if(V){let e=to.find(e=>e.id===V);return e?new Set([e.source,e.target]):null}return K?(0,tc.F1)(K,to.filter(e=>!e.hidden)):null},[K,V,to]),tz=e_.trim().length>0,tT=(0,r.useMemo)(()=>{if(!tz)return null;let e=new Set;for(let t of B)e4(t.data)&&(0,tm.Qk)((0,tm.$$)(t.data),e_)&&e.add(t.id);return e},[B,e_,e4,tz]),tD=(0,r.useMemo)(()=>"ARCHITECTURE"===e?(0,tf.d)(t):[],[e,t]),tO=(0,r.useCallback)(e=>{eA.current&&(e.focusIds.length?eA.current.fitView({nodes:e.focusIds.map(e=>({id:e})),duration:700,padding:.3,maxZoom:1.1}):eA.current.fitView({duration:700,padding:.2}))},[]),tP=(0,th.W)(tD,tO),t$=tP.focusIds,tL=t$??tT??tM,tY=tT??t$??tM,tF=(0,r.useMemo)(()=>e0?new Set(ts.filter(e=>!e.hidden&&!(0,ty.F)(e0,(0,eo.jR)(e.data.layer))).map(e=>e.id)):null,[e0,ts]),tU=(0,r.useMemo)(()=>ts.map(e=>{let t=Y.get(e.id),n=tt.get(e.id)??0,a={...t?{workOrderRank:t,isNext:1===t}:{},...n>0?{childCount:n,childDone:tn.get(e.id)??0,collapsed:e9.has(e.id),onToggleCollapse:te}:{}},r=t||n>0?{...e,data:{...e.data,...a}}:e;if(ey.has(e.id)&&(r={...r,zIndex:25}),r.hidden)return r;if(!tL)return tF?.has(e.id)?{...r,style:{...r.style,opacity:.3,filter:"saturate(0.3)",transition:"opacity 120ms, filter 120ms"}}:r;let s=tL.has(e.id),l=tY?tm.Uy:.45;return{...r,zIndex:s&&tY?24:r.zIndex,style:{...r.style,opacity:s?1:l,boxShadow:s&&tY?tm.RU:r.style?.boxShadow,borderRadius:s&&tY?"var(--radius-lg)":r.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}),[ts,tL,tY,Y,ey,tF,tt,tn,e9,te]),[tH,tB]=(0,r.useState)(()=>new Map),[t_,tX]=(0,r.useState)(()=>new Map),tG=(0,r.useMemo)(()=>new Set(($??[]).map(e=>e.id)),[$]),tK=(0,r.useMemo)(()=>{if("ROADMAP"===e&&!eU||"ROADMAP"!==e&&"ARCHITECTURE"!==e)return[];let t=new Map(tU.map(e=>[e.id,e])),n=[];for(let r of tU){var a;if(r.hidden||"annotation"===r.type)continue;let s=(r.data.parentId?t.get(r.data.parentId):void 0)??r,l="ROADMAP"===e&&eU?(a=s.data,"status"===eU?el.nR[a.status]?.label??a.status:"priority"===eU?`P${a.priority}`:a.cluster?.trim()||"—"):s.data.cluster?.trim()||"—";n.push({id:r.id,group:l,x:r.position.x,y:r.position.y,w:r.measured?.width??(r.data.isChild?224:256),h:r.measured?.height??96})}for(let e of $??[]){let t=t_.get(e.id)??e;n.push({id:e.id,group:e.group?.trim()||"—",x:t.x,y:t.y,w:tH.get(e.id)?.width??270,h:tH.get(e.id)?.height??200})}return(0,tw.S)(n)},[tU,eU,e,$,tH,t_]),tZ="ARCHITECTURE"===e||"cluster"===eU?"category":"neutral",tV=(0,r.useMemo)(()=>{if(t$)return to.map(e=>e.hidden?e:t$.has(e.source)&&t$.has(e.target)?{...e,style:{...e.style,opacity:1}}:{...e,label:void 0,style:{...e.style,opacity:.06}});if(tT)return to.map(e=>e.hidden?e:tT.has(e.source)&&tT.has(e.target)?{...e,style:{...e.style,opacity:1}}:{...e,label:void 0,style:{...e.style,opacity:.06}});let e=K??J;return V||e?to.map(t=>t.hidden?t:(V?t.id===V:t.source===e||t.target===e)?{...t,zIndex:20,style:{...t.style,opacity:1,strokeWidth:2.5}}:{...t,selectable:!1,label:void 0,markerEnd:void 0,style:{...t.style,opacity:.06}}):to.map(e=>{if(e.hidden)return e;let t=tF&&(tF.has(e.source)||tF.has(e.target));return P?{...e,style:{...e.style,opacity:t?.25:1}}:{...e,label:void 0,style:{...e.style,opacity:t?.06:.18}}})},[to,K,V,J,tT,tF,t$,P]),tW=void 0!==I,[tJ,tq]=(0,r.useState)(I??[]);(0,r.useEffect)(()=>{I&&tq(I)},[I]);let tQ=(0,r.useMemo)(()=>{if(tW){let e=new Set(t.map(e=>e.id));return tJ.filter(t=>"feature"===t.targetKind&&e.has(t.targetId)).map((e,t)=>({id:e.id,n:t+1,targetId:e.targetId,text:e.body,x:e.x,y:e.y}))}let e=new Map((C??[]).map(e=>[e.id,e.comment]));return(0,eB.m)(C??[],{tables:[],features:t.map(e=>({id:e.id,title:e.title}))}).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,text:e.get(t.annotationId)??"",x:null,y:null}))},[tW,tJ,C,t]),t0=(0,r.useMemo)(()=>{let e=new Map;for(let t of tQ){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:null}),e.set(t.targetId,n)}return e},[tQ]),t1=(0,r.useCallback)(async e=>{let n=(0,eB.m)([{id:"_",excerpt:e}],{tables:[],features:t.map(e=>({id:e.id,title:e.title}))})[0];if(!n)return;let a=await fetch("/api/board-annotations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetKind:"feature",targetId:n.targetId})});if(a.ok){let e=await a.json();tq(t=>[...t,e])}},[t]),t5=(0,r.useCallback)((e,t)=>{tq(n=>n.map(n=>n.id===e?{...n,...t}:n)),fetch(`/api/board-annotations/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)})},[]),t2=(0,r.useCallback)(e=>{tq(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),t3=tW?t1:k,[t4,t6]=(0,r.useState)(()=>new Map),t7=(0,r.useMemo)(()=>{let e=new Map(tU.map(e=>[e.id,e])),t=new Map,n=tQ.flatMap(n=>{let a=e.get(n.targetId);if(!a||a.hidden)return[];let r=t.get(n.targetId)??0;t.set(n.targetId,r+1);let s=a.measured?.height??96;return[{id:`anno-${n.id}`,type:"annotation",position:{x:n.x??a.position.x+26,y:n.y??a.position.y+s+56+112*r},measured:t4.get(`anno-${n.id}`),draggable:tW,data:{n:n.n,text:n.text,annotationId:n.id,onClick:tW||E?void 0:A,editable:tW||!!E,onChangeText:tW?(e,t)=>t5(e,{body:t}):E,onDelete:tW?t2:S}}]});return[...tU.map(e=>{let t=t0.get(e.id);return t||t3?{...e,data:{...e.data,pins:t,onPinClick:tW?void 0:A,onComment:t3}}:e}),...n,...($??[]).map(e=>({id:e.id,type:"lessonTable",position:t_.get(e.id)??{x:e.x,y:e.y},measured:tH.get(e.id),draggable:!0,data:e.data}))]},[tU,tQ,t0,tW,A,E,S,t3,t5,t2,t4,$,tH,t_]),t9=(0,r.useMemo)(()=>tQ.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"annotation",selectable:!1,zIndex:30,style:{stroke:y.V5,strokeWidth:1.5,opacity:.9}})),[tQ]),t8=(0,r.useCallback)(e=>{let t=[];for(let n of e)if("position"===n.type&&n.id.startsWith("anno-")&&n.position){let e=n.id.slice(5),{x:t,y:a}=n.position;tq(n=>n.map(n=>n.id===e?{...n,x:t,y:a}:n))}else if("dimensions"===n.type&&n.id.startsWith("anno-")){let e=n.dimensions;e&&t6(t=>{let a=t.get(n.id);if(a&&a.width===e.width&&a.height===e.height)return t;let r=new Map(t);return r.set(n.id,e),r})}else if("dimensions"===n.type&&tG.has(n.id)){let e=n.dimensions;e&&tB(t=>{let a=t.get(n.id);if(a&&a.width===e.width&&a.height===e.height)return t;let r=new Map(t);return r.set(n.id,e),r})}else if("position"===n.type&&tG.has(n.id)&&n.position){let{x:e,y:t}=n.position;tX(a=>new Map(a).set(n.id,{x:e,y:t}))}else t.push(n);t.length&&_(e=>(0,o._0)(t,e))},[tG]),ne=(0,r.useCallback)(e=>G(t=>(0,o.zW)(e,t)),[]),nt=(0,r.useCallback)(async e=>{if(!e.source||!e.target||e.source===e.target)return;let t=await fetch("/api/edges",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:e.source,toId:e.target,kind:"DEPENDS",sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null})});if(!t.ok)return;let n=await t.json(),a=tI.DEPENDS;G(t=>t.some(e=>e.id===n.id)?t:[...t,{id:n.id,source:n.fromId,sourceHandle:e.sourceHandle??void 0,target:n.toId,targetHandle:e.targetHandle??void 0,label:"depends on",type:"deletable",markerEnd:{type:l.TG.ArrowClosed,color:a.stroke},style:{stroke:a.stroke,strokeDasharray:a.dash}}])},[]),nn=(0,r.useCallback)(async(t,n,a)=>{let r=await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({view:e,title:"New node",parentId:t.id,cluster:t.data.cluster??null,status:"ARCHITECTURE"===e?"REBUILD":"PENDING",x:n,y:a})});if(!r.ok)return;let s=await r.json();_(r=>[...r,{id:s.id,type:"ROADMAP"===e?"roadmapNode":"archNode",position:{x:n,y:a},data:{title:s.title,role:s.role,plain:s.plain,status:s.status,priority:s.priority,cluster:s.cluster,view:s.view,source:s.source,sourceRef:s.sourceRef,kind:s.kind,isCriterion:!1,isChild:!0,parentId:t.id,openBugs:0}}]),G(e=>[...e,{id:`c-${s.id}`,source:t.id,sourceHandle:"sb",target:s.id,targetHandle:"tt",type:"smoothstep",style:{stroke:tI.CONTAINS.stroke}}]),ej(e=>new Set(e).add(s.id)),ew(s.id),Z(s.id)},[e]),na=(0,r.useCallback)(async(e,t)=>{if(t.isValid||!t.fromNode||!eA.current)return;let n=e.changedTouches,a=n?.[0]?.clientX??e.clientX,r=n?.[0]?.clientY??e.clientY,{x:s,y:l}=eA.current.screenToFlowPosition({x:a,y:r});await nn(t.fromNode,s,l)},[nn]);(0,r.useEffect)(()=>{if(!ek)return;let e=e=>{"Escape"===e.key&&eC(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ek]);let nr=(0,r.useMemo)(()=>t.find(e=>e.id===K)??null,[t,K]),ns=(0,r.useCallback)((e,t,n)=>{fetch(`/api/nodes/${e}/position`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({x:t,y:n})})},[]),nl=(0,r.useCallback)(e=>{Z(e),W(null);let t=eA.current?.getNode(e);if(!t||!eA.current)return;let n=t.measured?.width??128,a=t.measured?.height??48;eA.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:1.2,duration:600})},[]),no=(0,r.useCallback)(e=>{let t=(0,tj.VI)(B.map(e=>({id:e.id,parentId:e.data.parentId??null,cluster:e.data.cluster,status:e.data.status,priority:e.data.priority,title:e.data.title,role:e.data.role})),e,{viewportAspect:window.innerWidth/window.innerHeight});_(e=>e.map(e=>{let n=t.get(e.id);return n?{...e,position:n}:e}));let n=Array.from(t,([e,t])=>({id:e,x:t.x,y:t.y}));n.length&&fetch("/api/nodes/positions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({batch:n})}),eH(e),fetch("/api/board-layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({board:"roadmap",arrangedBy:e})}),requestAnimationFrame(()=>eA.current?.fitView({duration:600,padding:.2}))},[B]),ni=(0,r.useMemo)(()=>{let t=new Map;if("ROADMAP"!==e||!eU)return t;let n=e=>"status"===eU?e.status:"priority"===eU?`P${e.priority}`:e.cluster??"—";for(let e of B)"annotation"!==e.type&&t.set(e.id,n(e.data));return t},[B,eU,e]),nd=(0,r.useRef)(null);(0,r.useEffect)(()=>{let t=nd.current;if(nd.current=ni,!t||"ROADMAP"!==e||!eU)return;let n=!1;for(let[e,a]of ni)if(t.has(e)&&t.get(e)!==a){n=!0;break}n&&no(eU)},[ni,eU,e,no]);let nc=(0,r.useCallback)(()=>{let e=B.filter(e=>"annotation"!==e.type),t=(0,tv.to)(e.map(e=>({id:e.id,group:(e.data.cluster??"").trim()||"—"})),n.filter(e=>"DEPENDS"===e.kind).map(e=>({fromId:e.fromId,toId:e.toId})),{viewportAspect:window.innerWidth/window.innerHeight});_(e=>e.map(e=>{let n=t.get(e.id);return n?{...e,position:n}:e}));let a=Array.from(t,([e,t])=>({id:e,x:t.x,y:t.y}));a.length&&fetch("/api/nodes/positions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({batch:a})}),requestAnimationFrame(()=>eA.current?.fitView({duration:600,padding:.2}))},[B,n]),nu=(0,r.useMemo)(()=>tz?(0,tm.r2)(B.filter(e=>e4(e.data)),e_,e=>(0,tm.$$)(e.data),e=>({id:e.id,label:e.data.title,sublabel:e.data.cluster??e.data.status,kind:"feature"})):[],[B,e_,e4,tz]);function np(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,a.jsx)(ed.Provider,{value:eF,children:(0,a.jsxs)("div",{className:(0,eN.cn)("canvas-dots relative w-full",b?"h-full":"h-screen",ef&&"rf-panning"),onDragOver:e=>{e.dataTransfer.types.includes("application/beacon-node")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDrop:e=>{if(!e.dataTransfer.getData("application/beacon-node")||!eA.current)return;e.preventDefault();let{x:t,y:n}=eA.current.screenToFlowPosition({x:e.clientX,y:e.clientY});eT(t,n,"BUG"===e.dataTransfer.getData("application/beacon-node-kind")?"BUG":"FEATURE")},children:[(0,a.jsxs)(o.Gc,{...es,className:(0,eN.cn)(ei,(ec||ek)&&"rf-placing"),nodes:t7,edges:"far"===eG?[...tV,...t9].map(e=>({...e,hidden:!0})):[...tV,...t9],nodeTypes:tE,edgeTypes:tS,nodesConnectable:!T,connectionMode:l.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{eA.current=e},onNodesChange:t8,onEdgesChange:ne,onMoveStart:()=>eh(!0),onMoveEnd:()=>eh(!1),onConnect:nt,onConnectEnd:na,onNodeMouseEnter:(e,t)=>q(t.id),onNodeMouseLeave:()=>q(null),onEdgesDelete:e=>{for(let t of e)t.id.startsWith("c-")||fetch(`/api/edges/${t.id}`,{method:"DELETE"})},onNodesDelete:e=>{for(let t of e)t.id.startsWith("anno-")||(fetch(`/api/nodes/${t.id}`,{method:"DELETE"}),Z(e=>e===t.id?null:e))},onNodeClick:(e,t)=>{if(ec)return void eD(e.clientX,e.clientY);if("lessonTable"===t.type)return;if("annotation"===t.type){let e=t.data;e.editable||A?.(e.annotationId);return}if(ek){if(eC(!1),t.data.isChild)return;nn(t,t.position.x+300,t.position.y+60);return}let n=K===t.id;if(Z(t.id),W(null),en("details"),b){let t=e.target,a=t?.closest("input, textarea, select, button, [role='combobox']"),r=D&&!n&&!eg.current;a||r||ee(!0)}},onEdgeClick:(e,t)=>{W(t.id),Z(null),en("details")},onPaneClick:e=>{ec?eD(e.clientX,e.clientY):ek?eC(!1):(ee(!1),Z(null),W(null))},onNodeDragStop:(e,t)=>{if(t.id.startsWith("anno-")){tW&&t5(t.id.slice(5),{x:t.position.x,y:t.position.y});return}T||ns(t.id,t.position.x,t.position.y)},deleteKeyCode:T?null:["Backspace","Delete"],colorMode:"dark",fitView:!0,fitViewOptions:{padding:.15,minZoom:.38,maxZoom:.9},minZoom:.2,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,a.jsx)(tk.Z,{regions:tK,tone:tZ,lod:eG}),(0,a.jsx)(eu.J,{onLod:eK}),(0,a.jsx)(o.H2,{position:"bottom-right",className:"!overflow-hidden !rounded-xl !border !border-white/10 [&_button]:!border-white/10 [&_button]:!bg-card/70 [&_button]:!text-foreground [&_button]:!backdrop-blur"}),(0,a.jsx)(o.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,a.jsx)(td.H,{tool:ea,onChange:er})}),(0,a.jsx)(o.Zk,{position:"bottom-right",style:{marginBottom:152},children:(0,a.jsx)(tb.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,eN.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(i.A,{className:"size-4"})}),children:(0,a.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:["ROADMAP"===e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-sky-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"feature"}),(0,a.jsx)("span",{children:"top-level card \xb7 can have sub-tasks"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-zinc-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-zinc-300",children:"sub-task"}),(0,a.jsx)("span",{children:"child of a feature"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-rose-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-rose-300",children:"bug"}),(0,a.jsx)("span",{children:"a bug to fix \xb7 not a feature"})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-sky-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"component"}),(0,a.jsx)("span",{children:"a subsystem \xb7 can have sub-components"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-zinc-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-zinc-300",children:"sub-component"}),(0,a.jsx)("span",{children:"part of a component"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-rose-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-rose-300",children:"bug"}),(0,a.jsx)("span",{children:"a flagged issue on a component"})]})]}),z&&(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-3 w-1 shrink-0 rounded-sm",style:{background:(0,eo.A6)("fullstack")}}),(0,a.jsx)("span",{children:"left stripe \xb7 frontend / backend layer"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#33333a]"}),(0,a.jsx)("span",{children:"contains \xb7 drag the bottom handle to empty canvas"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#f5b942"}}),(0,a.jsxs)("span",{children:["depends on \xb7 drag between two ","ROADMAP"===e?"cards":"components"]})]})]})})}),(O??!b)&&(0,a.jsx)(o.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:e=>e.data?.priority===0?"#ff3860":"#555"}),!b&&(0,a.jsxs)(o.Zk,{position:"bottom-center",className:"!mb-4 flex flex-col items-center gap-2",children:[ek&&(0,a.jsxs)("div",{className:"glass rounded-full px-3 py-1 text-[11px] text-muted-foreground",children:["Click a ","ARCHITECTURE"===e?"component":"feature"," to attach the"," ","ARCHITECTURE"===e?"sub-component":"sub-task"," \xb7 Esc to cancel"]}),"ARCHITECTURE"===e&&(0,a.jsx)("div",{className:"glass flex items-center rounded-full p-0.5",children:(0,a.jsxs)("button",{onClick:nc,title:"Arrange components into a left→right dependency flow, grouped by domain",className:"flex h-6 items-center gap-1.5 rounded-full px-3 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:"size-3"}),"Arrange"]})}),"ROADMAP"===e&&(0,a.jsxs)("div",{className:"glass flex items-center gap-1 rounded-full p-1",children:[(0,a.jsx)("span",{className:"pl-2 pr-0.5 text-[11px] text-muted-foreground",children:"Group by"}),tC.map(e=>(0,a.jsx)("button",{onClick:()=>no(e.value),title:`Arrange features into lanes by ${e.label.toLowerCase()}`,className:(0,eN.cn)("h-7 rounded-full px-2.5 text-[11px] font-medium transition-colors",eU===e.value?"bg-white/[0.12] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:e.label},e.value))]}),(0,a.jsxs)("div",{className:"glass flex items-center gap-1 rounded-full p-1",children:[(0,a.jsxs)("button",{onClick:eO,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("application/beacon-node",e),t.dataTransfer.effectAllowed="copy"},title:"ARCHITECTURE"===e?"Add component (click, or drag onto the board to place it)":"Add feature (click, or drag onto the board to place it)",className:"flex h-8 cursor-grab items-center gap-1.5 rounded-full px-3 text-[12px] font-medium text-foreground transition-colors hover:bg-white/[0.06] active:cursor-grabbing",children:[(0,a.jsx)(c.A,{className:"size-3.5 text-[var(--accent-2,#ff7a45)]"}),"ARCHITECTURE"===e?"Component":"Feature"]}),"ROADMAP"===e&&(0,a.jsxs)("button",{onClick:eP,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("application/beacon-node",e),t.dataTransfer.setData("application/beacon-node-kind","BUG"),t.dataTransfer.effectAllowed="copy"},title:"Add bug (click, or drag onto the board to place it)",className:"flex h-8 cursor-grab items-center gap-1.5 rounded-full px-3 text-[12px] font-medium text-foreground transition-colors hover:bg-white/[0.06] active:cursor-grabbing",children:[(0,a.jsx)(u.A,{className:"size-3.5 text-rose-400"}),"Bug"]}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-5 w-px bg-white/10"}),(0,a.jsxs)("button",{onClick:()=>{ep(null),eC(e=>!e)},title:"ARCHITECTURE"===e?"Add sub-component (click a component next)":"Add sub-task (click a feature next)",className:(0,eN.cn)("flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-medium transition-colors",ek?"bg-white/[0.1] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,a.jsx)(p.A,{className:"size-3.5"}),"ARCHITECTURE"===e?"Sub-component":"Sub-task"]})]})]}),!b&&tD.length>0&&!tP.active&&(0,a.jsx)(o.Zk,{position:"top-left",className:"!mt-14",children:(0,a.jsxs)("button",{type:"button",onClick:tP.start,title:"Guided, domain-by-domain walkthrough of the architecture",className:"glass flex items-center gap-1.5 rounded-xl px-3 py-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:[(0,a.jsx)(x.A,{className:"size-3.5"}),"Start tour"]})}),!b&&(0,a.jsx)(o.Zk,{position:"top-right",className:(0,eN.cn)("glass rounded-full px-1 py-0.5 transition-[margin] duration-200",Q&&"!mr-[332px]"),children:(0,a.jsx)(tu.Z,{active:e,tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,a.jsxs)(o.Zk,{position:"top-right",className:(0,eN.cn)("!mt-14 flex items-center gap-1 transition-[margin] duration-200",Q&&"!mr-[332px]",b&&"hidden"),children:[(0,a.jsx)(tp.X,{query:e_,onQuery:eX,hits:nu,placeholder:"Find a feature…",onPick:e=>{eX(""),nl(e)},onZoomToMatches:()=>{tT?.size&&eA.current?.fitView({nodes:[...tT].map(e=>({id:e})),duration:600,padding:.2})}}),"ROADMAP"===e&&F&&(0,a.jsx)("button",{type:"button",onClick:()=>nl(F),title:"Jump to the next feature to work on",className:"glass flex size-8 items-center justify-center rounded-lg text-emerald-300 transition-colors hover:text-emerald-200",children:(0,a.jsx)(m.A,{className:"size-4"})}),(0,a.jsx)(tx.e,{defaultSelection:e}),(0,a.jsxs)(tb.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,eN.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||e6>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(f.A,{className:"size-4"}),e6>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)] px-1 text-[9px] font-semibold text-white",children:e6})]}),children:[z&&(0,a.jsx)(tb.r1,{title:"Layer",children:(0,a.jsx)(ty.o,{bare:!0,value:e0,onChange:e1})}),e5.length>0&&(0,a.jsx)(tb.r1,{title:"Status",children:e5.map(e=>(0,a.jsx)(tb.vu,{on:eZ.has(e),onClick:()=>np(e,eV),children:el.nR[e]?.label??e},e))}),e2.length>0&&(0,a.jsx)(tb.r1,{title:"Cluster",children:e2.map(e=>(0,a.jsx)(tb.vu,{on:eW.has(e),onClick:()=>np(e,eJ),children:e},e))}),e3.length>0&&(0,a.jsx)(tb.r1,{title:"Priority",children:e3.map(e=>(0,a.jsxs)(tb.vu,{on:eq.has(e),onClick:()=>np(e,eQ),children:["P",e]},e))}),e6>0&&(0,a.jsx)("button",{type:"button",onClick:e7,className:"mt-1 w-full rounded-md border border-white/10 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:"clear filters"})]}),!Q&&(0,a.jsx)("button",{onClick:()=>{ee(!0),en("details")},title:"Show panel",className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(h.A,{className:"size-4"})})]})]}),Q&&(0,a.jsx)(ta,{view:e,selected:nr,allNodes:t,onClose:()=>{ee(!1),en("details")},commentsContent:j,commentsCount:v,activeTab:et,onTabChange:en,onAddComment:t3,topOffset:b?64:void 0}),(0,a.jsx)(ti,{payload:e$,onDismiss:()=>eL(null)}),(ec||ek)&&ex&&(0,a.jsxs)("div",{className:"pointer-events-none fixed z-50 flex translate-x-3 translate-y-3 items-center gap-1.5 rounded-lg border border-white/15 bg-card/95 px-2.5 py-1.5 text-xs shadow-xl backdrop-blur",style:{left:ex.x,top:ex.y},children:[(0,a.jsx)("span",{className:(0,eN.cn)("rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide","BUG"===ec?"bg-rose-500/15 text-rose-300":"FEATURE"===ec?"bg-sky-500/15 text-sky-300":"bg-zinc-500/15 text-zinc-300"),children:"BUG"===ec?"Bug":"FEATURE"===ec?"ARCHITECTURE"===e?"Component":"Feature":"Sub-task"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:ec?"click to place \xb7 Esc":"click a feature to attach \xb7 Esc"})]}),tP.active&&tP.step&&(0,a.jsx)(tg.d,{steps:tD,index:tP.index,onPrev:tP.prev,onNext:tP.next,onExit:tP.stop,onGoto:tP.goto})]})})}},9991:(e,t,n)=>{n.d(t,{X:()=>c});var a=n(95155),r=n(12115),s=n(65377),l=n(9005),o=n(91337),i=n(56614);function d(e){if(!e||!e.tagName)return!1;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t||e.isContentEditable}function c({query:e,onQuery:t,hits:n,onPick:u,onZoomToMatches:p,placeholder:x="Search…"}){let[m,f]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=e=>{m||e.metaKey||e.ctrlKey||e.altKey||1!==e.key.length||" "===e.key||d(e.target)||d(document.activeElement)||(e.preventDefault(),f(!0),t(e.key))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m,t]),(0,a.jsxs)(i.er,{title:"Search",open:m,onOpenChange:e=>e?f(!0):void(f(!1),t("")),outsideClicksToClose:2,trigger:(t,n)=>(0,a.jsx)("button",{type:"button",onClick:n,title:"Search this canvas",className:(0,o.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",t||e.trim()?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(s.A,{className:"size-4"})}),children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{autoFocus:!0,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{"Enter"===e.key&&p&&(e.preventDefault(),p())},placeholder:x,className:"w-full rounded-md border border-white/10 bg-white/[0.04] py-1 pl-2 pr-7 text-[12px] outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.08]"}),e&&(0,a.jsx)("button",{type:"button",onClick:()=>t(""),title:"Clear search",className:"absolute right-1 top-1/2 flex size-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(l.A,{className:"size-3.5"})})]}),(0,a.jsxs)("div",{className:"mt-2 max-h-64 space-y-0.5 overflow-y-auto",children:[e.trim()&&0===n.length&&(0,a.jsx)("div",{className:"px-1 py-1 text-[11px] text-muted-foreground",children:"No matches"}),n.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{u(e.id),f(!1)},className:"group flex w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors hover:bg-white/5",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] text-muted-foreground transition-colors group-hover:text-foreground",children:e.label}),e.sublabel&&(0,a.jsx)("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground/50",children:e.sublabel})]},e.id))]})]})}},12410:(e,t,n)=>{n.d(t,{a2:()=>l,i3:()=>d,xZ:()=>o});let a=["bg-emerald-500/15 text-emerald-300","bg-sky-500/15 text-sky-300","bg-violet-500/15 text-violet-300","bg-amber-500/15 text-amber-200","bg-rose-500/15 text-rose-300","bg-cyan-500/15 text-cyan-300","bg-fuchsia-500/15 text-fuchsia-300","bg-lime-500/15 text-lime-300","bg-orange-500/15 text-orange-300","bg-teal-500/15 text-teal-300","bg-indigo-500/15 text-indigo-300","bg-pink-500/15 text-pink-300"],r=["border-emerald-500/20 bg-emerald-500/[0.04]","border-sky-500/20 bg-sky-500/[0.04]","border-violet-500/20 bg-violet-500/[0.04]","border-amber-500/20 bg-amber-500/[0.04]","border-rose-500/20 bg-rose-500/[0.04]","border-cyan-500/20 bg-cyan-500/[0.04]","border-fuchsia-500/20 bg-fuchsia-500/[0.04]","border-lime-500/20 bg-lime-500/[0.04]","border-orange-500/20 bg-orange-500/[0.04]","border-teal-500/20 bg-teal-500/[0.04]","border-indigo-500/20 bg-indigo-500/[0.04]","border-pink-500/20 bg-pink-500/[0.04]"];function s(e){let t=(e??"").trim().toUpperCase();if(!t)return null;let n=0;for(let e=0;e<t.length;e++)n=31*n+t.charCodeAt(e)>>>0;return n%a.length}function l(e){let t=s(e);return null===t?"bg-white/[0.06] text-muted-foreground":a[t]}function o(e){let t=s(e);return null===t?"border-white/10 bg-white/[0.02]":r[t]}let i=["#34d399","#38bdf8","#a78bfa","#fbbf24","#fb7185","#22d3ee","#e879f9","#a3e635","#fb923c","#2dd4bf","#818cf8","#f472b6"];function d(e){let t=s(e);return null===t?"#9ca3af":i[t]}},14983:(e,t,n)=>{n.d(t,{$$:()=>l,Qk:()=>s,RU:()=>a,Uy:()=>r,jF:()=>o,r2:()=>c,sQ:()=>i,zn:()=>d});let a="0 0 0 3px var(--accent-2,#ff7a45), 0 0 32px -2px var(--accent-2,#ff7a45)",r=.14;function s(e,t){let n=t.trim().toLowerCase();if(!n)return!1;for(let t of e)if(t&&t.toLowerCase().includes(n))return!0;return!1}function l(e){return[e.title,e.role,e.plain,e.cluster,e.status].filter(Boolean)}function o(e){let t=[e.name,e.domain,e.description];for(let n of e.columns??[])t.push(n.name,n.type,n.note);return t.filter(Boolean)}function i(e){return[e.method,e.path,e.domain,e.description].filter(Boolean)}function d(e){return[e.path,e.lang].filter(Boolean)}function c(e,t,n,a,r=12){let l=t.trim().toLowerCase();if(!l)return[];let o=[];for(let t of e){if(!s(n(t),l))continue;let e=a(t);o.push({hit:e,score:function(e,t){let n=e.toLowerCase();return n===t?0:n.startsWith(t)?1:RegExp(`(^|[^a-z0-9])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"i").test(e)?2:n.includes(t)?3:4}(e.label,l)})}return o.sort((e,t)=>e.score-t.score||e.hit.label.length-t.hit.label.length),o.slice(0,r).map(e=>e.hit)}},16607:(e,t,n)=>{n.d(t,{d:()=>c});var a=n(95155),r=n(24413),s=n(9005),l=n(78780),o=n(76721),i=n(82099),d=n(91337);function c({steps:e,index:t,onPrev:n,onNext:u,onExit:p,onGoto:x}){let m=e[t];if(!m)return null;let f=t===e.length-1;return(0,a.jsxs)(i.b,{className:"absolute bottom-3 left-3 top-16 z-10 flex w-72 flex-col rounded-2xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,a.jsx)(r.A,{className:"size-3.5"}),"Guided tour"]}),(0,a.jsx)("button",{onClick:p,title:"End tour (Esc)",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(s.A,{className:"size-4"})})]}),(0,a.jsxs)("div",{className:"border-b border-white/10 px-3.5 py-3",children:[(0,a.jsxs)("div",{className:"text-[10px] font-medium uppercase tracking-wide text-[var(--accent-2,#ff7a45)]",children:["Step ",t+1," / ",e.length]}),(0,a.jsx)("h2",{className:"mt-1 break-words text-sm font-semibold leading-tight",children:m.title}),(0,a.jsx)("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:m.summary})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:(0,a.jsx)("ol",{className:"space-y-0.5",children:e.map((e,n)=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{onClick:()=>x(n),title:e.title,className:(0,d.cn)("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",n===t?"bg-white/[0.08] text-foreground":"text-muted-foreground hover:bg-white/[0.04] hover:text-foreground"),children:[(0,a.jsx)("span",{className:(0,d.cn)("flex size-4 shrink-0 items-center justify-center rounded-full text-[9px] font-bold",n===t?"bg-[var(--accent-2,#ff7a45)] text-background":"bg-white/10 text-muted-foreground"),children:n+1}),(0,a.jsx)("span",{className:"truncate text-[11px]",children:e.title})]})},e.id))})}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-white/10 p-2",children:[(0,a.jsxs)("button",{onClick:n,disabled:0===t,className:"flex items-center gap-1 rounded-md px-2 py-1.5 text-[11px] text-muted-foreground transition-colors enabled:hover:bg-white/[0.06] enabled:hover:text-foreground disabled:opacity-40",children:[(0,a.jsx)(l.A,{className:"size-3.5"})," Prev"]}),f?(0,a.jsx)("button",{onClick:p,className:"rounded-md bg-[var(--accent-2,#ff7a45)]/90 px-3 py-1.5 text-[11px] font-semibold text-background transition-colors hover:bg-[var(--accent-2,#ff7a45)]",children:"Done"}):(0,a.jsxs)("button",{onClick:u,className:"flex items-center gap-1 rounded-md bg-white/10 px-3 py-1.5 text-[11px] font-semibold text-foreground transition-colors hover:bg-white/[0.16]",children:["Next ",(0,a.jsx)(o.A,{className:"size-3.5"})]})]})]})}},17918:(e,t,n)=>{n.d(t,{Sh:()=>c,V5:()=>d,e0:()=>p});var a=n(95155),r=n(12115),s=n(81750),l=n(6266),o=n(9005),i=n(91337);let d="#ff7a45";function c({data:e,selected:t}){let[n,u]=(0,r.useState)(e.text);return(0,r.useEffect)(()=>{u(e.text)},[e.text]),(0,a.jsxs)("div",{onClick:()=>e.onClick?.(e.annotationId),className:(0,i.cn)("group/anno relative w-[270px] rounded-xl border border-white/10 bg-[#1b1b1e]/95 px-4 py-3 shadow-[0_18px_50px_-20px_rgba(0,0,0,0.9)] backdrop-blur transition-colors hover:border-white/20",!e.editable&&"cursor-pointer",t&&"border-[#ff7a45]/50"),children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute -left-px bottom-2 top-2 w-[3px] rounded-full",style:{background:d}}),(0,a.jsx)(s.h7,{type:"target",id:"in",position:l.yX.Top,isConnectable:!1,className:"!pointer-events-none !size-1 !min-h-0 !min-w-0 !border-0 !bg-transparent",style:{left:"auto",right:22,top:0}}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.22em]",style:{color:d},children:"Annotation \xb7 You"}),e.editable&&e.onDelete&&(0,a.jsx)("button",{type:"button",title:"Delete annotation",onClick:t=>{t.stopPropagation(),e.onDelete?.(e.annotationId)},className:"nodrag nopan -mr-1 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity hover:text-red-300 group-hover/anno:opacity-100",children:(0,a.jsx)(o.A,{className:"size-3"})})]}),e.editable?(0,a.jsx)("textarea",{value:n,autoFocus:!e.text.trim(),placeholder:"Type your annotation…",onChange:e=>u(e.target.value),onBlur:()=>{n!==e.text&&e.onChangeText?.(e.annotationId,n)},onKeyDown:e=>e.stopPropagation(),className:"nodrag nopan field-sizing-content mt-1.5 max-h-40 min-h-[2.25rem] w-full resize-none overflow-y-auto bg-transparent text-[13px] leading-snug text-foreground/95 outline-none placeholder:text-muted-foreground/60"}):(0,a.jsx)("div",{className:"mt-1.5 max-h-40 overflow-y-auto text-[13px] leading-snug text-foreground/95",children:e.text.trim()?e.text:(0,a.jsx)("span",{className:"text-muted-foreground",children:"…"})})]})}function u({n:e,annotationId:t,onClick:n}){return(0,a.jsxs)("button",{type:"button",title:`Annotation ${e} — view comment`,onClick:e=>{e.stopPropagation(),n?.(t)},className:"nodrag nopan relative flex size-6 items-center justify-center rounded-full font-mono text-[11px] font-bold text-[#181818] shadow-[0_0_0_3px_rgba(255,122,69,0.22),0_0_16px_2px_rgba(255,122,69,0.4)] transition-transform hover:scale-110",style:{background:d},children:[e,(0,a.jsx)(s.h7,{type:"source",id:`pin-${t}`,position:l.yX.Bottom,isConnectable:!1,className:"!pointer-events-none !size-1 !min-h-0 !min-w-0 !border-0 !bg-transparent",style:{left:"50%",bottom:2}})]})}function p({pins:e,onPinClick:t}){return e.length?(0,a.jsx)("span",{className:"absolute -right-3 top-1/2 z-10 flex -translate-y-1/2 flex-row-reverse gap-1",children:e.map(e=>(0,a.jsx)(u,{n:e.n,annotationId:e.id,onClick:t},e.id))}):null}},18874:(e,t,n)=>{n.d(t,{F1:()=>o,e6:()=>s,qA:()=>r,ru:()=>l});let a={auth:"#4ea1ff",firms:"#c792ea",search:"#7bd389",storage:"#ffb86b",petitions:"#ff7a45",monitoring:"#f5b942",admin:"#ff6b9d"};function r(e){return e&&a[e]||"#8a8a8a"}let s={GET:"#7bd389",POST:"#4ea1ff",PUT:"#ffb86b",PATCH:"#ffb86b",DELETE:"#ff3860"},l={read:"#4ea1ff",write:"#ffb86b","read-write":"#c792ea"};function o(e,t){let n=new Set([e]);for(let a of t)a.source===e&&n.add(a.target),a.target===e&&n.add(a.source);return n}},24692:(e,t,n)=>{n.d(t,{I:()=>d});var a=n(95155),r=n(12115),s=n(81750),l=n(6266),o=n(65738),i=n(28736);function d(e){let{deleteElements:t}=(0,s.VH)(),n=(0,s.JY)(e.source),d=(0,s.JY)(e.target),c=(0,s.pk)(),u=n&&d?(0,i.U)(n,d):null,p=(0,r.useMemo)(()=>c.filter(t=>t.id!==e.source&&t.id!==e.target).map(e=>({x:e.position.x,y:e.position.y,w:e.measured?.width??e.width??0,h:e.measured?.height??e.height??0})).filter(e=>e.w>0&&e.h>0),[c,e.source,e.target]),x=u?(0,i.ZH)(u.sx,u.sy,u.tx,u.ty,p):null,[m,f,h]=(0,l.Fp)(u?{sourceX:u.sx,sourceY:u.sy,sourcePosition:u.sourcePos,targetX:u.tx,targetY:u.ty,targetPosition:u.targetPos}:{sourceX:e.sourceX,sourceY:e.sourceY,sourcePosition:e.sourcePosition,targetX:e.targetX,targetY:e.targetY,targetPosition:e.targetPosition}),g=x?.path??m,b=x?.labelX??f,y=x?.labelY??h;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.tE,{id:e.id,path:g,style:e.style,markerEnd:e.markerEnd,interactionWidth:20}),e.label&&(0,a.jsx)(s.rV,{children:(0,a.jsx)("div",{style:{position:"absolute",transform:`translate(-50%, -120%) translate(${b}px, ${y}px)`,fontSize:11,color:"#cfcfcf",background:"#161616",padding:"1px 4px",borderRadius:4,pointerEvents:"none",zIndex:1e3},children:e.label})}),e.selected&&(0,a.jsx)(s.rV,{children:(0,a.jsx)("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, 0) translate(${b}px, ${y+14}px)`,pointerEvents:"all",zIndex:1e3},children:(0,a.jsx)("button",{type:"button",onMouseDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),t({edges:[{id:e.id}]})},title:"Delete (or press Backspace)",className:"flex size-7 items-center justify-center rounded-full border border-white/20 bg-card/95 text-red-300 shadow-lg backdrop-blur-md transition-colors hover:bg-red-500/25 hover:text-red-200",children:(0,a.jsx)(o.A,{className:"size-3.5"})})})})]})}},28161:(e,t,n)=>{n.d(t,{A6:()=>i,An:()=>d,RR:()=>a,YG:()=>l,ZD:()=>o,jR:()=>s});let a=["frontend","backend","fullstack"],r={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function s(e){let t=(e??"").trim().toLowerCase();return t?a.includes(t)?t:r[t]??null:null}let l={frontend:{label:"Frontend",short:"FE"},backend:{label:"Backend",short:"BE"},fullstack:{label:"Fullstack",short:"FS"}},o={frontend:"#5AC8FA",backend:"#3ECF8E",fullstack:"#5AC8FA"};function i(e){return"fullstack"!==e?o[e]:`linear-gradient(to bottom, ${o.frontend} 0%, ${o.frontend} 50%, ${o.backend} 50%, ${o.backend} 100%)`}let d=/\.(tsx|jsx|vue|svelte)$/i},28736:(e,t,n)=>{n.d(t,{U:()=>o,ZH:()=>i,u1:()=>d});var a=n(6266);function r(e){let{x:t,y:n}=e.internals.positionAbsolute,a=e.measured?.width??0,r=e.measured?.height??0;return{x:t,y:n,w:a,h:r,cx:t+a/2,cy:n+r/2}}function s(e,t){let n=r(e),a=r(t),s=n.w/2||1,l=n.h/2||1,o=(a.cx-n.cx)/(2*s)-(a.cy-n.cy)/(2*l),i=(a.cx-n.cx)/(2*s)+(a.cy-n.cy)/(2*l),d=1/(Math.abs(o)+Math.abs(i)||1);return{x:s*d*(o+i)+n.cx,y:l*d*(-o+i)+n.cy}}function l(e,t){let n=r(e),s=Math.round(t.x),l=Math.round(t.y);return s<=Math.round(n.x)+1?a.yX.Left:s>=Math.round(n.x+n.w)-1?a.yX.Right:l<=Math.round(n.y)+1?a.yX.Top:a.yX.Bottom}function o(e,t){let n=s(e,t),a=s(t,e);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:l(e,n),targetPos:l(t,a)}}function i(e,t,n,a,r){let s=r.filter(r=>(function(e,t,n,a,r){let s=r.x-14,l=r.x+r.w+14,o=r.y-14,i=r.y+r.h+14;if(Math.max(e,n)<s||Math.min(e,n)>l||Math.max(t,a)<o||Math.min(t,a)>i)return!1;for(let r=1;r<24;r++){let d=r/24,c=e+(n-e)*d,u=t+(a-t)*d;if(c>=s&&c<=l&&u>=o&&u<=i)return!0}return!1})(e,t,n,a,r));if(!s.length)return null;let l=(e+n)/2,o=(t+a)/2,i=Math.min(...s.map(e=>e.y))-14-26,d=Math.max(...s.map(e=>e.y+e.h))+14+26,c=Math.abs(i-o)<=Math.abs(d-o)?i:d,u=e+(n-e)*.25,p=e+(n-e)*.75;return{path:`M ${e},${t} C ${u},${c} ${p},${c} ${n},${a}`,labelX:l,labelY:c}}function d(e,t){let n=e.x+e.w/2,a=e.y+e.h/2,r=t.x-n,s=t.y-a;if(0===r&&0===s)return{x:n,y:a};let l=1/Math.max(Math.abs(r)/(e.w/2||1),Math.abs(s)/(e.h/2||1));return{x:n+r*l,y:a+s*l}}},29523:(e,t,n)=>{n.d(t,{J:()=>o,k:()=>l});var a=n(12115),r=n(81750),s=n(70221);function l(e){let[t,n]=(0,a.useState)("full"),l=(0,r.Pj)(n=>(0,s.gt)(n.transform[2],t,e));return l!==t&&n(l),l}function o({onLod:e,thresholds:t}){let n=l(t),r=(0,a.useRef)(null);return(0,a.useEffect)(()=>{r.current!==n&&(r.current=n,e(n))},[n,e]),null}},29813:(e,t,n)=>{n.d(t,{to:()=>r});var a=n(94014);function r(e,t,n={}){if(0===e.length)return new Map;let s=function(e,t){let n=e.map(e=>e.id).sort(),a=new Map(n.map(e=>[e,[]]));for(let e of[...t].sort((e,t)=>e.fromId.localeCompare(t.fromId)||e.toId.localeCompare(t.toId)))a.get(e.fromId)?.push(e);let r=new Map,s=[],l=e=>{for(let t of(r.set(e,"visiting"),a.get(e)??[])){let e=r.get(t.toId);"visiting"!==e&&(s.push(t),"done"!==e&&l(t.toId))}r.set(e,"done")};for(let e of n)r.has(e)||l(e);return s}(e,t),l=function(e,t){let n=new Map(e.map(e=>[e.id,[]]));for(let e of t)n.get(e.fromId)?.push(e.toId);let a=new Map,r=e=>{let t=a.get(e);if(void 0!==t)return t;a.set(e,0);let s=n.get(e)??[],l=s.length?1+Math.max(...s.map(r)):0;return a.set(e,l),l};for(let t of e)r(t.id);return a}(e,s),o=new Map(e.map(e=>[e.id,[]]));for(let e of s)o.get(e.fromId)?.push(e.toId);let i=Array.from(new Set(e.map(e=>e.group))),d=i.filter(e=>"—"!==e).sort(),c=i.includes("—")?[...d,"—"]:d,u=[];for(let t of c){let n=e.filter(e=>e.group===t),a=Math.min(...n.map(e=>l.get(e.id)??0)),r=Math.max(...n.map(e=>l.get(e.id)??0)),s=new Map,i=new Map,d=0,c=0;for(let e=a;e<=r;e++){let t=n.filter(t=>l.get(t.id)===e);if(!t.length)continue;let a=e=>{let t=(o.get(e.id)??[]).map(e=>i.get(e)).filter(e=>void 0!==e);return t.length?t.reduce((e,t)=>e+t,0)/t.length:1/0};t.sort((e,t)=>a(e)-a(t)||e.id.localeCompare(t.id));let r=Math.max(1,Math.ceil(Math.sqrt(2*t.length))),u=[];t.forEach((e,t)=>{let n=Math.floor(t/r),a=t%r;i.set(e.id,a);let l=u[n]??0;s.set(e.id,{x:d+360*n,y:l}),u[n]=l+(e.h??150),c=Math.max(c,u[n])}),d+=360*Math.ceil(t.length/r)}u.push({d:t,w:d,h:Math.max(c,150),local:s})}let p=(0,a.Xi)(u.map(e=>({id:e.d,w:e.w,h:e.h})),{gapX:84,gapY:80,viewportAspect:n.viewportAspect,minBandW:1080,aspectSlack:1.5}),x=new Map;for(let e of u){let t=p.get(e.d);for(let[n,a]of e.local)x.set(n,{x:t.x+a.x,y:t.y+a.y})}return x}},36849:(e,t,n)=>{n.d(t,{VI:()=>l});var a=n(43137),r=n(94014);function s(e,t,n){let a,r;return null==e.title?n:Math.max(n,(r=66+(((a=(e.title??"").trim())?Math.max(1,Math.ceil(a.length/17)):1)-1)*19,e.role&&e.role.trim()&&(r+=16),t>0&&(r+=22),r+24))}function l(e,t,n={}){let o=n.colW??320,i=n.rowH??150,d=n.childIndent??24,c=n.laneGap??56,u=n.bandGap??110,p=n.maxCols??10,x=n.minBandW??3*o,m=new Set(e.map(e=>e.id)),f=e=>!e.parentId||!m.has(e.parentId),h=e.filter(f),g=new Map;for(let t of e){if(f(t))continue;let e=g.get(t.parentId);e?e.push(t):g.set(t.parentId,[t])}let b="status"===t?e=>e.status:"priority"===t?e=>String(e.priority):e=>(e.cluster??"").trim()||"—",y=new Map;for(let e of h){let t=b(e),n=y.get(t);n?n.push(e):y.set(t,[e])}let j=(function(e,t,n){if("status"===e)return[...a.TT];if("priority"===e)return["0","1","2","3"];let r=Array.from(new Set(t.map(n))),s=r.filter(e=>"—"!==e).sort();return r.includes("—")?[...s,"—"]:s})(t,h,b).filter(e=>y.has(e)),v=[];for(let e of j){let t=y.get(e),n=t.reduce((e,t)=>e+1+(g.get(t.id)?.length??0),0),a=Math.max(1,Math.min(p,t.length,Math.round(Math.sqrt(.85*n))||1)),r=Array(a).fill(0),l=new Map;for(let e of t){let t=0;for(let e=1;e<a;e++)r[e]<r[t]&&(t=e);let n=t*o,c=r[t];l.set(e.id,{x:n,y:c});let u=g.get(e.id)??[],p=c+s(e,u.length,i);for(let e of u)l.set(e.id,{x:n+d,y:p}),p+=s(e,0,i);r[t]=p}let c=r.reduce((e,t)=>Math.max(e,t),0);v.push({id:e,w:a*o,h:c,local:l})}let w=(0,r.Xi)(v.map(e=>({id:e.id,w:e.w,h:e.h})),{gapX:c,gapY:u,viewportAspect:n.viewportAspect,minBandW:x,aspectSlack:1.5}),N=new Map;for(let e of v){let t=w.get(e.id);for(let[n,a]of e.local)N.set(n,{x:t.x+a.x,y:t.y+a.y})}return N}},39658:(e,t,n)=>{n.d(t,{p:()=>s});var a=n(95155);n(12115);var r=n(91337);function s({className:e,type:t,...n}){return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,r.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}},40654:(e,t,n)=>{n.d(t,{e:()=>E});var a=n(95155),r=n(12115),s=n(5937),l=n(92571),o=n(74350),i=n(4474),d=n(91337),c=n(5989);let u=["ROADMAP","ARCHITECTURE","DATABASE"],p=c.k5(u),x=c.Ik({name:c.Yj(),type:c.Yj(),isPk:c.zM(),isFk:c.zM(),nullable:c.zM(),note:c.Yj().nullable()}),m=c.Ik({id:c.Yj(),view:c.Yj(),kind:c.Yj(),cluster:c.Yj().nullable(),layer:c.Yj().nullable(),title:c.Yj(),role:c.Yj().nullable(),plain:c.Yj().nullable(),status:c.Yj(),priority:c.ai(),x:c.ai(),y:c.ai(),source:c.Yj(),sourceRef:c.Yj().nullable(),parentId:c.Yj().nullable(),isCriterion:c.zM(),files:c.YO(c.Yj()),signals:c.bz().optional(),bugFlags:c.YO(c.bz())}),f=c.Ik({id:c.Yj(),fromId:c.Yj(),toId:c.Yj(),kind:c.Yj(),label:c.Yj().nullable(),sourceHandle:c.Yj().nullable(),targetHandle:c.Yj().nullable()}),h=c.Ik({nodes:c.YO(m),edges:c.YO(f),hasFrontend:c.zM()}),g=c.Ik({id:c.Yj(),name:c.Yj(),domain:c.Yj().nullable(),description:c.Yj().nullable(),source:c.Yj(),x:c.ai(),y:c.ai(),columns:c.YO(x)}),b=c.Ik({id:c.Yj(),fromTableId:c.Yj(),toTableId:c.Yj(),fromColumn:c.Yj(),toColumn:c.Yj(),label:c.Yj().nullable()}),y=c.Ik({id:c.Yj(),method:c.Yj(),path:c.Yj(),domain:c.Yj().nullable(),description:c.Yj().nullable(),source:c.Yj(),x:c.ai(),y:c.ai(),tables:c.YO(c.Ik({tableId:c.Yj(),access:c.Yj()}))}),j=c.Ik({proposedAt:c.ai(),status:c.Yj(),tables:c.YO(c.bz()),relations:c.YO(c.bz()),endpoints:c.YO(c.bz())}).nullable(),v=c.Ik({tables:c.YO(g),relations:c.YO(b),endpoints:c.YO(y),draft:j}),w=c.Ik({kind:c.eu("boards"),version:c.eu(1),createdAt:c.ai(),workspaceLabel:c.Yj(),selectedTabs:c.YO(p).min(1),roadmap:h.optional(),architecture:h.optional(),database:v.optional()}),N=c.Ik({kind:c.eu("plan"),version:c.eu(1),createdAt:c.ai(),workspaceLabel:c.Yj(),title:c.Yj(),markdown:c.Yj(),verdict:c.k5(["approved","discarded"]).nullable(),roadmap:h.optional(),draft:j.optional()});c.gM("kind",[w,N]);var k=n(89793),C=n(96719);let A=[{value:"ALL",label:"All"},{value:"ROADMAP",label:"Roadmap"},{value:"ARCHITECTURE",label:"Architecture"},{value:"DATABASE",label:"Database"}];function E({defaultSelection:e="ALL"}){let[t,n]=(0,r.useState)(!1),[c,p]=(0,r.useState)(e),{status:x,url:m,error:f,copied:h,mint:g,copy:b,reset:y}=(0,k.b)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",title:"Share a read-only link to these boards",onClick:function(){p(e),y(),n(!0)},className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(s.A,{className:"size-4"})}),(0,a.jsx)(o.lG,{open:t,onOpenChange:n,children:(0,a.jsxs)(o.Cf,{children:[(0,a.jsxs)(o.c7,{children:[(0,a.jsx)(o.L3,{children:"Share a read-only link"}),(0,a.jsx)(o.rr,{children:"Anyone with the link can view these boards — no Beacon needed. Links expire after 7 days."})]}),"done"===x?(0,a.jsx)(C.F,{url:m,copied:h,onCopy:b}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex rounded-lg border border-white/10 bg-background/40 p-0.5",children:A.map(e=>(0,a.jsx)("button",{onClick:()=>p(e.value),className:(0,d.cn)("flex-1 rounded-md px-1.5 py-1.5 text-[11px] font-medium transition-colors",c===e.value?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:e.label},e.value))}),"error"===x&&(0,a.jsx)("p",{className:"text-[12px] text-red-400",children:f}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(i.$,{size:"sm",onClick:function(){g({kind:"boards",tabs:"ALL"===c?[...u]:[c]})},disabled:"loading"===x,children:"loading"===x?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.A,{className:"size-3.5 animate-spin"})," Creating…"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.A,{className:"size-3.5"})," Create link"]})})})]})]})})]})}},43137:(e,t,n)=>{n.d(t,{TT:()=>s,Xf:()=>o,m6:()=>r,nR:()=>l,yl:()=>a});let a=["PENDING","IN_PROGRESS","DONE","BLOCKED","CANCELLED","DEPRIORITIZED"],r=["KEEP","REBUILD","REPLACE","DROP"],s=["IN_PROGRESS","PENDING","BLOCKED","DONE","DEPRIORITIZED","CANCELLED"],l={DONE:{label:"Done",className:"border-emerald-500/30 bg-emerald-500/15 text-emerald-300"},IN_PROGRESS:{label:"In progress",className:"border-sky-500/30 bg-sky-500/15 text-sky-300"},PENDING:{label:"Pending",className:"border-amber-500/30 bg-amber-500/10 text-amber-200"},BLOCKED:{label:"Blocked",className:"border-orange-500/30 bg-orange-500/15 text-orange-300"},CANCELLED:{label:"Cancelled",className:"border-zinc-500/30 bg-zinc-500/10 text-zinc-400 line-through"},DEPRIORITIZED:{label:"Deprioritized",className:"border-zinc-600/40 bg-zinc-600/10 text-zinc-400"},KEEP:{label:"Keep",className:"border-emerald-500/30 bg-emerald-500/15 text-emerald-300"},REBUILD:{label:"Rebuild",className:"border-violet-500/30 bg-violet-500/15 text-violet-300"},REPLACE:{label:"Replace",className:"border-rose-500/30 bg-rose-500/15 text-rose-300"},DROP:{label:"Drop",className:"border-zinc-500/30 bg-zinc-500/10 text-zinc-400 line-through"}};function o(e){return e?.trim()||"—"}},44267:(e,t,n)=>{n.d(t,{S:()=>a});function a(e,t={}){let n=t.pad??20,r=t.header??26,s=new Map;for(let t of e){let e=s.get(t.group);e?(e.minX=Math.min(e.minX,t.x),e.minY=Math.min(e.minY,t.y),e.maxX=Math.max(e.maxX,t.x+t.w),e.maxY=Math.max(e.maxY,t.y+t.h),e.count++):s.set(t.group,{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h,count:1})}return Array.from(s.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:e,label:e,x:t.minX-n,y:t.minY-n-r,w:t.maxX-t.minX+2*n,h:t.maxY-t.minY+2*n+r,count:t.count}))}},45437:(e,t,n)=>{n.d(t,{L:()=>l});var a=n(95155),r=n(81750),s=n(28736);function l(e){let t=(0,r.JY)(e.target),n=e.targetX,l=e.targetY,o=t?.measured?.width,i=t?.measured?.height;if(t&&o&&i){let a=(0,s.u1)({x:t.internals.positionAbsolute.x,y:t.internals.positionAbsolute.y,w:o,h:i},{x:e.sourceX,y:e.sourceY});n=a.x,l=a.y}let d=e.sourceX,c=e.sourceY,u=n-d,p=l-c,x=Math.hypot(u,p)||1,m=Math.min(.18*x,42),f=(d+n)/2+-p/x*m,h=(c+l)/2+u/x*m,g=`M${d},${c} Q${f},${h} ${n},${l}`;return(0,a.jsx)(r.tE,{id:e.id,path:g,style:e.style,markerEnd:e.markerEnd})}},47409:(e,t,n)=>{n.d(t,{h:()=>y});var a=n(95155),r=n(12115),s=n(25583),l=n(874),o=n(36483),i=n(9107),d=n(76721),c=n(14225),u=n(95660);function p(e,t){return{name:e,path:t,folders:new Map,files:new Map}}function x(e,t){return e.kind!==t.kind?"folder"===e.kind?-1:1:e.name.localeCompare(t.name,void 0,{sensitivity:"base"})}var m=n(91337);let f={added:"text-emerald-400",modified:"text-amber-300",deleted:"text-rose-400 line-through"},h={added:"bg-emerald-400",modified:"bg-amber-300",deleted:"bg-rose-400"};function g({name:e,className:t}){let n=e.slice(e.lastIndexOf(".")+1).toLowerCase();return["ts","tsx","js","jsx","mjs","cjs"].includes(n)?(0,a.jsx)(s.A,{className:t}):"json"===n?(0,a.jsx)(l.A,{className:t}):["md","mdx","txt","css","scss"].includes(n)?(0,a.jsx)(o.A,{className:t}):(0,a.jsx)(i.A,{className:t})}function b({nodes:e,depth:t,collapsed:n,onToggle:r,onSelect:s,selectedPath:l,livePath:o}){return(0,a.jsx)("ul",{className:(0,m.cn)(t>0&&"ml-[7px] border-l border-white/10 pl-1.5"),children:e.map(e=>{let i,p;return"folder"===e.kind?(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>r(e.path),title:e.path,className:"flex w-full items-center gap-1 rounded px-1.5 py-1 text-left text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:(0,m.cn)("size-3 shrink-0 transition-transform",!n.has(e.path)&&"rotate-90")}),n.has(e.path)?(0,a.jsx)(c.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,a.jsx)(u.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("span",{className:"truncate text-[11px] font-medium",children:e.name})]}),!n.has(e.path)&&(0,a.jsx)(b,{nodes:e.children,depth:t+1,collapsed:n,onToggle:r,onSelect:s,selectedPath:l,livePath:o})]},`d:${e.path}`):(i=e.path===l,p=e.path===o,(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onClick:()=>s(e),title:e.path,"aria-current":i?"true":void 0,className:(0,m.cn)("flex w-full items-center gap-1.5 rounded py-1 pl-[18px] pr-1.5 text-left transition-colors",i?"bg-white/[0.10]":p?"bg-[#ff7a45]/[0.08] hover:bg-[#ff7a45]/[0.13]":"hover:bg-white/[0.06]"),children:[(0,a.jsx)(g,{name:e.name,className:(0,m.cn)("size-3.5 shrink-0",p?"text-[#ff7a45]":e.status?f[e.status]:"text-muted-foreground")}),(0,a.jsx)("span",{className:(0,m.cn)("truncate text-[11px]",p?"font-medium text-[#ff7a45]":i?"text-foreground":e.status?f[e.status]:"text-foreground/90"),children:e.name}),(0,a.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[p&&(0,a.jsx)("span",{className:"size-1.5 rounded-full bg-[#ff7a45] motion-safe:animate-pulse",title:"The agent is editing this file now"}),e.meta&&(0,a.jsx)("span",{className:"text-[9px] text-teal-300/80",children:e.meta}),e.status&&(0,a.jsx)("span",{className:(0,m.cn)("size-1.5 rounded-full",h[e.status])})]})]})},`f:${e.path}`))})})}function y({files:e,onSelect:t,collapse:n=!0,emptyLabel:s,className:l,selectedPath:o,livePath:i}){let d=(0,r.useMemo)(()=>(function(e,t={}){let n=t.collapseSingleChildFolders??!0,a=p("","");for(let t of e){let e=t.path.split("\\").join("/").trim().replace(/^\/+/,"").replace(/\/+$/,"");if(!e)continue;let n=e.split("/").filter(Boolean);if(!n.length)continue;let r=a;for(let e=0;e<n.length-1;e++){let t=n[e],a=r.path?`${r.path}/${t}`:t,s=r.folders.get(t);s||(s=p(t,a),r.folders.set(t,s)),r=s}let s=n[n.length-1];r.files.set(s,{kind:"file",name:s,path:e,status:t.status,meta:t.meta})}return function e(t,n){let a=[];for(let r of t.folders.values())a.push(function(t,n){let a=t.name,r=t;for(;n&&0===r.files.size&&1===r.folders.size;){let e=r.folders.values().next().value;a=`${a}/${e.name}`,r=e}return{kind:"folder",name:a,path:r.path,children:e(r,n)}}(r,n));for(let e of t.files.values())a.push(e);return a.sort(x)}(a,n)})(e,{collapseSingleChildFolders:n}),[e,n]),[c,u]=(0,r.useState)(()=>new Set);return d.length?(0,a.jsx)("div",{className:l,children:(0,a.jsx)(b,{nodes:d,depth:0,collapsed:c,onToggle:e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{var n;return t?t(e.path):(n=e.path,void fetch(`/api/open?path=${encodeURIComponent(n)}`).catch(()=>{}))},selectedPath:o,livePath:i})}):s?(0,a.jsx)("p",{className:(0,m.cn)("px-2 py-1 text-[11px] text-muted-foreground",l),children:s}):null}},54698:(e,t,n)=>{n.d(t,{m:()=>a});function a(e,t){let n=[];return e.forEach((e,a)=>{let r=e.excerpt.trim();if(!r)return;let s={annotationId:e.id,n:a+1};for(let e of t.tables){if(r===e.name)return void n.push({...s,kind:"table",targetId:e.id,column:null});if(r.startsWith(`${e.name}.`)){let t=r.slice(e.name.length+1);if(e.columns.includes(t))return void n.push({...s,kind:"column",targetId:e.id,column:t})}}for(let e of t.endpoints??[])if(r===`${e.method} ${e.path}`)return void n.push({...s,kind:"endpoint",targetId:e.id,column:null});for(let e of t.features??[])if(r===e.title||r===`feature: ${e.title}`)return void n.push({...s,kind:"feature",targetId:e.id,column:null})}),n}},56614:(e,t,n)=>{n.d(t,{er:()=>l,r1:()=>o,vu:()=>i});var a=n(95155),r=n(12115),s=n(91337);function l({trigger:e,title:t,align:n="right",children:o,open:i,onOpenChange:d,outsideClicksToClose:c=1}){let[u,p]=(0,r.useState)(!1),[x,m]=(0,r.useState)("down"),f=i??u,h=e=>{void 0===i&&p(e),d?.(e)},g=(0,r.useRef)(null),b=(0,r.useRef)(()=>{});return(0,r.useEffect)(()=>{b.current=()=>h(!1)}),(0,r.useEffect)(()=>{if(!f)return;let e=g.current?.firstElementChild?.getBoundingClientRect();e&&m(window.innerHeight-e.bottom<260?"up":"down")},[f]),(0,r.useEffect)(()=>{if(!f)return;let e=0,t=null,n=()=>{t&&clearTimeout(t),t=null},a=a=>{if(g.current?.contains(a.target)){e=0,n();return}c<=1?b.current():(e+=1)>=c?(e=0,n(),b.current()):(n(),t=setTimeout(()=>{e=0},1500))},r=e=>{"Escape"===e.key&&b.current()};return window.addEventListener("mousedown",a,!0),window.addEventListener("keydown",r),()=>{n(),window.removeEventListener("mousedown",a,!0),window.removeEventListener("keydown",r)}},[f,c]),(0,a.jsxs)("div",{ref:g,className:"relative",children:[e(f,()=>h(!f)),f&&(0,a.jsxs)("div",{className:(0,s.cn)("glass absolute z-30 w-64 rounded-xl p-3 shadow-xl","up"===x?"bottom-full mb-1.5":"top-full mt-1.5","right"===n?"right-0":"left-0"),children:[t&&(0,a.jsx)("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),o]})]})}function o({title:e,children:t}){return(0,a.jsxs)("div",{className:"mb-2.5 last:mb-0",children:[(0,a.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80",children:e}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:t})]})}function i({on:e,onClick:t,children:n,tone:r="default"}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,s.cn)("rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",{default:e?"border-foreground/40 bg-white/10 text-foreground":"border-white/10 text-muted-foreground hover:text-foreground",danger:e?"border-red-500/40 bg-red-500/15 text-red-300":"border-white/10 text-muted-foreground hover:text-foreground",accent:e?"border-sky-500/40 bg-sky-500/15 text-sky-300":"border-white/10 text-muted-foreground hover:text-foreground"}[r]),children:n})}},56895:(e,t,n)=>{n.d(t,{W:()=>r});var a=n(12115);function r(e,t){let[n,r]=(0,a.useState)(!1),[s,l]=(0,a.useState)(0),o=n?e[s]??null:null,i=(0,a.useCallback)(()=>{l(0),r(!0)},[]),d=(0,a.useCallback)(()=>r(!1),[]),c=(0,a.useCallback)(()=>l(t=>Math.min(t+1,e.length-1)),[e.length]),u=(0,a.useCallback)(()=>l(e=>Math.max(e-1,0)),[]),p=(0,a.useCallback)(t=>{t>=0&&t<e.length&&l(t)},[e.length]);(0,a.useEffect)(()=>{if(!n)return;let a=e[s];a&&t(a)},[n,s]),(0,a.useEffect)(()=>{if(!n)return;let e=e=>{"ArrowRight"===e.key?(e.preventDefault(),c()):"ArrowLeft"===e.key?(e.preventDefault(),u()):"Escape"===e.key&&(e.preventDefault(),d())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,c,u,d]);let x=(0,a.useMemo)(()=>o&&o.focusIds.length?new Set(o.focusIds):null,[o]);return{active:n,index:s,step:o,start:i,stop:d,next:c,prev:u,goto:p,focusIds:x}}},62311:(e,t,n)=>{n.d(t,{Z:()=>f});var a=n(95155),r=n(12115),s=n(98500),l=n.n(s),o=n(25640),i=n(83599),d=n(94192),c=n(34306),u=n(60292),p=n(75514),x=n(91337);let m={ROADMAP:o.A,ARCHITECTURE:i.A,FILES:d.A,DATABASE:c.A};function f({tabs:e,active:t}){let[n,s]=(0,r.useState)(null);(0,r.useEffect)(()=>{s((0,u.fk)())},[]);let o=(0,p.$2)();return(0,a.jsx)("div",{className:"flex items-center gap-0.5",children:e.map(e=>{let r,s=e.value===t,i=e.Icon??m[e.value],d=(0,x.cn)("flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[12px] font-medium tracking-tight transition-colors",s?"border-white/10 bg-white/[0.07] text-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"border-transparent text-muted-foreground/80 hover:bg-white/5 hover:text-foreground"),c=(0,a.jsxs)(a.Fragment,{children:[i?(0,a.jsx)(i,{className:(0,x.cn)("size-3",s&&"text-[#ff7a45]")}):null,(0,a.jsx)("span",{className:"hidden lg:inline",children:e.label})]});return o?.views.has(e.value)?(0,a.jsx)("button",{type:"button",title:e.label,onClick:()=>o.switchTo(e.value),className:d,children:c},e.value):(0,a.jsx)(l(),{href:(r=e.href,n?`${r}${r.includes("?")?"&":"?"}ws=${n}`:r),title:e.label,className:d,children:c},e.value)})})}},66616:(e,t,n)=>{n.d(t,{E:()=>s});var a=n(95155),r=n(91337);function s({active:e,onClick:t,icon:n,children:l}){return(0,a.jsxs)("button",{type:"button",onClick:t,className:(0,r.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:[n,l]})}},70221:(e,t,n)=>{n.d(t,{fE:()=>s,gt:()=>l,kz:()=>r});let a={far:.3,farExit:.34,mid:.55,midExit:.6},r={far:.12,farExit:.15,mid:.45,midExit:.5},s={far:.2,farExit:.24,mid:.32,midExit:.36};function l(e,t="full",n=a){return e<n.far||"far"===t&&e<n.farExit?"far":e<n.mid||"mid"===t&&e<n.midExit?"mid":"full"}},70521:(e,t,n)=>{n.d(t,{$v:()=>w,EO:()=>b,Lt:()=>m,Rx:()=>N,Zr:()=>k,ck:()=>j,r7:()=>v,tv:()=>f,wd:()=>y});var a=n(95155);n(12115);var r=n(25381),s=n(7121),l=n(51880),o=n(35176),i=n(11248),d=n(82022),c=n(98758),u=n(45362),p=n(91337),x=n(4474);function m({...e}){return(0,a.jsx)(r.V,{"data-slot":"alert-dialog",...e})}function f({...e}){return(0,a.jsx)(s.t,{"data-slot":"alert-dialog-trigger",...e})}function h({...e}){return(0,a.jsx)(l.Z,{"data-slot":"alert-dialog-portal",...e})}function g({className:e,...t}){return(0,a.jsx)(o.X,{"data-slot":"alert-dialog-overlay",className:(0,p.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function b({className:e,size:t="default",...n}){return(0,a.jsxs)(h,{children:[(0,a.jsx)(g,{}),(0,a.jsx)(i.h,{"data-slot":"alert-dialog-content","data-size":t,className:(0,p.cn)("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function y({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,p.cn)("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function j({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,p.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function v({className:e,...t}){return(0,a.jsx)(d.L,{"data-slot":"alert-dialog-title",className:(0,p.cn)("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function w({className:e,...t}){return(0,a.jsx)(c.r,{"data-slot":"alert-dialog-description",className:(0,p.cn)("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function N({className:e,variant:t,size:n,...r}){return(0,a.jsx)(u.H,{"data-slot":"alert-dialog-action",className:(0,p.cn)(e),render:(0,a.jsx)(x.$,{variant:t,size:n}),...r})}function k({className:e,variant:t="outline",size:n="default",...r}){return(0,a.jsx)(u.H,{"data-slot":"alert-dialog-cancel",className:(0,p.cn)(e),render:(0,a.jsx)(x.$,{variant:t,size:n}),...r})}},70947:(e,t,n)=>{n.d(t,{Z:()=>o});var a=n(95155),r=n(81750),s=n(12410),l=n(91337);function o({regions:e,tone:t="neutral",lod:n="full"}){let i=(0,r.Pj)(e=>e.transform[2]);if(0===e.length)return null;let d="far"===n,c=Math.min(150,26/Math.max(i,.05)),u=Math.min(80,13/Math.max(i,.05));return(0,a.jsx)(r.DX,{children:e.map(e=>(0,a.jsx)("div",{style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none",zIndex:0},className:(0,l.cn)("rounded-2xl border","category"===t?(0,s.xZ)(e.key):"border-white/[0.08] bg-white/[0.015]",d&&"bg-card/80"),children:d?(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-[0.3em] px-2",children:[(0,a.jsx)("span",{className:"whitespace-nowrap text-center font-semibold tracking-tight text-foreground",style:{fontSize:Math.min(c,.34*e.h,(e.w-16)/(.74*Math.max(e.label.length,1))),lineHeight:1.1},children:e.label}),(0,a.jsxs)("span",{className:"tabular-nums text-muted-foreground",style:{fontSize:Math.min(u,.18*e.h)},children:[e.count," ",1===e.count?"card":"cards"]})]}):(0,a.jsxs)("div",{className:"flex items-baseline gap-2 px-3 py-1",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.label}),(0,a.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground/50",children:e.count})]})},e.key))})}},74350:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>y,L3:()=>j,c7:()=>b,lG:()=>m,rr:()=>v});var a=n(95155);n(12115);var r=n(17112),s=n(51880),l=n(35176),o=n(11248),i=n(45362),d=n(82022),c=n(98758),u=n(91337),p=n(4474),x=n(9005);function m({...e}){return(0,a.jsx)(r.D,{"data-slot":"dialog",...e})}function f({...e}){return(0,a.jsx)(s.Z,{"data-slot":"dialog-portal",...e})}function h({className:e,...t}){return(0,a.jsx)(l.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function g({className:e,children:t,showCloseButton:n=!0,...r}){return(0,a.jsxs)(f,{children:[(0,a.jsx)(h,{}),(0,a.jsxs)(o.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...r,children:[t,n&&(0,a.jsxs)(i.H,{"data-slot":"dialog-close",render:(0,a.jsx)(p.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,a.jsx)(x.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",e),...t})}function y({className:e,showCloseButton:t=!1,children:n,...r}){return(0,a.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...r,children:[n,t&&(0,a.jsx)(i.H,{render:(0,a.jsx)(p.$,{variant:"outline"}),children:"Close"})]})}function j({className:e,...t}){return(0,a.jsx)(d.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",e),...t})}function v({className:e,...t}){return(0,a.jsx)(c.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}},75514:(e,t,n)=>{n.d(t,{$2:()=>l,a4:()=>r,no:()=>s});var a=n(12115);let r=new Set(["ROADMAP","ARCHITECTURE","DATABASE"]),s=(0,a.createContext)(null);function l(){return(0,a.useContext)(s)}},80277:(e,t,n)=>{n.d(t,{H:()=>c,e:()=>d});var a=n(95155),r=n(12115),s=n(6266),l=n(61285),o=n(91906),i=n(91337);function d(e="pan"){let[t,n]=(0,r.useState)(e);(0,r.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))||("v"===e.key||"V"===e.key?n("select"):("h"===e.key||"H"===e.key)&&n("pan"))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let a="pan"===t?{panOnDrag:!0,selectionOnDrag:!1,selectionMode:s.Qc.Partial,selectNodesOnDrag:!1}:{panOnDrag:[1,2],selectionOnDrag:!0,selectionMode:s.Qc.Partial,selectNodesOnDrag:!1};return{tool:t,setTool:n,flowProps:a,paneClass:"select"===t?"rf-tool-select":void 0}}function c({tool:e,onChange:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-0.5 rounded-xl border border-white/15 bg-[#202024]/95 p-1 shadow-lg backdrop-blur",children:[(0,a.jsx)(u,{active:"select"===e,label:"Select tool (V) — drag to box-select; move many nodes at once",onClick:()=>t("select"),children:(0,a.jsx)(l.A,{className:"size-4"})}),(0,a.jsx)(u,{active:"pan"===e,label:"Hand tool (H) — drag to pan the board",onClick:()=>t("pan"),children:(0,a.jsx)(o.A,{className:"size-4"})})]})}function u({active:e,label:t,onClick:n,children:r}){return(0,a.jsx)("button",{type:"button",title:t,"aria-pressed":e,onClick:n,className:(0,i.cn)("flex size-7 items-center justify-center rounded-lg transition-colors",e?"bg-[#ff7a45]/15 text-[#ff7a45]":"text-muted-foreground hover:bg-white/8 hover:text-foreground"),children:r})}},89793:(e,t,n)=>{n.d(t,{b:()=>r});var a=n(12115);function r(){let[e,t]=(0,a.useState)("idle"),[n,r]=(0,a.useState)(""),[s,l]=(0,a.useState)(""),[o,i]=(0,a.useState)(!1);async function d(){try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)}catch{}}return{status:e,url:n,error:s,copied:o,mint:async function e(e){t("loading"),l(""),i(!1);try{let n=await fetch("/api/share/create",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),a=await n.json();if(!n.ok||!a.url){l(a.error??"Could not create the link."),t("error");return}r(a.url),t("done")}catch{l("Could not reach the local Beacon daemon."),t("error")}},copy:d,reset:function(){t("idle"),r(""),l(""),i(!1)}}}},91157:(e,t,n)=>{n.d(t,{b:()=>l,d:()=>o});let a=e=>e.slice(e.lastIndexOf("/")+1),r=(e,t)=>t>e?", …":"";function s(e){let t=new Map;for(let n of e)t.set(a(n),(t.get(a(n))??0)+1);return e.map(e=>{let n=a(e);if((t.get(n)??0)<=1)return n;let r=e.slice(0,e.lastIndexOf("/")),s=r.slice(r.lastIndexOf("/")+1);return s?`${s}/${n}`:n})}function l(e,t,n){if(0===e.length)return[];let a=e=>n.get(e)??"(root)",l=new Map;for(let t of e){let e=a(t.path),n=l.get(e);n?n.push(t):l.set(e,[t])}let o=[...l.keys()],i=e=>l.get(e)?.length??0,d=new Map,c=new Map;for(let e of o)d.set(e,new Set),c.set(e,0);let u=new Set;for(let e of t){if(e.circular)continue;let t=a(e.from),n=a(e.to);if(t===n||!d.has(t)||!d.has(n))continue;let r=`${t}\0${n}`;u.has(r)||(u.add(r),d.get(t).add(n),c.set(n,(c.get(n)??0)+1))}let p=(e,t)=>i(t)-i(e)||e.localeCompare(t),x=new Map(c),m=new Set,f=[];for(;f.length<o.length;){let e=o.filter(e=>!m.has(e)&&(x.get(e)??0)===0).sort(p);if(0===e.length){for(let e of o.filter(e=>!m.has(e)).sort((e,t)=>(x.get(e)??0)-(x.get(t)??0)||i(t)-i(e)||e.localeCompare(t)))f.push(e),m.add(e);break}for(let t of e)for(let e of(f.push(t),m.add(t),d.get(t)))x.set(e,(x.get(e)??0)-1)}let h=e.filter(e=>(e.inDegree??0)===0).sort((e,t)=>(t.outDegree??0)-(e.outDegree??0)||e.path.localeCompare(t.path)),g=[];if(g.push({id:"tour:overview",kind:"overview",title:"Project overview",summary:`${e.length} files across ${o.length} ${1===o.length?"area":"areas"} \xb7 ${t.length} imports. Step through the architecture in dependency order — entry points first.`,focusIds:[]}),h.length){let e=s(h.slice(0,4).map(e=>e.path));g.push({id:"tour:entry",kind:"entry",title:"Entry points",summary:`${h.length} file${1===h.length?"":"s"} nothing imports — where execution starts: ${e.join(", ")}${r(4,h.length)}.`,focusIds:h.slice(0,12).map(e=>e.path)})}for(let e of f){let t=l.get(e),n=s([...t].sort((e,t)=>(t.inDegree??0)-(e.inDegree??0)||e.path.localeCompare(t.path)).slice(0,3).map(e=>e.path)),a=[...d.get(e)].sort(p),o=a.length?` \xb7 imports ${a.slice(0,3).join(", ")}${r(3,a.length)}`:" \xb7 no cross-area imports";g.push({id:`tour:group:${e}`,kind:"group",title:e,summary:`${t.length} file${1===t.length?"":"s"}${o} \xb7 top hubs: ${n.join(", ")}.`,focusIds:t.map(e=>e.path)})}return g}function o(e){if(0===e.length)return[];let t=e=>e.cluster?.trim()||"—",n=new Map;for(let a of e){let e=t(a),r=n.get(e);r?r.push(a):n.set(e,[a])}let a=e=>Math.min(...n.get(e).map(e=>e.x??0)),s=[...n.keys()].sort((e,t)=>a(e)-a(t)||e.localeCompare(t)),l=[{id:"tour:overview",kind:"overview",title:"Architecture overview",summary:`${e.length} component${1===e.length?"":"s"} across ${s.length} ${1===s.length?"domain":"domains"}. Walk the architecture domain by domain, upstream first.`,focusIds:[]}];for(let e of s){let t=n.get(e),a=t.slice(0,3).map(e=>e.title?.trim()||e.id);l.push({id:`tour:domain:${e}`,kind:"group",title:e,summary:`${t.length} component${1===t.length?"":"s"}: ${a.join(", ")}${r(3,t.length)}.`,focusIds:t.map(e=>e.id)})}return l}},94014:(e,t,n)=>{n.d(t,{Xi:()=>a});function a(e,t){let n,a,r,s=(a=((n=t.viewportAspect)&&Number.isFinite(n)&&n>0?Math.min(3.2,Math.max(.7,n)):1.8)*(t.aspectSlack??1),r=e.reduce((e,n)=>e+(n.w+t.gapX)*(n.h+t.gapY),0),Math.max(t.minBandW,Math.round(Math.sqrt(r*a)))),l=new Map,o=0,i=0,d=0;for(let n of e)o>0&&o+n.w>s&&(i+=d+t.gapY,o=0,d=0),l.set(n.id,{x:o,y:i}),d=Math.max(d,n.h),o+=n.w+t.gapX;return l}},95635:(e,t,n)=>{n.d(t,{x:()=>l});var a=n(95155),r=n(81750),s=n(6266);function l(){let e="!h-2 !w-2 !border-0 !bg-zinc-400";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.h7,{type:"target",position:s.yX.Top,id:"tt",className:e}),(0,a.jsx)(r.h7,{type:"source",position:s.yX.Top,id:"st",className:e}),(0,a.jsx)(r.h7,{type:"target",position:s.yX.Right,id:"tr",className:e}),(0,a.jsx)(r.h7,{type:"source",position:s.yX.Right,id:"sr",className:e}),(0,a.jsx)(r.h7,{type:"target",position:s.yX.Bottom,id:"tb",className:e}),(0,a.jsx)(r.h7,{type:"source",position:s.yX.Bottom,id:"sb",className:e}),(0,a.jsx)(r.h7,{type:"target",position:s.yX.Left,id:"tl",className:e}),(0,a.jsx)(r.h7,{type:"source",position:s.yX.Left,id:"sl",className:e})]})}},96719:(e,t,n)=>{n.d(t,{F:()=>i});var a=n(95155),r=n(64577),s=n(99314),l=n(1275),o=n(4474);function i({url:e,copied:t,onCopy:n}){return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{readOnly:!0,value:e,onFocus:e=>e.currentTarget.select(),className:"min-w-0 flex-1 rounded-md border border-white/10 bg-background px-2.5 py-1.5 text-[12px] text-foreground outline-none"}),(0,a.jsxs)(o.$,{size:"sm",variant:"outline",onClick:n,children:[t?(0,a.jsx)(r.A,{className:"size-3.5"}):(0,a.jsx)(s.A,{className:"size-3.5"}),t?"Copied":"Copy"]})]}),(0,a.jsxs)("a",{href:e,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[12px] text-muted-foreground transition-colors hover:text-foreground",children:[(0,a.jsx)(l.A,{className:"size-3.5"})," Open the shared view"]})]})}},98238:(e,t,n)=>{n.d(t,{F:()=>l,o:()=>o});var a=n(95155),r=n(28161),s=n(91337);function l(e,t){return!!t&&("fullstack"===e?"fullstack"===t:t===e||"fullstack"===t)}function o({value:e,onChange:t,options:n=r.RR,bare:l=!1}){return(0,a.jsx)("div",{className:(0,s.cn)("flex items-center gap-0.5",!l&&"glass rounded-lg p-0.5"),children:n.map(n=>{let l=e===n;return(0,a.jsxs)("button",{type:"button",onClick:()=>t(l?null:n),title:l?"Show every layer at full strength again":`Highlight ${r.YG[n].label} — other cards dim, nothing is hidden`,className:(0,s.cn)("flex h-7 items-center gap-1.5 rounded-md px-2 text-[10px] font-semibold uppercase tracking-wide transition-colors",l?"bg-white/[0.12] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"h-3 w-[3px] shrink-0 rounded-full",style:{background:(0,r.A6)(n)}}),r.YG[n].short]},n)})})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{434:(e,t,s)=>{"use strict";s.d(t,{PlanBar:()=>u});var r=s(95155),n=s(98500),a=s.n(n),l=s(73321),i=s(86272),o=s(32133),c=s(65738),d=s(48484);function u(){let{status:e,discard:t}=(0,d.j)(),s=(0,l.usePathname)();return e.pending&&"/plan"!==s?(0,r.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-14 z-40 flex justify-center px-2",children:(0,r.jsxs)("div",{className:"pointer-events-auto flex max-w-3xl items-center gap-2 rounded-xl border border-emerald-500/30 bg-card/85 px-3 py-1.5 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-card/70",children:[(0,r.jsx)(i.A,{className:"size-3.5 shrink-0 text-emerald-300"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"truncate text-[12px] leading-tight text-foreground",children:[(0,r.jsx)("span",{className:"text-emerald-300/80",children:"Plan ready \xb7 "}),e.description||"(no description)"]}),(0,r.jsxs)("div",{className:"text-[10px] leading-tight text-muted-foreground",children:[e.features," feature(s) \xb7 ",e.tables," table(s) \xb7 ",e.endpoints," ","endpoint(s)"]})]}),(0,r.jsxs)(a(),{href:"/plan",className:"flex shrink-0 items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25",title:"Open Plannotator + canvases side by side",children:[(0,r.jsx)(o.A,{className:"size-3"})," Open plan"]}),(0,r.jsxs)("button",{onClick:t,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",title:"Discard the plan",children:[(0,r.jsx)(c.A,{className:"size-3"})," Discard"]})]})}):null}},10436:(e,t,s)=>{"use strict";s.d(t,{TopNav:()=>b});var r=s(95155),n=s(12115),a=s(98500),l=s.n(a),i=s(73321),o=s(82879),c=s(52965);let d=(0,s(30772).A)("folder-git-2",[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);var u=s(26518),h=s(91337),m=s(60292);function x({fallback:e}){let[t,s]=(0,n.useState)([]),[a,l]=(0,n.useState)(null);if((0,n.useEffect)(()=>{let e=!0,t=()=>fetch("/api/workspace").then(e=>e.ok?e.json():null).then(t=>{e&&t&&(s(t.workspaces??[]),l((0,m.fk)()??t.active??null))}).catch(()=>{});t();let r=setInterval(t,5e3);return()=>{e=!1,clearInterval(r)}},[]),0===t.length)return e?(0,r.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:["\xb7 ",e]}):null;async function i(e){l(e),(0,m.aE)(e),await Promise.race([fetch("/api/workspace",{method:"POST",headers:{"content-type":"application/json","x-beacon-workspace":e},body:JSON.stringify({id:e}),signal:AbortSignal.timeout(8e3)}).catch(()=>{}),new Promise(e=>setTimeout(e,2500))]);let t=new URLSearchParams(window.location.search);t.set("ws",e),window.location.href=`${window.location.pathname}?${t.toString()}`}let o=t.find(e=>e.id===a);return(0,r.jsxs)(u.l6,{value:a??"",onValueChange:e=>e&&i(e),children:[(0,r.jsxs)(u.bq,{title:o?.name,className:"h-7 max-w-[180px] gap-1.5 rounded-lg border-white/12 bg-white/[0.04] px-2 text-xs font-medium transition-colors hover:bg-white/[0.07]",children:[(0,r.jsx)(d,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(u.yv,{children:()=>o?.name??"Project"})]}),(0,r.jsxs)(u.gC,{align:"start",alignItemWithTrigger:!1,sideOffset:6,className:"min-w-[250px] border border-white/10 bg-popover/95 p-1.5 backdrop-blur-xl",children:[(0,r.jsx)("p",{className:"px-2 pt-1 pb-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Workspace"}),t.map(e=>{var t,s;let n,l=e.id===a;return(0,r.jsx)(u.eb,{value:e.id,className:(0,h.cn)("gap-2.5 rounded-lg py-1.5 pr-8 pl-1.5 transition-colors",l&&"bg-white/[0.05]"),children:(0,r.jsxs)("span",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:(0,h.cn)("flex size-7 shrink-0 items-center justify-center rounded-md border",l?"border-sky-400/30 bg-sky-400/10 text-sky-300":"border-white/10 bg-white/[0.03] text-muted-foreground"),children:(0,r.jsx)(d,{className:"size-3.5"})}),(0,r.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,r.jsx)("span",{className:"truncate text-[13px] font-medium leading-tight text-foreground",children:e.name}),(0,r.jsx)("span",{className:"truncate font-mono text-[10px] leading-tight text-muted-foreground",children:(t=e.path,s=e.name,(n=t.replace(/^\/(Users|home)\/[^/]+/,"~").split("/").filter(Boolean))[n.length-1]===s&&n.pop(),(n.length>3?[n[0],"…",n[n.length-1]]:n).join("/")||"~")})]})]})},e.id)})]})]})}var p=s(81984);let f=[{href:"/plan",label:"Plans"},{href:"/map",label:"Map"},{href:"/learn",label:"Learn"},{href:"/settings",label:"Settings"}];function b({repo:e}){let t=(0,i.usePathname)(),{toggle:s,open:a}=(0,p.b)(),[d,u]=(0,n.useState)(null);return(0,n.useEffect)(()=>{u((0,m.fk)())},[t]),(0,r.jsx)("header",{className:"pointer-events-none fixed left-3 top-3 z-30",children:(0,r.jsxs)("div",{className:"glass pointer-events-auto flex h-10 items-center gap-1 rounded-full pl-3 pr-1.5",children:[(0,r.jsxs)(l(),{href:"/",className:"mr-1 flex items-center gap-2 text-sm font-semibold tracking-tight",children:[(0,r.jsx)(c._,{size:18,className:"text-foreground"}),(0,r.jsx)("span",{className:"hidden lg:inline",children:"Beacon"})]}),(0,r.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,r.jsx)(x,{fallback:e}),(0,r.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,r.jsx)("nav",{className:"flex items-center gap-0.5 text-sm",children:f.map(e=>{let s=t===e.href||t.startsWith(e.href+"/");return(0,r.jsx)(l(),{href:(0,m.Fj)(e.href,d),className:(0,h.cn)("rounded-full px-3 py-1 text-[13px] tracking-tight transition-colors",s?"bg-white/[0.09] text-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"text-muted-foreground hover:bg-white/[0.04] hover:text-foreground"),children:e.label},e.href)})}),(0,r.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,r.jsx)("button",{type:"button",onClick:s,"aria-pressed":a,"aria-label":"Notes",title:"Notes",className:(0,h.cn)("flex items-center justify-center rounded-full p-1.5 transition-colors",a?"bg-white/[0.09] text-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"text-muted-foreground hover:bg-white/[0.04] hover:text-foreground"),children:(0,r.jsx)(o.A,{className:"size-4"})})]})})}},29510:(e,t,s)=>{"use strict";s.d(t,{UpdateBanner:()=>h});var r=s(95155),n=s(12115);let a=(0,s(30772).A)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);var l=s(9005),i=s(64577),o=s(99314),c=s(39593);function d(e){if("string"!=typeof e)return null;let t=e.trim().replace(/^v/i,"").match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/);return t?[Number(t[1]),Number(t[2]??0),Number(t[3]??0)]:null}let u="beacon:update-dismissed";function h({currentVersion:e}){let[t,s]=(0,n.useState)(null),[m,x]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await fetch(c.kw);if(!r.ok)return;let n=await r.json(),a="string"==typeof n?.version?n.version:"";if(t||!function(e,t){let s=d(e),r=d(t);if(!s||!r)return!1;for(let e=0;e<3;e++){if(s[e]>r[e])return!0;if(s[e]<r[e])break}return!1}(a,e)||localStorage.getItem(u)===a)return;s(a)}catch{}})(),()=>{t=!0}},[e]),!t)return null;let p=async()=>{try{await navigator.clipboard?.writeText(c.EO),x(!0),setTimeout(()=>x(!1),1600)}catch{}};return(0,r.jsx)("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex justify-end",children:(0,r.jsx)("div",{className:"glass pointer-events-auto w-[320px] rounded-xl p-3.5 shadow-xl",children:(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,r.jsx)(a,{className:"mt-0.5 size-4 shrink-0 text-[#ff7a45]"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:"New version available"}),(0,r.jsx)("button",{type:"button",onClick:()=>{try{localStorage.setItem(u,t)}catch{}s(null)},"aria-label":"Dismiss",className:"shrink-0 rounded-md p-0.5 text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,r.jsx)(l.A,{className:"size-3.5"})})]}),(0,r.jsxs)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[e," →"," ",(0,r.jsx)("span",{className:"text-foreground",children:t.replace(/^v/i,"")})," \xb7 update Beacon"]}),(0,r.jsxs)("button",{type:"button",onClick:p,title:"Copy the update command",className:"mt-2.5 flex w-full items-center justify-between gap-2 rounded-lg border border-white/10 bg-black/30 px-2.5 py-1.5 text-left font-mono text-[11px] text-muted-foreground transition-colors hover:border-white/20 hover:text-foreground",children:[(0,r.jsx)("span",{className:"truncate",children:c.EO}),m?(0,r.jsx)(i.A,{className:"size-3.5 shrink-0 text-[#ff7a45]"}):(0,r.jsx)(o.A,{className:"size-3.5 shrink-0"})]})]})]})})})}},35353:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_246ccd",variable:"__variable_246ccd"}},38332:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(30772).A)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]])},39593:(e,t,s)=>{"use strict";s.d(t,{EO:()=>l,kw:()=>n});var r=s(41463);let n="https://registry.npmjs.org/trybeacon/latest",a=(r.env.NEXT_PUBLIC_BEACON_SITE_URL??"https://www.trybeacon.sh").replace(/\/$/,""),l=`curl -fsSL ${a}/install.sh | sh`},42578:(e,t,s)=>{"use strict";s.d(t,{AskModal:()=>d});var r=s(95155),n=s(12115),a=s(9005),l=s(90467),i=s(4474),o=s(82099),c=s(91337);function d(){let[e,t]=(0,n.useState)(null),[s,d]=(0,n.useState)(new Set),[u,h]=(0,n.useState)(""),[m,x]=(0,n.useState)(!1),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=!0,s=async()=>{try{let s=await fetch("/api/ask",{cache:"no-store"});if(!s.ok||!e)return;let{ask:r}=await s.json();if(!e||r&&r.id===p.current)return;t(e=>e?.id===r?.id?e:r)}catch{}};s();let r=setInterval(s,1500);return()=>{e=!1,clearInterval(r)}},[]);let f=e?.id??null,b=(0,n.useRef)(null);f!==b.current&&(b.current=f,s.size&&d(new Set),u&&h(""));let g=(0,n.useCallback)(async s=>{if(e&&!m){x(!0),p.current=e.id,t(null);try{await fetch("/api/ask/answer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e.id,...s})})}catch{}finally{x(!1)}}},[e,m]);if(!e)return null;if("mirror"===e.mode&&"question"===e.kind&&e.question)return(0,r.jsx)("div",{className:"fixed right-4 bottom-4 z-[70] w-full max-w-sm",children:(0,r.jsxs)(o.b,{className:"rounded-2xl border border-border/60 p-4 shadow-2xl",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[0.7rem] font-medium text-muted-foreground",children:e.question.header||"The agent is asking"}),(0,r.jsx)("button",{type:"button",onClick:()=>{p.current=e.id,t(null)},className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Dismiss",children:(0,r.jsx)(a.A,{className:"size-4"})})]}),(0,r.jsx)("p",{className:"mb-3 text-sm font-medium text-foreground",children:e.question.question}),(0,r.jsx)("div",{className:"flex flex-col gap-1.5",children:e.question.options.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-border bg-background/40 px-3 py-1.5",children:[(0,r.jsx)("span",{className:"text-sm text-foreground",children:e.label}),e.description&&(0,r.jsx)("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:e.description})]},e.label))}),(0,r.jsx)("p",{className:"mt-3 text-[0.7rem] text-muted-foreground",children:"Answer in your terminal — this is a mirror."})]})});let v=()=>u.trim()&&g({selected:[u.trim()]});return(0,r.jsx)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/40 p-4 backdrop-blur-sm",children:(0,r.jsx)(o.b,{className:"w-full max-w-lg rounded-2xl border border-border/60 p-5 shadow-2xl",children:"question"===e.kind&&e.question?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[0.7rem] font-medium text-muted-foreground",children:e.question.header||"The agent is asking"}),e.question.multiSelect&&(0,r.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:"select all that apply"})]}),(0,r.jsx)("p",{className:"mb-4 text-sm font-medium text-foreground",children:e.question.question}),(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.question.options.map(t=>{let n=s.has(t.label);return(0,r.jsxs)("button",{type:"button",disabled:m,onClick:()=>{let s;return e.question.multiSelect?(s=t.label,d(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})):g({selected:[t.label]})},className:(0,c.cn)("rounded-lg border border-border bg-background/40 px-3 py-2 text-left transition-colors hover:bg-muted disabled:opacity-50",n&&"border-primary bg-primary/10"),children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.label}),t.description&&(0,r.jsx)("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:t.description})]},t.label)})}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,r.jsx)("input",{value:u,disabled:m,onChange:e=>h(e.target.value),onKeyDown:t=>"Enter"===t.key&&!e.question.multiSelect&&v(),placeholder:"Other…",className:"h-8 flex-1 rounded-lg border border-border bg-background/40 px-2.5 text-sm outline-none focus:border-primary"}),e.question.multiSelect?(0,r.jsx)(i.$,{size:"sm",onClick:()=>{let e=[...s,...u.trim()?[u.trim()]:[]];e.length&&g({selected:e})},disabled:m,children:"Submit"}):(0,r.jsx)(i.$,{size:"icon-sm",variant:"outline",onClick:v,disabled:m||!u.trim(),"aria-label":"Submit other",children:(0,r.jsx)(l.A,{})})]})]}):e.approval?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"mb-1 flex items-center gap-2",children:(0,r.jsxs)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[0.7rem] font-medium text-muted-foreground",children:["Approve ",e.approval.tool]})}),(0,r.jsx)("p",{className:"mb-3 text-sm font-medium text-foreground",children:e.approval.title}),e.approval.preview&&(0,r.jsx)("pre",{className:"mb-4 max-h-64 overflow-auto rounded-lg border border-border bg-background/40 p-3 text-xs whitespace-pre-wrap text-muted-foreground",children:e.approval.preview}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(i.$,{variant:"destructive",onClick:()=>g({decision:"deny"}),disabled:m,children:"Deny"}),(0,r.jsx)(i.$,{onClick:()=>g({decision:"allow"}),disabled:m,children:"Allow"})]})]}):null})})}},48484:(e,t,s)=>{"use strict";s.d(t,{PlanProvider:()=>d,j:()=>u});var r=s(95155),n=s(12115),a=s(73321),l=s(60292),i=s(99979);let o={pending:!1,proposedAt:0,tables:0,endpoints:0,features:0},c=(0,n.createContext)(null);function d({children:e}){let t=(0,a.useRouter)(),[s,u]=(0,n.useState)(o),h=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/plan",{method:"GET",cache:"no-store",headers:(0,l.dh)((0,i.X0)())});if(!e.ok)return;let t=await e.json();u(t)}catch{}},[]);(0,n.useEffect)(()=>{h();let e=setInterval(()=>void h(),4e3);return()=>clearInterval(e)},[h]);let m=(0,n.useCallback)(async()=>{await fetch("/api/plan",{method:"DELETE",headers:(0,l.dh)((0,i.X0)())}).catch(()=>{}),u(o),t.refresh()},[t]),x=(0,n.useCallback)(async()=>{await fetch("/api/plan/approve",{method:"POST",headers:(0,l.dh)((0,i.X0)())}).catch(()=>{}),u(o),t.refresh()},[t]);return(0,r.jsx)(c.Provider,{value:{status:s,discard:m,approvePlan:x,refresh:h},children:e})}function u(){let e=(0,n.useContext)(c);if(!e)throw Error("usePlan must be used inside PlanProvider");return e}},52174:(e,t,s)=>{"use strict";s.d(t,{MainRegion:()=>n});var r=s(95155);function n({children:e}){return(0,r.jsx)("main",{className:"flex flex-1 flex-col",children:e})}},52965:(e,t,s)=>{"use strict";s.d(t,{_:()=>n});var r=s(95155);function n({size:e=18,className:t}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"20 22 56 56",fill:"none",className:t,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M48 33 L72.5 73 L23.5 73 Z",fill:"none",stroke:"var(--accent-2, #ff7a45)",strokeWidth:7,strokeLinejoin:"round",strokeLinecap:"round"}),(0,r.jsx)("circle",{cx:"48",cy:"29.5",r:"7",fill:"var(--accent-2, #ff7a45)"})]})}},59089:(e,t,s)=>{Promise.resolve().then(s.t.bind(s,66872,23)),Promise.resolve().then(s.bind(s,52174)),Promise.resolve().then(s.bind(s,42578)),Promise.resolve().then(s.bind(s,81998)),Promise.resolve().then(s.bind(s,81984)),Promise.resolve().then(s.bind(s,71886)),Promise.resolve().then(s.bind(s,434)),Promise.resolve().then(s.bind(s,48484)),Promise.resolve().then(s.bind(s,77242)),Promise.resolve().then(s.bind(s,10436)),Promise.resolve().then(s.bind(s,29510)),Promise.resolve().then(s.t.bind(s,35353,23)),Promise.resolve().then(s.t.bind(s,63494,23))},63494:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_c29908",variable:"__variable_c29908"}},66872:()=>{},71886:(e,t,s)=>{"use strict";s.d(t,{NotesDrawer:()=>P});var r=s(95155),n=s(12115),a=s(82879),l=s(2125),i=s(9005),o=s(30772);let c=(0,o.A)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),d=(0,o.A)("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var u=s(65738),h=s(82099),m=s(13439),x=s(95112),p=s(67357);let f=(0,o.A)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);var b=s(38332),g=s(8143),v=s(58309),j=s(5497),w=s(54682),N=s(93492);function k({value:e,onChange:t}){let s=(0,m.hG)({extensions:w.II,content:e?(0,w.Gd)(e):void 0,immediatelyRender:!1,editorProps:{attributes:{class:"note-prose focus:outline-none"}},onUpdate:({editor:e})=>t((0,w.Z2)(e.getJSON()))});return s?(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)(y,{editor:s}),(0,r.jsx)(m.$Z,{editor:s,className:"min-h-0 flex-1 overflow-y-auto px-1 py-2 text-[14px] leading-relaxed"})]}):null}function y({editor:e}){(0,N.U)(e);let t=()=>e.chain().focus();return(0,r.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-white/10 pb-2",children:[(0,r.jsx)(N.I,{label:"Bold",active:e.isActive("bold"),onClick:()=>t().toggleBold().run(),children:(0,r.jsx)(x.A,{className:"size-4"})}),(0,r.jsx)(N.I,{label:"Italic",active:e.isActive("italic"),onClick:()=>t().toggleItalic().run(),children:(0,r.jsx)(p.A,{className:"size-4"})}),(0,r.jsx)(N.I,{label:"Underline",active:e.isActive("underline"),onClick:()=>t().toggleUnderline().run(),children:(0,r.jsx)(f,{className:"size-4"})}),(0,r.jsx)(N.I,{label:"Strikethrough",active:e.isActive("strike"),onClick:()=>t().toggleStrike().run(),children:(0,r.jsx)(b.A,{className:"size-4"})}),(0,r.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,r.jsx)(N.I,{label:"Checklist",active:e.isActive("taskList"),onClick:()=>t().toggleTaskList().run(),children:(0,r.jsx)(g.A,{className:"size-4"})}),(0,r.jsx)(N.I,{label:"Bullet list",active:e.isActive("bulletList"),onClick:()=>t().toggleBulletList().run(),children:(0,r.jsx)(v.A,{className:"size-4"})}),(0,r.jsx)(N.I,{label:"Numbered list",active:e.isActive("orderedList"),onClick:()=>t().toggleOrderedList().run(),children:(0,r.jsx)(j.A,{className:"size-4"})})]})}var S=s(81984),C=s(91337);function A(e){return[...e].sort((e,t)=>e.pinned!==t.pinned?Number(t.pinned)-Number(e.pinned):t.updatedAt.localeCompare(e.updatedAt))}function P(){let{open:e,close:t}=(0,S.b)(),[s,o]=(0,n.useState)([]),[m,x]=(0,n.useState)(null),p=(0,n.useRef)({}),f=(0,n.useRef)({}),b=(0,n.useCallback)(e=>{clearTimeout(p.current[e]);let t=f.current[e];t&&(delete f.current[e],fetch(`/api/notes/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)}).catch(()=>{}))},[]),g=(0,n.useCallback)((e,t)=>{f.current[e]={...f.current[e],...t},clearTimeout(p.current[e]),p.current[e]=setTimeout(()=>b(e),500)},[b]),v=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/notes",{cache:"no-store"});if(!e.ok)return;let t=await e.json();o(A(t)),x(e=>e??t[0]?.id??null)}catch{}},[]);(0,n.useEffect)(()=>{e?v():Object.keys(f.current).forEach(b)},[e,v,b]);let j=(0,n.useCallback)(async()=>{let e=await fetch("/api/notes",{method:"POST"}).catch(()=>null);if(!e?.ok)return;let t=await e.json();o(e=>A([t,...e])),x(t.id)},[]),w=(0,n.useCallback)(async e=>{clearTimeout(p.current[e]),delete f.current[e],o(t=>{let s=t.filter(t=>t.id!==e);return x(t=>t===e?s[0]?.id??null:t),s}),await fetch(`/api/notes/${e}`,{method:"DELETE"}).catch(()=>{})},[]),N=(0,n.useCallback)((e,t)=>{o(s=>A(s.map(s=>s.id===e?{...s,...t,updatedAt:new Date().toISOString()}:s))),g(e,t)},[g]),y=(0,n.useCallback)(e=>N(e.id,{pinned:!e.pinned}),[N]),P=s.find(e=>e.id===m)??null;return(0,r.jsx)("div",{"aria-hidden":!e,className:(0,C.cn)("fixed inset-y-0 right-0 z-40 flex transition-transform duration-300 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),children:(0,r.jsxs)(h.b,{className:"flex h-full w-[420px] flex-col rounded-l-2xl border-l border-white/10",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-white/10 px-3 py-2.5",children:[(0,r.jsx)(a.A,{className:"size-4 text-[var(--accent-2,#ff7a45)]"}),(0,r.jsx)("span",{className:"text-sm font-semibold tracking-tight",children:"Notes"}),(0,r.jsx)("span",{className:"ml-auto"}),(0,r.jsx)("button",{type:"button",onClick:j,"aria-label":"New note",title:"New note",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,r.jsx)(l.A,{className:"size-4"})}),(0,r.jsx)("button",{type:"button",onClick:t,"aria-label":"Close notes",title:"Close",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,r.jsx)(i.A,{className:"size-4"})})]}),(0,r.jsx)("div",{className:"max-h-44 shrink-0 overflow-y-auto border-b border-white/10 p-1.5",children:0===s.length?(0,r.jsxs)("p",{className:"px-2 py-3 text-[13px] text-muted-foreground",children:["No notes yet. Hit ",(0,r.jsx)("span",{className:"text-foreground",children:"+"})," to start one."]}):s.map(e=>(0,r.jsxs)("div",{className:(0,C.cn)("group flex items-center gap-1 rounded-md px-2 py-1.5 text-[13px]",e.id===m?"bg-white/[0.09] text-foreground":"text-muted-foreground hover:bg-white/[0.04]"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>x(e.id),className:"min-w-0 flex-1 truncate text-left",children:[e.pinned&&(0,r.jsx)(c,{className:"mr-1 inline size-3 -translate-y-px"}),e.title||"Untitled"]}),(0,r.jsx)("button",{type:"button",onClick:()=>y(e),"aria-label":e.pinned?"Unpin":"Pin",title:e.pinned?"Unpin":"Pin",className:"rounded p-1 opacity-0 transition hover:bg-white/[0.08] hover:text-foreground group-hover:opacity-100",children:e.pinned?(0,r.jsx)(d,{className:"size-3.5"}):(0,r.jsx)(c,{className:"size-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>w(e.id),"aria-label":"Delete note",title:"Delete",className:"rounded p-1 opacity-0 transition hover:bg-white/[0.08] hover:text-red-300 group-hover:opacity-100",children:(0,r.jsx)(u.A,{className:"size-3.5"})})]},e.id))}),P?(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-3",children:[(0,r.jsx)("input",{value:P.title,onChange:e=>N(P.id,{title:e.target.value}),placeholder:"Untitled",className:"w-full bg-transparent text-base font-semibold tracking-tight text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),(0,r.jsx)(k,{value:P.body,onChange:e=>N(P.id,{body:e})},P.id)]}):(0,r.jsxs)("div",{className:"flex flex-1 items-center justify-center p-6 text-center text-[13px] text-muted-foreground",children:["Select a note, or create one. Then ",(0,r.jsx)("span",{className:"px-1 text-foreground",children:"@"}),"-mention it in your terminal to turn it into features."]})]})})}},77242:(e,t,s)=>{"use strict";s.d(t,{TabWorkspace:()=>l});var r=s(12115),n=s(73321),a=s(60292);function l(){let e=(0,n.useRouter)(),t=(0,n.usePathname)();return(0,r.useEffect)(()=>{let e=window.fetch;if(e.__beaconPinned)return;let t=(t,s)=>{try{let r=(0,a.fk)();if(r){let n=window.location.origin;if(t instanceof Request){if((0,a.q0)(t.url,n)&&!t.headers.has("x-beacon-workspace")){let n=new Headers(t.headers);return n.set("x-beacon-workspace",r),e(new Request(t,{headers:n}),s)}}else{let l="string"==typeof t?t:t.href;if((0,a.q0)(l,n)){let n=new Headers(s?.headers);if(!n.has("x-beacon-workspace"))return n.set("x-beacon-workspace",r),e(t,{...s,headers:n})}}}}catch{}return e(t,s)};return t.__beaconPinned=!0,window.fetch=t,()=>{window.fetch=e}},[]),(0,r.useEffect)(()=>{let s=new URLSearchParams(window.location.search).get("ws");if(s){try{sessionStorage.setItem(a.Bz,s)}catch{}return}let r=null;try{r=sessionStorage.getItem(a.Bz)}catch{}if(!r)return;let n=new URLSearchParams(window.location.search);n.set("ws",r),e.replace(`${t}?${n.toString()}`)},[t,e]),null}},81984:(e,t,s)=>{"use strict";s.d(t,{NotesProvider:()=>l,b:()=>i});var r=s(95155),n=s(12115);let a=(0,n.createContext)(null);function l({children:e}){let[t,s]=(0,n.useState)(!1),i=(0,n.useCallback)(()=>s(!0),[]),o=(0,n.useCallback)(()=>s(!1),[]),c=(0,n.useCallback)(()=>s(e=>!e),[]),d=(0,n.useMemo)(()=>({open:t,openDrawer:i,close:o,toggle:c}),[t,i,o,c]);return(0,r.jsx)(a.Provider,{value:d,children:e})}function i(){let e=(0,n.useContext)(a);if(!e)throw Error("useNotes must be used inside NotesProvider");return e}},81998:(e,t,s)=>{"use strict";s.d(t,{LiveRefresh:()=>i});var r=s(12115),n=s(73321);let a={primed:!1,lastV:-1,lastNavSeq:-1};var l=s(60292);function i(){let e=(0,n.useRouter)();return(0,r.useEffect)(()=>{let t=(0,l.fk)(),s=new EventSource(t?`/api/stream?ws=${encodeURIComponent(t)}`:"/api/stream"),r=a;return s.onopen=()=>{r=a},s.onmessage=t=>{var s,n;let a;try{a=JSON.parse(t.data)}catch{e.refresh();return}let{state:l,action:i}=(s=r,n={v:"number"==typeof a.v?a.v:0,navSeq:a.nav?.seq??0,navPath:a.nav?.path??""},s.primed?n.navSeq!==s.lastNavSeq?{state:{primed:!0,lastV:n.v,lastNavSeq:n.navSeq},action:{kind:"push",path:n.navPath}}:n.v!==s.lastV?{state:{...s,lastV:n.v},action:{kind:"refresh"}}:{state:s,action:{kind:"none"}}:{state:{primed:!0,lastV:n.v,lastNavSeq:n.navSeq},action:{kind:"none"}});if(r=l,"refresh"===i.kind)e.refresh();else if("push"===i.kind&&i.path){e.push(i.path);try{window.focus()}catch{}}},()=>s.close()},[e]),(0,r.useEffect)(()=>{let e=(0,l.fk)(),t=()=>{"visible"===document.visibilityState&&document.hasFocus()&&fetch("/api/tab/view",{method:"POST",headers:e?{"x-beacon-workspace":e}:void 0}).catch(()=>{})};t();let s=setInterval(t,3e3);return window.addEventListener("focus",t),document.addEventListener("visibilitychange",t),()=>{clearInterval(s),window.removeEventListener("focus",t),document.removeEventListener("visibilitychange",t)}},[]),null}},82879:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(30772).A)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]])},90467:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(30772).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},99979:(e,t,s)=>{"use strict";function r(){return new URLSearchParams(window.location.search).get("ws")}function n(){return new URLSearchParams(window.location.search).get("plan")}function a(e){let t=new URLSearchParams,s=r();s&&t.set("ws",s);let a=n();for(let[s,r]of(a&&t.set("plan",a),Object.entries(e??{})))""===r?t.delete(s):t.set(s,r);let l=t.toString();return l?`/plan?${l}`:"/plan"}s.d(t,{X0:()=>r,d8:()=>n,rc:()=>a})}},e=>{e.O(0,[7513,7352,5004,277,8500,4888,7424,9887,3908,8441,3794,7358],()=>e(e.s=59089)),_N_E=e.O()}]);