trybeacon 0.1.20 → 0.1.22

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 (98) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +15 -15
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/_not-found.html +1 -1
  16. package/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/.next/server/app/api/init/route.js +1 -1
  24. package/.next/server/app/api/map/start/route.js +1 -1
  25. package/.next/server/app/api/nodes/subtasks/route.js +1 -1
  26. package/.next/server/app/api/plan/annotations/route.js +1 -1
  27. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  28. package/.next/server/app/docs.html +1 -1
  29. package/.next/server/app/docs.rsc +2 -2
  30. package/.next/server/app/docs.segments/_full.segment.rsc +2 -2
  31. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  32. package/.next/server/app/docs.segments/_index.segment.rsc +2 -2
  33. package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  34. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  35. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  36. package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
  37. package/.next/server/app/feedback.html +1 -1
  38. package/.next/server/app/feedback.rsc +2 -2
  39. package/.next/server/app/feedback.segments/_full.segment.rsc +2 -2
  40. package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
  41. package/.next/server/app/feedback.segments/_index.segment.rsc +2 -2
  42. package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
  43. package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
  44. package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
  45. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  46. package/.next/server/app/help.html +1 -1
  47. package/.next/server/app/help.rsc +2 -2
  48. package/.next/server/app/help.segments/_full.segment.rsc +2 -2
  49. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  50. package/.next/server/app/help.segments/_index.segment.rsc +2 -2
  51. package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
  52. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
  53. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  54. package/.next/server/app/index.html +1 -1
  55. package/.next/server/app/index.rsc +2 -2
  56. package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  57. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  58. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  59. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  60. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  61. package/.next/server/app/map/page.js +2 -2
  62. package/.next/server/app/map/page.js.nft.json +1 -1
  63. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  64. package/.next/server/app/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/plan/page.js +2 -2
  66. package/.next/server/app/plan/page.js.nft.json +1 -1
  67. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  68. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  69. package/.next/server/app-paths-manifest.json +15 -15
  70. package/.next/server/chunks/1130.js +1 -1
  71. package/.next/server/chunks/249.js +1 -1
  72. package/.next/server/chunks/5680.js +1 -0
  73. package/.next/server/middleware-build-manifest.js +1 -1
  74. package/.next/server/pages/404.html +1 -1
  75. package/.next/server/pages/500.html +1 -1
  76. package/.next/server/server-reference-manifest.js +1 -1
  77. package/.next/server/server-reference-manifest.json +1 -1
  78. package/.next/static/chunks/4779-6218ea303266aff3.js +1 -0
  79. package/.next/static/chunks/app/map/{page-d7c8e5236784398e.js → page-bd036db25a148fb3.js} +1 -1
  80. package/.next/static/chunks/app/plan/page-2aa7eb766eb1c2e3.js +1 -0
  81. package/.next/static/css/d41569044c50aaaf.css +1 -0
  82. package/.next/trace +37 -37
  83. package/.next/trace-build +1 -1
  84. package/dist/bin/doctor.js +4 -2
  85. package/dist/bin/hook.js +4 -2
  86. package/dist/bin/mcp.js +14 -12
  87. package/dist/bin/plan.js +4 -2
  88. package/dist/bin/uninstall.js +4 -2
  89. package/dist/lib/assets.js +4 -2
  90. package/dist/lib/codex-install.js +4 -2
  91. package/dist/lib/global-install.js +4 -2
  92. package/package.json +1 -1
  93. package/.next/server/chunks/9419.js +0 -1
  94. package/.next/static/chunks/8207-ec49c6e4ab8a4bab.js +0 -1
  95. package/.next/static/chunks/app/plan/page-64a53d9f43b74c26.js +0 -1
  96. package/.next/static/css/13ab752f24b58903.css +0 -1
  97. /package/.next/static/{gS_xE1cqbYifs05Z7A-hH → 08EMrNjd1iA9NlOduqVQX}/_buildManifest.js +0 -0
  98. /package/.next/static/{gS_xE1cqbYifs05Z7A-hH → 08EMrNjd1iA9NlOduqVQX}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8207],{4474:(e,t,n)=>{n.d(t,{$:()=>l});var a=n(95155),s=n(6539),r=n(18460),o=n(91337);let i=(0,r.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:n="default",...r}){return(0,a.jsx)(s.Button,{"data-slot":"button",className:(0,o.cn)(i({variant:t,size:n,className:e})),...r})}},17918:(e,t,n)=>{n.d(t,{Sh:()=>c,V5:()=>d,e0:()=>m});var a=n(95155),s=n(12115),r=n(81750),o=n(6266),i=n(9005),l=n(91337);let d="#ff7a45";function c({data:e,selected:t}){let[n,u]=(0,s.useState)(e.text);return(0,s.useEffect)(()=>{u(e.text)},[e.text]),(0,a.jsxs)("div",{onClick:()=>e.onClick?.(e.annotationId),className:(0,l.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)(r.h7,{type:"target",id:"in",position:o.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)(i.A,{className:"size-3"})})]}),e.editable?(0,a.jsx)("textarea",{value:n,autoFocus:!e.text.trim(),placeholder:"Type your annotation…",rows:Math.max(2,Math.min(6,n.split("\n").length)),onChange:e=>u(e.target.value),onBlur:()=>{n!==e.text&&e.onChangeText?.(e.annotationId,n)},onKeyDown:e=>e.stopPropagation(),className:"nodrag nopan mt-1.5 w-full resize-none bg-transparent text-[13px] leading-snug text-foreground/95 outline-none placeholder:text-muted-foreground/60"}):(0,a.jsx)("div",{className:"mt-1.5 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)(r.h7,{type:"source",id:`pin-${t}`,position:o.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 m({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:()=>i,e6:()=>r,qA:()=>s,ru:()=>o});let a={auth:"#4ea1ff",firms:"#c792ea",search:"#7bd389",storage:"#ffb86b",petitions:"#ff7a45",monitoring:"#f5b942",admin:"#ff6b9d"};function s(e){return e&&a[e]||"#8a8a8a"}let r={GET:"#7bd389",POST:"#4ea1ff",PUT:"#ffb86b",PATCH:"#ffb86b",DELETE:"#ff3860"},o={read:"#4ea1ff",write:"#ffb86b","read-write":"#c792ea"};function i(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}},26518:(e,t,n)=>{n.d(t,{bq:()=>w,eb:()=>C,gC:()=>k,l6:()=>j,yv:()=>N});var a=n(95155);n(12115);var s=n(40595),r=n(41294),o=n(75681),i=n(17314),l=n(37265),d=n(23107),c=n(70826),u=n(67564),m=n(1938),p=n(15433),x=n(5919),h=n(45450),f=n(88988),g=n(91337),b=n(12363),v=n(64577),y=n(94088);let j=s.H;function N({className:e,...t}){return(0,a.jsx)(r.y,{"data-slot":"select-value",className:(0,g.cn)("flex flex-1 text-left",e),...t})}function w({className:e,size:t="default",children:n,...s}){return(0,a.jsxs)(o.b,{"data-slot":"select-trigger","data-size":t,className:(0,g.cn)("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[n,(0,a.jsx)(i.w,{render:(0,a.jsx)(b.A,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function k({className:e,children:t,side:n="bottom",sideOffset:s=4,align:r="center",alignOffset:o=0,alignItemWithTrigger:i=!0,...m}){return(0,a.jsx)(l.V,{children:(0,a.jsx)(d.l,{side:n,sideOffset:s,align:r,alignOffset:o,alignItemWithTrigger:i,className:"isolate z-50",children:(0,a.jsxs)(c.t,{"data-slot":"select-content","data-align-trigger":i,className:(0,g.cn)("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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),...m,children:[(0,a.jsx)(E,{}),(0,a.jsx)(u.B,{children:t}),(0,a.jsx)(S,{})]})})})}function C({className:e,children:t,...n}){return(0,a.jsxs)(m.e,{"data-slot":"select-item",className:(0,g.cn)("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[(0,a.jsx)(p.h,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),(0,a.jsx)(x.h,{render:(0,a.jsx)("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:(0,a.jsx)(v.A,{className:"pointer-events-none"})})]})}function E({className:e,...t}){return(0,a.jsx)(h.w,{"data-slot":"select-scroll-up-button",className:(0,g.cn)("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:(0,a.jsx)(y.A,{})})}function S({className:e,...t}){return(0,a.jsx)(f.d,{"data-slot":"select-scroll-down-button",className:(0,g.cn)("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:(0,a.jsx)(b.A,{})})}},26856:(e,t,n)=>{n.d(t,{DbMapClient:()=>es});var a=n(95155),s=n(12115),r=n(73321),o=n(81750),i=n(6266);n(53255);var l=n(32133),d=n(81499),c=n(51128),u=n(65738),m=n(9005),p=n(2125),x=n(91337),h=n(18874);let f=(0,s.createContext)(null);function g(){let e=(0,s.useContext)(f);if(!e)throw Error("useDbEdit must be used inside DbEditContext");return e}var b=n(95635),v=n(17918);let y={danger:"bg-red-500/15 text-red-300",warn:"bg-amber-500/15 text-amber-300"};function j({badges:e,className:t}){return e.length?(0,a.jsx)("span",{className:(0,x.cn)("flex shrink-0 items-center gap-0.5",t),children:e.map(e=>(0,a.jsx)("span",{title:e.title,className:(0,x.cn)("rounded px-1 text-[8px] font-semibold uppercase tracking-wide",y[e.tone]),children:e.label},e.label))}):null}let N=/pass(word)?|token|secret|api[_-]?key|credential|priv(ate)?[_-]?key|hash|salt/i,w=/auth|login|logout|session|token|password|oauth|sso|credential/i,k="nodrag nopan",C=b.x;function E({onClick:e,title:t}){return(0,a.jsx)("button",{type:"button",title:t,onClick:t=>{t.stopPropagation(),e()},className:(0,x.cn)(k,"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)(l.A,{className:"size-3"})})}function S({c:e,fkTargets:t}){let n=t?.[e.name];return(0,a.jsx)("span",{className:"ml-auto shrink-0 truncate font-mono text-[11px] text-muted-foreground/80",children:n?(0,a.jsxs)(a.Fragment,{children:["→\xa0",n]}):e.type})}let A="nodrag nopan",T=["GET","POST","PUT","PATCH","DELETE"];var z=n(54698),I=n(82099),D=n(4474);let R=[{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 $({draftGraph:e}){let[t,n]=(0,s.useState)(null);if(0===e.tables.length)return null;async function r(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:"}),R.map(e=>(0,a.jsx)(D.$,{size:"sm",variant:"outline",className:"h-6 px-2 text-[11px]",onClick:()=>r(e),children:t===e.id?"✓":e.label},e.id))]})]})}function M({selected:e,tables:t,relations:n,endpoints:s,draftGraph:r,onClose:o,commentsContent:i,commentsCount:d=0,activeTab:c,onTabChange:u,onAddComment:p,topOffset:x}){let h,f,g=new Map(t.map(e=>[e.id,e.name])),b=!!i,v=c??"details",y=e?.kind==="table"?t.find(t=>t.id===e.id)?.name??null:e?.kind==="endpoint"&&(f=s.find(t=>t.id===e.id))?`${f.method} ${f.path}`:null;if(e?.kind==="table"){let r=t.find(t=>t.id===e.id);h=r?(0,a.jsx)(O,{table:r,relations:n,endpoints:s,nameById:g}):null}else if(e?.kind==="endpoint"){let t=s.find(t=>t.id===e.id);h=t?(0,a.jsx)(F,{ep:t,nameById:g}):null}else h=(0,a.jsx)(L,{tables:t,relations:n,endpoints:s});return(0,a.jsxs)(I.b,{className:"absolute bottom-3 right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:x??12},children:[b?(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)(P,{active:"details"===v,onClick:()=>u?.("details"),children:"Details"}),(0,a.jsxs)(P,{active:"comments"===v,onClick:()=>u?.("comments"),children:["Comments",d>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:d})]})]}),(0,a.jsx)("button",{onClick:o,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)(m.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:o,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(m.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:"comments"===v&&b?(0,a.jsx)("div",{className:"p-3",children:i}):(0,a.jsxs)(a.Fragment,{children:[r.tables.length>0&&(0,a.jsx)("div",{className:"border-b border-white/10 p-3.5",children:(0,a.jsx)($,{draftGraph:r})}),(0,a.jsxs)("div",{className:"p-4",children:[p&&y&&(0,a.jsxs)("button",{type:"button",onClick:()=>p(y),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)(l.A,{className:"size-3.5"}),"Comment on this ",e?.kind==="endpoint"?"endpoint":"table"]}),h]})]})})]})}function P({active:e,onClick:t,children:n}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,x.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 O({table:e,relations:t,endpoints:n,nameById:s}){let r=t.filter(t=>t.fromTableId===e.id),o=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,h.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)(_,{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)(d.A,{className:"size-3 text-amber-400"}):e.isFk?(0,a.jsx)(c.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))})}),r.length>0&&(0,a.jsx)(_,{title:"References (FK out)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:r.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[e.fromColumn," → ",s.get(e.toTableId),".",e.toColumn]},e.id))})}),o.length>0&&(0,a.jsx)(_,{title:"Referenced by (FK in)",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:[s.get(e.fromTableId),".",e.fromColumn]},e.id))})}),i.length>0&&(0,a.jsx)(_,{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:h.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:h.ru[t.access]},children:t.access})]},e.id))})})]})}function F({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:`${h.e6[e.method]}22`,color:h.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)(_,{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:h.ru[e.access]},children:e.access})]},e.tableId))})})]})}function L({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)(B,{label:"tables",value:e.length}),(0,a.jsx)(B,{label:"FKs",value:t.length}),(0,a.jsx)(B,{label:"endpoints",value:n.length})]}),(0,a.jsx)(_,{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)(d.A,{className:"size-3 text-amber-400"})," primary key"]}),(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(c.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 _({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 B({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 H=n(56614),U=n(62311);let K=new Set(["GET","HEAD","OPTIONS"]),G=e=>e.trim().toLowerCase();var X=n(85618),W=n(80846),Y=n(17356),Z=n(45486),J=n(15330),V=n(60976),q=n(64577),Q=n(57144);let ee={dbTable:function({id:e,data:t,selected:n}){var r;let o,i,l="DRAFT"===t.source,f="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",b="added"===t.diffStatus?"new":"modified"===t.diffStatus?"changed":"draft",y=t.diffChanges?.length?t.diffChanges.join("\n"):"draft",w=l?f:(0,h.qA)(t.domain),A=(r={domain:t.domain,columns:t.columns},o=[],(i=r.columns.filter(e=>N.test(e.name)).map(e=>e.name)).length&&o.push({label:"secrets",tone:"danger",title:`stores credentials: ${i.join(", ")}`}),r.domain&&/auth/i.test(r.domain)&&o.push({label:"auth",tone:"warn",title:"auth-domain table"}),o),T=g(),[z,I]=(0,s.useState)(t.name),[D,R]=(0,s.useState)(t.columns),[$,M]=(0,s.useState)(!1);(0,s.useEffect)(()=>{I(t.name),R(t.columns)},[t.rev]);let P=e=>e.stopPropagation(),O=t=>{R(t),T.patchTable(e,{columns:t})},F=(t.pins??[]).filter(e=>null===e.column),L=e=>(t.pins??[]).filter(t=>t.column===e),_=(0,x.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)]");return l?(0,a.jsxs)("div",{className:(0,x.cn)(_,"group/card w-[252px]"),style:{borderColor:`${f}59`},children:[(0,a.jsx)(C,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-1.5 rounded-t-[11px] px-3 py-2",style:{background:`${f}14`},children:[(0,a.jsx)("input",{value:z,onChange:e=>I(e.target.value),onBlur:()=>{let n=z.trim();n&&n!==t.name&&T.patchTable(e,{name:n})},onKeyDown:e=>{P(e),"Enter"===e.key&&e.currentTarget.blur()},placeholder:"table",className:(0,x.cn)(k,"min-w-0 flex-1 bg-transparent font-mono text-[13px] font-semibold tracking-tight outline-none")}),(0,a.jsx)(j,{badges:A}),(0,a.jsx)("span",{title:y,className:"shrink-0 rounded-md border px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em]",style:{background:`${f}1f`,borderColor:`${f}55`,color:f},children:b}),(0,a.jsx)("button",{type:"button",onClick:t=>{P(t),$?T.deleteTable(e):M(!0)},onBlur:()=>M(!1),title:"Delete table",className:(0,x.cn)(k,"shrink-0 transition-all",$?"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"})}),F.length>0?(0,a.jsx)(v.e0,{pins:F,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:[D.map((e,n)=>{let s=L(e.name);return(0,a.jsxs)("div",{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=>{P(e),O(D.map((e,t)=>t===n?{...e,isPk:!e.isPk}:e))},title:"Primary key",className:(0,x.cn)(k,"shrink-0",e.isPk?"text-amber-300/90":"text-muted-foreground/40 hover:text-amber-300"),children:(0,a.jsx)(d.A,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{P(e),O(D.map((e,t)=>t===n?{...e,isFk:!e.isFk}:e))},title:"Foreign key",className:(0,x.cn)(k,"shrink-0",e.isFk?"text-sky-400/80":"text-muted-foreground/40 hover:text-sky-400"),children:(0,a.jsx)(c.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:()=>O(D),onKeyDown:P,placeholder:"column",className:(0,x.cn)(k,"min-w-0 flex-1 bg-transparent font-mono outline-none")}),t.fkTargets?.[e.name]?(0,a.jsxs)("span",{className:"w-16 shrink-0 truncate text-right font-mono text-[11px] text-muted-foreground/80",children:["→\xa0",t.fkTargets[e.name]]}):(0,a.jsx)("input",{value:e.type,onChange:e=>R(t=>t.map((t,a)=>a===n?{...t,type:e.target.value}:t)),onBlur:()=>O(D),onKeyDown:P,placeholder:"type",className:(0,x.cn)(k,"w-16 shrink-0 bg-transparent text-right font-mono text-[11px] text-muted-foreground/80 outline-none")}),(0,a.jsx)("button",{type:"button",onClick:e=>{P(e),O(D.filter((e,t)=>t!==n))},title:"Remove column",className:(0,x.cn)(k,"shrink-0 text-muted-foreground/40 opacity-0 transition-opacity hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(m.A,{className:"size-3"})}),s.length>0?(0,a.jsx)(v.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=>{P(e),O([...D,{name:"",type:"text",isPk:!1,isFk:!1,nullable:!0,note:null}])},className:(0,x.cn)(k,"flex w-full items-center gap-1 px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(p.A,{className:"size-3"})," column"]})]})]}):(0,a.jsxs)("div",{className:(0,x.cn)(_,"w-[240px]"),style:{borderColor:`${w}3d`},children:[(0,a.jsx)(C,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center justify-between rounded-t-[11px] px-3 py-2",style:{background:`${w}14`},children:[(0,a.jsxs)("span",{className:"flex 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 rounded-full bg-emerald-400"}),t.name]}),(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(j,{badges:A}),t.domain&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-[0.14em]",style:{color:w},children:t.domain})]}),F.length>0?(0,a.jsx)(v.e0,{pins:F,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=L(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)(d.A,{className:"size-3 shrink-0 text-amber-300/90"}):e.isFk?(0,a.jsx)(c.A,{className:"size-3 shrink-0 text-sky-400/80"}):(0,a.jsx)("span",{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.name}),(0,a.jsx)(S,{c:e,fkTargets:t.fkTargets}),n.length>0?(0,a.jsx)(v.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)})})]})},endpoint:function({id:e,data:t,selected:n}){var r;let o,i=h.e6[t.method]??"#8a8a8a",d="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",f=(r={method:t.method,domain:t.domain,path:t.path},o=[],/^delete$/i.test(r.method.trim())&&o.push({label:"DELETE",tone:"danger",title:"destructive: deletes data"}),(r.domain&&/auth/i.test(r.domain)||w.test(r.path))&&o.push({label:"auth",tone:"warn",title:"auth-related endpoint"}),o),y=g(),[N,k]=(0,s.useState)(t.path),[C,E]=(0,s.useState)(!1);(0,s.useEffect)(()=>{k(t.path)},[t.rev]);let S=e=>e.stopPropagation();return(0,a.jsxs)("div",{className:(0,x.cn)("group relative flex w-[240px] 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",d?"border-dashed":"border-white/10",n&&"ring-2 ring-[var(--accent,#f5b942)]"),style:d?{borderColor:`${c}66`,background:`${c}0f`}:void 0,children:[(0,a.jsx)(b.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"}),d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:t.method,onChange:t=>y.patchEndpoint(e,{method:t.target.value}),onPointerDown:S,className:(0,x.cn)(A,"shrink-0 rounded bg-transparent text-[10px] font-bold outline-none"),style:{color:i},title:"Method",children:T.map(e=>(0,a.jsx)("option",{value:e,className:"bg-card text-foreground",children:e},e))}),(0,a.jsx)("input",{value:N,onChange:e=>k(e.target.value),onBlur:()=>{let n=N.trim();n&&n!==t.path&&y.patchEndpoint(e,{path:n})},onKeyDown:e=>{S(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,x.cn)(A,"min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none")}),(0,a.jsx)(j,{badges:f}),(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=>{S(t),C?y.deleteEndpoint(e):E(!0)},onBlur:()=>E(!1),title:"Delete",className:(0,x.cn)(A,"shrink-0 transition-colors",C?"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",{className:"min-w-0 flex-1 truncate font-mono text-[11px]",children:t.path}),(0,a.jsx)(j,{badges:f}),(0,a.jsx)("button",{type:"button",onClick:t=>{S(t),C?y.deleteRealEndpoint(e):E(!0)},onBlur:()=>E(!1),title:C?"Click again to delete":"Delete endpoint",className:(0,x.cn)(A,"shrink-0 opacity-0 transition-opacity group-hover:opacity-100",C?"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)(v.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Comment on ${t.method} ${t.path}`,onClick:e=>{S(e),t.onComment?.(`${t.method} ${t.path}`)},className:(0,x.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)(l.A,{className:"size-3"})})]})},annotation:v.Sh},et={deletable:Q.I},en="beacon:db-draft",ea={proposedAt:0,status:"pending",tables:[],relations:[],endpoints:[]};function es({tables:e,relations:t,endpoints:n,draft:l,workspaceId:d,embedded:c=!1,draftRef:m,onEdit:p,controlRef:g,commentsContent:b,commentsCount:y=0,onAddComment:j,annotations:N,onPinClick:w,onUpdateComment:k,onRemoveComment:C,boardAnnotations:E}){let S=(0,r.useRouter)(),[A,T]=(0,s.useState)(!0),[I,D]=(0,s.useState)(null),[R,$]=(0,s.useState)(null),[P,O]=(0,s.useState)(null),[F,L]=(0,s.useState)(!1),[_,B]=(0,s.useState)("details"),[Q,er]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(g)return g.current={open:()=>{L(!0),B("details")},close:()=>{L(!1),B("details")},openComments:()=>{L(!0),B("comments")}},()=>{g&&(g.current=null)}},[g]);let[eo,ei]=(0,s.useState)(new Set),[el,ed]=(0,s.useState)(new Set),[ec,eu]=(0,s.useState)(new Set),[em,ep]=(0,s.useState)(()=>({past:[],present:l??ea,future:[],rev:0,edited:!1})),ex=em.present,eh=(0,s.useCallback)(e=>{ep(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}})},[]),ef=(0,s.useCallback)(e=>{ep(t=>{let n=e(t.present);return n===t.present?t:{...t,present:n}})},[]),eg=(0,s.useCallback)(()=>ep(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),[]),eb=(0,s.useCallback)(()=>ep(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),[]),ev=(0,s.useCallback)(e=>ep(t=>({past:[],present:e,future:[],rev:t.rev+1,edited:!1})),[]),ey=(0,s.useRef)(!1),ej=l?.proposedAt??0;(0,s.useEffect)(()=>{let e=null;if(ey.current)l&&l.proposedAt!==ex.proposedAt?e=l:!l&&(ex.tables.length>0||ex.endpoints.length>0)&&(e=ea);else{ey.current=!0;let t=null;try{let e=localStorage.getItem(en);if(e){let n=JSON.parse(e);n.workspaceId===d&&n.doc&&l&&n.doc.proposedAt===l.proposedAt&&(t=n.doc)}}catch{}e=t??l??null}e&&ev(e)},[ej]),(0,s.useEffect)(()=>{try{ex.tables.length>0||ex.endpoints.length>0?localStorage.setItem(en,JSON.stringify({workspaceId:d,doc:ex})):localStorage.removeItem(en)}catch{}},[ex,d]),(0,s.useEffect)(()=>{m&&(m.current=ex)},[m,ex]);let eN=(0,s.useRef)(!1);(0,s.useEffect)(()=>{em.edited&&!eN.current&&(eN.current=!0,p?.())},[em.edited,p]);let ew=(0,s.useMemo)(()=>ex.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})),[ex]),ek=(0,s.useMemo)(()=>ex.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}))})),[ex]),eC=(0,s.useMemo)(()=>[...e,...ew],[e,ew]),eE=(0,s.useMemo)(()=>[...n,...ek],[n,ek]),eS=(0,s.useMemo)(()=>new Map,[]),eA=(0,s.useMemo)(()=>c?function(e,t){let n=new Map(e.map(e=>[G(e.name),e])),a=new Map;for(let e of t){let t=n.get(G(e.name));if(!t){a.set(e.id,{status:"added",changes:["new table"]});continue}let s=function(e,t){let n=new Map(e.map(e=>[G(e.name),e])),a=new Set(t.map(e=>G(e.name))),s=[];for(let e of t){let t=n.get(G(e.name));if(!t){s.push(`+ column ${e.name} (${e.type})`);continue}let a=[];G(t.type)!==G(e.type)&&a.push(`type ${t.type}→${e.type}`),t.isPk!==e.isPk&&a.push(e.isPk?"now PK":"no longer PK"),t.isFk!==e.isFk&&a.push(e.isFk?"now FK":"no longer FK"),t.nullable!==e.nullable&&a.push(e.nullable?"now nullable":"now required"),a.length&&s.push(`~ column ${e.name}: ${a.join(", ")}`)}for(let t of e)a.has(G(t.name))||s.push(`- column ${t.name}`);return s}(t.columns,e.columns);a.set(e.id,{status:s.length?"modified":"unchanged",changes:s})}return a}(e,ew):eS,[c,e,ew,eS]),eT=(0,s.useMemo)(()=>c?function(e,t){let n=e=>`${G(e.method)} ${G(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:[]}:{status:"added",changes:["new endpoint"]});return s}(n,ek):eS,[c,n,ek,eS]),ez=(0,s.useMemo)(()=>[...t,...ex.relations.map(e=>({id:e.id,fromTableId:e.fromTableId,toTableId:e.toTableId,fromColumn:e.fromColumn,toColumn:e.toColumn,label:e.label}))],[t,ex.relations]),eI=(0,s.useMemo)(()=>{let e=new Map;for(let t of eE)for(let n of t.tables)e.set(n.tableId,(e.get(n.tableId)??0)+1);return e},[eE]),eD=(0,s.useMemo)(()=>{let e=new Map;return eC.forEach(t=>e.set(t.id,t.x)),eE.forEach(t=>e.set(t.id,t.x)),e},[eC,eE]),eR=(0,s.useMemo)(()=>{let e=new Map(eC.map(e=>[e.id,e.name])),t=new Map;for(let n of ez){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},[ez,eC]),e$=void 0!==E,[eM,eP]=(0,s.useState)(E??[]);(0,s.useEffect)(()=>{E&&eP(E)},[E]);let eO=(0,s.useMemo)(()=>({tables:eC.map(e=>({id:e.id,name:e.name,columns:e.columns.map(e=>e.name)})),endpoints:eE.map(e=>({id:e.id,method:e.method,path:e.path}))}),[eC,eE]),eF=(0,s.useMemo)(()=>{if(e$){let e=new Set([...eC.map(e=>e.id),...eE.map(e=>e.id)]);return eM.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((N??[]).map(e=>[e.id,e.comment]));return(0,z.m)(N??[],eO).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,column:t.column,text:e.get(t.annotationId)??"",x:null,y:null}))},[e$,eM,N,eO,eC,eE]),eL=(0,s.useMemo)(()=>{let e=new Map;for(let t of eF){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:t.column}),e.set(t.targetId,n)}return e},[eF]),e_=(0,s.useMemo)(()=>new Map(eF.map(e=>[`anno-${e.id}`,e.targetId])),[eF]),eB=(0,s.useCallback)(async e=>{let t=(0,z.m)([{id:"_",excerpt:e}],eO)[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();eP(t=>[...t,e])}},[eO]),eH=(0,s.useCallback)((e,t)=>{eP(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)})},[]),eU=(0,s.useCallback)(e=>{eP(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),eK=e$?eB:j,eG=(0,s.useCallback)((e,t)=>(eD.get(e)??0)<=(eD.get(t)??0)?{sourceHandle:"sr",targetHandle:"tl"}:{sourceHandle:"sl",targetHandle:"tr"},[eD]),eX=(0,s.useMemo)(()=>new Set([...ex.tables.map(e=>e.id),...ex.endpoints.map(e=>e.id)]),[ex]),eW=(0,s.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),eY=(0,s.useCallback)(()=>{let e=eC.map(e=>({id:e.id,type:"dbTable",position:{x:e.x,y:e.y},data:{name:e.name,domain:e.domain,columns:e.columns,usageCount:eI.get(e.id)??0,source:e.source,rev:em.rev,diffStatus:eA.get(e.id)?.status,diffChanges:eA.get(e.id)?.changes,fkTargets:eR.get(e.id),pins:eL.get(e.id),onPinClick:w,onComment:eK}})),t=eE.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:em.rev,diffStatus:eT.get(e.id)?.status,diffChanges:eT.get(e.id)?.changes,pins:eL.get(e.id),onPinClick:w,onComment:eK}})),n=new Map,a=new Map(eC.map(e=>[e.id,e])),s=new Map(eE.map(e=>[e.id,e]));return[...e,...t,...eF.map(e=>{let t=a.get(e.targetId),r=s.get(e.targetId),o=t?.x??r?.x??0,i=t?.y??r?.y??0,l=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??o+26,y:e.y??i+l+64+112*d},data:{n:e.n,text:e.text,annotationId:e.id,onClick:e$||k?void 0:w,editable:e$||!!k,onChangeText:e$?(e,t)=>eH(e,{body:t}):k,onDelete:e$?eU:C}}})]},[eC,eE,eI,em.rev,eA,eT,eR,eL,eF,e$,w,k,C,eK,eH,eU]),[eZ,eJ,eV]=(0,o.ck)(eY());(0,s.useEffect)(()=>{eJ(e=>{let t=new Map(e.map(e=>[e.id,e.position]));return eY().map(e=>({...e,position:t.get(e.id)??e.position}))})},[eY,eJ]);let eq=(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})})},[]),eQ=(0,s.useCallback)((e,t)=>{let{x:n,y:a}=t.position;if(t.id.startsWith("anno-")){e$&&eH(t.id.slice(5),{x:n,y:a});return}eX.has(t.id)?ef(e=>e.tables.some(e=>e.id===t.id)?{...e,tables:e.tables.map(e=>e.id===t.id?{...e,x:n,y:a}:e)}:e.endpoints.some(e=>e.id===t.id)?{...e,endpoints:e.endpoints.map(e=>e.id===t.id?{...e,x:n,y:a}:e)}:e):eq("endpoint"===t.type?"endpoint":"table",t.id,n,a)},[eX,ef,eq,e$,eH]),e0=(0,s.useMemo)(()=>ez.map(e=>({id:`fk-${e.id}`,source:e.fromTableId,target:e.toTableId,...eG(e.fromTableId,e.toTableId),type:"deletable",label:e.label??void 0,markerEnd:{type:i.TG.ArrowClosed,color:"#6b6b6b"},style:{stroke:"#6b6b6b"}})),[ez,eG]),e1=(0,s.useMemo)(()=>eE.flatMap(e=>e.tables.map(t=>{let n=h.ru[t.access]??"#5a5a5a";return{id:`u-${e.id}-${t.tableId}`,source:e.id,target:t.tableId,...eG(e.id,t.tableId),type:"default",markerEnd:{type:i.TG.ArrowClosed,color:n},style:{stroke:n,strokeDasharray:"4 4",opacity:.7}}})),[eE,eG]),e5=(0,s.useMemo)(()=>A?[...e0,...e1]:e0,[e0,e1,A]),e2=(0,s.useMemo)(()=>eF.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"default",selectable:!1,zIndex:30,style:{stroke:v.V5,strokeWidth:1.5,opacity:.9}})),[eF]),e3=I?.id??P,e4=(0,s.useMemo)(()=>{if(R){let e=e5.find(e=>e.id===R);return e?new Set([e.source,e.target]):null}return e3?(0,h.F1)(e3,e5):null},[e3,R,e5]),e6=(0,s.useMemo)(()=>new Map(eC.map(e=>[e.id,{domain:e.domain,source:e.source}])),[eC]),e8=(0,s.useMemo)(()=>new Map(eE.map(e=>[e.id,{method:e.method,source:e.source}])),[eE]),e9=(0,s.useMemo)(()=>{let e=new Set;if(!A)for(let t of e8.keys())e.add(t);for(let[t,n]of e6)!eo.size||n.domain&&eo.has(n.domain)||e.add(t),el.size&&!el.has(n.source)&&e.add(t);for(let[t,n]of e8)ec.size&&!ec.has(n.method)&&e.add(t),el.size&&!el.has(n.source)&&e.add(t);return e},[A,e6,e8,eo,el,ec]),e7=(0,s.useMemo)(()=>eZ.map(e=>{if(e.id.startsWith("anno-")){let t=e_.get(e.id),n=!!t&&e9.has(t);return!!e.hidden!==n?{...e,hidden:n}:e}let t=e9.has(e.id);return e4?{...e,hidden:t,style:{...e.style,opacity:e4.has(e.id)?1:.45,transition:"opacity 120ms"}}:t?{...e,hidden:t}:e}),[eZ,e9,e4,e_]),te=(0,s.useMemo)(()=>e5.map(e=>{let t=e9.has(e.source)||e9.has(e.target);return e3||R?(R?e.id===R:e3&&(e.source===e3||e.target===e3))?{...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}}:t?{...e,hidden:t}:e}),[e5,e3,R,e9]),tt=(0,s.useMemo)(()=>Array.from(new Set(eC.map(e=>e.domain).filter(e=>!!e))).sort(),[eC]),tn=(0,s.useMemo)(()=>Array.from(new Set([...eC.map(e=>e.source),...eE.map(e=>e.source)])).sort(),[eC,eE]),ta=(0,s.useMemo)(()=>Array.from(new Set(eE.map(e=>e.method))).sort(),[eE]);function ts(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let tr=+!A+eo.size+el.size+ec.size,to=(0,s.useCallback)(()=>{T(!0),ei(new Set),ed(new Set),eu(new Set)},[]),ti=(0,s.useCallback)(e=>{let{source:t,target:n}=e;t&&n&&t!==n&&eh(e=>{if(!(e.tables.some(e=>e.id===n)||eW.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,K.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})},[eh,eW]),tl=(0,s.useMemo)(()=>({patchEndpoint:(e,t)=>eh(n=>({...n,endpoints:n.endpoints.map(n=>n.id===e?{...n,...t}:n)})),deleteEndpoint:e=>eh(t=>({...t,endpoints:t.endpoints.filter(t=>t.id!==e)})),patchTable:(e,t)=>eh(n=>({...n,tables:n.tables.map(n=>n.id===e?{...n,...t}:n)})),deleteTable:e=>eh(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&&S.refresh()})}}),[eh,S]);(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?eb():eg()):"y"===n&&(e.preventDefault(),eb())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eg,eb]);let td=(0,s.useCallback)(async()=>{er(!0);try{if((await fetch("/api/draft/approve",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(ex)})).ok){try{localStorage.removeItem(en)}catch{}ev(ea),S.refresh()}}finally{er(!1)}},[ex,ev,S]),tc=(0,s.useCallback)(async()=>{er(!0);try{await fetch("/api/draft",{method:"DELETE"})}catch{}try{localStorage.removeItem(en)}catch{}ev(ea),S.refresh(),er(!1)},[ev,S]),tu=(0,s.useMemo)(()=>{let e;return e=new Map(ex.tables.map(e=>[e.id,e.name])),{tables:ex.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:ex.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:ex.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}]:[]})}))}},[ex]),tm=ex.tables.length>0||ex.endpoints.length>0,tp=em.past.length>0,tx=em.future.length>0;return(0,a.jsx)(f.Provider,{value:tl,children:(0,a.jsxs)("div",{className:(0,x.cn)("canvas-dots relative w-full",c?"h-full":"h-screen"),children:[(0,a.jsxs)(o.Gc,{nodes:e7,edges:[...te,...e2.map(e=>({...e,hidden:e9.has(e.source)}))],nodeTypes:ee,edgeTypes:et,connectionMode:i.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onNodesChange:eV,onConnect:ti,onNodeMouseEnter:(e,t)=>{"annotation"!==t.type&&O(t.id)},onNodeMouseLeave:()=>O(null),onNodeClick:(e,t)=>{if("annotation"===t.type)return void w?.(t.data.annotationId);let n="endpoint"===t.type?"endpoint":"table";D({id:t.id,kind:n}),$(null),L(!0),B("details")},onEdgeClick:(e,t)=>{$(t.id),D(null)},onPaneClick:()=>{D(null),$(null)},onNodeDragStop:eQ,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-")||eX.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:["Backspace","Delete"],colorMode:"dark",fitView:!0,minZoom:.15,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(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"}),!c&&(0,a.jsx)(o.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:"#555"}),!c&&(0,a.jsx)(o.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,a.jsx)(U.Z,{active:"DATABASE",tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"FILES",label:"Files",href:"/map?view=FILES"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"}]})}),(0,a.jsxs)(o.Zk,{position:"top-right",className:(0,x.cn)("flex items-center gap-1 transition-[margin] duration-200",F&&"!mr-[332px]",c&&"hidden"),children:[(0,a.jsx)("button",{type:"button",title:"Arrange board — pack tables + endpoints side by side",disabled:Q,onClick:async()=>{er(!0);try{await fetch("/api/db/arrange",{method:"POST"}),S.refresh()}finally{er(!1)}},className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40",children:(0,a.jsx)(X.A,{className:"size-4"})}),(0,a.jsxs)(H.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,x.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||tr>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(W.A,{className:"size-4"}),tr>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:tr})]}),children:[(0,a.jsx)(H.r1,{title:"Show",children:(0,a.jsx)(H.vu,{tone:"accent",on:A,onClick:()=>T(e=>!e),children:"endpoints"})}),tt.length>0&&(0,a.jsx)(H.r1,{title:"Domain",children:tt.map(e=>(0,a.jsx)(H.vu,{on:eo.has(e),onClick:()=>ts(e,ei),children:e},e))}),ta.length>0&&(0,a.jsx)(H.r1,{title:"Method",children:ta.map(e=>(0,a.jsx)(H.vu,{on:ec.has(e),onClick:()=>ts(e,eu),children:e},e))}),tn.length>0&&(0,a.jsx)(H.r1,{title:"Source",children:tn.map(e=>(0,a.jsx)(H.vu,{on:el.has(e),onClick:()=>ts(e,ed),children:e.toLowerCase()},e))}),tr>0&&(0,a.jsx)("button",{type:"button",onClick:to,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)(H.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,x.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)(Y.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",{"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"})]})]})}),!F&&(0,a.jsx)("button",{onClick:()=>L(!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)(Z.A,{className:"size-4"})})]}),tm&&(0,a.jsxs)(o.Zk,{position:"bottom-center",className:"glass flex items-center gap-1 rounded-xl p-1.5",children:[(0,a.jsxs)("button",{onClick:eg,disabled:!tp,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)(J.A,{className:"size-3.5"})," undo"]}),(0,a.jsxs)("button",{onClick:eb,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)(V.A,{className:"size-3.5"})," redo"]}),!c&&(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:tc,disabled:Q,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:td,disabled:Q,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)(q.A,{className:"size-3.5"})," approve draft"]})]})]})]}),F&&(0,a.jsx)(M,{selected:I,tables:eC,relations:ez,endpoints:eE,draftGraph:tu,onClose:()=>{L(!1),B("details")},commentsContent:b,commentsCount:y,activeTab:_,onTabChange:B,onAddComment:eK,topOffset:c?64:void 0})]})})}},30210:(e,t,n)=>{n.d(t,{MapClient:()=>ej});var a=n(95155),s=n(12115),r=n(98112),o=n(6266),i=n(81750);n(53255);var l=n(17356),d=n(2125),c=n(68319),u=n(15480),m=n(65377),p=n(17494),x=n(80846),h=n(45486),f=n(73321),g=n(95635),b=n(17918),v=n(32133),y=n(65408),j=n(8962),N=n(84824),w=n(5736),k=n(86272),C=n(65738),E=n(40638),S=n(26518);let A=["PENDING","IN_PROGRESS","DONE","BLOCKED","CANCELLED","DEPRIORITIZED"],T=["KEEP","REBUILD","REPLACE","DROP"],z=["IN_PROGRESS","PENDING","BLOCKED","DONE","DEPRIORITIZED","CANCELLED"],I={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"}},D=["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"];function R(e){let t=(e??"").trim().toUpperCase();if(!t)return"bg-white/[0.06] text-muted-foreground";let n=0;for(let e=0;e<t.length;e++)n=31*n+t.charCodeAt(e)>>>0;return D[n%D.length]}let $=(0,s.createContext)(null);var M=n(60874),P=n(91337);let O=[{v:0,l:"P0 \xb7 critical"},{v:1,l:"P1 \xb7 high"},{v:2,l:"P2 \xb7 medium"},{v:3,l:"P3 \xb7 low"}],F="nodrag nopan";function L({nodeId:e}){let t=(0,f.useRouter)(),[n,r]=(0,s.useState)(!1),[o,i]=(0,s.useState)(""),[l,d]=(0,s.useState)(!1),u=()=>{r(!1),i("")},m=async()=>{let n=o.trim();if(n&&!l){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&&(u(),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(),r(e=>!e)},className:(0,P.cn)(F,"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)(c.A,{className:"size-3"})}),n&&(0,a.jsxs)("div",{onClick:e=>e.stopPropagation(),className:(0,P.cn)(F,"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)(c.A,{className:"size-3"})," Flag a bug"]}),(0,a.jsx)("button",{type:"button",title:"Cancel",onClick:u,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:o,placeholder:"What did you find?",onChange:e=>i(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&u(),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m())},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:l||!o.trim(),onClick:()=>void m(),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:l?"Flagging…":"Flag bug"})]})]})}function _({id:e,data:t,selected:n}){let{categories:r,statuses:o,patch:i,isExpanded:l,toggleExpand:d,openDetailed:u,removeNode:m,editingTitleId:p,onAskAgent:x}=function(){let e=(0,s.useContext)($);if(!e)throw Error("useNodeEdit must be used inside NodeEditContext");return e}(),f=l(e),[A,T]=(0,s.useState)(!1),[z,D]=(0,s.useState)(!1),[B,H]=(0,s.useState)(t.title),[U,K]=(0,s.useState)(t.cluster??""),[G,X]=(0,s.useState)(t.plain??""),W=0===t.priority,Y="BUG"===t.kind&&"ROADMAP"===t.view,Z="ARCHITECTURE"===t.view,J=t.openBugs??0,V="CANCELLED"===t.status||"DROP"===t.status,q="DEPRIORITIZED"===t.status,Q="DRAFT"===t.source,ee="IN_PROGRESS"===t.status,et="INIT"===t.source&&"ROADMAP"===t.view,en=e=>e.stopPropagation();return(0,a.jsxs)("div",{className:(0,P.cn)("group/nc relative rounded-lg border bg-card px-2.5 py-2 text-card-foreground shadow-sm transition",f?"w-80":"w-64",Q?"border-dashed border-sky-400/50 bg-sky-500/[0.06]":et?"border-dashed border-violet-400/60 bg-violet-500/[0.07] shadow-[0_0_0_1px_rgba(167,139,250,0.18)]":W?"border-[#ff3860]/60 shadow-[0_0_0_1px_rgba(255,56,96,0.15)]":"border-border",Y&&!Q&&"border-rose-400/50 bg-rose-500/[0.05]",ee&&"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)]",n&&"ring-2 ring-[var(--accent,#f5b942)]",V&&"opacity-60",q&&"opacity-70 border-dashed"),children:[(0,a.jsx)(g.x,{}),Z&&(0,a.jsx)(L,{nodeId:e}),(t.pins?.length??0)>0?(0,a.jsx)(b.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Annotate ${t.title}`,onClick:e=>{en(e),t.onComment?.(t.title)},className:(0,P.cn)(F,"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)(v.A,{className:"size-3"})}),t.isNext&&(0,a.jsx)("div",{className:"mb-1 inline-flex items-center gap-1 rounded bg-emerald-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-emerald-300",children:"work on next"}),(0,a.jsxs)("div",{className:"flex items-start gap-1.5",children:[ee&&(0,a.jsx)("span",{title:"em andamento",className:"mt-1.5 inline-block size-2 shrink-0 animate-pulse rounded-full bg-sky-400"}),t.isCriterion&&!ee&&(0,a.jsx)("span",{title:"Success criterion",className:"mt-1.5 inline-block size-1.5 shrink-0 rounded-full bg-[var(--accent,#f5b942)]"}),(0,a.jsx)("textarea",{rows:1,value:B,autoFocus:p===e,placeholder:"Title…",onFocus:t=>{p===e&&t.currentTarget.select()},onChange:e=>H(e.target.value),onBlur:()=>{let n=B.trim();n&&n!==t.title&&i(e,{title:n},!0)},onKeyDown:e=>{en(e),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())},className:(0,P.cn)(F,"field-sizing-content w-full resize-none bg-transparent text-sm font-medium leading-snug outline-none placeholder:text-muted-foreground/60",V&&"line-through")}),(0,a.jsx)("button",{type:"button",onClick:t=>{en(t),d(e)},title:f?"Collapse":"Expand",className:(0,P.cn)(F,"mt-0.5 shrink-0 text-muted-foreground hover:text-foreground"),children:f?(0,a.jsx)(y.A,{className:"size-3.5"}):(0,a.jsx)(j.A,{className:"size-3.5"})})]}),((t.signals?.untested??0)>0||t.signals?.auth||J>0)&&(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[J>0&&(0,a.jsxs)("span",{title:`${J} open bug flag(s) — raised by you or an agent examining this code`,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)(c.A,{className:"size-2.5"}),J," ",1===J?"bug":"bugs"]}),(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)(N.A,{className:"size-2.5"}),t.signals.untested," 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"]})]}),t.role&&(0,a.jsx)("div",{className:(0,P.cn)("mt-0.5 text-[10px] leading-snug text-muted-foreground",!f&&"line-clamp-1"),children:t.role}),(0,a.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:["ROADMAP"===t.view?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{title:Y?"Bug — something to fix":t.isChild?"Sub-task of a feature":"Feature — top-level roadmap item",className:(0,P.cn)("flex shrink-0 items-center gap-1 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide",Y?"bg-rose-500/15 text-rose-300":t.isChild?"bg-zinc-500/15 text-zinc-300":"bg-sky-500/15 text-sky-300"),children:[Y&&(0,a.jsx)(c.A,{className:"size-2.5"}),Y?"bug":t.isChild?"sub-task":"feature"]}),et&&(0,a.jsxs)("span",{className:"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",children:[(0,a.jsx)(k.A,{className:"size-2.5"})," IA"]}),(0,a.jsx)("input",{list:`cats-${e}`,value:U,placeholder:"category",onChange:e=>K(e.target.value),onBlur:()=>{let n=U.trim()||null;n!==(t.cluster??null)&&i(e,{cluster:n},!0)},onKeyDown:e=>{en(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,P.cn)(F,"field-sizing-content min-w-12 max-w-[65%] rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide outline-none focus:brightness-125 [&::-webkit-calendar-picker-indicator]:hidden",R(U))})]}):(0,a.jsxs)(a.Fragment,{children:[t.isChild&&(0,a.jsx)("span",{title:"Sub-component",className:"shrink-0 rounded bg-zinc-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-zinc-300",children:"sub"}),(0,a.jsx)("input",{list:`cats-${e}`,value:U,placeholder:"domain",title:"Architecture domain — the lane this component lives in",onChange:e=>K(e.target.value),onBlur:()=>{let n=U.trim()||null;n!==(t.cluster??null)&&i(e,{cluster:n},!0)},onKeyDown:e=>{en(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,P.cn)(F,"field-sizing-content min-w-12 max-w-[65%] rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide outline-none focus:brightness-125 [&::-webkit-calendar-picker-indicator]:hidden",R(U))})]}),(0,a.jsx)("datalist",{id:`cats-${e}`,children:r.map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsxs)(S.l6,{value:t.status,onValueChange:t=>i(e,{status:t},!0),children:[(0,a.jsx)(S.bq,{className:(0,P.cn)(F,"ml-auto h-6 shrink-0 gap-1 rounded border px-1.5 py-0 text-[10px] font-medium",I[t.status]?.className??"border-white/10"),children:(0,a.jsx)(S.yv,{children:e=>I[e]?.label??e})}),(0,a.jsx)(S.gC,{alignItemWithTrigger:!1,children:o.map(e=>(0,a.jsx)(S.eb,{value:e,children:I[e]?.label??e},e))})]})]}),f&&(0,a.jsxs)("div",{className:"mt-2 space-y-2 border-t border-white/10 pt-2",children:[z||!G.trim()?(0,a.jsx)("textarea",{autoFocus:z,value:G,placeholder:"Description (markdown)…",onChange:e=>X(e.target.value),onBlur:()=>{D(!1);let n=G.trim()||null;n!==(t.plain??null)&&i(e,{plain:n},!0)},onKeyDown:en,rows:3,className:(0,P.cn)(F,"field-sizing-content max-h-[24rem] min-h-[4.5rem] w-full resize-y rounded bg-white/[0.04] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.08]")}):(0,a.jsx)("div",{onClick:e=>{en(e),D(!0)},title:"Click to edit",className:"cursor-text rounded bg-white/[0.02] px-1.5 py-1 text-xs hover:bg-white/[0.05]",children:(0,a.jsx)(M.pO,{markdown:G,variant:"compact",className:"text-[12px]"})}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)(S.l6,{value:String(t.priority),onValueChange:t=>i(e,{priority:Number(t)},!0),children:[(0,a.jsx)(S.bq,{className:(0,P.cn)(F,"h-6 gap-1 rounded border-white/10 px-1.5 py-0 text-[10px]"),children:(0,a.jsx)(S.yv,{children:e=>O.find(t=>String(t.v)===e)?.l??e})}),(0,a.jsx)(S.gC,{alignItemWithTrigger:!1,children:O.map(e=>(0,a.jsx)(S.eb,{value:String(e.v),children:e.l},e.v))})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsxs)("button",{type:"button",onClick:t=>{en(t),A?m(e):T(!0)},onBlur:()=>T(!1),title:"Delete node",className:(0,P.cn)(F,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] transition-colors",A?"bg-red-500/20 text-red-300":"text-muted-foreground hover:bg-white/5 hover:text-red-300"),children:[(0,a.jsx)(C.A,{className:"size-3"}),A&&"Delete?"]}),x&&(0,a.jsxs)("button",{type:"button",onClick:e=>{en(e),x(`feature: ${t.title}`)},title:"Ask the agent a question about this feature (answered in its next round)",className:(0,P.cn)(F,"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)(E.A,{className:"size-3"})," Ask"]}),(0,a.jsxs)("button",{type:"button",onClick:t=>{en(t),u(e)},className:(0,P.cn)(F,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-muted-foreground hover:bg-white/5 hover:text-foreground"),children:[(0,a.jsx)(h.A,{className:"size-3"})," Details"]})]})]})]})]})}var B=n(54698),H=n(57144),U=n(9005),K=n(82099),G=n(4474),X=n(70521),W=n(74350);function Y({className:e,type:t,...n}){return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,P.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})}function Z({className:e,...t}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,P.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 J=n(61388);function V({className:e,...t}){return(0,a.jsx)(J.b,{"data-slot":"label",className:(0,P.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})}var q=n(9339);let Q=(0,q.createServerReference)("40abd7201e6177a48960d6632593f5dd4fa0b30a4a",q.callServer,void 0,q.findSourceMapURL,"createNodeAction"),ee=(0,q.createServerReference)("60daa4623b6a1d47f7c7d529d8553f58934ca2e3b5",q.callServer,void 0,q.findSourceMapURL,"updateNodeAction");function et({open:e,onOpenChange:t,mode:n,view:r,heading:o,nodeId:i,parentId:l,position:d,defaults:c}){let u=(0,f.useRouter)(),[m,p]=(0,s.useState)(c?.title??""),[x,h]=(0,s.useState)(c?.role??""),[g,b]=(0,s.useState)(c?.plain??""),[v,y]=(0,s.useState)(c?.cluster??""),[j,N]=(0,s.useState)(c?.status??("ARCHITECTURE"===r?"REBUILD":"PENDING")),[w,k]=(0,s.useState)(c?.kind==="BUG"?"BUG":"FEATURE"),[C,E]=(0,s.useState)(!1),z="ARCHITECTURE"===r?T:A;async function D(){if(m.trim()){E(!0);try{"create"===n?await Q({view:r,..."ROADMAP"===r?{kind:w}:{},title:m.trim(),role:x.trim()||null,plain:g.trim()||null,cluster:v.trim()||null,parentId:l??null,status:j,x:d?.x??60,y:d?.y??60}):i&&await ee(i,{..."ROADMAP"===r?{kind:w}:{},title:m.trim(),role:x.trim()||null,plain:g.trim()||null,cluster:v.trim()||null,status:j}),t(!1),u.refresh()}finally{E(!1)}}}return(0,a.jsx)(W.lG,{open:e,onOpenChange:t,children:(0,a.jsxs)(W.Cf,{children:[(0,a.jsx)(W.c7,{children:(0,a.jsx)(W.L3,{children:o})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(V,{htmlFor:"nf-title",children:"Title"}),(0,a.jsx)(Y,{id:"nf-title",value:m,autoFocus:!0,onChange:e=>p(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(V,{htmlFor:"nf-role",children:"Role (one line)"}),(0,a.jsx)(Y,{id:"nf-role",value:x,onChange:e=>h(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(V,{htmlFor:"nf-plain",children:"Description"}),(0,a.jsx)(Z,{id:"nf-plain",rows:3,value:g,onChange:e=>b(e.target.value)})]}),"ROADMAP"===r&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(V,{children:"Kind"}),(0,a.jsxs)(S.l6,{value:w,onValueChange:e=>null!=e&&k(e),children:[(0,a.jsx)(S.bq,{children:(0,a.jsx)(S.yv,{children:e=>"BUG"===e?"Bug":"Feature"})}),(0,a.jsxs)(S.gC,{children:[(0,a.jsx)(S.eb,{value:"FEATURE",children:"Feature"}),(0,a.jsx)(S.eb,{value:"BUG",children:"Bug"})]})]})]}),(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)(V,{children:"Status"}),(0,a.jsxs)(S.l6,{value:j,onValueChange:e=>null!=e&&N(e),children:[(0,a.jsx)(S.bq,{children:(0,a.jsx)(S.yv,{children:e=>I[e]?.label??e})}),(0,a.jsx)(S.gC,{children:z.map(e=>(0,a.jsx)(S.eb,{value:e,children:I[e]?.label??e},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(V,{htmlFor:"nf-cluster",children:"Cluster / lane"}),(0,a.jsx)(Y,{id:"nf-cluster",value:v,onChange:e=>y(e.target.value)})]})]})]}),(0,a.jsxs)(W.Es,{children:[(0,a.jsx)(G.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(G.$,{onClick:D,disabled:C||!m.trim(),children:C?"Saving…":"Save"})]})]})})}let en=(0,q.createServerReference)("404e9531712123693e865b18c14f86981c97bb47de",q.callServer,void 0,q.findSourceMapURL,"acceptSuggestionAction"),ea=(0,q.createServerReference)("40d394326fa5e9651a35137d5f0a26e6b609d7bcdd",q.callServer,void 0,q.findSourceMapURL,"deleteNodeAction"),es=(0,q.createServerReference)("604d59913f6b60f237a0a3fa7ede611000355aea60",q.callServer,void 0,q.findSourceMapURL,"setStatusAction"),er=(0,q.createServerReference)("406cbd79a02baf3d8a2877caa010507e919bc5ce63",q.callServer,void 0,q.findSourceMapURL,"cancelAction"),eo=(0,q.createServerReference)("401f9c7f6af1ba4e533bc22611dadf5508a617bf40",q.callServer,void 0,q.findSourceMapURL,"deprioritizeAction");function ei({view:e,selected:t,allNodes:n,onClose:s,commentsContent:r,commentsCount:o=0,activeTab:i,onTabChange:l,onAddComment:d,topOffset:c}){let u=!!r,m=i??"details";return(0,a.jsxs)(K.b,{className:"absolute bottom-3 right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:c??12},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)(el,{active:"details"===m,onClick:()=>l?.("details"),children:"Details"}),(0,a.jsxs)(el,{active:"comments"===m,onClick:()=>l?.("comments"),children:["Comments",o>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:o})]})]}),(0,a.jsx)("button",{onClick:s,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)(U.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:s,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(U.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsx)("div",{className:"p-3",children:"comments"===m&&u?r: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)(v.A,{className:"size-3.5"}),"Comment on this ","ARCHITECTURE"===e?"component":"feature"]}),(0,a.jsx)(ed,{node:t,view:e},t.id)]}):(0,a.jsx)(eu,{view:e,nodes:n})})})]})}function el({active:e,onClick:t,children:n}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,P.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 ed({node:e,view:t}){var n;let r=(0,f.useRouter)(),[o,i]=(0,s.useTransition)(),[l,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1),m="ARCHITECTURE"===t?T:A,p=e=>i(async()=>{await e(),r.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:[(n=e.cluster,n?.trim()||"—"),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&&(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)(k.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)(G.$,{size:"sm",className:"h-7 px-2.5 text-xs",disabled:o,onClick:()=>p(()=>en(e.id)),children:"Accept"}),(0,a.jsx)(G.$,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs text-muted-foreground",disabled:o,onClick:()=>p(()=>ea(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)(S.l6,{value:e.status,onValueChange:t=>null!=t&&p(()=>es(e.id,t)),children:[(0,a.jsx)(S.bq,{className:"h-8",disabled:o,children:(0,a.jsx)(S.yv,{children:e=>I[e]?.label??e})}),(0,a.jsx)(S.gC,{children:m.map(e=>(0,a.jsx)(S.eb,{value:e,children:I[e]?.label??e},e))})]})]}),e.plain&&(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)(M.pO,{markdown:e.plain,variant:"compact",className:"text-[12.5px]"})}),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}),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)("ul",{className:"space-y-0.5",children:e.files.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("button",{onClick:()=>fetch(`/api/open?path=${encodeURIComponent(e)}`).catch(()=>{}),title:`Open ${e} in editor`,className:"block w-full truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:e})},e))})]}),"ARCHITECTURE"===t&&(0,a.jsx)(ec,{node:e}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[(0,a.jsx)(G.$,{size:"sm",variant:"outline",onClick:()=>d(!0),children:"Edit"}),(0,a.jsx)(G.$,{size:"sm",variant:"outline",onClick:()=>u(!0),children:"+ Sub-node"}),(0,a.jsx)(G.$,{size:"sm",variant:"outline",disabled:o,onClick:()=>p(()=>er(e.id)),children:"Cancel"}),(0,a.jsx)(G.$,{size:"sm",variant:"outline",disabled:o,onClick:()=>p(()=>eo(e.id)),children:"Deprioritize"}),(0,a.jsxs)(X.Lt,{children:[(0,a.jsx)(X.tv,{render:(0,a.jsx)(G.$,{size:"sm",variant:"outline",className:"text-red-300",children:"Delete"})}),(0,a.jsxs)(X.EO,{children:[(0,a.jsxs)(X.wd,{children:[(0,a.jsxs)(X.r7,{children:["Delete “",e.title,"”?"]}),(0,a.jsx)(X.$v,{children:"This removes the node and all its sub-nodes. It can’t be undone."})]}),(0,a.jsxs)(X.ck,{children:[(0,a.jsx)(X.Zr,{children:"Cancel"}),(0,a.jsx)(X.Rx,{onClick:()=>p(()=>ea(e.id)),children:"Delete"})]})]})]})]}),l&&(0,a.jsx)(et,{open:!0,onOpenChange:d,mode:"edit",view:t,heading:"Edit node",nodeId:e.id,defaults:{title:e.title,role:e.role,plain:e.plain,status:e.status,cluster:e.cluster,kind:e.kind}}),c&&(0,a.jsx)(et,{open:!0,onOpenChange:u,mode:"create",view:t,heading:"New sub-node",parentId:e.id,position:{x:e.x,y:e.y+120},defaults:{cluster:e.cluster}})]})}function ec({node:e}){let t=(0,f.useRouter)(),[n,r]=(0,s.useState)(""),[o,i]=(0,s.useState)(!1),l=e.bugFlags.filter(e=>!e.resolved),d=e=>{i(!0),e().then(()=>t.refresh()).finally(()=>i(!1))},u=()=>{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&&r("")})};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)(c.A,{className:"size-3.5 text-rose-300"}),"Bug flags",l.length>0&&` (${l.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,P.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,P.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:o,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:o,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)(U.A,{className:"size-3"})})]})]}),(0,a.jsx)("p",{className:(0,P.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=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),u())},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)(G.$,{size:"sm",variant:"outline",className:"h-7 shrink-0 px-2 text-[11px]",disabled:o||!n.trim(),onClick:u,children:"Flag"})]})]})}function eu({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)(em,{label:"nodes",value:t.length}),(0,a.jsx)(em,{label:"critical",value:n})]})]})}function em({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})]})}var ep=n(18874),ex=n(62311),eh=n(56614);let ef=[{value:"cluster",label:"Theme"},{value:"status",label:"Status"},{value:"priority",label:"Priority"}],eg=new Set(["title","role","plain","cluster","status","priority"]),eb={roadmapNode:_,archNode:_,annotation:b.Sh},ev={deletable:H.I},ey={CONTAINS:{stroke:"#7c7c8a"},DEPENDS:{stroke:"#f5b942",dash:"6 4"},RELATES:{stroke:"#8a8a95",dash:"4 4"},REPLACES:{stroke:"#ff6b9d"}};function ej({view:e,nodes:t,edges:n,workOnNextId:f=null,embedded:g=!1,commentsContent:v,commentsCount:y=0,controlRef:j,onAskAgent:N,onAddComment:w,annotations:k,onPinClick:C,onUpdateComment:E,onRemoveComment:S,boardAnnotations:D}){let R=(0,s.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,view:e.view,kind:e.kind,source:e.source,sourceRef:e.sourceRef,isCriterion:e.isCriterion,isChild:null!=e.parentId,parentId:e.parentId,signals:e.signals,openBugs:e.bugFlags.filter(e=>!e.resolved).length}})),[t]),M=(0,s.useMemo)(()=>{let e;return e=new Set(t.map(e=>e.id)),[...t.filter(t=>t.parentId&&e.has(t.parentId)).map(e=>({id:`c-${e.id}`,source:e.parentId,sourceHandle:"sb",target:e.id,targetHandle:"tt",type:"smoothstep",style:{stroke:ey.CONTAINS.stroke}})),...n.filter(t=>e.has(t.fromId)&&e.has(t.toId)).map(e=>{let t=ey[e.kind]??ey.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:o.TG.ArrowClosed,color:t.stroke},style:{stroke:t.stroke,strokeDasharray:t.dash}}})]},[t,n]),[O,F]=(0,s.useState)(R),[L,_]=(0,s.useState)(M),[H,U]=(0,s.useState)(null),[K,G]=(0,s.useState)(null),[X,W]=(0,s.useState)(null),[Y,Z]=(0,s.useState)(!1),[J,V]=(0,s.useState)("details"),q=(0,s.useRef)(!1),Q=(0,s.useRef)("details");(0,s.useEffect)(()=>{q.current=Y},[Y]),(0,s.useEffect)(()=>{Q.current=J},[J]),(0,s.useEffect)(()=>{if(j)return j.current={open:()=>{if(q.current){Z(!1),V("details");return}Z(!0),V("details")},close:()=>{Z(!1),V("details")},openComments:()=>{Z(!0),V("comments")}},()=>{j&&(j.current=null)}},[j]);let[ee,et]=(0,s.useState)(new Set),[en,ea]=(0,s.useState)(null),[es,er]=(0,s.useState)(!1),eo=(0,s.useRef)(0),el=(0,s.useRef)(null);(0,s.useEffect)(()=>F(R),[R]),(0,s.useEffect)(()=>_(M),[M]);let ed=(0,s.useCallback)((e,t,n)=>{F(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])=>eg.has(e))))})},[]),ec=(0,s.useMemo)(()=>Array.from(new Set(O.map(e=>e.data.cluster).filter(e=>!!e))).sort(),[O]),eu=(0,s.useCallback)(e=>et(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),em=(0,s.useCallback)(e=>{U(e),Z(!0),V("details")},[]),eN=(0,s.useCallback)(e=>{F(t=>t.filter(t=>t.id!==e)),U(t=>t===e?null:t),fetch(`/api/nodes/${e}`,{method:"DELETE"})},[]),ew=(0,s.useCallback)(async(t,n,a="FEATURE")=>{let s=(0,r.sX)(),o="ARCHITECTURE"===e?"REBUILD":"PENDING",i="BUG"===a?"New bug":"New node";F(r=>[...r,{id:s,type:"ROADMAP"===e?"roadmapNode":"archNode",position:{x:t,y:n},data:{title:i,role:null,plain:null,status:o,priority:2,cluster:null,view:e,kind:a,source:"MANUAL",sourceRef:null,isCriterion:!1,isChild:!1,parentId:null,openBugs:0}}]),et(e=>new Set(e).add(s)),ea(s),U(s);try{if(!(await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,view:e,kind:a,title:i,status:o,x:t,y:n})})).ok)throw Error("create failed")}catch{F(e=>e.filter(e=>e.id!==s)),et(e=>{let t=new Set(e);return t.delete(s),t}),ea(e=>e===s?null:e),U(e=>e===s?null:e)}},[e]),ek=(0,s.useCallback)(()=>{let e=eo.current++%8*28;ew(80+e,80+e)},[ew]),eC=(0,s.useCallback)(()=>{let e=eo.current++%8*28;ew(80+e,80+e,"BUG")},[ew]),eE=(0,s.useMemo)(()=>({view:e,categories:ec,statuses:"ARCHITECTURE"===e?T:A,patch:ed,isExpanded:e=>ee.has(e),toggleExpand:eu,openDetailed:em,removeNode:eN,editingTitleId:en,onAskAgent:N}),[e,ec,ed,ee,eu,em,eN,en,N]),[eS,eA]=(0,s.useState)(null),[eT,ez]=(0,s.useState)(""),[eI,eD]=(0,s.useState)(new Set),[eR,e$]=(0,s.useState)(new Set),[eM,eP]=(0,s.useState)(new Set),eO=(0,s.useMemo)(()=>Array.from(new Set(t.map(e=>e.status))),[t]),eF=(0,s.useMemo)(()=>Array.from(new Set(t.map(e=>e.cluster).filter(e=>!!e))).sort(),[t]),eL=(0,s.useMemo)(()=>Array.from(new Set(t.map(e=>e.priority))).sort((e,t)=>e-t),[t]),e_=(0,s.useCallback)(e=>(!eI.size||!!eI.has(e.status))&&(!eR.size||!!e.cluster&&!!eR.has(e.cluster))&&(!eM.size||!!eM.has(e.priority)),[eI,eR,eM]),eB=eI.size+eR.size+eM.size,eH=(0,s.useCallback)(()=>{eD(new Set),e$(new Set),eP(new Set)},[]),eU=(0,s.useMemo)(()=>O.map(e=>({...e,hidden:!e_(e.data)})),[O,e_]),eK=(0,s.useMemo)(()=>new Set(eU.filter(e=>e.hidden).map(e=>e.id)),[eU]),eG=(0,s.useMemo)(()=>L.map(e=>({...e,hidden:eK.has(e.source)||eK.has(e.target)})),[L,eK]),eX=(0,s.useMemo)(()=>{if(K){let e=eG.find(e=>e.id===K);return e?new Set([e.source,e.target]):null}return H?(0,ep.F1)(H,eG.filter(e=>!e.hidden)):null},[H,K,eG]),eW=(0,s.useMemo)(()=>eU.map(e=>{let t=f&&e.id===f?{...e,data:{...e.data,isNext:!0}}:e;return!eX||t.hidden?t:{...t,style:{...t.style,opacity:eX.has(e.id)?1:.45,transition:"opacity 120ms"}}}),[eU,eX,f]),eY=(0,s.useMemo)(()=>{if(!eS||"ROADMAP"!==e)return[];let t=new Map(eW.map(e=>[e.id,e])),n=new Map;for(let e of eW){var a;if(e.hidden)continue;let s=(a=((e.data.parentId?t.get(e.data.parentId):void 0)??e).data,"status"===eS?I[a.status]?.label??a.status:"priority"===eS?`P${a.priority}`:a.cluster?.trim()||"—"),r=e.measured?.width??(e.data.isChild?224:256),o=e.measured?.height??96,i=e.position.x,l=e.position.y,d=n.get(s);d?(d.minX=Math.min(d.minX,i),d.minY=Math.min(d.minY,l),d.maxX=Math.max(d.maxX,i+r),d.maxY=Math.max(d.maxY,l+o)):n.set(s,{label:s,minX:i,minY:l,maxX:i+r,maxY:l+o})}return Array.from(n.values()).map(e=>({label:e.label,x:e.minX-20,y:e.minY-20-26,w:e.maxX-e.minX+40,h:e.maxY-e.minY+40+26}))},[eW,eS,e]),eZ=(0,s.useMemo)(()=>{let e=H??X;return K||e?eG.map(t=>t.hidden?t:(K?t.id===K: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}}):eG.map(e=>e.hidden?e:{...e,label:void 0,style:{...e.style,opacity:.18}})},[eG,H,K,X]),eJ=void 0!==D,[eV,eq]=(0,s.useState)(D??[]);(0,s.useEffect)(()=>{D&&eq(D)},[D]);let eQ=(0,s.useMemo)(()=>{if(eJ){let e=new Set(t.map(e=>e.id));return eV.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((k??[]).map(e=>[e.id,e.comment]));return(0,B.m)(k??[],{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}))},[eJ,eV,k,t]),e0=(0,s.useMemo)(()=>{let e=new Map;for(let t of eQ){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:null}),e.set(t.targetId,n)}return e},[eQ]),e1=(0,s.useCallback)(async e=>{let n=(0,B.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();eq(t=>[...t,e])}},[t]),e5=(0,s.useCallback)((e,t)=>{eq(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)})},[]),e2=(0,s.useCallback)(e=>{eq(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),e3=eJ?e1:w,[e4,e6]=(0,s.useState)(()=>new Map),e8=(0,s.useMemo)(()=>{let e=new Map(eW.map(e=>[e.id,e])),t=new Map,n=eQ.flatMap(n=>{let a=e.get(n.targetId);if(!a||a.hidden)return[];let s=t.get(n.targetId)??0;t.set(n.targetId,s+1);let r=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+r+56+112*s},measured:e4.get(`anno-${n.id}`),draggable:eJ,data:{n:n.n,text:n.text,annotationId:n.id,onClick:eJ||E?void 0:C,editable:eJ||!!E,onChangeText:eJ?(e,t)=>e5(e,{body:t}):E,onDelete:eJ?e2:S}}]});return[...eW.map(e=>{let t=e0.get(e.id);return t||e3?{...e,data:{...e.data,pins:t,onPinClick:eJ?void 0:C,onComment:e3}}:e}),...n]},[eW,eQ,e0,eJ,C,E,S,e3,e5,e2,e4]),e9=(0,s.useMemo)(()=>eQ.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"default",selectable:!1,zIndex:30,style:{stroke:b.V5,strokeWidth:1.5,opacity:.9}})),[eQ]),e7=(0,s.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;eq(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&&e6(t=>{let a=t.get(n.id);if(a&&a.width===e.width&&a.height===e.height)return t;let s=new Map(t);return s.set(n.id,e),s})}else t.push(n);t.length&&F(e=>(0,i._0)(t,e))},[]),te=(0,s.useCallback)(e=>_(t=>(0,i.zW)(e,t)),[]),tt=(0,s.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=ey.DEPENDS;_(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:o.TG.ArrowClosed,color:a.stroke},style:{stroke:a.stroke,strokeDasharray:a.dash}}])},[]),tn=(0,s.useCallback)(async(t,n,a)=>{let s=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(!s.ok)return;let r=await s.json();F(s=>[...s,{id:r.id,type:"ROADMAP"===e?"roadmapNode":"archNode",position:{x:n,y:a},data:{title:r.title,role:r.role,plain:r.plain,status:r.status,priority:r.priority,cluster:r.cluster,view:r.view,source:r.source,sourceRef:r.sourceRef,kind:r.kind,isCriterion:!1,isChild:!0,parentId:t.id,openBugs:0}}]),_(e=>[...e,{id:`c-${r.id}`,source:t.id,target:r.id,type:"smoothstep",style:{stroke:ey.CONTAINS.stroke}}]),et(e=>new Set(e).add(r.id)),ea(r.id),U(r.id)},[e]),ta=(0,s.useCallback)(async(e,t)=>{if(t.isValid||!t.fromNode||!el.current)return;let n=e.changedTouches,a=n?.[0]?.clientX??e.clientX,s=n?.[0]?.clientY??e.clientY,{x:r,y:o}=el.current.screenToFlowPosition({x:a,y:s});await tn(t.fromNode,r,o)},[tn]);(0,s.useEffect)(()=>{if(!es)return;let e=e=>{"Escape"===e.key&&er(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[es]);let ts=(0,s.useMemo)(()=>t.find(e=>e.id===H)??null,[t,H]),tr=(0,s.useCallback)((e,t,n)=>{fetch(`/api/nodes/${e}/position`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({x:t,y:n})})},[]),to=(0,s.useCallback)(e=>{U(e),G(null);let t=el.current?.getNode(e);if(!t||!el.current)return;let n=t.measured?.width??128,a=t.measured?.height??48;el.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:1.2,duration:600})},[]),ti=(0,s.useCallback)(e=>{let t=function(e,t,n={}){let a=n.colW??320,s=n.rowH??150,r=n.childIndent??24,o=n.laneGap??56,i=n.bandGap??110,l=n.maxCols??4,d=n.maxBandW??6*a,c=new Set(e.map(e=>e.id)),u=e=>!e.parentId||!c.has(e.parentId),m=e.filter(u),p=new Map;for(let t of e){if(u(t))continue;let e=p.get(t.parentId);e?e.push(t):p.set(t.parentId,[t])}let x="status"===t?e=>e.status:"priority"===t?e=>String(e.priority):e=>(e.cluster??"").trim()||"—",h=new Map;for(let e of m){let t=x(e),n=h.get(t);n?n.push(e):h.set(t,[e])}let f=(function(e,t,n){if("status"===e)return[...z];if("priority"===e)return["0","1","2","3"];let a=Array.from(new Set(t.map(n))),s=a.filter(e=>"—"!==e).sort();return a.includes("—")?[...s,"—"]:s})(t,m,x).filter(e=>h.has(e)),g=new Map,b=0,v=0,y=0;for(let e of f){let t=h.get(e),n=Math.max(1,Math.min(l,Math.ceil(Math.sqrt(t.length)))),c=n*a;b>0&&b+c>d&&(b=0,v+=y+i,y=0);let u=Array(n).fill(0);for(let e of t){let t=0;for(let e=1;e<n;e++)u[e]<u[t]&&(t=e);let o=b+t*a,i=v+u[t]*s;g.set(e.id,{x:o,y:i});let l=p.get(e.id)??[];l.forEach((e,t)=>{g.set(e.id,{x:o+r,y:i+(t+1)*s})}),u[t]+=1+l.length}y=Math.max(y,u.reduce((e,t)=>Math.max(e,t),0)*s),b+=c+o}return g}(O.map(e=>({id:e.id,parentId:e.data.parentId??null,cluster:e.data.cluster,status:e.data.status,priority:e.data.priority})),e);F(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})}),eA(e),requestAnimationFrame(()=>el.current?.fitView({duration:600,padding:.2}))},[O]),tl=(0,s.useMemo)(()=>{let e=eT.trim().toLowerCase();return e?O.filter(t=>e_(t.data)&&t.data.title.toLowerCase().includes(e)).slice(0,8):[]},[O,eT,e_]);function td(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,a.jsx)($.Provider,{value:eE,children:(0,a.jsxs)("div",{className:(0,P.cn)("canvas-dots relative w-full",g?"h-full":"h-screen"),onDragOver:e=>{e.dataTransfer.types.includes("application/beacon-node")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDrop:e=>{if(!e.dataTransfer.getData("application/beacon-node")||!el.current)return;e.preventDefault();let{x:t,y:n}=el.current.screenToFlowPosition({x:e.clientX,y:e.clientY});ew(t,n,"BUG"===e.dataTransfer.getData("application/beacon-node-kind")?"BUG":"FEATURE")},children:[(0,a.jsxs)(i.Gc,{nodes:e8,edges:[...eZ,...e9],nodeTypes:eb,edgeTypes:ev,connectionMode:o.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{el.current=e},onNodesChange:e7,onEdgesChange:te,onConnect:tt,onConnectEnd:ta,onNodeMouseEnter:(e,t)=>W(t.id),onNodeMouseLeave:()=>W(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"}),U(e=>e===t.id?null:e))},onNodeClick:(e,t)=>{if("annotation"===t.type)return void C?.(t.data.annotationId);if(es){if(er(!1),t.data.isChild)return;tn(t,t.position.x+300,t.position.y+60);return}if(U(t.id),G(null),V("details"),g){let t=e.target;t?.closest("input, textarea, select, button, [role='combobox']")||Z(!0)}},onEdgeClick:(e,t)=>{G(t.id),U(null),V("details")},onPaneClick:()=>{es?er(!1):(U(null),G(null))},onNodeDragStop:(e,t)=>{if(t.id.startsWith("anno-")){eJ&&e5(t.id.slice(5),{x:t.position.x,y:t.position.y});return}tr(t.id,t.position.x,t.position.y)},deleteKeyCode:["Backspace","Delete"],colorMode:"dark",fitView:!0,minZoom:.2,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[eY.length>0&&(0,a.jsx)(i.DX,{children:eY.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:"rounded-2xl border border-white/[0.08] bg-white/[0.015]",children:(0,a.jsx)("div",{className:"px-3 py-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:e.label})},e.label))}),(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"}),(0,a.jsx)(i.Zk,{position:"bottom-right",style:{marginBottom:152},children:(0,a.jsx)(eh.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,P.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)(l.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 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",{"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.jsx)("span",{children:"depends on \xb7 drag between two cards"})]})]})})}),!g&&(0,a.jsx)(i.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:e=>e.data?.priority===0?"#ff3860":"#555"}),(0,a.jsxs)(i.Zk,{position:"bottom-center",className:"!mb-4 flex flex-col items-center gap-2",children:[es&&(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"]}),"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"}),ef.map(e=>(0,a.jsx)("button",{onClick:()=>ti(e.value),title:`Arrange features into lanes by ${e.label.toLowerCase()}`,className:(0,P.cn)("h-7 rounded-full px-2.5 text-[11px] font-medium transition-colors",eS===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:ek,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)(d.A,{className:"size-3.5 text-[var(--accent-2,#ff7a45)]"}),"ARCHITECTURE"===e?"Component":"Feature"]}),"ROADMAP"===e&&(0,a.jsxs)("button",{onClick:eC,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)(c.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:()=>er(e=>!e),title:"ARCHITECTURE"===e?"Add sub-component (click a component next)":"Add sub-task (click a feature next)",className:(0,P.cn)("flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-medium transition-colors",es?"bg-white/[0.1] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,a.jsx)(u.A,{className:"size-3.5"}),"ARCHITECTURE"===e?"Sub-component":"Sub-task"]})]})]}),!g&&(0,a.jsx)(i.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,a.jsx)(ex.Z,{active:e,tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"FILES",label:"Files",href:"/map?view=FILES"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"}]})}),(0,a.jsxs)(i.Zk,{position:"top-right",className:(0,P.cn)("flex items-center gap-1 transition-[margin] duration-200",Y&&"!mr-[332px]",g&&"hidden"),children:[(0,a.jsxs)(eh.er,{title:"Search",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Search features",className:(0,P.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)(m.A,{className:"size-4"})}),children:[(0,a.jsx)("input",{autoFocus:!0,value:eT,onChange:e=>ez(e.target.value),placeholder:"Find a feature…",className:"w-full rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[12px] outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.08]"}),(0,a.jsxs)("div",{className:"mt-2 max-h-64 space-y-0.5 overflow-y-auto",children:[eT.trim()&&0===tl.length&&(0,a.jsx)("div",{className:"px-1 py-1 text-[11px] text-muted-foreground",children:"No matches"}),tl.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>to(e.id),className:"block w-full truncate rounded-md px-2 py-1 text-left text-[12px] text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:e.data.title},e.id))]})]}),"ROADMAP"===e&&f&&(0,a.jsx)("button",{type:"button",onClick:()=>to(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)(p.A,{className:"size-4"})}),(0,a.jsxs)(eh.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,P.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||eB>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(x.A,{className:"size-4"}),eB>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:eB})]}),children:[eO.length>0&&(0,a.jsx)(eh.r1,{title:"Status",children:eO.map(e=>(0,a.jsx)(eh.vu,{on:eI.has(e),onClick:()=>td(e,eD),children:I[e]?.label??e},e))}),eF.length>0&&(0,a.jsx)(eh.r1,{title:"Cluster",children:eF.map(e=>(0,a.jsx)(eh.vu,{on:eR.has(e),onClick:()=>td(e,e$),children:e},e))}),eL.length>0&&(0,a.jsx)(eh.r1,{title:"Priority",children:eL.map(e=>(0,a.jsxs)(eh.vu,{on:eM.has(e),onClick:()=>td(e,eP),children:["P",e]},e))}),eB>0&&(0,a.jsx)("button",{type:"button",onClick:eH,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"})]}),!Y&&(0,a.jsx)("button",{onClick:()=>{Z(!0),V("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"})})]})]}),Y&&(0,a.jsx)(ei,{view:e,selected:ts,allNodes:t,onClose:()=>{Z(!1),V("details")},commentsContent:v,commentsCount:y,activeTab:J,onTabChange:V,onAddComment:e3,topOffset:g?64:void 0})]})})}},54698:(e,t,n)=>{n.d(t,{m:()=>a});function a(e,t){let n=[];return e.forEach((e,a)=>{let s=e.excerpt.trim();if(!s)return;let r={annotationId:e.id,n:a+1};for(let e of t.tables){if(s===e.name)return void n.push({...r,kind:"table",targetId:e.id,column:null});if(s.startsWith(`${e.name}.`)){let t=s.slice(e.name.length+1);if(e.columns.includes(t))return void n.push({...r,kind:"column",targetId:e.id,column:t})}}for(let e of t.endpoints??[])if(s===`${e.method} ${e.path}`)return void n.push({...r,kind:"endpoint",targetId:e.id,column:null});for(let e of t.features??[])if(s===e.title||s===`feature: ${e.title}`)return void n.push({...r,kind:"feature",targetId:e.id,column:null})}),n}},56614:(e,t,n)=>{n.d(t,{er:()=>o,r1:()=>i,vu:()=>l});var a=n(95155),s=n(12115),r=n(91337);function o({trigger:e,title:t,align:n="right",children:i}){let[l,d]=(0,s.useState)(!1),c=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!l)return;let e=e=>{c.current?.contains(e.target)||d(!1)},t=e=>{"Escape"===e.key&&d(!1)};return window.addEventListener("mousedown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("keydown",t)}},[l]),(0,a.jsxs)("div",{ref:c,className:"relative",children:[e(l,()=>d(e=>!e)),l&&(0,a.jsxs)("div",{className:(0,r.cn)("glass absolute top-full z-30 mt-1.5 w-64 rounded-xl p-3 shadow-xl","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}),i]})]})}function i({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 l({on:e,onClick:t,children:n,tone:s="default"}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,r.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"}[s]),children:n})}},57144:(e,t,n)=>{n.d(t,{I:()=>c});var a=n(95155),s=n(81750),r=n(6266),o=n(65738);function i(e){let{x:t,y:n}=e.internals.positionAbsolute,a=e.measured?.width??0,s=e.measured?.height??0;return{x:t,y:n,w:a,h:s,cx:t+a/2,cy:n+s/2}}function l(e,t){let n=i(e),a=i(t),s=n.w/2||1,r=n.h/2||1,o=(a.cx-n.cx)/(2*s)-(a.cy-n.cy)/(2*r),l=(a.cx-n.cx)/(2*s)+(a.cy-n.cy)/(2*r),d=1/(Math.abs(o)+Math.abs(l)||1);return{x:s*d*(o+l)+n.cx,y:r*d*(-o+l)+n.cy}}function d(e,t){let n=i(e),a=Math.round(t.x),s=Math.round(t.y);return a<=Math.round(n.x)+1?r.yX.Left:a>=Math.round(n.x+n.w)-1?r.yX.Right:s<=Math.round(n.y)+1?r.yX.Top:r.yX.Bottom}function c(e){let t,n,{deleteElements:i}=(0,s.VH)(),c=(0,s.JY)(e.source),u=(0,s.JY)(e.target),m=c&&u?(t=l(c,u),n=l(u,c),{sx:t.x,sy:t.y,tx:n.x,ty:n.y,sourcePos:d(c,t),targetPos:d(u,n)}):null,[p,x,h]=(0,r.Fp)(m?{sourceX:m.sx,sourceY:m.sy,sourcePosition:m.sourcePos,targetX:m.tx,targetY:m.ty,targetPosition:m.targetPos}:{sourceX:e.sourceX,sourceY:e.sourceY,sourcePosition:e.sourcePosition,targetX:e.targetX,targetY:e.targetY,targetPosition:e.targetPosition});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.tE,{id:e.id,path:p,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(${x}px, ${h}px)`,fontSize:11,color:"#cfcfcf",background:"#161616",padding:"1px 4px",borderRadius:4,pointerEvents:"none"},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(${x}px, ${h+14}px)`,pointerEvents:"all",zIndex:1e3},children:(0,a.jsx)("button",{type:"button",onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),i({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"})})})})]})}},60874:(e,t,n)=>{n.d(t,{F8:()=>b,NG:()=>x,QH:()=>h,Vq:()=>g,aM:()=>j,cV:()=>w,kz:()=>y,n$:()=>m,pO:()=>o,vB:()=>v});var a=n(95155),s=n(12115),r=n(91337);function o({markdown:e,className:t,variant:n="reading"}){let i=(0,s.useMemo)(()=>m(e),[e]),l="reading"===n;return(0,a.jsx)("div",{className:(0,r.cn)("min-w-0 [overflow-wrap:anywhere]",l?"mx-auto w-full max-w-[66ch] space-y-4 text-[15px] leading-[1.6]":"space-y-3.5 text-[13px] leading-relaxed",t),children:i.map((e,t)=>(0,a.jsx)(N,{block:e,variant:n},t))})}function i(e){let t=e.trim();return t.includes("|")&&t.includes("-")&&/^[\s|:-]+$/.test(t)}function l(e){return""!==e.trim()&&e.includes("|")}function d(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(e=>e.trim())}function c(e){let t=e.trim(),n=t.startsWith(":"),a=t.endsWith(":");return n&&a?"center":a?"right":n?"left":null}let u=/^\s*```[^\s`]*\s*$/;function m(e){let t=e.split("\n"),n=[],a=[],s=()=>{a.length&&(n.push({kind:"p",text:a.join("\n")}),a=[])},r=null,o=()=>{null!==r&&(n.push({kind:"quote",text:r.join("\n")}),r=null)},m=e=>Math.min(6,Math.floor(e.length/2)),p=null,x=null;for(let e=0;e<t.length;e++){let h=t[e];if(null!==p){u.test(h)?(n.push({kind:"code",text:p.join("\n")}),p=null):p.push(h);continue}let f=h.match(/^>\s?(.*)$/);if(f){s(),x=null,(r??=[]).push(f[1]);continue}if(o(),u.test(h)){s(),x=null,p=[];continue}if(/^\s*$/.test(h)){s(),x=null;continue}let g=h.match(/^#### +(.+)$/);if(g){s(),x=null,n.push({kind:"h4",text:g[1]});continue}let b=h.match(/^### +(.+)$/);if(b){s(),x=null,n.push({kind:"h3",text:b[1]});continue}let v=h.match(/^## +(.+)$/);if(v){s(),x=null,n.push({kind:"h2",text:v[1]});continue}let y=h.match(/^# +(.+)$/);if(y){s(),x=null,n.push({kind:"h1",text:y[1]});continue}if(l(h)&&e+1<t.length&&i(t[e+1])){s(),x=null;let a=[d(h)],r=d(t[e+1]).map(c),o=e+2;for(;o<t.length&&l(t[o])&&!i(t[o]);)a.push(d(t[o])),o++;n.push({kind:"table",text:t.slice(e,o).join("\n"),rows:a,align:r}),e=o-1;continue}let j=h.match(/^(\s*)(\d+)\. +(.+)$/);if(j){s(),n.push({kind:"ol",text:j[3],depth:m(j[1]),marker:j[2]}),x=n.length-1;continue}let N=h.match(/^(\s*)- +(.+)$/);if(N){s(),n.push({kind:"ul",text:N[2],depth:m(N[1])}),x=n.length-1;continue}if(null!==x&&0===a.length){n[x].text+=" "+h.trim();continue}a.push(h)}return s(),o(),null!==p&&n.push({kind:"code",text:p.join("\n")}),n}let p=/("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function x({text:e}){let t=function(e){let t=e.trim();if(!t||"{"!==t[0]&&"["!==t[0])return null;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}}(e);return(0,a.jsx)("pre",{className:"overflow-x-auto rounded-lg border border-white/10 bg-white/[0.06] p-3 text-[12px] leading-relaxed",children:(0,a.jsx)("code",{className:"whitespace-pre font-mono [overflow-wrap:normal]",children:t?function(e){let t,n=[],s=0,r=0,o=e=>(0,a.jsx)("span",{className:"text-foreground/45",children:e},r++);for(p.lastIndex=0;null!==(t=p.exec(e));){if(t.index>s&&n.push(o(e.slice(s,t.index))),void 0!==t[1]){let e=void 0!==t[2];n.push((0,a.jsx)("span",{className:e?"text-sky-300":"text-emerald-300/90",children:t[1]},r++)),e&&t[2]&&n.push(o(t[2]))}else void 0!==t[3]?n.push((0,a.jsx)("span",{className:"text-purple-300",children:t[3]},r++)):void 0!==t[4]&&n.push((0,a.jsx)("span",{className:"text-amber-300",children:t[4]},r++));s=p.lastIndex}return s<e.length&&n.push(o(e.slice(s))),n}(t):(0,a.jsx)("span",{className:"text-foreground/85",children:e})})})}function h({block:e}){let t=e.rows??[];if(0===t.length)return null;let[n,...s]=t,o=e.align??[],i=e=>"center"===o[e]?"text-center":"right"===o[e]?"text-right":"text-left";return(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-white/10",children:(0,a.jsxs)("table",{className:"w-full border-collapse text-[13px] [overflow-wrap:normal]",children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{className:"border-b border-white/15 bg-white/[0.04]",children:n.map((e,t)=>(0,a.jsx)("th",{className:(0,r.cn)("whitespace-nowrap px-3 py-1.5 font-semibold text-foreground",i(t)),children:(0,a.jsx)(w,{text:e})},t))})}),(0,a.jsx)("tbody",{children:s.map((e,t)=>(0,a.jsx)("tr",{className:"border-b border-white/5 last:border-0",children:e.map((e,t)=>(0,a.jsx)("td",{className:(0,r.cn)("px-3 py-1.5 align-top text-foreground/90",i(t)),children:(0,a.jsx)(w,{text:e})},t))},t))})]})})}let f=["h1","h2","h3","h4"];function g(e){return f.includes(e)}function b(e){let t=f.indexOf(e);return t<0?0:t}function v(e){return`plan-h-${e}`}function y(e){return e.replace(/[`*]/g,"").trim()}function j(e,t,n,s){let o="reading"===n;switch(e.kind){case"h1":return(0,a.jsx)("h1",{id:s,className:o?"scroll-mt-24 text-xl font-semibold tracking-tight text-foreground":"text-base font-semibold text-foreground",children:t});case"h2":return(0,a.jsx)("h2",{id:s,className:o?"mt-6 scroll-mt-24 border-b border-white/10 pb-1 text-lg font-semibold text-foreground":"mt-3 text-sm font-semibold text-muted-foreground",children:t});case"h3":return(0,a.jsx)("h3",{id:s,className:o?"mt-4 scroll-mt-24 text-base font-semibold text-foreground":"mt-2 text-[13px] font-semibold text-foreground",children:t});case"h4":return(0,a.jsx)("h4",{id:s,className:o?"mt-3 scroll-mt-24 text-sm font-semibold text-muted-foreground":"mt-2 text-[13px] font-semibold text-muted-foreground",children:t});case"ul":case"ol":{let n=e.depth??0;return(0,a.jsxs)("div",{className:(0,r.cn)("flex gap-2",o?"text-foreground/95":"text-foreground/90"),style:{marginLeft:`${.75+1.25*n}rem`},children:[(0,a.jsx)("span",{className:"shrink-0 select-none text-muted-foreground tabular-nums",children:"ol"===e.kind?`${e.marker}.`:"•"}),(0,a.jsx)("span",{className:"min-w-0 flex-1",children:t})]})}case"quote":return(0,a.jsx)("blockquote",{className:(0,r.cn)("whitespace-pre-wrap border-l-2 pl-3 italic",o?"border-white/15 text-foreground/80":"border-white/10 text-foreground/75"),children:t});default:return(0,a.jsx)("p",{className:(0,r.cn)("whitespace-pre-wrap",o?"text-foreground/95":"text-foreground/90"),children:t})}}function N({block:e,variant:t}){return"code"===e.kind?(0,a.jsx)(x,{text:e.text}):"table"===e.kind?(0,a.jsx)(h,{block:e}):(0,a.jsx)(a.Fragment,{children:j(e,(0,a.jsx)(w,{text:e.text}),t)})}function w({text:e}){let t=e.split(/(`[^`]+`|\*\*[\s\S]+?\*\*|\*[^*]+\*)/g);return(0,a.jsx)(a.Fragment,{children:t.map((e,t)=>/^`[^`]+`$/.test(e)?(0,a.jsx)("code",{className:"rounded bg-white/5 px-1 font-mono text-[12px]",children:e.slice(1,-1)},t):/^\*\*[\s\S]+\*\*$/.test(e)?(0,a.jsx)("strong",{className:"font-semibold text-foreground",children:(0,a.jsx)(w,{text:e.slice(2,-2)})},t):/^\*[^*]+\*$/.test(e)?(0,a.jsx)("em",{className:"text-muted-foreground",children:(0,a.jsx)(w,{text:e.slice(1,-1)})},t):(0,a.jsx)("span",{children:e},t))})}},62311:(e,t,n)=>{n.d(t,{Z:()=>m});var a=n(95155),s=n(98500),r=n.n(s),o=n(25640),i=n(83599),l=n(94192),d=n(34306),c=n(91337);let u={ROADMAP:o.A,ARCHITECTURE:i.A,FILES:l.A,DATABASE:d.A};function m({tabs:e,active:t}){return(0,a.jsx)("div",{className:"flex items-center gap-0.5",children:e.map(e=>{let n=e.value===t,s=e.Icon??u[e.value];return(0,a.jsxs)(r(),{href:e.href,className:(0,c.cn)("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[12px] font-medium tracking-tight transition-colors",n?"bg-white/10 text-foreground":"text-muted-foreground/80 hover:bg-white/5 hover:text-foreground"),children:[s?(0,a.jsx)(s,{className:"size-3"}):null,(0,a.jsx)("span",{children:e.label})]},e.value)})})}},70521:(e,t,n)=>{n.d(t,{$v:()=>N,EO:()=>b,Lt:()=>x,Rx:()=>w,Zr:()=>k,ck:()=>y,r7:()=>j,tv:()=>h,wd:()=>v});var a=n(95155);n(12115);var s=n(25381),r=n(7121),o=n(51880),i=n(35176),l=n(11248),d=n(82022),c=n(98758),u=n(45362),m=n(91337),p=n(4474);function x({...e}){return(0,a.jsx)(s.V,{"data-slot":"alert-dialog",...e})}function h({...e}){return(0,a.jsx)(r.t,{"data-slot":"alert-dialog-trigger",...e})}function f({...e}){return(0,a.jsx)(o.Z,{"data-slot":"alert-dialog-portal",...e})}function g({className:e,...t}){return(0,a.jsx)(i.X,{"data-slot":"alert-dialog-overlay",className:(0,m.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)(f,{children:[(0,a.jsx)(g,{}),(0,a.jsx)(l.h,{"data-slot":"alert-dialog-content","data-size":t,className:(0,m.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 v({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,m.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 y({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,m.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 j({className:e,...t}){return(0,a.jsx)(d.L,{"data-slot":"alert-dialog-title",className:(0,m.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 N({className:e,...t}){return(0,a.jsx)(c.r,{"data-slot":"alert-dialog-description",className:(0,m.cn)("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function w({className:e,variant:t,size:n,...s}){return(0,a.jsx)(u.H,{"data-slot":"alert-dialog-action",className:(0,m.cn)(e),render:(0,a.jsx)(p.$,{variant:t,size:n}),...s})}function k({className:e,variant:t="outline",size:n="default",...s}){return(0,a.jsx)(u.H,{"data-slot":"alert-dialog-cancel",className:(0,m.cn)(e),render:(0,a.jsx)(p.$,{variant:t,size:n}),...s})}},74350:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>v,L3:()=>y,c7:()=>b,lG:()=>x,rr:()=>j});var a=n(95155);n(12115);var s=n(17112),r=n(51880),o=n(35176),i=n(11248),l=n(45362),d=n(82022),c=n(98758),u=n(91337),m=n(4474),p=n(9005);function x({...e}){return(0,a.jsx)(s.D,{"data-slot":"dialog",...e})}function h({...e}){return(0,a.jsx)(r.Z,{"data-slot":"dialog-portal",...e})}function f({className:e,...t}){return(0,a.jsx)(o.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,...s}){return(0,a.jsxs)(h,{children:[(0,a.jsx)(f,{}),(0,a.jsxs)(i.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),...s,children:[t,n&&(0,a.jsxs)(l.H,{"data-slot":"dialog-close",render:(0,a.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,a.jsx)(p.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 v({className:e,showCloseButton:t=!1,children:n,...s}){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),...s,children:[n,t&&(0,a.jsx)(l.H,{render:(0,a.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function y({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 j({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})}},82099:(e,t,n)=>{n.d(t,{b:()=>r});var a=n(95155);n(12115);var s=n(91337);function r({className:e,children:t,...n}){return(0,a.jsxs)("div",{className:(0,s.cn)("glass relative isolate overflow-hidden",e),...n,children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 -z-10 rounded-[inherit]",style:{background:"radial-gradient(90% 60% at 0% 0%, oklch(1 0 0 / 0.04), transparent 42%)"}}),(0,a.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 -z-10 rounded-[inherit] opacity-[0.035] mix-blend-overlay",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")",backgroundSize:"120px 120px"}}),t]})}},91337:(e,t,n)=>{n.d(t,{cn:()=>r});var a=n(29722),s=n(622);function r(...e){return(0,s.QP)((0,a.$)(e))}},95635:(e,t,n)=>{n.d(t,{x:()=>o});var a=n(95155),s=n(81750),r=n(6266);function o(){let e="!h-2 !w-2 !border-0 !bg-zinc-400";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.h7,{type:"target",position:r.yX.Top,id:"tt",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Top,id:"st",className:e}),(0,a.jsx)(s.h7,{type:"target",position:r.yX.Right,id:"tr",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Right,id:"sr",className:e}),(0,a.jsx)(s.h7,{type:"target",position:r.yX.Bottom,id:"tb",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Bottom,id:"sb",className:e}),(0,a.jsx)(s.h7,{type:"target",position:r.yX.Left,id:"tl",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Left,id:"sl",className:e})]})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6624],{8143:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});let s=(0,n(30772).A)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]])},9383:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});let s=(0,n(30772).A)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},10396:(e,t,n)=>{"use strict";n.d(t,{PlanWorkspace:()=>Y});var s=n(95155),r=n(12115),a=n(64577),o=n(25640),l=n(34306),i=n(92571),d=n(65408),c=n(30772);let u=(0,c.A)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);var m=n(8143);let x=(0,c.A)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var p=n(82879),h=n(17356),f=n(9383),g=n(9005),b=n(65738),v=n(8962),j=n(73321),y=n(48484),w=n(99979),k=n(32133),N=n(38332),C=n(91337),A=n(60874);function S({markdown:e,round:t,onApi:n,hideSubmit:o=!1,getExtraSubmitPayload:l}){let[i,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(""),[m,x]=(0,r.useState)(!1),[p,h]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[j,y]=(0,r.useState)(null),[A,E]=(0,r.useState)(!1),[P,M]=(0,r.useState)(!1),O=(0,r.useRef)(null),D=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await fetch("/api/plan/annotations",{cache:"no-store",headers:(0,w.dh)((0,w.X0)())});if(!t.ok)return;let n=await t.json();if(!e)return;d(n.annotations??[]),u(n.globalComment??""),M(!!n.submitted)}catch{}})(),()=>{e=!1}},[e,t]),(0,r.useEffect)(()=>{if(P)return;let e=setTimeout(()=>{fetch("/api/plan/annotations",{method:"PUT",headers:{"content-type":"application/json",...(0,w.dh)((0,w.X0)())},body:JSON.stringify({annotations:i,globalComment:c})}).catch(()=>{})},400);return()=>clearTimeout(e)},[i,c,P]);let T=(0,r.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed)return void h(null);let t=e.toString().trim();if(!t)return void h(null);if(!O.current?.contains(e.anchorNode))return;let n=e.getRangeAt(0).getBoundingClientRect();h({x:n.right+window.scrollX,y:n.top+window.scrollY,excerpt:t})},[]);(0,r.useEffect)(()=>{let e=()=>setTimeout(T,0);return document.addEventListener("mouseup",e),document.addEventListener("selectionchange",e),()=>{document.removeEventListener("mouseup",e),document.removeEventListener("selectionchange",e)}},[T]);let L=(0,r.useCallback)((e,t="comment",n="")=>{let s=`a-${Date.now()}-${Math.floor(1e6*Math.random())}`;d(r=>[...r,{id:s,excerpt:e,comment:n,kind:t}]),"comment"===t&&y(s),h(null),window.getSelection()?.removeAllRanges()},[]);(0,r.useEffect)(()=>{let e=e=>{let t=window.getSelection();if(!t||t.isCollapsed)return;let n=t.toString().trim();if(!n||!O.current?.contains(t.anchorNode))return;let s=document.activeElement;if(s&&/^(TEXTAREA|INPUT)$/.test(s.tagName)||!(1===e.key.length&&!e.metaKey&&!e.ctrlKey&&!e.altKey))return;e.preventDefault();let r=t.getRangeAt(0).getBoundingClientRect();v({x:r.right+window.scrollX,y:r.top+window.scrollY,excerpt:n,seed:e.key}),h(null),window.getSelection()?.removeAllRanges()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,r.useEffect)(()=>{if(!m)return;let e=e=>{let t=e.target;!t||D.current?.contains(t)||t.closest("[data-overall-toggle]")||x(!1)},t=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[m]);let I=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,comment:t}:n)),$=e=>d(t=>t.filter(t=>t.id!==e)),F=()=>{d([]),u(""),x(!1),fetch("/api/plan/annotations",{method:"DELETE",headers:(0,w.dh)((0,w.X0)())}).catch(()=>{})},U=async()=>{if(!A){E(!0);try{let e=l?.()??{};(await fetch("/api/plan/annotations",{method:"POST",headers:{"content-type":"application/json",...(0,w.dh)((0,w.X0)())},body:JSON.stringify({annotations:i,globalComment:c,...e})})).ok&&M(!0)}finally{E(!1)}}},X=(0,r.useMemo)(()=>i.filter(e=>"deletion"===e.kind||e.comment.trim()).length+ +!!c.trim(),[i,c]);return(0,r.useEffect)(()=>{n?.({liveCount:X,submitting:A,submitted:P,submit:()=>void U(),clearAll:F,annotationCount:i.length,hasGlobalComment:!!c.trim(),globalOpen:m,toggleOverall:()=>x(e=>!e),annotations:i,updateComment:I,removeAnnotation:$,focusOnAnnotation:e=>y(e),addComment:e=>L(e,"comment")})},[X,A,P,i,c,m]),(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,s.jsx)("div",{className:"relative shrink-0",children:(0,s.jsxs)("div",{className:"absolute right-3 top-2 z-30 flex items-center gap-1",children:[!o&&(0,s.jsxs)("button",{onClick:()=>void U(),disabled:A||0===X,className:(0,C.cn)("flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-semibold transition-colors",P?"border-emerald-500/40 bg-emerald-500/15 text-emerald-300":0===X?"border-white/10 text-muted-foreground opacity-50":"border-sky-500/40 bg-sky-500/15 text-sky-300 hover:bg-sky-500/25"),title:P?"Submitted — your terminal session is reading the feedback":"Submit all feedback so the agent can revise the plan",children:[P?(0,s.jsx)(a.A,{className:"size-3"}):(0,s.jsx)(f.A,{className:"size-3"}),P?"Submitted":"Submit feedback"]}),m&&(0,s.jsxs)("div",{ref:D,className:"absolute right-0 top-[calc(100%+6px)] z-50 w-[320px] rounded-md border border-white/10 bg-card p-2 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Overall feedback"}),(0,s.jsx)("button",{onClick:()=>x(!1),title:"Close (Esc)",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(g.A,{className:"size-3"})})]}),(0,s.jsx)("textarea",{autoFocus:!0,value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&e.shiftKey?(e.preventDefault(),!A&&X>0&&(U(),x(!1))):"Escape"===e.key&&(e.preventDefault(),x(!1))},placeholder:"Plan-level notes — e.g. 'split this into two phases' or 'wrong abstraction'…",rows:4,className:"w-full resize-y rounded border border-white/5 bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-sky-400/40"}),(0,s.jsx)("div",{className:"mt-1 text-right text-[9px] text-muted-foreground/70",children:"Shift+Enter to submit \xb7 Esc to close"})]})]})}),(0,s.jsx)("div",{ref:O,className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5 pt-16 text-[15px] leading-[1.6] selection:bg-[var(--accent-2,#ff7a45)]/30",children:(0,s.jsx)(R,{markdown:e,annotations:i,focusOnId:j,onClearFocus:()=>y(null),onUpdate:I,onRemove:$})}),p&&(0,s.jsxs)("div",{style:{position:"fixed",left:p.x+4,top:p.y-30,zIndex:60},className:"flex items-center gap-0.5 rounded-md border border-white/15 bg-card/95 p-0.5 shadow-lg backdrop-blur",children:[(0,s.jsx)("button",{onClick:()=>{v({...p,seed:""}),h(null),window.getSelection()?.removeAllRanges()},title:"Comment on this text",className:"rounded p-1 text-sky-300 hover:bg-sky-500/15",children:(0,s.jsx)(k.A,{className:"size-3.5"})}),(0,s.jsx)("button",{onClick:()=>L(p.excerpt,"deletion"),title:"Mark this for deletion",className:"rounded p-1 text-red-300 hover:bg-red-500/15",children:(0,s.jsx)(N.A,{className:"size-3.5"})})]}),b&&(0,s.jsx)(z,{excerpt:b.excerpt,x:b.x,y:b.y,seed:b.seed,onConfirm:e=>{L(b.excerpt,"comment",e),v(null)},onCancel:()=>v(null)})]})}function z({excerpt:e,x:t,y:n,seed:a,onConfirm:o,onCancel:l}){let[i,d]=(0,r.useState)(a);return(0,s.jsxs)("div",{style:{position:"fixed",left:t+4,top:n-6,zIndex:60},className:"w-64 rounded-md border border-white/15 bg-card/95 p-1.5 shadow-xl backdrop-blur",children:[(0,s.jsxs)("div",{className:"mb-1 line-clamp-1 text-[10px] text-muted-foreground",children:["“",e,"”"]}),(0,s.jsx)("textarea",{autoFocus:!0,value:i,onChange:e=>d(e.target.value),onFocus:e=>e.currentTarget.setSelectionRange(i.length,i.length),placeholder:"Comment… (Enter to save \xb7 Esc to cancel)",onKeyDown:e=>{e.stopPropagation(),"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),l()):(e.preventDefault(),i.trim()?o(i.trim()):l())},onBlur:()=>i.trim()?o(i.trim()):l(),className:"h-16 w-full resize-none rounded bg-white/[0.05] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.08]"})]})}function E({annotations:e,updateComment:t,removeAnnotation:n,focusOnAnnotation:r,onClose:a}){return 0===e.length?(0,s.jsx)("div",{className:"rounded-lg border border-dashed border-white/10 px-3 py-6 text-center text-[11px] text-muted-foreground",children:"Highlight any text in the plan to leave an inline comment."}):(0,s.jsx)("ul",{className:"space-y-1.5",children:e.map(e=>(0,s.jsx)("li",{className:(0,C.cn)("group rounded-md border bg-background/30 px-2 py-1.5 transition-colors hover:bg-background/50","deletion"===e.kind?"border-red-500/25":"border-sky-500/15"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{r(e.id),a?.()},title:"Jump to this excerpt in the plan",className:(0,C.cn)("block w-full truncate text-left text-[10.5px] font-mono","deletion"===e.kind?"text-red-300/90 line-through":"text-foreground/80 hover:text-foreground"),children:["“",e.excerpt,"”"]}),"deletion"!==e.kind&&(0,s.jsx)("textarea",{value:e.comment,onChange:n=>t(e.id,n.target.value),placeholder:"Write your comment…",rows:1,className:"field-sizing-content mt-1 w-full resize-none bg-transparent text-[11px] leading-snug text-foreground/90 outline-none placeholder:text-muted-foreground/60 focus:text-foreground"})]}),(0,s.jsx)("button",{onClick:()=>n(e.id),title:"Remove this annotation",className:"shrink-0 rounded p-1 text-muted-foreground/70 opacity-0 transition-opacity hover:bg-red-500/15 hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(b.A,{className:"size-3"})})]})},e.id))})}function R({markdown:e,annotations:t,focusOnId:n,onClearFocus:a,onUpdate:o,onRemove:l}){let i=(0,r.useMemo)(()=>(0,A.n$)(e),[e]);return(0,s.jsx)("div",{className:"mx-auto w-full max-w-[66ch] space-y-4",children:i.map((e,r)=>(0,s.jsx)(P,{block:e,index:r,annotations:t,focusOnId:n,onClearFocus:a,onUpdate:o,onRemove:l},r))})}function P({block:e,index:t,annotations:n,focusOnId:r,onClearFocus:a,onUpdate:o,onRemove:l}){if("code"===e.kind)return(0,s.jsx)(A.NG,{text:e.text});if("table"===e.kind)return(0,s.jsx)(A.QH,{block:e});let i=(0,s.jsx)(M,{text:e.text,annotations:n,focusOnId:r,onClearFocus:a,onUpdate:o,onRemove:l}),d=(0,A.Vq)(e.kind)?(0,A.vB)(t):void 0;return(0,s.jsx)(s.Fragment,{children:(0,A.aM)(e,i,"reading",d)})}function M({text:e,annotations:t,focusOnId:n,onClearFocus:r,onUpdate:a,onRemove:o}){let l=t.map(t=>({a:t,idx:e.indexOf(t.excerpt)})).filter(e=>e.idx>=0).sort((e,t)=>e.idx-t.idx);if(!l.length)return(0,s.jsx)(D,{text:e});let i=[],d=0;for(let{a:t,idx:c}of l)c<d||(c>d&&i.push((0,s.jsx)(D,{text:e.slice(d,c)},`p-${d}`)),i.push((0,s.jsx)(O,{annotation:t,autoFocus:n===t.id,onClearFocus:r,onUpdate:a,onRemove:o},t.id)),d=c+t.excerpt.length);return d<e.length&&i.push((0,s.jsx)(D,{text:e.slice(d)},"p-tail")),(0,s.jsx)(s.Fragment,{children:i})}function O({annotation:e,autoFocus:t,onClearFocus:n,onUpdate:a,onRemove:o}){let l=(0,r.useRef)(null);return((0,r.useEffect)(()=>{if(t&&l.current){l.current.focus();let e=l.current.value;l.current.setSelectionRange(e.length,e.length),n()}},[t,n]),"deletion"===(e.kind??"comment"))?(0,s.jsxs)("span",{className:"relative inline",children:[(0,s.jsx)("span",{className:"rounded bg-red-500/15 px-0.5 text-red-200/90 line-through decoration-red-300/70 decoration-2",children:(0,s.jsx)(D,{text:e.excerpt})}),(0,s.jsx)("button",{type:"button",onClick:()=>o(e.id),title:"Unmark",className:"ml-0.5 inline-flex translate-y-[-1px] items-center text-red-300/70 hover:text-red-300",children:(0,s.jsx)(b.A,{className:"size-3"})})]}):(0,s.jsx)("span",{className:"rounded bg-[var(--accent-2,#ff7a45)]/15 px-0.5","data-annotation-id":e.id,children:(0,s.jsx)(D,{text:e.excerpt})})}function D({text:e}){return(0,s.jsx)(A.cV,{text:e})}let T=(0,c.A)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);function L({pendingPlan:e=!1}={}){let t=(0,j.useRouter)(),[n,i]=(0,r.useState)([]),[d,c]=(0,r.useState)(null),[m,x]=(0,r.useState)(null),[p,h]=(0,r.useState)("markdown");(0,r.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/plan/history");if(!e.ok)return;let t=await e.json();i(t.items),t.items.length&&!d&&c(t.items[0].id)}catch{}})()},[]),(0,r.useEffect)(()=>{d&&(async()=>{let e=await fetch(`/api/plan/history?id=${encodeURIComponent(d)}`);e.ok&&x(await e.json())})()},[d]);let f=(0,r.useMemo)(()=>(function(e){let t=new Map;for(let n of e){let e=new Date(n.archivedAt).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"});t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries())})(n),[n]),b=e?(0,s.jsxs)("button",{onClick:()=>t.push((0,w.rc)()),className:"glass pointer-events-auto fixed left-3 top-3 z-30 flex h-10 items-center gap-1.5 rounded-full px-3 text-[11px] font-semibold text-sky-300 transition-colors hover:bg-sky-500/15",title:"Return to the plan that's still pending review",children:[(0,s.jsx)(T,{className:"size-3.5"})," Back to current plan"]}):null;return 0===n.length?(0,s.jsxs)(s.Fragment,{children:[b,(0,s.jsx)("div",{className:"flex h-screen items-center justify-center px-6 pt-14 text-center",children:(0,s.jsxs)("div",{className:"max-w-md text-sm text-muted-foreground",children:[(0,s.jsx)(u,{className:"mx-auto mb-3 size-7 text-muted-foreground/40"}),(0,s.jsx)("div",{className:"mb-2 text-base font-semibold text-foreground",children:"No plans yet."}),"Ask the agent to propose a feature in your terminal session — it lands here via MCP and you can review + annotate on both sides. Past plans get archived to this page for browsing."]})})]}):(0,s.jsxs)("div",{className:"flex h-screen min-h-0 pt-14",children:[b,m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"glass pointer-events-auto fixed left-1/2 top-3 z-30 flex -translate-x-1/2 items-center gap-0.5 rounded-full p-1",children:[(0,s.jsx)(I,{active:"markdown"===p,onClick:()=>h("markdown"),children:"Plan"}),(0,s.jsx)(I,{active:"map"===p,onClick:()=>h("map"),icon:(0,s.jsx)(o.A,{className:"size-3"}),children:"Features"}),(0,s.jsx)(I,{active:"db"===p,onClick:()=>h("db"),icon:(0,s.jsx)(l.A,{className:"size-3"}),children:"Schema"})]}),(0,s.jsxs)("div",{className:"glass pointer-events-auto fixed right-3 top-3 z-30 flex h-9 items-center gap-2 rounded-full px-3",children:[(0,s.jsx)("span",{className:(0,C.cn)("rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide","approved"===m.verdict?"bg-emerald-500/15 text-emerald-300":"bg-red-500/15 text-red-300"),children:m.verdict}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(m.archivedAt).toLocaleString()})]})]}),(0,s.jsxs)("aside",{className:"flex w-64 min-w-0 shrink-0 flex-col border-r border-white/5 bg-card/30",children:[(0,s.jsxs)("div",{className:"border-b border-white/5 px-3 py-2 text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Plan history \xb7 ",n.length]}),(0,s.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto",children:f.map(([e,t])=>(0,s.jsxs)("li",{children:[(0,s.jsx)("div",{className:"px-3 pb-1 pt-3 text-[9px] font-semibold uppercase tracking-widest text-muted-foreground/60",children:e}),(0,s.jsx)("ul",{children:t.map(e=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{onClick:()=>c(e.id),className:(0,C.cn)("flex w-full items-start gap-1.5 px-3 py-1.5 text-left text-[12px] transition-colors",d===e.id?"bg-white/[0.06] text-foreground":"text-muted-foreground hover:bg-white/[0.03] hover:text-foreground"),children:[(0,s.jsx)("span",{className:(0,C.cn)("mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded-full","approved"===e.verdict?"bg-emerald-500/15 text-emerald-300":"bg-red-500/15 text-red-300"),title:e.verdict,children:"approved"===e.verdict?(0,s.jsx)(a.A,{className:"size-2.5"}):(0,s.jsx)(g.A,{className:"size-2.5"})}),(0,s.jsx)("span",{className:"line-clamp-2",children:e.description})]})},e.id))})]},e))})]}),m?(0,s.jsx)("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:["markdown"===p&&(0,s.jsxs)("div",{className:"px-5 py-4",children:[(0,s.jsx)(A.pO,{markdown:m.markdown}),""===m.markdown.replace(/^#[^\n]*\n?/,"").trim()&&(0,s.jsx)("p",{className:"mt-2 text-[13px] text-muted-foreground",children:(m.featureGraph?.features?.length??0)===0&&(m.draftDoc?.tables?.length??0)===0&&(m.draftDoc?.endpoints?.length??0)===0?"This plan was approved without a detailed write-up — no features or schema were attached either.":"This plan has no written body. See the Features and Schema tabs for what it proposed."}),m.globalComment&&(0,s.jsxs)("div",{className:"mt-4 rounded-lg border border-white/5 bg-card/40 p-3",children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Overall feedback"}),(0,s.jsx)("div",{className:"text-[12px] whitespace-pre-wrap",children:m.globalComment})]})]}),"map"===p&&(0,s.jsx)($,{featureGraph:m.featureGraph}),"db"===p&&(0,s.jsx)(F,{draftDoc:m.draftDoc})]})}):(0,s.jsx)("section",{className:"flex min-h-0 min-w-0 flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a plan on the left to view it."})]})}function I({active:e,onClick:t,icon:n,children:r}){return(0,s.jsxs)("button",{onClick:t,className:(0,C.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:[n,r]})}function $({featureGraph:e}){let t=e?.features??[];return 0===t.length?(0,s.jsx)("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:"No features were proposed in this plan."}):(0,s.jsx)("div",{className:"grid gap-3 px-5 py-4 sm:grid-cols-2 lg:grid-cols-3",children:t.map((e,t)=>(0,s.jsxs)("div",{className:"rounded-lg border border-sky-500/20 bg-card/50 p-3",children:[(0,s.jsxs)("div",{className:"mb-1.5 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"rounded bg-sky-500/15 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"feature"}),e.cluster&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.cluster})]}),(0,s.jsx)("div",{className:"text-sm font-semibold leading-tight",children:e.title}),e.role&&(0,s.jsx)("div",{className:"mt-1 text-[11px] text-muted-foreground",children:e.role}),e.plain&&(0,s.jsx)("div",{className:"mt-2 text-[12px] text-foreground/80",children:e.plain})]},t))})}function F({draftDoc:e}){let t=e?.tables??[],n=e?.endpoints??[];return 0===t.length&&0===n.length?(0,s.jsx)("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:"No schema was proposed in this plan."}):(0,s.jsxs)("div",{className:"space-y-5 px-5 py-4",children:[t.length>0&&(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-2 text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Tables \xb7 ",t.length]}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:t.map(e=>(0,s.jsxs)("div",{className:"rounded-lg border border-white/5 bg-card/40 p-3",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"font-mono text-[13px] font-semibold",children:e.name}),e.domain&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.domain})]}),e.description&&(0,s.jsx)("div",{className:"mb-1.5 text-[11px] text-muted-foreground",children:e.description}),(0,s.jsx)("ul",{className:"space-y-0.5 text-[11px]",children:e.columns.map((e,t)=>(0,s.jsxs)("li",{className:"flex items-baseline gap-1.5",children:[(0,s.jsx)("code",{className:"rounded bg-white/5 px-1 font-mono text-[11px]",children:e.name}),(0,s.jsx)("span",{className:"text-muted-foreground",children:e.type}),e.isPk&&(0,s.jsx)("span",{className:"text-amber-300/80 text-[9px]",children:"PK"}),e.isFk&&(0,s.jsx)("span",{className:"text-sky-300/80 text-[9px]",children:"FK"}),!e.nullable&&(0,s.jsx)("span",{className:"text-muted-foreground/60 text-[9px]",children:"NOT NULL"})]},t))})]},e.id))})]}),n.length>0&&(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-2 text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Endpoints \xb7 ",n.length]}),(0,s.jsx)("ul",{className:"space-y-1.5",children:n.map(e=>{let t;return(0,s.jsxs)("li",{className:"flex items-center gap-2 rounded-md border border-white/5 bg-card/40 px-2.5 py-1.5 text-[12px]",children:[(0,s.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-bold",style:(t=U[e.method.toUpperCase()]??"#8a8a8a",{background:`${t}22`,color:t}),children:e.method}),(0,s.jsx)("span",{className:"font-mono",children:e.path}),e.description&&(0,s.jsx)("span",{className:"ml-2 text-[11px] text-muted-foreground",children:e.description})]},e.id)})})]})]})}let U={GET:"#7bd389",POST:"#4ea1ff",PUT:"#ffb86b",PATCH:"#ffb86b",DELETE:"#ff3860"};function X({markdown:e}){let t=(0,r.useMemo)(()=>(0,A.n$)(e).map((e,t)=>({b:e,i:t})).filter(({b:e})=>(0,A.Vq)(e.kind)).map(({b:e,i:t})=>({id:(0,A.vB)(t),level:(0,A.F8)(e.kind),label:(0,A.kz)(e.text)})).filter(e=>e.label.length>0),[e]),[n,a]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if("u"<typeof IntersectionObserver||0===t.length)return;let e=t.map(e=>document.getElementById(e.id)).filter(e=>null!==e);if(0===e.length)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top);t[0]&&a(t[0].target.id)},{rootMargin:"-12% 0px -70% 0px",threshold:0});return e.forEach(e=>n.observe(e)),()=>n.disconnect()},[t]),(0,s.jsxs)("aside",{className:"flex w-60 shrink-0 flex-col overflow-y-auto border-r border-white/5 bg-background pt-16",children:[(0,s.jsx)("div",{className:"px-4 pb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Sections"}),0===t.length?(0,s.jsx)("p",{className:"px-4 text-[12px] text-muted-foreground/70",children:"No headings in this plan."}):(0,s.jsx)("nav",{className:"space-y-0.5 px-2 pb-6",children:t.map(e=>(0,s.jsx)("button",{onClick:()=>{var t;let n;return t=e.id,void((n=document.getElementById(t))&&(n.scrollIntoView({behavior:"smooth",block:"start"}),a(t)))},title:e.label,style:{paddingLeft:`${.5+.75*e.level}rem`},className:(0,C.cn)("block w-full truncate rounded py-1 pr-2 text-left text-[12px] leading-snug transition-colors",n===e.id?"bg-white/10 font-medium text-foreground":"text-muted-foreground hover:bg-white/[0.05] hover:text-foreground"),children:e.label},e.id))})]})}var B=n(50981),K=n(74350),q=n(4474),G=n(97358);function H({open:e,onOpenChange:t,onConfirmed:n}){let[o,l]=(0,r.useState)("bypassPermissions"),[i,d]=(0,r.useState)(!1);async function c(){d(!0);try{await fetch("/api/preferences",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({planApprovalMode:o})}).catch(()=>{}),t(!1),n()}finally{d(!1)}}return(0,s.jsx)(K.lG,{open:e,onOpenChange:t,children:(0,s.jsxs)(K.Cf,{className:"max-w-lg",children:[(0,s.jsxs)(K.c7,{children:[(0,s.jsxs)(K.L3,{className:"flex items-center gap-2",children:[(0,s.jsx)(B.A,{className:"size-4 text-emerald-400"}),"After approving, the agent should…"]}),(0,s.jsx)(K.rr,{children:"Pick the permission mode your terminal session enters when you approve a plan. We ask once and remember it for every project — change it anytime in Settings."})]}),(0,s.jsx)("div",{className:"space-y-2 py-1",children:G.pC.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>l(e.value),className:(0,C.cn)("flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors",o===e.value?"border-emerald-500/50 bg-emerald-500/10":"border-white/10 bg-white/[0.03] hover:bg-white/[0.06]"),children:[(0,s.jsx)("span",{className:(0,C.cn)("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border",o===e.value?"border-emerald-400 bg-emerald-400/20":"border-white/30"),children:o===e.value&&(0,s.jsx)(a.A,{className:"size-3 text-emerald-300"})}),(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e.label}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e.description})]})]},e.value))}),(0,s.jsxs)(K.Es,{className:"items-center justify-between gap-2 sm:justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),(0,s.jsx)(q.$,{onClick:c,disabled:i,size:"sm",children:i?"Saving…":"Save & approve"})]})]})})}var V=n(30210),_=n(26856);function Y({dbProps:e,mapProps:t,planMarkdown:n,forceHistory:c=!1}){let k=(0,j.useRouter)(),{status:N,discard:A}=(0,y.j)(),[z,R]=(0,r.useState)("map"),[P,M]=(0,r.useState)(!1),[O,D]=(0,r.useState)(!1),[T,I]=(0,r.useState)(null),$=(0,r.useCallback)(async()=>{await fetch("/api/plan/approve",{method:"POST",headers:(0,w.dh)((0,w.X0)())}).catch(()=>{}),I({features:N.features,tables:N.tables,endpoints:N.endpoints})},[N.features,N.tables,N.endpoints]),F=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/preferences",{cache:"no-store"});if((await e.json()).planApprovalModeConfigured)return void $()}catch{$();return}D(!0)},[$]),[U,B]=(0,r.useState)(null),K=(0,r.useCallback)(e=>B(e),[]),q=(0,r.useRef)(null),G=(0,r.useRef)(null),Q=(0,r.useRef)(e.draft),[Z,ee]=(0,r.useState)(!1),et=(0,r.useCallback)(()=>ee(!0),[]),[en,es]=(0,r.useState)([]),[er,ea]=(0,r.useState)(!1),[eo,el]=(0,r.useState)(""),ei=(0,r.useCallback)(e=>{el(e),ea(!0)},[]),ed=(0,r.useRef)(en);(0,r.useEffect)(()=>{ed.current=en},[en]),(0,r.useEffect)(()=>{es([]),ea(!1)},[N.proposedAt]),(0,r.useEffect)(()=>{let e=()=>void fetch("/api/plan/presence",{method:"POST",cache:"no-store",headers:(0,w.dh)((0,w.X0)())}).catch(()=>{});e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]);let ec=(0,r.useCallback)(()=>({draft:Q.current,questions:ed.current}),[]),eu=(0,r.useMemo)(()=>{let n=[];for(let e of t.nodes)n.push(`feature: ${e.title}`);for(let t of e.draft?.tables??[])n.push(`table: ${t.name}`);for(let t of e.tables)n.push(`table: ${t.name}`);for(let t of e.draft?.endpoints??[])n.push(`endpoint: ${t.method} ${t.path}`);for(let t of e.endpoints)n.push(`endpoint: ${t.method} ${t.path}`);return Array.from(new Set(n))},[t.nodes,e]),em=U?(0,s.jsx)(E,{annotations:U.annotations,updateComment:U.updateComment,removeAnnotation:U.removeAnnotation,focusOnAnnotation:U.focusOnAnnotation,onClose:()=>q.current?.close()}):null,ex=(0,r.useCallback)(()=>{q.current?.open()},[]),ep=(0,r.useCallback)(()=>{"db"===z?G.current?.openComments():q.current?.openComments()},[z]),eh=(0,r.useCallback)(e=>{U?.addComment(e)},[U]),ef=(0,r.useCallback)(e=>{U?.focusOnAnnotation(e),"db"===z?G.current?.openComments():q.current?.openComments()},[U,z]),[eg,eb]=(0,r.useState)(()=>{try{let e=window.localStorage.getItem("beacon:plan-left-pct");return e?Math.max(20,Math.min(80,Number(e))):50}catch{return 50}}),ev=(0,r.useRef)(null),ej=(0,r.useRef)(!1),ey=(0,r.useCallback)(e=>{e.preventDefault(),ej.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);(0,r.useEffect)(()=>{let e=e=>{if(!ej.current||!ev.current)return;let t=ev.current.getBoundingClientRect();eb(Math.max(20,Math.min(80,(e.clientX-t.left)/t.width*100)))},t=()=>{if(ej.current){ej.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("beacon:plan-left-pct",String(eg))}catch{}}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[eg]);let ew=async()=>{await fetch("/api/plan/annotations",{method:"DELETE",headers:(0,w.dh)((0,w.X0)())}).catch(()=>{}),await A(),k.refresh()};if((!N.pending||c)&&!T)return(0,s.jsx)(L,{pendingPlan:N.pending});let ek=t.nodes.length>0||e.tables.length>0||e.endpoints.length>0||(e.draft?.tables.length??0)>0||(e.draft?.endpoints.length??0)>0,eN=ek&&!P,eC=!ek||P,eA=((U?.liveCount??0)>0||Z||en.length>0)&&!U?.submitted;return(0,s.jsxs)("div",{className:"relative flex h-screen flex-col",children:[T&&(0,s.jsxs)("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center gap-5 bg-background/97 px-6 text-center backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-emerald-500/15",children:(0,s.jsx)(a.A,{className:"size-6 text-emerald-300"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Plan approved"}),(0,s.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:T.features>0||T.tables>0||T.endpoints>0?"It's committed. Here's where to find it:":"It's archived to your plan history."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[T.features>0&&(0,s.jsxs)("button",{onClick:()=>k.push("/map?view=ROADMAP"),className:"flex items-center gap-2 rounded-lg border border-white/12 px-3 py-2 text-sm text-foreground transition-colors hover:bg-white/[0.06]",children:[(0,s.jsx)(o.A,{className:"size-4 text-sky-300"})," ",T.features," feature",1===T.features?"":"s"," → Map"]}),(T.tables>0||T.endpoints>0)&&(0,s.jsxs)("button",{onClick:()=>k.push("/map?view=DATABASE"),className:"flex items-center gap-2 rounded-lg border border-white/12 px-3 py-2 text-sm text-foreground transition-colors hover:bg-white/[0.06]",children:[(0,s.jsx)(l.A,{className:"size-4 text-violet-300"})," ",T.tables," table",1===T.tables?"":"s"," \xb7 ",T.endpoints," endpoint",1===T.endpoints?"":"s"," → Database"]})]}),(0,s.jsx)("button",{onClick:()=>{I(null),k.push((0,w.rc)({view:"history"}))},className:"rounded-full border border-white/12 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:"Done — browse plan history"})]}),U?.submitted&&(0,s.jsxs)("div",{className:"absolute inset-0 z-40 flex flex-col items-center justify-center gap-4 bg-background/95 px-6 text-center backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-sky-500/15",children:(0,s.jsx)(i.A,{className:"size-6 animate-spin text-sky-300"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Feedback sent"}),(0,s.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Your terminal session is revising the plan based on your comments. The updated plan will appear here automatically — no need to refresh."})]}),(0,s.jsx)("button",{onClick:()=>k.push((0,w.rc)({view:"history"})),className:"rounded-full border border-white/12 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:"Browse past plans"})]}),(0,s.jsxs)("div",{className:"pointer-events-none fixed right-3 top-3 z-30 flex items-center gap-2",children:[ek&&P&&(0,s.jsx)("button",{onClick:()=>M(!1),title:"Collapse — show the board again",className:"glass pointer-events-auto flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,s.jsx)(d.A,{className:"size-3.5"})}),(0,s.jsxs)("div",{className:"glass pointer-events-auto flex h-10 items-center gap-0.5 rounded-full px-1",children:[(0,s.jsx)("button",{onClick:()=>k.push((0,w.rc)({view:"history"})),title:"Browse past plans (you can come back to this one)",className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,s.jsx)(u,{className:"size-3.5"})}),(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,s.jsx)("button",{onClick:ex,disabled:!U,title:"Open the side panel (details)",className:"relative flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,s.jsx)(m.A,{className:"size-3.5"})}),(0,s.jsxs)("button",{onClick:ep,disabled:!U,title:U?.annotationCount?`Open comments \xb7 ${U.annotationCount} comment${1===U.annotationCount?"":"s"} so far`:"Open comments — select a card/table and 'Comment on this', or highlight text",className:"relative flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,s.jsx)(x,{className:"size-3.5"}),U&&(U.annotationCount??0)>0&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-sky-500 px-1 text-[9px] font-semibold text-white",children:U.annotationCount})]}),(0,s.jsxs)("button",{"data-overall-toggle":!0,onClick:()=>U?.toggleOverall?.(),disabled:!U?.toggleOverall,title:U?.hasGlobalComment?"Edit your overall feedback":"Add overall plan-level feedback",className:(0,C.cn)("relative flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",U?.globalOpen?"bg-white/10 text-foreground":U?.hasGlobalComment?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,s.jsx)(p.A,{className:"size-3.5"}),U?.hasGlobalComment&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-sky-400"})]}),(0,s.jsxs)("button",{onClick:()=>ea(e=>!e),title:"Ask the agent a question about a node (answered in its next round)",className:(0,C.cn)("relative flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",er?"bg-white/10 text-foreground":en.length?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,s.jsx)(h.A,{className:"size-3.5"}),en.length>0&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-sky-500 px-1 text-[9px] font-semibold text-white",children:en.length})]}),(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-white/10"}),(0,s.jsxs)("button",{onClick:()=>U?.submit(),disabled:!U||U.submitting||0===U.liveCount&&!Z&&0===en.length,title:U&&(0!==U.liveCount||Z||0!==en.length)?U.submitted?"Submitted — your terminal session is reading the feedback":"Submit feedback (comments + canvas edits) so the agent can revise the plan":"Highlight text or edit the canvas, then submit",className:(0,C.cn)("flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-semibold transition-colors",U?.submitted?"text-sky-300":U&&(0!==U.liveCount||Z||0!==en.length)?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground opacity-50"),children:[U?.submitted?(0,s.jsx)(a.A,{className:"size-3"}):(0,s.jsx)(f.A,{className:"size-3"}),U?.submitted?"Submitted":"Feedback"]}),eA&&(0,s.jsxs)("button",{onClick:()=>{U?.clearAll?.(),ee(!1),es([])},title:"Discard your unsubmitted comments / canvas edits so you can approve the plan as-is",className:"flex shrink-0 items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium text-amber-300/90 transition-colors hover:bg-amber-500/15",children:[(0,s.jsx)(g.A,{className:"size-3"})," Clear to approve"]}),(0,s.jsxs)("button",{onClick:()=>void F(),disabled:eA,title:eA?"You have unsubmitted feedback — submit it, or click ‘Clear to approve’ to drop it":"Approve the plan",className:(0,C.cn)("flex shrink-0 items-center gap-1 rounded-full 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",eA&&"opacity-40 hover:bg-emerald-500/15"),children:[(0,s.jsx)(a.A,{className:"size-3"})," Approve"]}),(0,s.jsxs)("button",{onClick:ew,className:"flex shrink-0 items-center gap-1 rounded-full px-2.5 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,s.jsx)(b.A,{className:"size-3"})," Discard"]}),(0,s.jsx)(H,{open:O,onOpenChange:D,onConfirmed:()=>void $()})]})]}),er&&(0,s.jsxs)("div",{className:"fixed right-3 top-16 z-30 w-80 rounded-xl border border-white/10 bg-card p-3 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Ask the agent"}),(0,s.jsx)("button",{onClick:()=>ea(!1),title:"Close",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(g.A,{className:"size-3.5"})})]}),(0,s.jsx)(J,{targets:eu,initialTarget:eo,onAdd:e=>es(t=>[...t,e])}),en.length>0&&(0,s.jsx)("ul",{className:"mt-2 space-y-1",children:en.map((e,t)=>(0,s.jsxs)("li",{className:"group flex items-start justify-between gap-2 rounded-md border border-white/5 bg-background/40 px-2 py-1",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-mono text-[10px] text-sky-300/90",children:e.target}),(0,s.jsx)("div",{className:"text-[11px] text-foreground/90",children:e.question})]}),(0,s.jsx)("button",{onClick:()=>es(e=>e.filter((e,n)=>n!==t)),title:"Remove",className:"shrink-0 rounded p-0.5 text-muted-foreground/70 opacity-0 transition-opacity hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(g.A,{className:"size-3"})})]},t))}),(0,s.jsx)("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"Questions are sent with your feedback on Submit — the agent answers them in its next round."})]}),(0,s.jsxs)("div",{ref:ev,className:"flex min-h-0 flex-1",children:[eC&&(0,s.jsx)(X,{markdown:n}),(0,s.jsxs)("div",{className:(0,C.cn)("relative flex min-w-0 flex-col",!eN&&"flex-1"),style:eN?{width:`${eg}%`}:void 0,children:[eN&&(0,s.jsx)("div",{className:"pointer-events-none absolute right-3 top-3 z-20",children:(0,s.jsx)("button",{onClick:()=>M(!0),title:"Expand the plan to full width",className:"glass pointer-events-auto flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:(0,s.jsx)(v.A,{className:"size-3.5"})})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:(0,s.jsx)(S,{markdown:n,round:N.proposedAt,onApi:K,hideSubmit:!0,getExtraSubmitPayload:ec})})]}),eN&&(0,s.jsx)("div",{onPointerDown:ey,className:"group relative w-px shrink-0 cursor-col-resize bg-white/5 hover:bg-white/15",title:"Drag to resize",children:(0,s.jsx)("div",{className:"absolute inset-y-0 -left-1.5 right-[-6px] z-10"})}),eN&&(0,s.jsxs)("div",{className:"relative flex min-w-0 flex-col",style:{width:`${100-eg}%`},children:[(0,s.jsx)("div",{className:"pointer-events-none absolute left-3 top-3 z-20",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-1 rounded-full p-0.5",children:[(0,s.jsx)(W,{active:"map"===z,onClick:()=>R("map"),icon:(0,s.jsx)(o.A,{className:"size-3"}),children:"Map"}),(0,s.jsx)(W,{active:"db"===z,onClick:()=>R("db"),icon:(0,s.jsx)(l.A,{className:"size-3"}),children:"Database"})]})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:"map"===z?(0,s.jsx)(V.MapClient,{view:t.view,nodes:t.nodes,edges:t.edges,embedded:!0,commentsContent:em,commentsCount:U?.annotationCount??0,controlRef:q,onAskAgent:ei,onAddComment:eh,annotations:U?.annotations,onPinClick:ef,onUpdateComment:U?.updateComment,onRemoveComment:U?.removeAnnotation}):(0,s.jsx)(_.DbMapClient,{tables:e.tables,relations:e.relations,endpoints:e.endpoints,draft:e.draft,workspaceId:e.workspaceId,embedded:!0,draftRef:Q,onEdit:et,controlRef:G,commentsContent:em,commentsCount:U?.annotationCount??0,onAddComment:eh,annotations:U?.annotations,onPinClick:ef,onUpdateComment:U?.updateComment,onRemoveComment:U?.removeAnnotation})})]})]})]})}function J({targets:e,onAdd:t,initialTarget:n}){let[a,o]=(0,r.useState)(n||e[0]||""),[l,i]=(0,r.useState)("");(0,r.useEffect)(()=>{n&&o(n)},[n]),(0,r.useEffect)(()=>{!a&&e[0]&&o(e[0])},[e,a]);let d=()=>{let e=l.trim();e&&(t({target:a||"(plan)",question:e}),i(""))};return(0,s.jsxs)("div",{className:"space-y-1.5",children:[e.length>0&&(0,s.jsx)("select",{value:a,onChange:e=>o(e.target.value),className:"w-full rounded border border-white/10 bg-background px-2 py-1 text-[11px] outline-none focus:border-sky-400/40",children:e.map(e=>(0,s.jsx)("option",{value:e,className:"bg-card",children:e},e))}),(0,s.jsx)("textarea",{value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())},rows:2,placeholder:"e.g. why a new table instead of reusing users? (⌘/Ctrl+Enter to add)",className:"w-full resize-y rounded border border-white/10 bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-sky-400/40"}),(0,s.jsx)("button",{onClick:d,disabled:!l.trim(),className:(0,C.cn)("w-full rounded-md px-2 py-1 text-[11px] font-semibold transition-colors",l.trim()?"bg-sky-500/15 text-sky-300 hover:bg-sky-500/25":"text-muted-foreground opacity-50"),children:"Add question"})]})}function W({active:e,onClick:t,icon:n,children:r}){return(0,s.jsxs)("button",{onClick:t,className:(0,C.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,r]})}},22137:(e,t,n)=>{Promise.resolve().then(n.bind(n,10396))},38332:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});let s=(0,n(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"}]])},48484:(e,t,n)=>{"use strict";n.d(t,{PlanProvider:()=>d,j:()=>c});var s=n(95155),r=n(12115),a=n(73321),o=n(99979);let l={pending:!1,proposedAt:0,tables:0,endpoints:0,features:0},i=(0,r.createContext)(null);function d({children:e}){let t=(0,a.useRouter)(),[n,c]=(0,r.useState)(l),u=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/plan",{method:"GET",cache:"no-store",headers:(0,o.dh)((0,o.X0)())});if(!e.ok)return;let t=await e.json();c(t)}catch{}},[]);(0,r.useEffect)(()=>{u();let e=setInterval(()=>void u(),4e3);return()=>clearInterval(e)},[u]);let m=(0,r.useCallback)(async()=>{await fetch("/api/plan",{method:"DELETE",headers:(0,o.dh)((0,o.X0)())}).catch(()=>{}),c(l),t.refresh()},[t]),x=(0,r.useCallback)(async()=>{await fetch("/api/plan/approve",{method:"POST",headers:(0,o.dh)((0,o.X0)())}).catch(()=>{}),c(l),t.refresh()},[t]);return(0,s.jsx)(i.Provider,{value:{status:n,discard:m,approvePlan:x,refresh:u},children:e})}function c(){let e=(0,r.useContext)(i);if(!e)throw Error("usePlan must be used inside PlanProvider");return e}},50981:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});let s=(0,n(30772).A)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},82879:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});let s=(0,n(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"}]])},92571:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});let s=(0,n(30772).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},97358:(e,t,n)=>{"use strict";n.d(t,{pC:()=>s});let s=[{value:"default",label:"Manual approval",description:"Approve each tool call yourself — Claude Code's default."},{value:"acceptEdits",label:"Auto-accept edits",description:"Auto-approve file edits; still ask before running other tools."},{value:"bypassPermissions",label:"Bypass permissions",description:"Auto-approve every tool call (like --dangerously-skip-permissions)."},{value:"auto",label:"Auto",description:"Autonomous, gated by a safety classifier (needs a recent Claude Code + Sonnet 4.6+)."}]},99979:(e,t,n)=>{"use strict";function s(){return new URLSearchParams(window.location.search).get("ws")}function r(e){return e?{"x-beacon-workspace":e}:{}}function a(e){let t=new URLSearchParams,n=s();for(let[s,r]of(n&&t.set("ws",n),Object.entries(e??{})))t.set(s,r);let r=t.toString();return r?`/plan?${r}`:"/plan"}n.d(t,{X0:()=>s,dh:()=>r,rc:()=>a})}},e=>{e.O(0,[2574,3862,8500,4294,766,1202,8207,8441,3794,7358],()=>e(e.s=22137)),_N_E=e.O()}]);