trybeacon 0.1.3 → 0.1.4

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 (89) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +8 -8
  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 +9 -9
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +9 -9
  18. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_index.segment.rsc +9 -9
  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 +1 -1
  23. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/docs.html +1 -1
  25. package/.next/server/app/docs.rsc +9 -9
  26. package/.next/server/app/docs.segments/_full.segment.rsc +9 -9
  27. package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  28. package/.next/server/app/docs.segments/_index.segment.rsc +9 -9
  29. package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
  30. package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  31. package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  32. package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
  33. package/.next/server/app/feedback.html +1 -1
  34. package/.next/server/app/feedback.rsc +9 -9
  35. package/.next/server/app/feedback.segments/_full.segment.rsc +9 -9
  36. package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
  37. package/.next/server/app/feedback.segments/_index.segment.rsc +9 -9
  38. package/.next/server/app/feedback.segments/_tree.segment.rsc +1 -1
  39. package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
  40. package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
  41. package/.next/server/app/help/page_client-reference-manifest.js +1 -1
  42. package/.next/server/app/help.html +1 -1
  43. package/.next/server/app/help.rsc +9 -9
  44. package/.next/server/app/help.segments/_full.segment.rsc +9 -9
  45. package/.next/server/app/help.segments/_head.segment.rsc +1 -1
  46. package/.next/server/app/help.segments/_index.segment.rsc +9 -9
  47. package/.next/server/app/help.segments/_tree.segment.rsc +1 -1
  48. package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
  49. package/.next/server/app/help.segments/help.segment.rsc +1 -1
  50. package/.next/server/app/index.html +1 -1
  51. package/.next/server/app/index.rsc +9 -9
  52. package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  53. package/.next/server/app/index.segments/_full.segment.rsc +9 -9
  54. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  55. package/.next/server/app/index.segments/_index.segment.rsc +9 -9
  56. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  57. package/.next/server/app/map/page.js +2 -2
  58. package/.next/server/app/map/page.js.nft.json +1 -1
  59. package/.next/server/app/map/page_client-reference-manifest.js +1 -1
  60. package/.next/server/app/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/plan/page.js +2 -2
  62. package/.next/server/app/plan/page.js.nft.json +1 -1
  63. package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
  64. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app-paths-manifest.json +8 -8
  66. package/.next/server/chunks/2525.js +1 -0
  67. package/.next/server/chunks/333.js +1 -1
  68. package/.next/server/middleware-build-manifest.js +1 -1
  69. package/.next/server/pages/404.html +1 -1
  70. package/.next/server/pages/500.html +1 -1
  71. package/.next/server/server-reference-manifest.js +1 -1
  72. package/.next/server/server-reference-manifest.json +1 -1
  73. package/.next/static/chunks/{3578-63ae773de1f640f9.js → 7891-585996b11715c8eb.js} +1 -1
  74. package/.next/static/chunks/app/{layout-2a51aad13d2ead37.js → layout-d4b764b7fd4ec5c6.js} +1 -1
  75. package/.next/static/chunks/app/map/{page-372190c290ac7c11.js → page-058b99be72068acb.js} +1 -1
  76. package/.next/static/chunks/app/plan/{page-33f773c27042a370.js → page-dcd783d55e97a5c4.js} +1 -1
  77. package/.next/trace +37 -37
  78. package/.next/trace-build +1 -1
  79. package/dist/bin/doctor.js +1 -1
  80. package/dist/bin/hook.js +1 -1
  81. package/dist/bin/mcp.js +3 -3
  82. package/dist/bin/plan.js +1 -1
  83. package/dist/bin/uninstall.js +1 -1
  84. package/dist/lib/assets.js +1 -1
  85. package/dist/lib/global-install.js +1 -1
  86. package/package.json +1 -1
  87. package/.next/server/chunks/6636.js +0 -1
  88. /package/.next/static/{0iRi3qaAhwRK-PeUsJDYf → NZ--RKeiRmheNS1cScXxv}/_buildManifest.js +0 -0
  89. /package/.next/static/{0iRi3qaAhwRK-PeUsJDYf → NZ--RKeiRmheNS1cScXxv}/_ssgManifest.js +0 -0
package/.next/trace-build CHANGED
@@ -1 +1 @@
1
- [{"name":"run-webpack","duration":6804442,"timestamp":197233362884,"id":14,"parentId":1,"tags":{},"startTime":1781011953304,"traceId":"2ebfd76be84b7cd1"},{"name":"run-typescript","duration":3341930,"timestamp":197240168560,"id":3875,"parentId":1,"tags":{},"startTime":1781011960110,"traceId":"2ebfd76be84b7cd1"},{"name":"static-check","duration":360872,"timestamp":197243519163,"id":3878,"parentId":1,"tags":{},"startTime":1781011963460,"traceId":"2ebfd76be84b7cd1"},{"name":"static-generation","duration":989843,"timestamp":197244245316,"id":4008,"parentId":1,"tags":{},"startTime":1781011964186,"traceId":"2ebfd76be84b7cd1"},{"name":"collect-build-traces","duration":3867339,"timestamp":197243881583,"id":4005,"parentId":1,"tags":{},"startTime":1781011963823,"traceId":"2ebfd76be84b7cd1"},{"name":"telemetry-flush","duration":16,"timestamp":197247750447,"id":4017,"parentId":1,"tags":{},"startTime":1781011967691,"traceId":"2ebfd76be84b7cd1"},{"name":"next-build","duration":14427843,"timestamp":197233322624,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1781011953264,"traceId":"2ebfd76be84b7cd1"}]
1
+ [{"name":"run-webpack","duration":9233983,"timestamp":218246430137,"id":14,"parentId":1,"tags":{},"startTime":1781032966344,"traceId":"1508400a7e9857a1"},{"name":"run-typescript","duration":3475723,"timestamp":218255666906,"id":3875,"parentId":1,"tags":{},"startTime":1781032975581,"traceId":"1508400a7e9857a1"},{"name":"static-check","duration":332813,"timestamp":218259151992,"id":3878,"parentId":1,"tags":{},"startTime":1781032979066,"traceId":"1508400a7e9857a1"},{"name":"static-generation","duration":996924,"timestamp":218259841563,"id":4008,"parentId":1,"tags":{},"startTime":1781032979755,"traceId":"1508400a7e9857a1"},{"name":"collect-build-traces","duration":3820691,"timestamp":218259486168,"id":4005,"parentId":1,"tags":{},"startTime":1781032979400,"traceId":"1508400a7e9857a1"},{"name":"telemetry-flush","duration":14,"timestamp":218263308354,"id":4017,"parentId":1,"tags":{},"startTime":1781032983222,"traceId":"1508400a7e9857a1"},{"name":"next-build","duration":16983705,"timestamp":218246324667,"id":1,"tags":{"buildMode":"default","version":"16.2.7","bundler":"webpack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1781032966239,"traceId":"1508400a7e9857a1"}]
@@ -143,7 +143,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
143
143
  `,F="<!-- beacon:workflow:start -->",S="<!-- beacon:workflow:end -->",XQ;var m=QQ(()=>{XQ=`${F}
144
144
  ## Beacon \u2014 feature workflow
145
145
 
146
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
147
147
 
148
148
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
149
149
 
package/dist/bin/hook.js CHANGED
@@ -143,7 +143,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
143
143
  `,M="<!-- beacon:workflow:start -->",A="<!-- beacon:workflow:end -->",t;var r=n(()=>{t=`${M}
144
144
  ## Beacon \u2014 feature workflow
145
145
 
146
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
147
147
 
148
148
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
149
149
 
package/dist/bin/mcp.js CHANGED
@@ -143,7 +143,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
143
143
  `,$0="<!-- beacon:workflow:start -->",W0="<!-- beacon:workflow:end -->",m0;var d0=b0(()=>{m0=`${$0}
144
144
  ## Beacon \u2014 feature workflow
145
145
 
146
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
147
147
 
148
148
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
149
149
 
@@ -224,7 +224,7 @@ ${Q}
224
224
 
225
225
  `).trimStart();return J0(s(),Z),!0}function V$(){let $={};for(let Z of w0)$[Z]=n0(Z);let Q={};for(let Z of q0)Q[Z.event]=n5({event:Z.event,command:Z.command});return{homeExists:P0(z()),skills:$,hooks:Q,claudeMdBlock:r0()}}async function t5(){let{INIT_SKILL:$,REFRESH_SKILL:Q,PLAN_SKILL:Z}=await Promise.resolve().then(() => (d0(),s0)),X={"beacon-init":$,"beacon-refresh":Q,"beacon-plan":Z},V=[];for(let N of w0){if(!n0(N))V.push(N);s5(N,X[N])}let H=0;for(let N of q0)if(o5({event:N.event,matcher:N.matcher,command:N.command}))H++;let B=r0();return r5(l5),{skillsAdded:V,hooksAdded:H,claudeMdBlockTouched:!B}}async function i0(){try{return{ok:!0,...await t5()}}catch($){return{ok:!1,error:$ instanceof Error?$.message:String($),skillsAdded:[],hooksAdded:0,claudeMdBlockTouched:!1}}}function H$(){let $=[];for(let X of w0)if(d5(X))$.push(X);let Q=0;for(let X of q0)if(a5(X))Q++;let Z=i5();return{skillsRemoved:$,hooksRemoved:Q,claudeMdBlockRemoved:Z}}import{AsyncLocalStorage as N9}from"async_hooks";import{spawnSync as K9}from"child_process";import{createHash as M9}from"crypto";import{existsSync as Z5,mkdirSync as Y0,readFileSync as J5,writeFileSync as X5}from"fs";import{homedir as W9}from"os";import{basename as U9,join as b}from"path";function d(){return process.env.BEACON_HOME||b(W9(),".beacon")}function v0(){return b(d(),"workspaces.json")}function V0($){return M9("sha256").update($).digest("hex").slice(0,12)}function Y5($=process.cwd()){let Q=K9("git",["rev-parse","--show-toplevel"],{cwd:$,stdio:["ignore","pipe","ignore"]});if(Q.status===0){let Z=Q.stdout?.toString().trim();if(Z)return Z}return $}function A0($){return b(d(),$)}function R0($){return`file:${b(A0($),"db.sqlite")}`}function o(){try{let $=JSON.parse(J5(v0(),"utf8"));return Array.isArray($)?$:[]}catch{return[]}}function E0($){Y0(d(),{recursive:!0}),X5(v0(),JSON.stringify($,null,2))}function P9(){return o().sort(($,Q)=>Q.lastOpenedAt.localeCompare($.lastOpenedAt))}function h($){return o().find((Q)=>Q.id===$)??null}function _0($,Q,Z=new Date().toISOString()){let X=V0($),V=o(),H=V.find((K)=>K.id===X),B={id:X,path:$,name:Q||H?.name||U9($),lastOpenedAt:Z},N=[B,...V.filter((K)=>K.id!==X)];return Y0(A0(X),{recursive:!0}),E0(N),B}function D$($,Q=new Date().toISOString()){let Z=o(),X=Z.find((V)=>V.id===$);if(!X)return;X.lastOpenedAt=Q,E0(Z)}function F$($){if(E0(o().filter((Q)=>Q.id!==$)),n()===$)C9(P9()[0]?.id??null)}function V5(){return b(d(),"active")}function n(){try{return J5(V5(),"utf8").trim()||null}catch{return null}}function C9($){Y0(d(),{recursive:!0}),X5(V5(),$??"")}function v$(){let $=n();return $?h($):null}function A$(){let $=L0()??n();return $?h($):null}function R$($){return h($)?.path??null}function E$(){return Z5(v0())}var H5="beacon_ws";function G5($,Q){let Z=$.headers.get("cookie");if(!Z)return null;for(let X of Z.split(";")){let V=X.indexOf("=");if(V===-1)continue;if(X.slice(0,V).trim()===Q)return decodeURIComponent(X.slice(V+1).trim())}return null}function _$($){let Q=$.headers.get("x-beacon-workspace");if(Q&&h(Q))return Q;let Z=G5($,H5);if(Z&&h(Z))return Z;return null}var I0="x-beacon-workspace-path";async function I$($){let Q=$.headers.get("x-beacon-workspace");if(Q&&h(Q))return Q;let Z=$.headers.get(I0);if(Z&&(!Q||V0(Z)===Q)){let V=_0(Z);return await k0(V.id),V.id}let X=G5($,H5);if(X&&h(X))return X;return null}var B5=new N9;function O9($,Q){return $?B5.run($,Q):Q()}function L0(){return B5.getStore()??null}var Q5=new Set;async function k0($){let Q=A0($),Z=b(Q,"db.sqlite"),X=Z5(Z);if(X&&Q5.has(Z))return{ok:!0,created:!1,migrated:!1};try{Y0(Q,{recursive:!0});let{provisionDb:V}=await $5().then(() => e0),H=await V(R0($));return Q5.add(Z),{ok:!0,created:!X,migrated:X&&H.migrated}}catch(V){return{ok:!1,created:!1,migrated:!1,error:V instanceof Error?V.message:String(V)}}}import{McpServer as t9,ResourceTemplate as f0}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as e9}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as J}from"zod";import{z as G}from"zod";var w9=new Set(["GET","HEAD","OPTIONS"]);function j5($){return w9.has($.trim().toUpperCase())?"read":"write"}var q9=G.preprocess(($)=>{if(typeof $==="string"){let[Q,...Z]=$.trim().split(/\s+/);return{name:Q,type:Z.join(" ")||"text"}}return $},G.object({name:G.string().trim().min(1),type:G.string().trim().min(1),isPk:G.boolean().optional(),isFk:G.boolean().optional(),nullable:G.boolean().optional(),note:G.string().nullish()})),N5=G.object({name:G.string().trim().min(1),domain:G.string().nullish(),description:G.string().nullish(),columns:G.array(q9).default([])}),K5=G.object({fromTable:G.string(),fromColumn:G.string(),toTable:G.string(),toColumn:G.string(),label:G.string().nullish()}),M5=G.object({method:G.string().trim().min(1),path:G.string().trim().min(1),domain:G.string().nullish(),description:G.string().nullish(),uses:G.array(G.object({table:G.string().trim().min(1),access:G.string().optional()})).default([])}).transform(($)=>({...$,uses:$.uses.map((Q)=>({...Q,access:Q.access??j5($.method)}))})),h$=G.object({tables:G.array(N5).default([]),relations:G.array(K5).default([]),endpoints:G.array(M5).default([])});import{z as R}from"zod";import{and as $Q,eq as QQ,inArray as ZQ}from"drizzle-orm";import{drizzle as p9}from"drizzle-orm/libsql";import{createClient as c9}from"@libsql/client";var T0={};e(T0,{tag:()=>m,syncState:()=>A9,projectMeta:()=>E9,note:()=>v9,nodeTags:()=>y,nodeFile:()=>a,node:()=>U,endpointTable:()=>g,endpoint:()=>p,edge:()=>S,draftTable:()=>A,draftRelation:()=>f,draftColumn:()=>i,dbTable:()=>w,dbRelation:()=>x,dbColumn:()=>r,codeFileEdge:()=>u,codeFile:()=>L,appSetting:()=>R9});import{sqliteTable as P,index as W,foreignKey as D9,text as Y,integer as j,real as v,uniqueIndex as k,primaryKey as F9}from"drizzle-orm/sqlite-core";import{createId as F}from"@paralleldrive/cuid2";var U=P("Node",{id:Y().primaryKey().$defaultFn(()=>F()),view:Y().notNull(),cluster:Y(),title:Y().notNull(),role:Y(),plain:Y(),status:Y().default("PENDING").notNull(),priority:j().default(2).notNull(),progress:j().default(0).notNull(),x:v().default(0).notNull(),y:v().default(0).notNull(),sourceRef:Y(),externalId:Y(),source:Y().default("MANUAL").notNull(),parentId:Y(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date),embedding:Y()},($)=>[W("Node_cluster_idx").on($.cluster),W("Node_parentId_idx").on($.parentId),W("Node_view_idx").on($.view),D9(()=>({columns:[$.parentId],foreignColumns:[$.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),a=P("NodeFile",{id:Y().primaryKey().$defaultFn(()=>F()),nodeId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),path:Y().notNull()},($)=>[k("NodeFile_nodeId_path_key").on($.nodeId,$.path),W("NodeFile_nodeId_idx").on($.nodeId)]),m=P("Tag",{id:Y().primaryKey().$defaultFn(()=>F()),label:Y().notNull(),color:Y()},($)=>[k("Tag_label_key").on($.label)]),S=P("Edge",{id:Y().primaryKey().$defaultFn(()=>F()),fromId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:Y().notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:Y().default("DEPENDS").notNull(),label:Y(),sourceHandle:Y(),targetHandle:Y()},($)=>[k("Edge_fromId_toId_kind_key").on($.fromId,$.toId,$.kind),W("Edge_toId_idx").on($.toId),W("Edge_fromId_idx").on($.fromId)]),y=P("_NodeTags",{a:Y("A").notNull().references(()=>U.id,{onDelete:"cascade",onUpdate:"cascade"}),b:Y("B").notNull().references(()=>m.id,{onDelete:"cascade",onUpdate:"cascade"})},($)=>[k("_NodeTags_AB_unique").on($.a,$.b),W("_NodeTags_B_index").on($.b)]),v9=P("Note",{id:Y().primaryKey().$defaultFn(()=>F()),title:Y().default("Untitled").notNull(),body:Y().default("").notNull(),ord:v().default(0).notNull(),pinned:j({mode:"boolean"}).default(!1).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("Note_updatedAt_idx").on($.updatedAt)]),w=P("DbTable",{id:Y().primaryKey().$defaultFn(()=>F()),name:Y().notNull(),domain:Y(),description:Y(),source:Y().default("MANUAL").notNull(),x:v().default(0).notNull(),y:v().default(0).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[W("DbTable_domain_idx").on($.domain),k("DbTable_name_key").on($.name)]),r=P("DbColumn",{id:Y().primaryKey().$defaultFn(()=>F()),tableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),name:Y().notNull(),type:Y().notNull(),isPk:j({mode:"boolean"}).default(!1).notNull(),isFk:j({mode:"boolean"}).default(!1).notNull(),nullable:j({mode:"boolean"}).default(!0).notNull(),note:Y(),ord:j().default(0).notNull()},($)=>[k("DbColumn_tableId_name_key").on($.tableId,$.name),W("DbColumn_tableId_idx").on($.tableId)]),x=P("DbRelation",{id:Y().primaryKey().$defaultFn(()=>F()),fromTableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:Y().notNull(),toColumn:Y().notNull(),label:Y()},($)=>[W("DbRelation_toTableId_idx").on($.toTableId),W("DbRelation_fromTableId_idx").on($.fromTableId)]),p=P("Endpoint",{id:Y().primaryKey().$defaultFn(()=>F()),method:Y().notNull(),path:Y().notNull(),domain:Y(),description:Y(),source:Y().default("MANUAL").notNull(),x:v().default(0).notNull(),y:v().default(0).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},($)=>[k("Endpoint_method_path_key").on($.method,$.path),W("Endpoint_domain_idx").on($.domain)]),g=P("EndpointTable",{id:Y().primaryKey().$defaultFn(()=>F()),endpointId:Y().notNull().references(()=>p.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:Y().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),access:Y().default("read").notNull()},($)=>[k("EndpointTable_endpointId_tableId_key").on($.endpointId,$.tableId),W("EndpointTable_tableId_idx").on($.tableId)]),A=P("DraftTable",{id:Y().primaryKey().$defaultFn(()=>F()),name:Y().notNull(),domain:Y(),description:Y(),x:v().default(0).notNull(),y:v().default(0).notNull(),createdAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},($)=>[k("DraftTable_name_key").on($.name)]),i=P("DraftColumn",{id:Y().primaryKey().$defaultFn(()=>F()),tableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),name:Y().notNull(),type:Y().notNull(),isPk:j({mode:"boolean"}).default(!1).notNull(),isFk:j({mode:"boolean"}).default(!1).notNull(),nullable:j({mode:"boolean"}).default(!0).notNull(),note:Y(),ord:j().default(0).notNull()},($)=>[W("DraftColumn_tableId_idx").on($.tableId)]),f=P("DraftRelation",{id:Y().primaryKey().$defaultFn(()=>F()),fromTableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:Y().notNull().references(()=>A.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:Y().notNull(),toColumn:Y().notNull(),label:Y()},($)=>[W("DraftRelation_toTableId_idx").on($.toTableId),W("DraftRelation_fromTableId_idx").on($.fromTableId)]),L=P("CodeFile",{path:Y().primaryKey(),root:Y(),lang:Y(),x:v().default(0).notNull(),y:v().default(0).notNull(),mtimeMs:v(),size:j(),inDegree:j().default(0).notNull(),outDegree:j().default(0).notNull(),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),u=P("CodeFileEdge",{fromPath:Y().notNull().references(()=>L.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:Y().notNull().references(()=>L.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:j({mode:"boolean"}).default(!1).notNull()},($)=>[W("CodeFileEdge_circular_idx").on($.circular),W("CodeFileEdge_toPath_idx").on($.toPath),W("CodeFileEdge_fromPath_idx").on($.fromPath),F9({columns:[$.fromPath,$.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),A9=P("SyncState",{id:Y().primaryKey().default("singleton"),version:j().default(0).notNull(),codeGraphSyncedAt:j({mode:"timestamp_ms"}),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),R9=P("AppSetting",{id:Y().primaryKey().default("singleton"),intelModel:Y().default("claude-haiku-4-5").notNull(),intelProvider:Y().default("auto").notNull(),editor:Y().default("auto").notNull(),currentFeatureId:Y(),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),E9=P("ProjectMeta",{id:Y().primaryKey().default("singleton"),overview:Y(),conventions:Y().default("[]").notNull(),updatedAt:j({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)});var S0={};e(S0,{tagRelations:()=>L9,nodeTagsRelations:()=>k9,nodeRelations:()=>_9,nodeFileRelations:()=>I9,endpointTableRelations:()=>g9,endpointRelations:()=>x9,edgeRelations:()=>T9,draftTableRelations:()=>f9,draftRelationRelations:()=>z9,draftColumnRelations:()=>u9,dbTableRelations:()=>S9,dbRelationRelations:()=>y9,dbColumnRelations:()=>h9,codeFileRelations:()=>b9,codeFileEdgeRelations:()=>m9});import{relations as q}from"drizzle-orm";var _9=q(U,({one:$,many:Q})=>({files:Q(a),nodeTags:Q(y),edgesOut:Q(S,{relationName:"EdgeFrom"}),edgesIn:Q(S,{relationName:"EdgeTo"}),parent:$(U,{fields:[U.parentId],references:[U.id],relationName:"NodeTree"}),children:Q(U,{relationName:"NodeTree"})})),I9=q(a,({one:$})=>({node:$(U,{fields:[a.nodeId],references:[U.id]})})),L9=q(m,({many:$})=>({nodeTags:$(y)})),k9=q(y,({one:$})=>({node:$(U,{fields:[y.a],references:[U.id]}),tag:$(m,{fields:[y.b],references:[m.id]})})),T9=q(S,({one:$})=>({from:$(U,{fields:[S.fromId],references:[U.id],relationName:"EdgeFrom"}),to:$(U,{fields:[S.toId],references:[U.id],relationName:"EdgeTo"})})),S9=q(w,({many:$})=>({columns:$(r),fksOut:$(x,{relationName:"FkFrom"}),fksIn:$(x,{relationName:"FkTo"}),usages:$(g)})),h9=q(r,({one:$})=>({table:$(w,{fields:[r.tableId],references:[w.id]})})),y9=q(x,({one:$})=>({fromTable:$(w,{fields:[x.fromTableId],references:[w.id],relationName:"FkFrom"}),toTable:$(w,{fields:[x.toTableId],references:[w.id],relationName:"FkTo"})})),x9=q(p,({many:$})=>({tables:$(g)})),g9=q(g,({one:$})=>({endpoint:$(p,{fields:[g.endpointId],references:[p.id]}),table:$(w,{fields:[g.tableId],references:[w.id]})})),f9=q(A,({many:$})=>({columns:$(i),fksOut:$(f,{relationName:"DraftFkFrom"}),fksIn:$(f,{relationName:"DraftFkTo"})})),u9=q(i,({one:$})=>({table:$(A,{fields:[i.tableId],references:[A.id]})})),z9=q(f,({one:$})=>({fromTable:$(A,{fields:[f.fromTableId],references:[A.id],relationName:"DraftFkFrom"}),toTable:$(A,{fields:[f.toTableId],references:[A.id],relationName:"DraftFkTo"})})),b9=q(L,({many:$})=>({edgesOut:$(u,{relationName:"CFEFrom"}),edgesIn:$(u,{relationName:"CFETo"})})),m9=q(u,({one:$})=>({fromFile:$(L,{fields:[u.fromPath],references:[L.path],relationName:"CFEFrom"}),toFile:$(L,{fields:[u.toPath],references:[L.path],relationName:"CFETo"})}));var l9={...T0,...S0};function s9(){let $=process.env.DATABASE_URL;if($&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test($))return $;return"file:./dev.db"}var d9=s9();function U5($){let Q=c9({url:$});return Q.execute("PRAGMA foreign_keys = ON;"),p9(Q,{schema:l9})}var y0=globalThis,h0=y0.dzDefault??U5(d9);y0.dzDefault=h0;var W5=y0.dzByUrl??=new Map;function o9($){let Q=W5.get($);if(!Q)Q=U5($),W5.set($,Q);return Q}function n9(){if(process.env.BEACON_REPO)return h0;let $=L0()??n();if(!$)return h0;return o9(R0($))}var a9=new Proxy({},{get($,Q){let Z=n9(),X=Z[Q];return typeof X==="function"?X.bind(Z):X}});import{forceCenter as s$,forceCollide as d$,forceLink as o$,forceManyBody as n$,forceSimulation as a$}from"d3-force";var P5=R.object({title:R.string().trim().min(1),role:R.string().nullish(),plain:R.string().nullish(),cluster:R.string().nullish(),category:R.string().nullish(),domain:R.string().nullish(),priority:R.number().nullish(),dependsOn:R.array(R.string()).nullish()}).transform(({category:$,domain:Q,priority:Z,...X})=>({...X,cluster:X.cluster??$??Q??null,priority:Z==null?null:Math.max(0,Math.min(3,Math.round(Z)))})),VQ=R.object({features:R.array(P5).default([])});var r9=/(\bmigrations?\b|\balembic\b|make revision|prisma migrate|unique\s?constraint|foreign\s?keys?|primary\s?keys?|\bFKs?\b|\bJSONB\b|create\s+table|alter\s+table|add\s+(a\s+)?column|new\s+(table|model|column)|app\/models\/|\bBaseModel\b|DeclarativeBase|schema\.prisma|@@unique|natural\s+keys?|\bpgvector\b|\bTSVECTOR\b|\bDbTable\b)/i;function C5($){return!!$&&r9.test($)}function i9($){return $.cluster??$.category??$.domain??null}function O5($){let Q=$.map((Z)=>{let X=[],V=i9(Z);if(!V||!V.trim())X.push("category");if(Z.priority==null)X.push("priority");return X.length?` \u2022 "${Z.title?.trim()||"(untitled)"}" \u2014 missing ${X.join(" + ")}`:null}).filter((Z)=>Z!==null);if(Q.length===0)return null;return"\u26D4 Every roadmap feature needs a category AND a priority \u2014 they drive grouping and ordering "+`on the board, and the user shouldn't have to add them by hand. Missing:
226
226
  `+Q.join(`
227
- `)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low). Set BOTH on EVERY feature; don't rely on defaults."}var x0=1500,UQ=345600000,g0=1800000,w5=3000;function t($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function q5($){return`${t($.title)}-${$.id.slice(-6)}`}function D5($){return{resources:$.map((Q)=>({uri:`beacon://note/${q5(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function F5($,Q){return $.find((Z)=>q5(Z)===Q)}function v5($){let Q=$.body.trim()||"(this note is empty)";return[`# ${$.title||"Untitled"}`,"","_User note from Beacon. To turn it into roadmap work, call `beacon_propose_plan` \u2014"+" checkbox `- [ ]` / `- [x]` items become subtasks, and order the features with `dependsOn`. Do NOT implement until it returns approval._","","---","",Q].join(`
227
+ `)+"\n\nRe-present with each feature carrying its category as `category` (or `cluster` \u2014 both "+"work; e.g. AUTH, SEARCH, DATA, INTEL, BILLING \u2026) and `priority` (0 = P0 critical, 1 = P1 "+"high, 2 = P2 medium, 3 = P3 low). Set BOTH on EVERY feature; don't rely on defaults."}var x0=1500,UQ=345600000,g0=1800000,w5=3000;function t($){return $.toLowerCase().normalize("NFD").replace(/[\u0300-\u036F]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"item"}function q5($){return`${t($.title)}-${$.id.slice(-6)}`}function D5($){return{resources:$.map((Q)=>({uri:`note://${q5(Q)}`,name:Q.title||"Untitled",description:`${Q.title||"Untitled"}${Q.pinned?" \xB7 pinned":""} \xB7 note`,mimeType:"text/markdown"}))}}function F5($,Q){return $.find((Z)=>q5(Z)===Q)}function v5($){let Q=$.body.trim()||"(this note is empty)";return[`# ${$.title||"Untitled"}`,"","_User note from Beacon. To turn it into roadmap work, call `beacon_propose_plan` \u2014"+" checkbox `- [ ]` / `- [x]` items become subtasks, and order the features with `dependsOn`. Do NOT implement until it returns approval._","","---","",Q].join(`
228
228
  `)}await i0();var u0=process.env.BEACON_URL||`http://localhost:${process.env.PORT||4319}`,z0=Y5(),B0=V0(z0);try{_0(z0);let $=await k0(B0);if(!$.ok)console.error(`[beacon mcp] db provisioning failed: ${$.error}`)}catch($){console.error(`[beacon mcp] workspace registration failed: ${$ instanceof Error?$.message:$}`)}async function E($,Q){let Z=new Headers(Q?.headers);Z.set("x-beacon-workspace",B0),Z.set(I0,z0);let X=await fetch(`${u0}${$}`,{...Q,headers:Z}),V=await X.text();if(!X.ok)throw Error(`Beacon ${$} -> ${X.status} ${V}`);return V?JSON.parse(V):null}function c($,Q){return E($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}function R5($){let Q=$ instanceof Error?$.message:String($),Z=Q.match(/\{[\s\S]*\}$/);if(Z)try{let X=JSON.parse(Z[0]);if(X?.error)return{content:[{type:"text",text:X.error}],isError:!0}}catch{}return{content:[{type:"text",text:Q}],isError:!0}}var D=new t9({name:"beacon",version:"0.1.0"});D.registerTool("beacon_map",{description:"List existing features on the roadmap. Call before starting work."},async()=>{let $=await E("/api/map");return{content:[{type:"text",text:JSON.stringify($,null,2)}]}});D.registerTool("beacon_start_feature",{description:"Flag that you're working on a feature. If the title matches an existing feature it just marks it IN_PROGRESS (no category needed); if it's NEW it creates the node \u2014 and a new feature REQUIRES a `category`. Call beacon_map first so you reuse an existing feature/category instead of duplicating one.",inputSchema:{title:J.string(),id:J.string().optional().describe("node id from beacon_map (preferred)"),category:J.string().optional().describe("Domain lane for a NEW feature: AUTH | SEARCH | DATA | INTEL | BILLING | INFRA | UI | \u2026 REQUIRED when this creates a new top-level feature; reuse a category already on the board. Ignored when flagging an existing feature or nesting under a `front` (inherits the parent's)."),front:J.string().optional().describe("Title of an EXISTING parent feature to nest this under (draws the parent \u2192 child edge). It must match a real feature \u2014 it is NOT a domain tag (use `category` for the domain). A `front` that matches nothing is REJECTED; create the parent first via beacon_propose_plan."),detail:J.string().optional().describe("One-line plain-language description shown on the canvas card. Replaced later by beacon_describe_feature's markdown when the work is done.")}},async({title:$,id:Q,front:Z,detail:X,category:V})=>{try{let H=await c("/api/map/start",{title:$,id:Q,front:Z,detail:X,category:V});return{content:[{type:"text",text:JSON.stringify(H)}]}}catch(H){return R5(H)}});D.registerTool("beacon_add_subtasks",{description:"Add N sub-tasks under an existing feature in one call. Use when the user says 'add these as subtasks to <feature>' or you want to record follow-ups discovered during work. Parent resolves by `parentId` (preferred \u2014 get it from beacon_map / beacon_entities) or by `parentTitle` (fuzzy-matched against top-level features). Children inherit the parent's view and cluster and land in a row beneath it; bumps the sync version so an open /map canvas refreshes.",inputSchema:{parentId:J.string().optional().describe("node id of the parent feature (preferred)"),parentTitle:J.string().optional().describe("fuzzy title of the parent feature; ignored if parentId is provided"),items:J.array(J.object({title:J.string().describe("short sub-task title"),plain:J.string().optional().describe("one-paragraph description / why / acceptance hint")})).describe("the sub-tasks to add")}},async({parentId:$,parentTitle:Q,items:Z})=>{try{let X=await c("/api/nodes/subtasks",{parentId:$,parentTitle:Q,items:Z});return{content:[{type:"text",text:JSON.stringify(X,null,2)}]}}catch(X){return R5(X)}});D.registerTool("beacon_describe_feature",{description:"Call ONCE at the end of a feature: marks status=DONE, records the files you touched (kept on the FEATURE for context), and replaces the node's description with `description` markdown. Subsumes touch_files + finish_feature. If the feature added or materially changed a REAL architectural component (a subsystem \u2014 never a file), also pass `architecture` to keep the Architecture map accurate.",inputSchema:{description:J.string().describe("Markdown: ### Overview ... ### Files - `path` \u2014 what it does"),files:J.array(J.string()).optional().describe("repo-relative files this feature touches"),id:J.string().optional().describe("node id from beacon_map (preferred over title)"),title:J.string().optional().describe("feature title (fuzzy-matched if no id)"),architecture:J.array(J.object({title:J.string().describe("real component/subsystem name (e.g. 'Plan review loop') \u2014 NEVER a file"),domain:J.string().describe("uppercase lane: PLAN | DATA | UI | MCP | INTEL | \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),status:J.enum(["KEEP","REBUILD","REPLACE","DROP"]).optional(),files:J.array(J.string()).optional(),depends:J.array(J.string()).optional().describe("titles of components this one depends on")})).optional().describe("Only when the feature adds/changes a REAL architectural component \u2014 upserts curated nodes, never one-per-file")}},async({description:$,files:Q,id:Z,title:X,architecture:V})=>{let H=await c("/api/map/describe",{description:$,files:Q,id:Z,title:X,architecture:V});return{content:[{type:"text",text:JSON.stringify(H)}]}});D.registerTool("beacon_init_persist",{description:"Use ONLY inside the `beacon-init` skill. After YOU (Claude Code) have read the repo and built the architecture analysis, call this once to persist it into Beacon. Replaces any prior init-derived map. Same DB shape as `beacon_propose_plan` for tables/endpoints, but it commits directly (no /plan review step) because the user explicitly invoked init.",inputSchema:{overview:J.string().optional().describe("one-paragraph summary of the project \u2014 written to ProjectMeta + AGENTS.md"),conventions:J.array(J.string()).optional().describe("3-8 concrete conventions/gotchas a contributor must follow"),components:J.array(J.object({title:J.string(),domain:J.string().describe("short UPPERCASE area: AUTH, API, DATA, UI, JOBS, INFRA, \u2026"),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence"),files:J.array(J.string()).optional().describe("repo-relative key files"),depends:J.array(J.string()).optional().describe("titles of other components it depends on")})).describe("8-25 main building blocks, not every file"),roadmap:J.array(J.object({title:J.string(),why:J.string().optional(),category:J.string().optional().describe("category for the board (AUTH | SEARCH | DATA | INTEL | \u2026) \u2014 set it so the item isn't category-less"),priority:J.number().int().min(0).max(3).optional().describe("0=P0 critical .. 3=P3 low")})).optional().describe("3-6 broad strategic directions (NOT detailed tasks); each with a `category` + `priority`. Re-runs DEDUPE roadmap features by title, so re-persisting won't double up existing ones."),snapshot:J.object({tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string(),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}).optional().describe("optional: also seed /db with the schema you discovered from prisma/SQLAlchemy/etc.")}},async($)=>{let Q=await c("/api/init",$);return{content:[{type:"text",text:JSON.stringify(Q)}]}});D.registerTool("beacon_context_for_feature",{description:"Use BEFORE Glob/Grep/Read when starting work on a feature. Returns a single bundle of everything Beacon knows about it: attached files, what those files import + what imports them (1-hop blast radius from the live code graph), endpoints in the feature's domain + the tables each touches, those tables' FK relations, sibling architecture components, and the project's conventions. Saves an entire discovery-phase round of file reads. Match by id (preferred), exact title, or a natural-language query.",inputSchema:{id:J.string().optional().describe("node id from beacon_map (preferred)"),title:J.string().optional().describe("feature title (case-insensitive contains)"),query:J.string().optional().describe("natural-language phrase \u2014 OR-matched against title + plain description")}},async({id:$,title:Q,query:Z})=>{let X=new URLSearchParams;if($)X.set("id",$);if(Q)X.set("title",Q);if(Z)X.set("query",Z);let V=await E(`/api/context/feature?${X.toString()}`);return{content:[{type:"text",text:JSON.stringify(V,null,2)}]}});D.registerTool("beacon_blast_radius",{description:"For 'if I change this file, what else cares?' \u2014 returns the file's 1-hop imports + importedBy, the TRANSITIVE blast radius both directions (downstream = who depends on it, upstream = what it depends on, grouped by depth), hub/centrality scoring (inDegree/outDegree + isHub), and every feature/component that has the file attached. Use mid-feature when deciding the impact of a change, or before refactoring a hub file.",inputSchema:{path:J.string().describe("repo-relative POSIX file path"),depth:J.number().optional().describe("how far to walk the transitive graph (default 2, capped at 5)")}},async({path:$,depth:Q})=>{let Z=new URLSearchParams({path:$});if(Q!=null)Z.set("depth",String(Q));let X=await E(`/api/context/file?${Z.toString()}`);return{content:[{type:"text",text:JSON.stringify(X,null,2)}]}});D.registerTool("beacon_entities",{description:"Read planning data. `features` = roadmap, `architecture` = components, `tables`/`endpoints` = DB map.",inputSchema:{kind:J.enum(["features","architecture","tables","endpoints"])}},async({kind:$})=>{let Q=await E(`/api/entities?kind=${$}`);return{content:[{type:"text",text:JSON.stringify(Q,null,2)}]}});D.registerTool("beacon_propose_plan",{description:"BLOCKS until the user reviews. Pushes a feature plan (top-level roadmap features + DB tables + endpoints) to Beacon's /plan page. Use when the user asks you to plan a feature. EVERY feature MUST include `cluster` (its category) and `priority` (0=P0 critical .. 3=P3 low) \u2014 the tool REJECTS a plan whose features omit either, so set both on every feature. Do not implement code or migrations until this returns approval. If it returns inline feedback, revise and call again.",inputSchema:{description:J.string().describe("Short summary the user will see in the review header"),features:J.array(J.object({title:J.string(),role:J.string().optional().describe("one-line technical role"),plain:J.string().optional().describe("one plain-language sentence for the user"),category:J.string().optional().describe("REQUIRED category for the board (AUTH | SEARCH | BILLING | DATA | INTEL | \u2026)"),cluster:J.string().optional().describe("alias for `category`"),domain:J.string().optional().describe("alias for `category`"),priority:J.number().int().min(0).max(3).optional().describe("REQUIRED priority: 0=P0 critical, 1=P1 high, 2=P2 medium, 3=P3 low"),dependsOn:J.array(J.string()).optional().describe("titles of other features in THIS plan that must ship first \u2014 drawn as 'depends on' links so the board shows the dependency chain, not loose cards")})).optional().describe("the top-level roadmap features this plan adds"),tables:J.array(J.object({name:J.string(),domain:J.string().optional(),description:J.string().optional(),columns:J.array(J.object({name:J.string(),type:J.string(),isPk:J.boolean().optional(),isFk:J.boolean().optional(),nullable:J.boolean().optional(),note:J.string().optional()}))})).optional(),relations:J.array(J.object({fromTable:J.string(),fromColumn:J.string(),toTable:J.string(),toColumn:J.string(),label:J.string().optional()})).optional(),endpoints:J.array(J.object({method:J.string().describe("GET|POST|PUT|PATCH|DELETE"),path:J.string(),domain:J.string().optional(),description:J.string().optional(),uses:J.array(J.object({table:J.string(),access:J.string().optional()})).optional()})).optional()}},async({description:$,features:Q,tables:Z,relations:X,endpoints:V})=>{let H=(M)=>new Promise((j0)=>setTimeout(j0,M)),B=(M)=>({content:[{type:"text",text:M}]}),N=(Z?.length??0)>0,K=(Q??[]).map((M)=>`${M.title} ${M.role??""} ${M.plain??""}`).join(`
229
229
  `),O=(V?.length??0)>0||C5(`${$}
230
230
  ${K}`);if(!N&&O)return B("\u26D4 This plan touches the database \u2014 it declares endpoints and/or its text describes "+"models/tables/migrations \u2014 but you passed NO `tables`. Beacon's schema board renders "+"ONLY from structured `tables`; prose is never parsed, so the /db tab would be empty and nothing would persist on approve.\n\nRe-call `beacon_propose_plan` with every table in `tables` (each with its `columns`), the `relations` (FKs), and keep the `endpoints` (each with `uses:[{table,access}]`). Mirror EVERY database entity your plan mentions into the structured fields.");if(Q?.length){let M=O5(Q);if(M)return B(M)}let l=(Z?.length??0)+(V?.length??0)>0;await c("/api/plan",{description:$,draft:l?{tables:Z??[],relations:X??[],endpoints:V??[]}:void 0,features:Q?.length?Q:void 0}),await fetch(`${u0}/api/workspace/activate?id=${B0}`).catch(()=>{});let L5=Date.now()+g0;while(Date.now()<L5){await H(x0);let M=await E("/api/plan/verdict").catch(()=>null);if(!M)continue;if(M.kind==="feedback")return B("\uD83D\uDCAC The user left feedback on the plan in Beacon \u2014 text comments and/or edits they "+"made directly on the /map and /db boards. Read everything below, revise the plan accordingly (matching the board changes verbatim), and call `beacon_propose_plan` "+`again with the revised version \u2014 DO NOT implement yet:
@@ -244,4 +244,4 @@ Implement EXACTLY the schema below (migrations + code) \u2014 the user may have
244
244
  Implement exactly what's on the board:
245
245
 
246
246
  ${H.detail}`:""));if(H.kind==="discarded")return X(`\u274C The user discarded the plan in Beacon. ${H.summary??""} Ask what they want to adjust before presenting again.`.trim())}return X("Still waiting for the user to review in Beacon. Your plan is preserved \u2014 call "+"`beacon_present_plan` again with the SAME plan to resume, or ask whether they've reviewed it.")});var E5=($)=>Array.isArray($)?$[0]:$;async function G0($){return(await E(`/api/entities?kind=${$}`)).items}function _5($,Q){return{resources:$.map((Z)=>({uri:`${Q}${t(Z.title)}`,name:Z.title,description:`${Z.title}${Z.cluster?` \xB7 ${Z.cluster}`:""} \xB7 ${Z.status}`,mimeType:"text/markdown"}))}}async function I5($,Q,Z){let X=(await G0(Z)).find((N)=>t(N.title)===E5(Q));if(!X)return{contents:[{uri:$.href,mimeType:"text/markdown",text:"(not found)"}]};let H=((await E("/api/entities?kind=tables")).items??[]).map((N)=>N.name),B=[`# ${X.title}`];if(X.cluster)B.push(`*Domain:* \`${X.cluster}\``);if(X.status)B.push(`*Status:* \`${X.status}\``);if(B.push(""),B.push(X.plain?.trim()||"(this node has no description yet \u2014 add one on Beacon's /map page)"),B.push("","## Existing DB tables in this project"),B.push(H.length?H.join(", "):"(none yet)"),Z==="features"){let N=await G0("features"),K=[...new Set(N.map((O)=>O.cluster?.trim()).filter((O)=>!!O))].sort();B.push("","## Existing feature categories \u2014 reuse one before inventing a new one"),B.push(K.length?K.join(", "):"(none yet)"),B.push("","## Beacon feature loop \u2014 follow IN ORDER (do not jump to Glob/Grep/Read)","1. **Load context FIRST.** Call `beacon_context_for_feature({ title })` for this feature BEFORE any Glob/Grep/Read. It returns the attached files, 1-hop import blast radius, the domain's endpoints + tables + FK relations, sibling components, and the project conventions \u2014 and marks this feature active so your edits attach to it. That bundle replaces the discovery phase; Glob is a last resort.","2. **Design data before code.** Identify the tables this feature needs. If ANY are missing from the list above, design the schema and call `beacon_propose_plan` (tables + relations + endpoints, each endpoint with `uses:[{table,access}]`). It BLOCKS until the user approves on /plan \u2014 do NOT write migrations or code until it returns approval.","3. **Register at the end.** When the work is done, call `beacon_describe_feature` with the files you touched + a short markdown summary, so the map and AGENTS.md stay accurate for the next session.")}return{contents:[{uri:$.href,mimeType:"text/markdown",text:B.join(`
247
- `)}]}}D.registerResource("beacon-feature",new f0("beacon://feature/{slug}",{list:async()=>_5(await G0("features"),"beacon://feature/")}),{title:"Beacon: features",description:"Roadmap features \u2014 picking one imports the node's description plus existing-DB context.",mimeType:"text/markdown"},($,{slug:Q})=>I5($,Q,"features"));D.registerResource("beacon-component",new f0("beacon://component/{slug}",{list:async()=>_5(await G0("architecture"),"beacon://component/")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>I5($,Q,"architecture"));async function A5(){return await E("/api/notes")}D.registerResource("beacon-note",new f0("beacon://note/{slug}",{list:async()=>D5(await A5())}),{title:"Beacon: notes",description:"Your Beacon notes \u2014 picking one imports its markdown verbatim so you can turn it into features.",mimeType:"text/markdown"},async($,{slug:Q})=>{let Z=F5(await A5(),E5(Q)),X=Z?v5(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:X}]}});await D.connect(new e9);var H0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(H0===-1)H0=$;else if($!==H0)H0=$,D.sendResourceListChanged()}catch{}},w5);
247
+ `)}]}}D.registerResource("beacon-feature",new f0("feature://{slug}",{list:async()=>_5(await G0("features"),"feature://")}),{title:"Beacon: features",description:"Roadmap features \u2014 picking one imports the node's description plus existing-DB context.",mimeType:"text/markdown"},($,{slug:Q})=>I5($,Q,"features"));D.registerResource("beacon-component",new f0("component://{slug}",{list:async()=>_5(await G0("architecture"),"component://")}),{title:"Beacon: architecture",description:"Architecture components \u2014 picking one imports 'what the agent sees'.",mimeType:"text/markdown"},($,{slug:Q})=>I5($,Q,"architecture"));async function A5(){return await E("/api/notes")}D.registerResource("beacon-note",new f0("note://{slug}",{list:async()=>D5(await A5())}),{title:"Beacon: notes",description:"Your Beacon notes \u2014 picking one imports its markdown verbatim so you can turn it into features.",mimeType:"text/markdown"},async($,{slug:Q})=>{let Z=F5(await A5(),E5(Q)),X=Z?v5(Z):"(not found)";return{contents:[{uri:$.href,mimeType:"text/markdown",text:X}]}});await D.connect(new e9);var H0=-1;setInterval(async()=>{try{let{version:$}=await E("/api/version");if(H0===-1)H0=$;else if($!==H0)H0=$,D.sendResourceListChanged()}catch{}},w5);
package/dist/bin/plan.js CHANGED
@@ -143,7 +143,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
143
143
  `,f="<!-- beacon:workflow:start -->",_="<!-- beacon:workflow:end -->",i;var $Q=r(()=>{i=`${f}
144
144
  ## Beacon \u2014 feature workflow
145
145
 
146
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
147
147
 
148
148
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
149
149
 
@@ -143,7 +143,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
143
143
  `,F="<!-- beacon:workflow:start -->",S="<!-- beacon:workflow:end -->",ZQ;var m=XQ(()=>{ZQ=`${F}
144
144
  ## Beacon \u2014 feature workflow
145
145
 
146
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
147
147
 
148
148
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
149
149
 
@@ -142,7 +142,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
142
142
  `,H="<!-- beacon:workflow:start -->",v="<!-- beacon:workflow:end -->",E;var g=A(()=>{E=`${H}
143
143
  ## Beacon \u2014 feature workflow
144
144
 
145
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
145
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
146
 
147
147
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
148
148
 
@@ -142,7 +142,7 @@ ExitPlanMode with the same \`\`\`beacon block, or tell the user to run \`beacon\
142
142
  `,B="<!-- beacon:workflow:start -->",M="<!-- beacon:workflow:end -->",k;var y=n(()=>{k=`${B}
143
143
  ## Beacon \u2014 feature workflow
144
144
 
145
- This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon://note/\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
145
+ This project uses Beacon (a local planning/visualization panel; run \`beacon\` to open it). When you start work on a FEATURE \u2014 whether referenced via an \`@beacon:feature://\u2026\` mention, an \`@beacon:note://\u2026\` note the user wrote in the Notes panel (treat its checkbox \`- [ ]\` todos as subtasks and order features by their dependencies), or just described in chat \u2014 follow these steps in order:
146
146
 
147
147
  ### 1. Load context FIRST \u2014 do NOT Glob/Grep the codebase blind
148
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trybeacon",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The visual planning surface for the coding agent in your terminal.",
5
5
  "homepage": "https://trybeacon.sh",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- "use strict";exports.id=6636,exports.ids=[6636],exports.modules={526:(a,b,c)=>{},1110:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{HQ:()=>n,Oz:()=>o,cl:()=>s,hY:()=>q,hg:()=>r,pJ:()=>t,t3:()=>p});var e=c(95349),f=c(42650),g=c(39321),h=c(62896),i=c(22443),j=c(3173),k=c(89337),l=a([h,j]);function m(){(0,f.revalidatePath)("/map")}async function n(a){let b=await (0,j.RM)(a);return m(),b}async function o(a,b){let c=await (0,j.OK)(a,b);return m(),c}async function p(a,b){let c=await (0,j.Pj)(a,b);return m(),c}async function q(a){let b=await (0,j.Vp)(a);return m(),b}async function r(a){let b=await (0,j.x$)(a);return m(),b}async function s(a){await (0,j.AC)(a),m()}async function t(a){await h.db.update(i.node).set({source:"MANUAL"}).where((0,g.eq)(i.node.id,a)),m()}[h,j]=l.then?(await l)():l,(0,k.D)([n,o,p,q,r,s,t]),(0,e.A)(n,"4099598b1b435dbaca58bc6fdbd700bcfc04eb45dc",null),(0,e.A)(o,"60d20a0b6491606482cb101bb50c6cb23beb455434",null),(0,e.A)(p,"609776d59f19549c087b9e29c25e813680eaae5094",null),(0,e.A)(q,"400a1a19efb5bad5dcee9b5c4155c23a63a919e104",null),(0,e.A)(r,"40b2717d960d406320c2ccb5dda21c7a5389fbf44c",null),(0,e.A)(s,"4094b0463f9ea824c069012b69bf9ef151e263f5ea",null),(0,e.A)(t,"40271ac32342b618526d8666e025edce79c267e1fd",null),d()}catch(a){d(a)}})},1229:(a,b,c)=>{c.d(b,{x:()=>g});var d=c(48249),e=c(56024),f=c(55030);function g(){let a="!h-2 !w-2 !border-0 !bg-zinc-400";return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.h7,{type:"target",position:f.yX.Top,id:"tt",className:a}),(0,d.jsx)(e.h7,{type:"source",position:f.yX.Top,id:"st",className:a}),(0,d.jsx)(e.h7,{type:"target",position:f.yX.Right,id:"tr",className:a}),(0,d.jsx)(e.h7,{type:"source",position:f.yX.Right,id:"sr",className:a}),(0,d.jsx)(e.h7,{type:"target",position:f.yX.Bottom,id:"tb",className:a}),(0,d.jsx)(e.h7,{type:"source",position:f.yX.Bottom,id:"sb",className:a}),(0,d.jsx)(e.h7,{type:"target",position:f.yX.Left,id:"tl",className:a}),(0,d.jsx)(e.h7,{type:"source",position:f.yX.Left,id:"sl",className:a})]})}},2367:(a,b,c)=>{c.a(a,async(a,b)=>{try{var d=c(62896);c(22443);var e=a([d]);d=(e.then?(await e)():e)[0],b()}catch(a){b(a)}})},2942:(a,b,c)=>{c.d(b,{F8:()=>s,NG:()=>o,QH:()=>p,Vq:()=>r,aM:()=>v,cV:()=>x,kz:()=>u,n$:()=>m,pO:()=>g,vB:()=>t});var d=c(48249),e=c(67484),f=c(33191);function g({markdown:a,className:b,variant:c="reading"}){let h=(0,e.useMemo)(()=>m(a),[a]),i="reading"===c;return(0,d.jsx)("div",{className:(0,f.cn)("min-w-0 [overflow-wrap:anywhere]",i?"mx-auto w-full max-w-[66ch] space-y-4 text-[15px] leading-[1.6]":"space-y-3.5 text-[13px] leading-relaxed",b),children:h.map((a,b)=>(0,d.jsx)(w,{block:a,variant:c},b))})}function h(a){let b=a.trim();return b.includes("|")&&b.includes("-")&&/^[\s|:-]+$/.test(b)}function i(a){return""!==a.trim()&&a.includes("|")}function j(a){let b=a.trim();return b.startsWith("|")&&(b=b.slice(1)),b.endsWith("|")&&(b=b.slice(0,-1)),b.split("|").map(a=>a.trim())}function k(a){let b=a.trim(),c=b.startsWith(":"),d=b.endsWith(":");return c&&d?"center":d?"right":c?"left":null}let l=/^\s*```[^\s`]*\s*$/;function m(a){let b=a.split("\n"),c=[],d=[],e=()=>{d.length&&(c.push({kind:"p",text:d.join("\n")}),d=[])},f=null,g=()=>{null!==f&&(c.push({kind:"quote",text:f.join("\n")}),f=null)},m=a=>Math.min(6,Math.floor(a.length/2)),n=null,o=null;for(let a=0;a<b.length;a++){let p=b[a];if(null!==n){l.test(p)?(c.push({kind:"code",text:n.join("\n")}),n=null):n.push(p);continue}let q=p.match(/^>\s?(.*)$/);if(q){e(),o=null,(f??=[]).push(q[1]);continue}if(g(),l.test(p)){e(),o=null,n=[];continue}if(/^\s*$/.test(p)){e(),o=null;continue}let r=p.match(/^#### +(.+)$/);if(r){e(),o=null,c.push({kind:"h4",text:r[1]});continue}let s=p.match(/^### +(.+)$/);if(s){e(),o=null,c.push({kind:"h3",text:s[1]});continue}let t=p.match(/^## +(.+)$/);if(t){e(),o=null,c.push({kind:"h2",text:t[1]});continue}let u=p.match(/^# +(.+)$/);if(u){e(),o=null,c.push({kind:"h1",text:u[1]});continue}if(i(p)&&a+1<b.length&&h(b[a+1])){e(),o=null;let d=[j(p)],f=j(b[a+1]).map(k),g=a+2;for(;g<b.length&&i(b[g])&&!h(b[g]);)d.push(j(b[g])),g++;c.push({kind:"table",text:b.slice(a,g).join("\n"),rows:d,align:f}),a=g-1;continue}let v=p.match(/^(\s*)(\d+)\. +(.+)$/);if(v){e(),c.push({kind:"ol",text:v[3],depth:m(v[1]),marker:v[2]}),o=c.length-1;continue}let w=p.match(/^(\s*)- +(.+)$/);if(w){e(),c.push({kind:"ul",text:w[2],depth:m(w[1])}),o=c.length-1;continue}if(null!==o&&0===d.length){c[o].text+=" "+p.trim();continue}d.push(p)}return e(),g(),null!==n&&c.push({kind:"code",text:n.join("\n")}),c}let n=/("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function o({text:a}){let b=function(a){let b=a.trim();if(!b||"{"!==b[0]&&"["!==b[0])return null;try{return JSON.stringify(JSON.parse(b),null,2)}catch{return null}}(a);return(0,d.jsx)("pre",{className:"overflow-x-auto rounded-lg border border-white/10 bg-white/[0.06] p-3 text-[12px] leading-relaxed",children:(0,d.jsx)("code",{className:"whitespace-pre font-mono [overflow-wrap:normal]",children:b?function(a){let b,c=[],e=0,f=0,g=a=>(0,d.jsx)("span",{className:"text-foreground/45",children:a},f++);for(n.lastIndex=0;null!==(b=n.exec(a));){if(b.index>e&&c.push(g(a.slice(e,b.index))),void 0!==b[1]){let a=void 0!==b[2];c.push((0,d.jsx)("span",{className:a?"text-sky-300":"text-emerald-300/90",children:b[1]},f++)),a&&b[2]&&c.push(g(b[2]))}else void 0!==b[3]?c.push((0,d.jsx)("span",{className:"text-purple-300",children:b[3]},f++)):void 0!==b[4]&&c.push((0,d.jsx)("span",{className:"text-amber-300",children:b[4]},f++));e=n.lastIndex}return e<a.length&&c.push(g(a.slice(e))),c}(b):(0,d.jsx)("span",{className:"text-foreground/85",children:a})})})}function p({block:a}){let b=a.rows??[];if(0===b.length)return null;let[c,...e]=b,g=a.align??[],h=a=>"center"===g[a]?"text-center":"right"===g[a]?"text-right":"text-left";return(0,d.jsx)("div",{className:"overflow-x-auto rounded-lg border border-white/10",children:(0,d.jsxs)("table",{className:"w-full border-collapse text-[13px] [overflow-wrap:normal]",children:[(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{className:"border-b border-white/15 bg-white/[0.04]",children:c.map((a,b)=>(0,d.jsx)("th",{className:(0,f.cn)("whitespace-nowrap px-3 py-1.5 font-semibold text-foreground",h(b)),children:(0,d.jsx)(x,{text:a})},b))})}),(0,d.jsx)("tbody",{children:e.map((a,b)=>(0,d.jsx)("tr",{className:"border-b border-white/5 last:border-0",children:a.map((a,b)=>(0,d.jsx)("td",{className:(0,f.cn)("px-3 py-1.5 align-top text-foreground/90",h(b)),children:(0,d.jsx)(x,{text:a})},b))},b))})]})})}let q=["h1","h2","h3","h4"];function r(a){return q.includes(a)}function s(a){let b=q.indexOf(a);return b<0?0:b}function t(a){return`plan-h-${a}`}function u(a){return a.replace(/[`*]/g,"").trim()}function v(a,b,c,e){let g="reading"===c;switch(a.kind){case"h1":return(0,d.jsx)("h1",{id:e,className:g?"scroll-mt-24 text-xl font-semibold tracking-tight text-foreground":"text-base font-semibold text-foreground",children:b});case"h2":return(0,d.jsx)("h2",{id:e,className:g?"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:b});case"h3":return(0,d.jsx)("h3",{id:e,className:g?"mt-4 scroll-mt-24 text-base font-semibold text-foreground":"mt-2 text-[13px] font-semibold text-foreground",children:b});case"h4":return(0,d.jsx)("h4",{id:e,className:g?"mt-3 scroll-mt-24 text-sm font-semibold text-muted-foreground":"mt-2 text-[13px] font-semibold text-muted-foreground",children:b});case"ul":case"ol":{let c=a.depth??0;return(0,d.jsxs)("div",{className:(0,f.cn)("flex gap-2",g?"text-foreground/95":"text-foreground/90"),style:{marginLeft:`${.75+1.25*c}rem`},children:[(0,d.jsx)("span",{className:"shrink-0 select-none text-muted-foreground tabular-nums",children:"ol"===a.kind?`${a.marker}.`:"•"}),(0,d.jsx)("span",{className:"min-w-0 flex-1",children:b})]})}case"quote":return(0,d.jsx)("blockquote",{className:(0,f.cn)("whitespace-pre-wrap border-l-2 pl-3 italic",g?"border-white/15 text-foreground/80":"border-white/10 text-foreground/75"),children:b});default:return(0,d.jsx)("p",{className:(0,f.cn)("whitespace-pre-wrap",g?"text-foreground/95":"text-foreground/90"),children:b})}}function w({block:a,variant:b}){return"code"===a.kind?(0,d.jsx)(o,{text:a.text}):"table"===a.kind?(0,d.jsx)(p,{block:a}):(0,d.jsx)(d.Fragment,{children:v(a,(0,d.jsx)(x,{text:a.text}),b)})}function x({text:a}){let b=a.split(/(`[^`]+`|\*\*[\s\S]+?\*\*|\*[^*]+\*)/g);return(0,d.jsx)(d.Fragment,{children:b.map((a,b)=>/^`[^`]+`$/.test(a)?(0,d.jsx)("code",{className:"rounded bg-white/5 px-1 font-mono text-[12px]",children:a.slice(1,-1)},b):/^\*\*[\s\S]+\*\*$/.test(a)?(0,d.jsx)("strong",{className:"font-semibold text-foreground",children:(0,d.jsx)(x,{text:a.slice(2,-2)})},b):/^\*[^*]+\*$/.test(a)?(0,d.jsx)("em",{className:"text-muted-foreground",children:(0,d.jsx)(x,{text:a.slice(1,-1)})},b):(0,d.jsx)("span",{children:a},b))})}},3173:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{AC:()=>q,OK:()=>m,Pj:()=>n,RM:()=>l,Vp:()=>o,x$:()=>p});var e=c(39321),f=c(62896),g=c(22443),h=c(53501),i=c(8292),j=c(7913),k=a([f,i]);[f,i]=k.then?(await k)():k;let r=new Set(["title","role","plain","cluster"]);async function l(a){let b=j.gY.parse(a),c="ARCHITECTURE"===b.view?"REBUILD":"PENDING",[d]=await f.db.insert(g.node).values({view:b.view,title:b.title,cluster:b.cluster??null,role:b.role??null,plain:b.plain??null,parentId:b.parentId??null,status:b.status??c,priority:b.priority??2,x:b.x??0,y:b.y??0,sourceRef:b.sourceRef??null}).returning();return await (0,h.x0)(d.id),d}async function m(a,b){let c=j.$Y.parse(b),[d]=await f.db.update(g.node).set(c).where((0,e.eq)(g.node.id,a)).returning();return Object.keys(c).some(a=>r.has(a))&&await (0,h.x0)(a),void 0!==c.status&&await (0,i.Nh)(a),d}async function n(a,b){let c=j.M7.parse(b),[d]=await f.db.update(g.node).set({status:c}).where((0,e.eq)(g.node.id,a)).returning();return await (0,i.Nh)(a),d}async function o(a){let[b]=await f.db.update(g.node).set({status:"DEPRIORITIZED",priority:3}).where((0,e.eq)(g.node.id,a)).returning();return await (0,i.Nh)(a),b}async function p(a){let[b]=await f.db.update(g.node).set({status:"CANCELLED"}).where((0,e.eq)(g.node.id,a)).returning();return await (0,i.Nh)(a),b}async function q(a){let[b]=await f.db.delete(g.node).where((0,e.eq)(g.node.id,a)).returning();return b}d()}catch(a){d(a)}})},4120:(a,b,c)=>{c.a(a,async(a,b)=>{try{var d=c(62896);c(22443);var e=a([d]);d=(e.then?(await e)():e)[0],b()}catch(a){b(a)}})},4963:(a,b,c)=>{c.a(a,async(a,b)=>{try{var d=c(23873),e=c(62896);c(22443);var f=c(2367),g=c(29303),h=c(50320),i=a([e,f,g,h]);[e,f,g,h]=i.then?(await i)():i,d.Ik({tables:d.YO(d.Ik({name:d.Yj().trim().min(1),domain:d.Yj().nullish(),description:d.Yj().nullish(),columns:d.YO(d.Ik({name:d.Yj().trim().min(1),type:d.Yj().trim().min(1),isPk:d.zM().optional(),isFk:d.zM().optional(),nullable:d.zM().optional(),note:d.Yj().nullish()})).default([])})).default([]),relations:d.YO(d.Ik({fromTable:d.Yj(),fromColumn:d.Yj(),toTable:d.Yj(),toColumn:d.Yj(),label:d.Yj().nullish()})).default([]),endpoints:d.YO(d.Ik({method:d.Yj().trim().min(1),path:d.Yj().trim().min(1),domain:d.Yj().nullish(),description:d.Yj().nullish(),uses:d.YO(d.Ik({table:d.Yj(),access:d.Yj().default("read")})).default([])})).default([])}),b()}catch(a){b(a)}})},7913:(a,b,c)=>{c.d(b,{$Y:()=>h,M7:()=>f,gY:()=>g});var d=c(23873);let e=d.k5(["ROADMAP","ARCHITECTURE"]),f=d.k5(["PENDING","IN_PROGRESS","DONE","BLOCKED","CANCELLED","DEPRIORITIZED","KEEP","REBUILD","REPLACE","DROP"]);d.k5(["DEPENDS","CONTAINS","RELATES","REPLACES"]);let g=d.Ik({view:e,title:d.Yj().trim().min(1).max(200),cluster:d.Yj().trim().max(64).nullish(),role:d.Yj().trim().max(500).nullish(),plain:d.Yj().trim().max(2e3).nullish(),parentId:d.Yj().nullish(),status:f.optional(),priority:d.ai().int().min(0).max(3).optional(),x:d.ai().optional(),y:d.ai().optional(),sourceRef:d.Yj().trim().max(300).nullish()}),h=d.Ik({title:d.Yj().trim().min(1).max(200).optional(),role:d.Yj().trim().max(500).nullish(),plain:d.Yj().trim().max(2e3).nullish(),cluster:d.Yj().trim().max(64).nullish(),status:f.optional(),priority:d.ai().int().min(0).max(3).optional(),sourceRef:d.Yj().trim().max(300).nullish()});d.Ik({x:d.ai(),y:d.ai()}),d.Ik({fromId:d.Yj().min(1),toId:d.Yj().min(1),kind:d.k5(["DEPENDS","RELATES","REPLACES"]).optional(),label:d.Yj().trim().max(80).nullish(),sourceHandle:d.Yj().trim().max(16).nullish(),targetHandle:d.Yj().trim().max(16).nullish()})},8292:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Nh:()=>m});var e=c(23873),f=c(39321),g=c(62896),h=c(22443),i=c(4963);c(526),c(58149),c(26905),c(60569);var j=c(3173);c(50042);var k=c(4120),l=a([g,i,j,k]);[g,i,j,k]=l.then?(await l)():l;let n=new Set(["DONE","CANCELLED","DEPRIORITIZED"]),o=new Set(["IN_PROGRESS","BLOCKED"]),p=new Set(["CANCELLED","DEPRIORITIZED"]);async function m(a){var b;let c=await g.db.query.node.findFirst({where:(b,{eq:c})=>c(b.id,a),columns:{parentId:!0,view:!0}});if(!c?.parentId||"ROADMAP"!==c.view)return;let d=await g.db.query.node.findFirst({where:(a,{eq:b})=>b(a.id,c.parentId),columns:{id:!0,status:!0,view:!0}});if(!d||"ROADMAP"!==d.view||p.has(d.status))return;let e=(b=(await g.db.query.node.findMany({where:(a,{eq:b})=>b(a.parentId,d.id),columns:{status:!0}})).map(a=>a.status)).length?b.every(a=>n.has(a))?"DONE":b.some(a=>o.has(a))?"IN_PROGRESS":"PENDING":"PENDING";d.status!==e&&(await g.db.update(h.node).set({status:e}).where((0,f.eq)(h.node.id,d.id)),await m(d.id))}e.Ik({title:e.Yj().trim().min(1),domain:e.Yj().trim().min(1),role:e.Yj().nullish(),plain:e.Yj().nullish(),status:e.Yj().nullish(),files:e.YO(e.Yj()).optional(),depends:e.YO(e.Yj()).optional()}),d()}catch(a){d(a)}})},22443:(a,b,c)=>{c.r(b),c.d(b,{appSetting:()=>C,codeFile:()=>z,codeFileEdge:()=>A,dbColumn:()=>s,dbRelation:()=>t,dbTable:()=>r,draftColumn:()=>x,draftRelation:()=>y,draftTable:()=>w,edge:()=>o,endpoint:()=>u,endpointTable:()=>v,node:()=>l,nodeFile:()=>m,nodeTags:()=>p,note:()=>q,projectMeta:()=>D,syncState:()=>B,tag:()=>n});var d=c(16996),e=c(55402),f=c(76003),g=c(24267),h=c(3161),i=c(80822),j=c(96508),k=c(70202);let l=(0,d.D)("Node",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),view:(0,e.Qq)().notNull(),cluster:(0,e.Qq)(),title:(0,e.Qq)().notNull(),role:(0,e.Qq)(),plain:(0,e.Qq)(),status:(0,e.Qq)().default("PENDING").notNull(),priority:(0,f.nd)().default(2).notNull(),progress:(0,f.nd)().default(0).notNull(),x:(0,g.x)().default(0).notNull(),y:(0,g.x)().default(0).notNull(),sourceRef:(0,e.Qq)(),externalId:(0,e.Qq)(),source:(0,e.Qq)().default("MANUAL").notNull(),parentId:(0,e.Qq)(),createdAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date),embedding:(0,e.Qq)()},a=>[(0,h.Pe)("Node_cluster_idx").on(a.cluster),(0,h.Pe)("Node_parentId_idx").on(a.parentId),(0,h.Pe)("Node_view_idx").on(a.view),(0,i.mt)(()=>({columns:[a.parentId],foreignColumns:[a.id],name:"Node_parentId_Node_id_fk"})).onUpdate("cascade").onDelete("cascade")]),m=(0,d.D)("NodeFile",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),nodeId:(0,e.Qq)().notNull().references(()=>l.id,{onDelete:"cascade",onUpdate:"cascade"}),path:(0,e.Qq)().notNull()},a=>[(0,h.GL)("NodeFile_nodeId_path_key").on(a.nodeId,a.path),(0,h.Pe)("NodeFile_nodeId_idx").on(a.nodeId)]),n=(0,d.D)("Tag",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),label:(0,e.Qq)().notNull(),color:(0,e.Qq)()},a=>[(0,h.GL)("Tag_label_key").on(a.label)]),o=(0,d.D)("Edge",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),fromId:(0,e.Qq)().notNull().references(()=>l.id,{onDelete:"cascade",onUpdate:"cascade"}),toId:(0,e.Qq)().notNull().references(()=>l.id,{onDelete:"cascade",onUpdate:"cascade"}),kind:(0,e.Qq)().default("DEPENDS").notNull(),label:(0,e.Qq)(),sourceHandle:(0,e.Qq)(),targetHandle:(0,e.Qq)()},a=>[(0,h.GL)("Edge_fromId_toId_kind_key").on(a.fromId,a.toId,a.kind),(0,h.Pe)("Edge_toId_idx").on(a.toId),(0,h.Pe)("Edge_fromId_idx").on(a.fromId)]),p=(0,d.D)("_NodeTags",{a:(0,e.Qq)("A").notNull().references(()=>l.id,{onDelete:"cascade",onUpdate:"cascade"}),b:(0,e.Qq)("B").notNull().references(()=>n.id,{onDelete:"cascade",onUpdate:"cascade"})},a=>[(0,h.GL)("_NodeTags_AB_unique").on(a.a,a.b),(0,h.Pe)("_NodeTags_B_index").on(a.b)]),q=(0,d.D)("Note",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),title:(0,e.Qq)().default("Untitled").notNull(),body:(0,e.Qq)().default("").notNull(),ord:(0,g.x)().default(0).notNull(),pinned:(0,f.nd)({mode:"boolean"}).default(!1).notNull(),createdAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},a=>[(0,h.Pe)("Note_updatedAt_idx").on(a.updatedAt)]),r=(0,d.D)("DbTable",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),name:(0,e.Qq)().notNull(),domain:(0,e.Qq)(),description:(0,e.Qq)(),source:(0,e.Qq)().default("MANUAL").notNull(),x:(0,g.x)().default(0).notNull(),y:(0,g.x)().default(0).notNull(),createdAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},a=>[(0,h.Pe)("DbTable_domain_idx").on(a.domain),(0,h.GL)("DbTable_name_key").on(a.name)]),s=(0,d.D)("DbColumn",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),tableId:(0,e.Qq)().notNull().references(()=>r.id,{onDelete:"cascade",onUpdate:"cascade"}),name:(0,e.Qq)().notNull(),type:(0,e.Qq)().notNull(),isPk:(0,f.nd)({mode:"boolean"}).default(!1).notNull(),isFk:(0,f.nd)({mode:"boolean"}).default(!1).notNull(),nullable:(0,f.nd)({mode:"boolean"}).default(!0).notNull(),note:(0,e.Qq)(),ord:(0,f.nd)().default(0).notNull()},a=>[(0,h.GL)("DbColumn_tableId_name_key").on(a.tableId,a.name),(0,h.Pe)("DbColumn_tableId_idx").on(a.tableId)]),t=(0,d.D)("DbRelation",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),fromTableId:(0,e.Qq)().notNull().references(()=>r.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:(0,e.Qq)().notNull().references(()=>r.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:(0,e.Qq)().notNull(),toColumn:(0,e.Qq)().notNull(),label:(0,e.Qq)()},a=>[(0,h.Pe)("DbRelation_toTableId_idx").on(a.toTableId),(0,h.Pe)("DbRelation_fromTableId_idx").on(a.fromTableId)]),u=(0,d.D)("Endpoint",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),method:(0,e.Qq)().notNull(),path:(0,e.Qq)().notNull(),domain:(0,e.Qq)(),description:(0,e.Qq)(),source:(0,e.Qq)().default("MANUAL").notNull(),x:(0,g.x)().default(0).notNull(),y:(0,g.x)().default(0).notNull(),createdAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)},a=>[(0,h.GL)("Endpoint_method_path_key").on(a.method,a.path),(0,h.Pe)("Endpoint_domain_idx").on(a.domain)]),v=(0,d.D)("EndpointTable",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),endpointId:(0,e.Qq)().notNull().references(()=>u.id,{onDelete:"cascade",onUpdate:"cascade"}),tableId:(0,e.Qq)().notNull().references(()=>r.id,{onDelete:"cascade",onUpdate:"cascade"}),access:(0,e.Qq)().default("read").notNull()},a=>[(0,h.GL)("EndpointTable_endpointId_tableId_key").on(a.endpointId,a.tableId),(0,h.Pe)("EndpointTable_tableId_idx").on(a.tableId)]),w=(0,d.D)("DraftTable",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),name:(0,e.Qq)().notNull(),domain:(0,e.Qq)(),description:(0,e.Qq)(),x:(0,g.x)().default(0).notNull(),y:(0,g.x)().default(0).notNull(),createdAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},a=>[(0,h.GL)("DraftTable_name_key").on(a.name)]),x=(0,d.D)("DraftColumn",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),tableId:(0,e.Qq)().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),name:(0,e.Qq)().notNull(),type:(0,e.Qq)().notNull(),isPk:(0,f.nd)({mode:"boolean"}).default(!1).notNull(),isFk:(0,f.nd)({mode:"boolean"}).default(!1).notNull(),nullable:(0,f.nd)({mode:"boolean"}).default(!0).notNull(),note:(0,e.Qq)(),ord:(0,f.nd)().default(0).notNull()},a=>[(0,h.Pe)("DraftColumn_tableId_idx").on(a.tableId)]),y=(0,d.D)("DraftRelation",{id:(0,e.Qq)().primaryKey().$defaultFn(()=>(0,k.sX)()),fromTableId:(0,e.Qq)().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),toTableId:(0,e.Qq)().notNull().references(()=>w.id,{onDelete:"cascade",onUpdate:"cascade"}),fromColumn:(0,e.Qq)().notNull(),toColumn:(0,e.Qq)().notNull(),label:(0,e.Qq)()},a=>[(0,h.Pe)("DraftRelation_toTableId_idx").on(a.toTableId),(0,h.Pe)("DraftRelation_fromTableId_idx").on(a.fromTableId)]),z=(0,d.D)("CodeFile",{path:(0,e.Qq)().primaryKey(),root:(0,e.Qq)(),lang:(0,e.Qq)(),x:(0,g.x)().default(0).notNull(),y:(0,g.x)().default(0).notNull(),mtimeMs:(0,g.x)(),size:(0,f.nd)(),inDegree:(0,f.nd)().default(0).notNull(),outDegree:(0,f.nd)().default(0).notNull(),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),A=(0,d.D)("CodeFileEdge",{fromPath:(0,e.Qq)().notNull().references(()=>z.path,{onDelete:"cascade",onUpdate:"cascade"}),toPath:(0,e.Qq)().notNull().references(()=>z.path,{onDelete:"cascade",onUpdate:"cascade"}),circular:(0,f.nd)({mode:"boolean"}).default(!1).notNull()},a=>[(0,h.Pe)("CodeFileEdge_circular_idx").on(a.circular),(0,h.Pe)("CodeFileEdge_toPath_idx").on(a.toPath),(0,h.Pe)("CodeFileEdge_fromPath_idx").on(a.fromPath),(0,j.ie)({columns:[a.fromPath,a.toPath],name:"CodeFileEdge_fromPath_toPath_pk"})]),B=(0,d.D)("SyncState",{id:(0,e.Qq)().primaryKey().default("singleton"),version:(0,f.nd)().default(0).notNull(),codeGraphSyncedAt:(0,f.nd)({mode:"timestamp_ms"}),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),C=(0,d.D)("AppSetting",{id:(0,e.Qq)().primaryKey().default("singleton"),intelModel:(0,e.Qq)().default("claude-haiku-4-5").notNull(),intelProvider:(0,e.Qq)().default("auto").notNull(),editor:(0,e.Qq)().default("auto").notNull(),currentFeatureId:(0,e.Qq)(),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)}),D=(0,d.D)("ProjectMeta",{id:(0,e.Qq)().primaryKey().default("singleton"),overview:(0,e.Qq)(),conventions:(0,e.Qq)().default("[]").notNull(),updatedAt:(0,f.nd)({mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date).$onUpdate(()=>new Date)})},26284:(a,b,c)=>{c.d(b,{$:()=>i});var d=c(48249),e=c(70813),f=c(21654),g=c(33191);let h=(0,f.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 i({className:a,variant:b="default",size:c="default",...f}){return(0,d.jsx)(e.Button,{"data-slot":"button",className:(0,g.cn)(h({variant:b,size:c,className:a})),...f})}},26905:(a,b,c)=>{},29303:(a,b,c)=>{c.a(a,async(a,b)=>{try{var d=c(62896);c(22443);var e=a([d]);d=(e.then?(await e)():e)[0],b()}catch(a){b(a)}})},38476:(a,b,c)=>{c.d(b,{F1:()=>h,e6:()=>f,qA:()=>e,ru:()=>g});let d={auth:"#4ea1ff",firms:"#c792ea",search:"#7bd389",storage:"#ffb86b",petitions:"#ff7a45",monitoring:"#f5b942",admin:"#ff6b9d"};function e(a){return a&&d[a]||"#8a8a8a"}let f={GET:"#7bd389",POST:"#4ea1ff",PUT:"#ffb86b",PATCH:"#ffb86b",DELETE:"#ff3860"},g={read:"#4ea1ff",write:"#ffb86b","read-write":"#c792ea"};function h(a,b){let c=new Set([a]);for(let d of b)d.source===a&&c.add(d.target),d.target===a&&c.add(d.source);return c}},50042:(a,b,c)=>{c(31421),c(77598),c(48161),c(76760),c(80941)},50320:(a,b,c)=>{c.a(a,async(a,b)=>{try{var d=c(62896);c(22443);var e=a([d]);d=(e.then?(await e)():e)[0],b()}catch(a){b(a)}})},52351:(a,b,c)=>{c.d(b,{$v:()=>w,EO:()=>s,Lt:()=>o,Rx:()=>x,Zr:()=>y,ck:()=>u,r7:()=>v,tv:()=>p,wd:()=>t});var d=c(48249);c(67484);var e=c(71523),f=c(99469),g=c(60388),h=c(74283),i=c(25845),j=c(36902),k=c(64230),l=c(87298),m=c(33191),n=c(26284);function o({...a}){return(0,d.jsx)(e.V,{"data-slot":"alert-dialog",...a})}function p({...a}){return(0,d.jsx)(f.t,{"data-slot":"alert-dialog-trigger",...a})}function q({...a}){return(0,d.jsx)(g.Z,{"data-slot":"alert-dialog-portal",...a})}function r({className:a,...b}){return(0,d.jsx)(h.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",a),...b})}function s({className:a,size:b="default",...c}){return(0,d.jsxs)(q,{children:[(0,d.jsx)(r,{}),(0,d.jsx)(i.h,{"data-slot":"alert-dialog-content","data-size":b,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",a),...c})]})}function t({className:a,...b}){return(0,d.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]",a),...b})}function u({className:a,...b}){return(0,d.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",a),...b})}function v({className:a,...b}){return(0,d.jsx)(j.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",a),...b})}function w({className:a,...b}){return(0,d.jsx)(k.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",a),...b})}function x({className:a,variant:b,size:c,...e}){return(0,d.jsx)(l.H,{"data-slot":"alert-dialog-action",className:(0,m.cn)(a),render:(0,d.jsx)(n.$,{variant:b,size:c}),...e})}function y({className:a,variant:b="outline",size:c="default",...e}){return(0,d.jsx)(l.H,{"data-slot":"alert-dialog-cancel",className:(0,m.cn)(a),render:(0,d.jsx)(n.$,{variant:b,size:c}),...e})}},53501:(a,b,c)=>{c.d(b,{x0:()=>g});let d=null;async function e(){return d||(d=(async()=>{let{pipeline:a}=await Promise.resolve().then(c.bind(c,99253));return await a("feature-extraction","Xenova/all-MiniLM-L6-v2")})().catch(a=>{throw d=null,a})),d}async function f(a){let b=a.trim();if(!b)return null;try{let a=await e(),c=await a(b,{pooling:"mean",normalize:!0});return Array.from(c.data)}catch(a){return console.error("[embeddings] failed:",a instanceof Error?a.message:a),null}}async function g(a){try{let{db:b}=await c.e(9353).then(c.bind(c,89353)),{node:d}=await Promise.resolve().then(c.bind(c,22443)),{eq:e}=await c.e(6911).then(c.bind(c,46911)),g=await b.query.node.findFirst({where:(b,{eq:c})=>c(b.id,a),columns:{title:!0,role:!0,plain:!0,cluster:!0}});if(!g)return;let h=await f([g.title,g.role,g.plain,g.cluster].filter(Boolean).join(". "));if(!h)return;await b.update(d).set({embedding:JSON.stringify(h)}).where(e(d.id,a))}catch(b){console.error("[embeddings] reembed failed:",a,b instanceof Error?b.message:b)}}},55805:(a,b,c)=>{c.d(b,{Z:()=>m});var d=c(48249),e=c(2116),f=c.n(e),g=c(15996),h=c(41665),i=c(79602),j=c(36274),k=c(33191);let l={ROADMAP:g.A,ARCHITECTURE:h.A,FILES:i.A,DATABASE:j.A};function m({tabs:a,active:b}){return(0,d.jsx)("div",{className:"flex items-center gap-0.5",children:a.map(a=>{let c=a.value===b,e=a.Icon??l[a.value];return(0,d.jsxs)(f(),{href:a.href,className:(0,k.cn)("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[12px] font-medium tracking-tight transition-colors",c?"bg-white/10 text-foreground":"text-muted-foreground/80 hover:bg-white/5 hover:text-foreground"),children:[e?(0,d.jsx)(e,{className:"size-3"}):null,(0,d.jsx)("span",{children:a.label})]},a.value)})})}},58149:(a,b,c)=>{c(526)},60569:(a,b,c)=>{c(73024),c(76760),c(50042)},62896:(a,b,c)=>{c.a(a,async(a,d)=>{try{let l;c.d(b,{db:()=>r});var e=c(58296),f=c(28855),g=c(22443),h=c(76909),i=c(80941),j=a([f,e]);[f,e]=j.then?(await j)():j;let m={...g,...h},n=(l=process.env.DATABASE_URL)&&/^(file:|libsql:|wss?:|https?:|:memory:)/i.test(l)?l:"file:./dev.db";function k(a){let b=(0,f.createClient)({url:a});return b.execute("PRAGMA foreign_keys = ON;"),(0,e.f)(b,{schema:m})}let o=globalThis,p=o.dzDefault??k(n),q=o.dzByUrl??=new Map,r=new Proxy({},{get(a,b){let c=function(){var a;let b;if(process.env.BEACON_REPO)return p;let c=(0,i.p1)()??(0,i.UP)();return c?(a=(0,i.Nx)(c),(b=q.get(a))||(b=k(a),q.set(a,b)),b):p}(),d=c[b];return"function"==typeof d?d.bind(c):d}});d()}catch(a){d(a)}})},73149:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{"400a1a19efb5bad5dcee9b5c4155c23a63a919e104":()=>e.hY,"40271ac32342b618526d8666e025edce79c267e1fd":()=>e.pJ,"4094b0463f9ea824c069012b69bf9ef151e263f5ea":()=>e.cl,"4099598b1b435dbaca58bc6fdbd700bcfc04eb45dc":()=>e.HQ,"40b2717d960d406320c2ccb5dda21c7a5389fbf44c":()=>e.hg,"609776d59f19549c087b9e29c25e813680eaae5094":()=>e.t3,"60d20a0b6491606482cb101bb50c6cb23beb455434":()=>e.Oz});var e=c(1110),f=a([e]);e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},74732:(a,b,c)=>{c.d(b,{Cf:()=>r,Es:()=>t,L3:()=>u,c7:()=>s,lG:()=>o,rr:()=>v});var d=c(48249);c(67484);var e=c(76424),f=c(60388),g=c(74283),h=c(25845),i=c(87298),j=c(36902),k=c(64230),l=c(33191),m=c(26284),n=c(45535);function o({...a}){return(0,d.jsx)(e.D,{"data-slot":"dialog",...a})}function p({...a}){return(0,d.jsx)(f.Z,{"data-slot":"dialog-portal",...a})}function q({className:a,...b}){return(0,d.jsx)(g.X,{"data-slot":"dialog-overlay",className:(0,l.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",a),...b})}function r({className:a,children:b,showCloseButton:c=!0,...e}){return(0,d.jsxs)(p,{children:[(0,d.jsx)(q,{}),(0,d.jsxs)(h.h,{"data-slot":"dialog-content",className:(0,l.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",a),...e,children:[b,c&&(0,d.jsxs)(i.H,{"data-slot":"dialog-close",render:(0,d.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,d.jsx)(n.A,{}),(0,d.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function s({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"dialog-header",className:(0,l.cn)("flex flex-col gap-2",a),...b})}function t({className:a,showCloseButton:b=!1,children:c,...e}){return(0,d.jsxs)("div",{"data-slot":"dialog-footer",className:(0,l.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",a),...e,children:[c,b&&(0,d.jsx)(i.H,{render:(0,d.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function u({className:a,...b}){return(0,d.jsx)(j.L,{"data-slot":"dialog-title",className:(0,l.cn)("font-heading text-base leading-none font-medium",a),...b})}function v({className:a,...b}){return(0,d.jsx)(k.r,{"data-slot":"dialog-description",className:(0,l.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",a),...b})}},76909:(a,b,c)=>{c.r(b),c.d(b,{codeFileEdgeRelations:()=>t,codeFileRelations:()=>s,dbColumnRelations:()=>l,dbRelationRelations:()=>m,dbTableRelations:()=>k,draftColumnRelations:()=>q,draftRelationRelations:()=>r,draftTableRelations:()=>p,edgeRelations:()=>j,endpointRelations:()=>n,endpointTableRelations:()=>o,nodeFileRelations:()=>g,nodeRelations:()=>f,nodeTagsRelations:()=>i,tagRelations:()=>h});var d=c(74184),e=c(22443);let f=(0,d.K1)(e.node,({one:a,many:b})=>({files:b(e.nodeFile),nodeTags:b(e.nodeTags),edgesOut:b(e.edge,{relationName:"EdgeFrom"}),edgesIn:b(e.edge,{relationName:"EdgeTo"}),parent:a(e.node,{fields:[e.node.parentId],references:[e.node.id],relationName:"NodeTree"}),children:b(e.node,{relationName:"NodeTree"})})),g=(0,d.K1)(e.nodeFile,({one:a})=>({node:a(e.node,{fields:[e.nodeFile.nodeId],references:[e.node.id]})})),h=(0,d.K1)(e.tag,({many:a})=>({nodeTags:a(e.nodeTags)})),i=(0,d.K1)(e.nodeTags,({one:a})=>({node:a(e.node,{fields:[e.nodeTags.a],references:[e.node.id]}),tag:a(e.tag,{fields:[e.nodeTags.b],references:[e.tag.id]})})),j=(0,d.K1)(e.edge,({one:a})=>({from:a(e.node,{fields:[e.edge.fromId],references:[e.node.id],relationName:"EdgeFrom"}),to:a(e.node,{fields:[e.edge.toId],references:[e.node.id],relationName:"EdgeTo"})})),k=(0,d.K1)(e.dbTable,({many:a})=>({columns:a(e.dbColumn),fksOut:a(e.dbRelation,{relationName:"FkFrom"}),fksIn:a(e.dbRelation,{relationName:"FkTo"}),usages:a(e.endpointTable)})),l=(0,d.K1)(e.dbColumn,({one:a})=>({table:a(e.dbTable,{fields:[e.dbColumn.tableId],references:[e.dbTable.id]})})),m=(0,d.K1)(e.dbRelation,({one:a})=>({fromTable:a(e.dbTable,{fields:[e.dbRelation.fromTableId],references:[e.dbTable.id],relationName:"FkFrom"}),toTable:a(e.dbTable,{fields:[e.dbRelation.toTableId],references:[e.dbTable.id],relationName:"FkTo"})})),n=(0,d.K1)(e.endpoint,({many:a})=>({tables:a(e.endpointTable)})),o=(0,d.K1)(e.endpointTable,({one:a})=>({endpoint:a(e.endpoint,{fields:[e.endpointTable.endpointId],references:[e.endpoint.id]}),table:a(e.dbTable,{fields:[e.endpointTable.tableId],references:[e.dbTable.id]})})),p=(0,d.K1)(e.draftTable,({many:a})=>({columns:a(e.draftColumn),fksOut:a(e.draftRelation,{relationName:"DraftFkFrom"}),fksIn:a(e.draftRelation,{relationName:"DraftFkTo"})})),q=(0,d.K1)(e.draftColumn,({one:a})=>({table:a(e.draftTable,{fields:[e.draftColumn.tableId],references:[e.draftTable.id]})})),r=(0,d.K1)(e.draftRelation,({one:a})=>({fromTable:a(e.draftTable,{fields:[e.draftRelation.fromTableId],references:[e.draftTable.id],relationName:"DraftFkFrom"}),toTable:a(e.draftTable,{fields:[e.draftRelation.toTableId],references:[e.draftTable.id],relationName:"DraftFkTo"})})),s=(0,d.K1)(e.codeFile,({many:a})=>({edgesOut:a(e.codeFileEdge,{relationName:"CFEFrom"}),edgesIn:a(e.codeFileEdge,{relationName:"CFETo"})})),t=(0,d.K1)(e.codeFileEdge,({one:a})=>({fromFile:a(e.codeFile,{fields:[e.codeFileEdge.fromPath],references:[e.codeFile.path],relationName:"CFEFrom"}),toFile:a(e.codeFile,{fields:[e.codeFileEdge.toPath],references:[e.codeFile.path],relationName:"CFETo"})}))},79664:(a,b,c)=>{c.d(b,{MapClient:()=>ap});var d=c(48249),e=c(67484),f=c(55030),g=c(56024);c(71763);var h=c(10920),i=c(69473),j=c(28624),k=c(29813),l=c(90498),m=c(30170),n=c(95744),o=c(1229),p=c(25148),q=c(24422),r=c(47578),s=c(97432),t=c(47352),u=c(57684),v=c(83394),w=c(55056);let x=["PENDING","IN_PROGRESS","DONE","BLOCKED","CANCELLED","DEPRIORITIZED"],y=["KEEP","REBUILD","REPLACE","DROP"],z=["IN_PROGRESS","PENDING","BLOCKED","DONE","DEPRIORITIZED","CANCELLED"],A={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"}},B=["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 C(a){let b=(a??"").trim().toUpperCase();if(!b)return"bg-white/[0.06] text-muted-foreground";let c=0;for(let a=0;a<b.length;a++)c=31*c+b.charCodeAt(a)>>>0;return B[c%B.length]}let D=(0,e.createContext)(null);var E=c(2942),F=c(33191);let G=[{v:0,l:"P0 \xb7 critical"},{v:1,l:"P1 \xb7 high"},{v:2,l:"P2 \xb7 medium"},{v:3,l:"P3 \xb7 low"}],H="nodrag nopan";function I({id:a,data:b,selected:c}){let{categories:f,statuses:g,patch:h,isExpanded:i,toggleExpand:j,openDetailed:k,removeNode:l,editingTitleId:m,onAskAgent:x}=function(){let a=(0,e.useContext)(D);if(!a)throw Error("useNodeEdit must be used inside NodeEditContext");return a}(),y=i(a),[z,B]=(0,e.useState)(!1),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(b.title),[N,O]=(0,e.useState)(b.cluster??""),[P,Q]=(0,e.useState)(b.plain??""),R=0===b.priority,S="CANCELLED"===b.status||"DROP"===b.status,T="DEPRIORITIZED"===b.status,U="DRAFT"===b.source,V="IN_PROGRESS"===b.status,W="INIT"===b.source&&"ROADMAP"===b.view,X=a=>a.stopPropagation();return(0,d.jsxs)("div",{className:(0,F.cn)("rounded-lg border bg-card px-2.5 py-2 text-card-foreground shadow-sm transition",y?"w-80":b.isChild?"w-56":"w-64",U?"border-dashed border-sky-400/50 bg-sky-500/[0.06]":W?"border-dashed border-violet-400/60 bg-violet-500/[0.07] shadow-[0_0_0_1px_rgba(167,139,250,0.18)]":R?"border-[#ff3860]/60 shadow-[0_0_0_1px_rgba(255,56,96,0.15)]":"border-border",V&&"border-sky-400/60 shadow-[0_0_0_1px_rgba(56,160,255,0.25)]",b.isNext&&"border-emerald-400/70 shadow-[0_0_0_2px_rgba(52,211,153,0.35)]",c&&"ring-2 ring-[var(--accent,#f5b942)]",S&&"opacity-60",T&&"opacity-70 border-dashed"),children:[(0,d.jsx)(o.x,{}),b.isNext&&(0,d.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,d.jsxs)("div",{className:"flex items-start gap-1.5",children:[V&&(0,d.jsx)("span",{title:"em andamento",className:"mt-1.5 inline-block size-2 shrink-0 animate-pulse rounded-full bg-sky-400"}),b.isCriterion&&!V&&(0,d.jsx)("span",{title:"Success criterion",className:"mt-1.5 inline-block size-1.5 shrink-0 rounded-full bg-[var(--accent,#f5b942)]"}),(0,d.jsx)("textarea",{rows:1,value:L,autoFocus:m===a,placeholder:"Title…",onFocus:b=>{m===a&&b.currentTarget.select()},onChange:a=>M(a.target.value),onBlur:()=>{let c=L.trim();c&&c!==b.title&&h(a,{title:c},!0)},onKeyDown:a=>{X(a),"Enter"!==a.key||a.shiftKey||(a.preventDefault(),a.currentTarget.blur())},className:(0,F.cn)(H,"field-sizing-content w-full resize-none bg-transparent text-sm font-medium leading-snug outline-none placeholder:text-muted-foreground/60",S&&"line-through")}),(0,d.jsx)("button",{type:"button",onClick:b=>{X(b),j(a)},title:y?"Collapse":"Expand",className:(0,F.cn)(H,"mt-0.5 shrink-0 text-muted-foreground hover:text-foreground"),children:y?(0,d.jsx)(p.A,{className:"size-3.5"}):(0,d.jsx)(q.A,{className:"size-3.5"})})]}),((b.signals?.untested??0)>0||b.signals?.auth)&&(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[(b.signals?.untested??0)>0&&(0,d.jsxs)("span",{title:`${b.signals.untested} of ${b.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,d.jsx)(r.A,{className:"size-2.5"}),b.signals.untested," untested"]}),b.signals?.auth&&(0,d.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,d.jsx)(s.A,{className:"size-2.5"})," auth"]})]}),b.role&&(0,d.jsx)("div",{className:(0,F.cn)("mt-0.5 text-[10px] leading-snug text-muted-foreground",!y&&"line-clamp-1"),children:b.role}),(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-1.5",children:["ROADMAP"===b.view?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{title:b.isChild?"Sub-task of a feature":"Feature — top-level roadmap item",className:(0,F.cn)("shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide",b.isChild?"bg-zinc-500/15 text-zinc-300":"bg-sky-500/15 text-sky-300"),children:b.isChild?"sub-task":"feature"}),W&&(0,d.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,d.jsx)(t.A,{className:"size-2.5"})," IA"]}),(0,d.jsx)("input",{list:`cats-${a}`,value:N,placeholder:"category",onChange:a=>O(a.target.value),onBlur:()=>{let c=N.trim()||null;c!==(b.cluster??null)&&h(a,{cluster:c},!0)},onKeyDown:a=>{X(a),"Enter"===a.key&&a.currentTarget.blur()},className:(0,F.cn)(H,"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",C(N))})]}):(0,d.jsxs)(d.Fragment,{children:[b.isChild&&(0,d.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,d.jsx)("input",{list:`cats-${a}`,value:N,placeholder:"domain",title:"Architecture domain — the lane this component lives in",onChange:a=>O(a.target.value),onBlur:()=>{let c=N.trim()||null;c!==(b.cluster??null)&&h(a,{cluster:c},!0)},onKeyDown:a=>{X(a),"Enter"===a.key&&a.currentTarget.blur()},className:(0,F.cn)(H,"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",C(N))})]}),(0,d.jsx)("datalist",{id:`cats-${a}`,children:f.map(a=>(0,d.jsx)("option",{value:a},a))}),(0,d.jsxs)(w.l6,{value:b.status,onValueChange:b=>h(a,{status:b},!0),children:[(0,d.jsx)(w.bq,{className:(0,F.cn)(H,"ml-auto h-6 shrink-0 gap-1 rounded border px-1.5 py-0 text-[10px] font-medium",A[b.status]?.className??"border-white/10"),children:(0,d.jsx)(w.yv,{children:a=>A[a]?.label??a})}),(0,d.jsx)(w.gC,{alignItemWithTrigger:!1,children:g.map(a=>(0,d.jsx)(w.eb,{value:a,children:A[a]?.label??a},a))})]})]}),y&&(0,d.jsxs)("div",{className:"mt-2 space-y-2 border-t border-white/10 pt-2",children:[J||!P.trim()?(0,d.jsx)("textarea",{autoFocus:J,value:P,placeholder:"Description (markdown)…",onChange:a=>Q(a.target.value),onBlur:()=>{K(!1);let c=P.trim()||null;c!==(b.plain??null)&&h(a,{plain:c},!0)},onKeyDown:X,rows:3,className:(0,F.cn)(H,"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,d.jsx)("div",{onClick:a=>{X(a),K(!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,d.jsx)(E.pO,{markdown:P,variant:"compact",className:"text-[12px]"})}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)(w.l6,{value:String(b.priority),onValueChange:b=>h(a,{priority:Number(b)},!0),children:[(0,d.jsx)(w.bq,{className:(0,F.cn)(H,"h-6 gap-1 rounded border-white/10 px-1.5 py-0 text-[10px]"),children:(0,d.jsx)(w.yv,{children:a=>G.find(b=>String(b.v)===a)?.l??a})}),(0,d.jsx)(w.gC,{alignItemWithTrigger:!1,children:G.map(a=>(0,d.jsx)(w.eb,{value:String(a.v),children:a.l},a.v))})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:b=>{X(b),z?l(a):B(!0)},onBlur:()=>B(!1),title:"Delete node",className:(0,F.cn)(H,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] transition-colors",z?"bg-red-500/20 text-red-300":"text-muted-foreground hover:bg-white/5 hover:text-red-300"),children:[(0,d.jsx)(u.A,{className:"size-3"}),z&&"Delete?"]}),x&&(0,d.jsxs)("button",{type:"button",onClick:a=>{X(a),x(`feature: ${b.title}`)},title:"Ask the agent a question about this feature (answered in its next round)",className:(0,F.cn)(H,"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,d.jsx)(v.A,{className:"size-3"})," Ask"]}),(0,d.jsxs)("button",{type:"button",onClick:b=>{X(b),k(a)},className:(0,F.cn)(H,"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,d.jsx)(n.A,{className:"size-3"})," Details"]})]})]})]})]})}var J=c(82145),K=c(19099),L=c(45535),M=c(49783),N=c(48779),O=c(26284),P=c(52351),Q=c(74732);function R({className:a,type:b,...c}){return(0,d.jsx)("input",{type:b,"data-slot":"input",className:(0,F.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",a),...c})}function S({className:a,...b}){return(0,d.jsx)("textarea",{"data-slot":"textarea",className:(0,F.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",a),...b})}var T=c(86371);function U({className:a,...b}){return(0,d.jsx)(T.b,{"data-slot":"label",className:(0,F.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",a),...b})}var V=c(99829);let W=(0,V.createServerReference)("4099598b1b435dbaca58bc6fdbd700bcfc04eb45dc",V.callServer,void 0,V.findSourceMapURL,"createNodeAction"),X=(0,V.createServerReference)("60d20a0b6491606482cb101bb50c6cb23beb455434",V.callServer,void 0,V.findSourceMapURL,"updateNodeAction");function Y({open:a,onOpenChange:b,mode:c,view:f,heading:g,nodeId:h,parentId:i,position:j,defaults:k}){let l=(0,K.useRouter)(),[m,n]=(0,e.useState)(k?.title??""),[o,p]=(0,e.useState)(k?.role??""),[q,r]=(0,e.useState)(k?.plain??""),[s,t]=(0,e.useState)(k?.cluster??""),[u,v]=(0,e.useState)(k?.status??("ARCHITECTURE"===f?"REBUILD":"PENDING")),[z,B]=(0,e.useState)(!1),C="ARCHITECTURE"===f?y:x;async function D(){if(m.trim()){B(!0);try{"create"===c?await W({view:f,title:m.trim(),role:o.trim()||null,plain:q.trim()||null,cluster:s.trim()||null,parentId:i??null,status:u,x:j?.x??60,y:j?.y??60}):h&&await X(h,{title:m.trim(),role:o.trim()||null,plain:q.trim()||null,cluster:s.trim()||null,status:u}),b(!1),l.refresh()}finally{B(!1)}}}return(0,d.jsx)(Q.lG,{open:a,onOpenChange:b,children:(0,d.jsxs)(Q.Cf,{children:[(0,d.jsx)(Q.c7,{children:(0,d.jsx)(Q.L3,{children:g})}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(U,{htmlFor:"nf-title",children:"Title"}),(0,d.jsx)(R,{id:"nf-title",value:m,autoFocus:!0,onChange:a=>n(a.target.value)})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(U,{htmlFor:"nf-role",children:"Role (one line)"}),(0,d.jsx)(R,{id:"nf-role",value:o,onChange:a=>p(a.target.value)})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(U,{htmlFor:"nf-plain",children:"Description"}),(0,d.jsx)(S,{id:"nf-plain",rows:3,value:q,onChange:a=>r(a.target.value)})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(U,{children:"Status"}),(0,d.jsxs)(w.l6,{value:u,onValueChange:a=>null!=a&&v(a),children:[(0,d.jsx)(w.bq,{children:(0,d.jsx)(w.yv,{children:a=>A[a]?.label??a})}),(0,d.jsx)(w.gC,{children:C.map(a=>(0,d.jsx)(w.eb,{value:a,children:A[a]?.label??a},a))})]})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(U,{htmlFor:"nf-cluster",children:"Cluster / lane"}),(0,d.jsx)(R,{id:"nf-cluster",value:s,onChange:a=>t(a.target.value)})]})]})]}),(0,d.jsxs)(Q.Es,{children:[(0,d.jsx)(O.$,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),(0,d.jsx)(O.$,{onClick:D,disabled:z||!m.trim(),children:z?"Saving…":"Save"})]})]})})}let Z=(0,V.createServerReference)("40271ac32342b618526d8666e025edce79c267e1fd",V.callServer,void 0,V.findSourceMapURL,"acceptSuggestionAction"),$=(0,V.createServerReference)("4094b0463f9ea824c069012b69bf9ef151e263f5ea",V.callServer,void 0,V.findSourceMapURL,"deleteNodeAction"),_=(0,V.createServerReference)("609776d59f19549c087b9e29c25e813680eaae5094",V.callServer,void 0,V.findSourceMapURL,"setStatusAction"),aa=(0,V.createServerReference)("40b2717d960d406320c2ccb5dda21c7a5389fbf44c",V.callServer,void 0,V.findSourceMapURL,"cancelAction"),ab=(0,V.createServerReference)("400a1a19efb5bad5dcee9b5c4155c23a63a919e104",V.callServer,void 0,V.findSourceMapURL,"deprioritizeAction");function ac({view:a,selected:b,allNodes:c,onClose:e,commentsContent:f,commentsCount:g=0,activeTab:h,onTabChange:i,onAddComment:j,topOffset:k}){let l=!!f,m=h??"details";return(0,d.jsxs)(N.b,{className:"absolute bottom-3 right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:k??12},children:[l?(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)(ad,{active:"details"===m,onClick:()=>i?.("details"),children:"Details"}),(0,d.jsxs)(ad,{active:"comments"===m,onClick:()=>i?.("comments"),children:["Comments",g>0&&(0,d.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:g})]})]}),(0,d.jsx)("button",{onClick:e,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,d.jsx)(L.A,{className:"size-4"})})]}):(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Details"}),(0,d.jsx)("button",{onClick:e,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,d.jsx)(L.A,{className:"size-4"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsx)("div",{className:"p-3",children:"comments"===m&&l?f:b?(0,d.jsxs)(d.Fragment,{children:[j&&(0,d.jsxs)("button",{type:"button",onClick:()=>j(b.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,d.jsx)(M.A,{className:"size-3.5"}),"Comment on this ","ARCHITECTURE"===a?"component":"feature"]}),(0,d.jsx)(ae,{node:b,view:a},b.id)]}):(0,d.jsx)(af,{view:a,nodes:c})})})]})}function ad({active:a,onClick:b,children:c}){return(0,d.jsx)("button",{type:"button",onClick:b,className:(0,F.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",a?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:c})}function ae({node:a,view:b}){var c;let f=(0,K.useRouter)(),[g,h]=(0,e.useTransition)(),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),m="ARCHITECTURE"===b?y:x,n=a=>h(async()=>{await a(),f.refresh()});return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:[(c=a.cluster,c?.trim()||"—"),0===a.priority&&(0,d.jsx)("span",{className:"ml-2 text-[#ff7a90]",children:"\xb7 critical path"})]}),(0,d.jsx)("h2",{className:"mt-1 text-lg font-semibold leading-tight",children:a.title})]}),"INIT"===a.source&&(0,d.jsxs)("div",{className:"rounded-lg border border-violet-400/30 bg-violet-500/[0.06] p-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-violet-300",children:[(0,d.jsx)(t.A,{className:"size-3.5"})," AI suggestion"]}),(0,d.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,d.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[(0,d.jsx)(O.$,{size:"sm",className:"h-7 px-2.5 text-xs",disabled:g,onClick:()=>n(()=>Z(a.id)),children:"Accept"}),(0,d.jsx)(O.$,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs text-muted-foreground",disabled:g,onClick:()=>n(()=>$(a.id)),children:"Dismiss"})]})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"Status"}),(0,d.jsxs)(w.l6,{value:a.status,onValueChange:b=>null!=b&&n(()=>_(a.id,b)),children:[(0,d.jsx)(w.bq,{className:"h-8",disabled:g,children:(0,d.jsx)(w.yv,{children:a=>A[a]?.label??a})}),(0,d.jsx)(w.gC,{children:m.map(a=>(0,d.jsx)(w.eb,{value:a,children:A[a]?.label??a},a))})]})]}),a.plain&&(0,d.jsx)("div",{className:"rounded-md border border-white/5 bg-card/40 px-2.5 py-2 text-sm",children:(0,d.jsx)(E.pO,{markdown:a.plain,variant:"compact",className:"text-[12.5px]"})}),a.sourceRef&&(0,d.jsx)("div",{className:"rounded-md border border-border bg-card px-2 py-1.5 font-mono text-xs text-muted-foreground",children:a.sourceRef}),a.files.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Files (",a.files.length,")"]}),(0,d.jsx)("ul",{className:"space-y-0.5",children:a.files.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)("button",{onClick:()=>fetch(`/api/open?path=${encodeURIComponent(a)}`).catch(()=>{}),title:`Open ${a} 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:a})},a))})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[(0,d.jsx)(O.$,{size:"sm",variant:"outline",onClick:()=>j(!0),children:"Edit"}),(0,d.jsx)(O.$,{size:"sm",variant:"outline",onClick:()=>l(!0),children:"+ Sub-node"}),(0,d.jsx)(O.$,{size:"sm",variant:"outline",disabled:g,onClick:()=>n(()=>aa(a.id)),children:"Cancel"}),(0,d.jsx)(O.$,{size:"sm",variant:"outline",disabled:g,onClick:()=>n(()=>ab(a.id)),children:"Deprioritize"}),(0,d.jsxs)(P.Lt,{children:[(0,d.jsx)(P.tv,{render:(0,d.jsx)(O.$,{size:"sm",variant:"outline",className:"text-red-300",children:"Delete"})}),(0,d.jsxs)(P.EO,{children:[(0,d.jsxs)(P.wd,{children:[(0,d.jsxs)(P.r7,{children:["Delete “",a.title,"”?"]}),(0,d.jsx)(P.$v,{children:"This removes the node and all its sub-nodes. It can’t be undone."})]}),(0,d.jsxs)(P.ck,{children:[(0,d.jsx)(P.Zr,{children:"Cancel"}),(0,d.jsx)(P.Rx,{onClick:()=>n(()=>$(a.id)),children:"Delete"})]})]})]})]}),i&&(0,d.jsx)(Y,{open:!0,onOpenChange:j,mode:"edit",view:b,heading:"Edit node",nodeId:a.id,defaults:{title:a.title,role:a.role,plain:a.plain,status:a.status,cluster:a.cluster}}),k&&(0,d.jsx)(Y,{open:!0,onOpenChange:l,mode:"create",view:b,heading:"New sub-node",parentId:a.id,position:{x:a.x,y:a.y+120},defaults:{cluster:a.cluster}})]})}function af({view:a,nodes:b}){let c=b.filter(a=>0===a.priority).length;return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-sm font-semibold",children:"ROADMAP"===a?"Roadmap":"Architecture"}),(0,d.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,d.jsxs)("dl",{className:"grid grid-cols-2 gap-2 text-center",children:[(0,d.jsx)(ag,{label:"nodes",value:b.length}),(0,d.jsx)(ag,{label:"critical",value:c})]})]})}function ag({label:a,value:b}){return(0,d.jsxs)("div",{className:"rounded-md border border-border bg-card py-2",children:[(0,d.jsx)("div",{className:"text-lg font-semibold",children:b}),(0,d.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:a})]})}var ah=c(38476),ai=c(55805),aj=c(92994);let ak=[{value:"cluster",label:"Theme"},{value:"status",label:"Status"},{value:"priority",label:"Priority"}],al=new Set(["title","role","plain","cluster","status","priority"]),am={roadmapNode:I,archNode:I},an={deletable:J.I},ao={CONTAINS:{stroke:"#7c7c8a"},DEPENDS:{stroke:"#f5b942",dash:"6 4"},RELATES:{stroke:"#8a8a95",dash:"4 4"},REPLACES:{stroke:"#ff6b9d"}};function ap({view:a,nodes:b,edges:c,workOnNextId:o=null,embedded:p=!1,commentsContent:q,commentsCount:r=0,controlRef:s,onAskAgent:t,onAddComment:u}){let v=(0,e.useMemo)(()=>b.map(a=>({id:a.id,type:"ROADMAP"===a.view?"roadmapNode":"archNode",position:{x:a.x,y:a.y},data:{title:a.title,role:a.role,plain:a.plain,status:a.status,priority:a.priority,cluster:a.cluster,view:a.view,source:a.source,sourceRef:a.sourceRef,isCriterion:a.isCriterion,isChild:null!=a.parentId,parentId:a.parentId,signals:a.signals}})),[b]),w=(0,e.useMemo)(()=>{let a;return a=new Set(b.map(a=>a.id)),[...b.filter(b=>b.parentId&&a.has(b.parentId)).map(a=>({id:`c-${a.id}`,source:a.parentId,sourceHandle:"sb",target:a.id,targetHandle:"tt",type:"smoothstep",style:{stroke:ao.CONTAINS.stroke}})),...c.filter(b=>a.has(b.fromId)&&a.has(b.toId)).map(a=>{let b=ao[a.kind]??ao.RELATES,c="DEPENDS"===a.kind?"depends on":void 0;return{id:a.id,source:a.fromId,sourceHandle:a.sourceHandle??void 0,target:a.toId,targetHandle:a.targetHandle??void 0,label:a.label??c,type:"deletable",markerEnd:{type:f.TG.ArrowClosed,color:b.stroke},style:{stroke:b.stroke,strokeDasharray:b.dash}}})]},[b,c]),[B,C]=(0,e.useState)(v),[E,G]=(0,e.useState)(w),[H,I]=(0,e.useState)(null),[J,K]=(0,e.useState)(null),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(!1),[P,Q]=(0,e.useState)("details");(0,e.useRef)(!1),(0,e.useRef)("details");let[R,S]=(0,e.useState)(new Set),[T,U]=(0,e.useState)(null),[V,W]=(0,e.useState)(!1),X=(0,e.useRef)(0),Y=(0,e.useRef)(null),Z=(0,e.useCallback)((a,b,c)=>{C(c=>c.map(c=>c.id===a?{...c,data:{...c.data,...b}}:c)),c&&fetch(`/api/nodes/${a}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(Object.fromEntries(Object.entries(b).filter(([a])=>al.has(a))))})},[]),$=(0,e.useMemo)(()=>Array.from(new Set(B.map(a=>a.data.cluster).filter(a=>!!a))).sort(),[B]),_=(0,e.useCallback)(a=>S(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c}),[]),aa=(0,e.useCallback)(a=>{I(a),O(!0),Q("details")},[]),ab=(0,e.useCallback)(a=>{C(b=>b.filter(b=>b.id!==a)),I(b=>b===a?null:b),fetch(`/api/nodes/${a}`,{method:"DELETE"})},[]),ad=(0,e.useCallback)(async()=>{let b=X.current++%8*28,c=80+b,d=80+b;try{let b=await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({view:a,title:"New node",status:"ARCHITECTURE"===a?"REBUILD":"PENDING",x:c,y:d})});if(!b.ok)return;let e=await b.json();C(b=>[...b,{id:e.id,type:"ROADMAP"===a?"roadmapNode":"archNode",position:{x:c,y:d},data:{title:e.title,role:e.role,plain:e.plain,status:e.status,priority:e.priority,cluster:e.cluster,view:e.view,source:e.source,sourceRef:e.sourceRef,isCriterion:!1,isChild:null!=e.parentId,parentId:e.parentId??null}}]),S(a=>new Set(a).add(e.id)),U(e.id),I(e.id)}catch{}},[a]),ae=(0,e.useMemo)(()=>({view:a,categories:$,statuses:"ARCHITECTURE"===a?y:x,patch:Z,isExpanded:a=>R.has(a),toggleExpand:_,openDetailed:aa,removeNode:ab,editingTitleId:T,onAskAgent:t}),[a,$,Z,R,_,aa,ab,T,t]),[af,ag]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(""),[as,at]=(0,e.useState)(new Set),[au,av]=(0,e.useState)(new Set),[aw,ax]=(0,e.useState)(new Set),ay=(0,e.useMemo)(()=>Array.from(new Set(b.map(a=>a.status))),[b]),az=(0,e.useMemo)(()=>Array.from(new Set(b.map(a=>a.cluster).filter(a=>!!a))).sort(),[b]),aA=(0,e.useMemo)(()=>Array.from(new Set(b.map(a=>a.priority))).sort((a,b)=>a-b),[b]),aB=(0,e.useCallback)(a=>(!as.size||!!as.has(a.status))&&(!au.size||!!a.cluster&&!!au.has(a.cluster))&&(!aw.size||!!aw.has(a.priority)),[as,au,aw]),aC=as.size+au.size+aw.size,aD=(0,e.useCallback)(()=>{at(new Set),av(new Set),ax(new Set)},[]),aE=(0,e.useMemo)(()=>B.map(a=>({...a,hidden:!aB(a.data)})),[B,aB]),aF=(0,e.useMemo)(()=>new Set(aE.filter(a=>a.hidden).map(a=>a.id)),[aE]),aG=(0,e.useMemo)(()=>E.map(a=>({...a,hidden:aF.has(a.source)||aF.has(a.target)})),[E,aF]),aH=(0,e.useMemo)(()=>{if(J){let a=aG.find(a=>a.id===J);return a?new Set([a.source,a.target]):null}return H?(0,ah.F1)(H,aG.filter(a=>!a.hidden)):null},[H,J,aG]),aI=(0,e.useMemo)(()=>aE.map(a=>{let b=o&&a.id===o?{...a,data:{...a.data,isNext:!0}}:a;return!aH||b.hidden?b:{...b,style:{...b.style,opacity:aH.has(a.id)?1:.45,transition:"opacity 120ms"}}}),[aE,aH,o]),aJ=(0,e.useMemo)(()=>{if(!af||"ROADMAP"!==a)return[];let b=new Map(aI.map(a=>[a.id,a])),c=new Map;for(let a of aI){var d;if(a.hidden)continue;let e=(d=((a.data.parentId?b.get(a.data.parentId):void 0)??a).data,"status"===af?A[d.status]?.label??d.status:"priority"===af?`P${d.priority}`:d.cluster?.trim()||"—"),f=a.measured?.width??(a.data.isChild?224:256),g=a.measured?.height??96,h=a.position.x,i=a.position.y,j=c.get(e);j?(j.minX=Math.min(j.minX,h),j.minY=Math.min(j.minY,i),j.maxX=Math.max(j.maxX,h+f),j.maxY=Math.max(j.maxY,i+g)):c.set(e,{label:e,minX:h,minY:i,maxX:h+f,maxY:i+g})}return Array.from(c.values()).map(a=>({label:a.label,x:a.minX-20,y:a.minY-20-26,w:a.maxX-a.minX+40,h:a.maxY-a.minY+40+26}))},[aI,af,a]),aK=(0,e.useMemo)(()=>{let a=H??L;return J||a?aG.map(b=>b.hidden?b:(J?b.id===J:b.source===a||b.target===a)?{...b,zIndex:20,style:{...b.style,opacity:1,strokeWidth:2.5}}:{...b,selectable:!1,label:void 0,markerEnd:void 0,style:{...b.style,opacity:.06}}):aG.map(a=>a.hidden?a:{...a,label:void 0,style:{...a.style,opacity:.18}})},[aG,H,J,L]),aL=(0,e.useCallback)(a=>C(b=>(0,g._0)(a,b)),[]),aM=(0,e.useCallback)(a=>G(b=>(0,g.zW)(a,b)),[]),aN=(0,e.useCallback)(async a=>{if(!a.source||!a.target||a.source===a.target)return;let b=await fetch("/api/edges",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:a.source,toId:a.target,kind:"DEPENDS",sourceHandle:a.sourceHandle??null,targetHandle:a.targetHandle??null})});if(!b.ok)return;let c=await b.json(),d=ao.DEPENDS;G(b=>b.some(a=>a.id===c.id)?b:[...b,{id:c.id,source:c.fromId,sourceHandle:a.sourceHandle??void 0,target:c.toId,targetHandle:a.targetHandle??void 0,label:"depends on",type:"deletable",markerEnd:{type:f.TG.ArrowClosed,color:d.stroke},style:{stroke:d.stroke,strokeDasharray:d.dash}}])},[]),aO=(0,e.useCallback)(async(b,c,d)=>{let e=await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({view:a,title:"New node",parentId:b.id,cluster:b.data.cluster??null,status:"ARCHITECTURE"===a?"REBUILD":"PENDING",x:c,y:d})});if(!e.ok)return;let f=await e.json();C(e=>[...e,{id:f.id,type:"ROADMAP"===a?"roadmapNode":"archNode",position:{x:c,y:d},data:{title:f.title,role:f.role,plain:f.plain,status:f.status,priority:f.priority,cluster:f.cluster,view:f.view,source:f.source,sourceRef:f.sourceRef,isCriterion:!1,isChild:!0,parentId:b.id}}]),G(a=>[...a,{id:`c-${f.id}`,source:b.id,target:f.id,type:"smoothstep",style:{stroke:ao.CONTAINS.stroke}}]),S(a=>new Set(a).add(f.id)),U(f.id),I(f.id)},[a]),aP=(0,e.useCallback)(async(a,b)=>{if(b.isValid||!b.fromNode||!Y.current)return;let c=a.changedTouches,d=c?.[0]?.clientX??a.clientX,e=c?.[0]?.clientY??a.clientY,{x:f,y:g}=Y.current.screenToFlowPosition({x:d,y:e});await aO(b.fromNode,f,g)},[aO]),aQ=(0,e.useMemo)(()=>b.find(a=>a.id===H)??null,[b,H]),aR=(0,e.useCallback)((a,b,c)=>{fetch(`/api/nodes/${a}/position`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({x:b,y:c})})},[]),aS=(0,e.useCallback)(a=>{I(a),K(null);let b=Y.current?.getNode(a);if(!b||!Y.current)return;let c=b.measured?.width??128,d=b.measured?.height??48;Y.current.setCenter(b.position.x+c/2,b.position.y+d/2,{zoom:1.2,duration:600})},[]),aT=(0,e.useCallback)(a=>{let b=function(a,b,c={}){let d=c.colW??320,e=c.rowH??150,f=c.childIndent??24,g=c.laneGap??56,h=c.bandGap??110,i=c.maxCols??4,j=c.maxBandW??6*d,k=new Set(a.map(a=>a.id)),l=a=>!a.parentId||!k.has(a.parentId),m=a.filter(l),n=new Map;for(let b of a){if(l(b))continue;let a=n.get(b.parentId);a?a.push(b):n.set(b.parentId,[b])}let o="status"===b?a=>a.status:"priority"===b?a=>String(a.priority):a=>(a.cluster??"").trim()||"—",p=new Map;for(let a of m){let b=o(a),c=p.get(b);c?c.push(a):p.set(b,[a])}let q=(function(a,b,c){if("status"===a)return[...z];if("priority"===a)return["0","1","2","3"];let d=Array.from(new Set(b.map(c))),e=d.filter(a=>"—"!==a).sort();return d.includes("—")?[...e,"—"]:e})(b,m,o).filter(a=>p.has(a)),r=new Map,s=0,t=0,u=0;for(let a of q){let b=p.get(a),c=Math.max(1,Math.min(i,Math.ceil(Math.sqrt(b.length)))),k=c*d;s>0&&s+k>j&&(s=0,t+=u+h,u=0);let l=Array(c).fill(0);for(let a of b){let b=0;for(let a=1;a<c;a++)l[a]<l[b]&&(b=a);let g=s+b*d,h=t+l[b]*e;r.set(a.id,{x:g,y:h});let i=n.get(a.id)??[];i.forEach((a,b)=>{r.set(a.id,{x:g+f,y:h+(b+1)*e})}),l[b]+=1+i.length}u=Math.max(u,l.reduce((a,b)=>Math.max(a,b),0)*e),s+=k+g}return r}(B.map(a=>({id:a.id,parentId:a.data.parentId??null,cluster:a.data.cluster,status:a.data.status,priority:a.data.priority})),a);C(a=>a.map(a=>{let c=b.get(a.id);return c?{...a,position:c}:a}));let c=Array.from(b,([a,b])=>({id:a,x:b.x,y:b.y}));c.length&&fetch("/api/nodes/positions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({batch:c})}),ag(a),requestAnimationFrame(()=>Y.current?.fitView({duration:600,padding:.2}))},[B]),aU=(0,e.useMemo)(()=>{let a=aq.trim().toLowerCase();return a?B.filter(b=>aB(b.data)&&b.data.title.toLowerCase().includes(a)).slice(0,8):[]},[B,aq,aB]);function aV(a,b){b(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})}return(0,d.jsx)(D.Provider,{value:ae,children:(0,d.jsxs)("div",{className:(0,F.cn)("relative w-full",p?"h-full":"h-screen"),children:[(0,d.jsxs)(g.Gc,{nodes:aI,edges:aK,nodeTypes:am,edgeTypes:an,connectionMode:f.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:a=>{Y.current=a},onNodesChange:aL,onEdgesChange:aM,onConnect:aN,onConnectEnd:aP,onNodeMouseEnter:(a,b)=>M(b.id),onNodeMouseLeave:()=>M(null),onEdgesDelete:a=>{for(let b of a)b.id.startsWith("c-")||fetch(`/api/edges/${b.id}`,{method:"DELETE"})},onNodesDelete:a=>{for(let b of a)fetch(`/api/nodes/${b.id}`,{method:"DELETE"}),I(a=>a===b.id?null:a)},onNodeClick:(a,b)=>{if(V){if(W(!1),b.data.isChild)return;aO(b,b.position.x+300,b.position.y+60);return}if(I(b.id),K(null),Q("details"),p){let b=a.target;b?.closest("input, textarea, select, button, [role='combobox']")||O(!0)}},onEdgeClick:(a,b)=>{K(b.id),I(null),Q("details")},onPaneClick:()=>{V?W(!1):(I(null),K(null))},onNodeDragStop:(a,b)=>aR(b.id,b.position.x,b.position.y),deleteKeyCode:["Backspace","Delete"],colorMode:"dark",fitView:!0,minZoom:.2,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,d.jsx)(g.VS,{gap:22,color:"#2a2a32"}),aJ.length>0&&(0,d.jsx)(g.DX,{children:aJ.map(a=>(0,d.jsx)("div",{style:{position:"absolute",transform:`translate(${a.x}px, ${a.y}px)`,width:a.w,height:a.h,pointerEvents:"none",zIndex:0},className:"rounded-2xl border border-white/[0.08] bg-white/[0.015]",children:(0,d.jsx)("div",{className:"px-3 py-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:a.label})},a.label))}),(0,d.jsx)(g.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,d.jsx)(g.Zk,{position:"bottom-right",style:{marginBottom:152},children:(0,d.jsx)(aj.er,{title:"Legend",trigger:(a,b)=>(0,d.jsx)("button",{type:"button",onClick:b,title:"Legend",className:(0,F.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",a?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,d.jsx)(h.A,{className:"size-4"})}),children:(0,d.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.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,d.jsx)("span",{children:"top-level card \xb7 can have sub-tasks"})]}),(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.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,d.jsx)("span",{children:"child of a feature"})]}),(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#33333a]"}),(0,d.jsx)("span",{children:"contains \xb7 drag the bottom handle to empty canvas"})]}),(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#f5b942"}}),(0,d.jsx)("span",{children:"depends on \xb7 drag between two cards"})]})]})})}),!p&&(0,d.jsx)(g.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:a=>a.data?.priority===0?"#ff3860":"#555"}),(0,d.jsxs)(g.Zk,{position:"bottom-center",className:"!mb-4 flex flex-col items-center gap-2",children:[V&&(0,d.jsxs)("div",{className:"glass rounded-full px-3 py-1 text-[11px] text-muted-foreground",children:["Click a ","ARCHITECTURE"===a?"component":"feature"," to attach the"," ","ARCHITECTURE"===a?"sub-component":"sub-task"," \xb7 Esc to cancel"]}),"ROADMAP"===a&&(0,d.jsxs)("div",{className:"glass flex items-center gap-1 rounded-full p-1",children:[(0,d.jsx)("span",{className:"pl-2 pr-0.5 text-[11px] text-muted-foreground",children:"Group by"}),ak.map(a=>(0,d.jsx)("button",{onClick:()=>aT(a.value),title:`Arrange features into lanes by ${a.label.toLowerCase()}`,className:(0,F.cn)("h-7 rounded-full px-2.5 text-[11px] font-medium transition-colors",af===a.value?"bg-white/[0.12] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:a.label},a.value))]}),(0,d.jsxs)("div",{className:"glass flex items-center gap-1 rounded-full p-1",children:[(0,d.jsxs)("button",{onClick:()=>void ad(),title:"ARCHITECTURE"===a?"Add component":"Add feature",className:"flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-medium text-foreground transition-colors hover:bg-white/[0.06]",children:[(0,d.jsx)(i.A,{className:"size-3.5 text-[var(--accent-2,#ff7a45)]"}),"ARCHITECTURE"===a?"Component":"Feature"]}),(0,d.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-5 w-px bg-white/10"}),(0,d.jsxs)("button",{onClick:()=>W(a=>!a),title:"ARCHITECTURE"===a?"Add sub-component (click a component next)":"Add sub-task (click a feature next)",className:(0,F.cn)("flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-medium transition-colors",V?"bg-white/[0.1] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,d.jsx)(j.A,{className:"size-3.5"}),"ARCHITECTURE"===a?"Sub-component":"Sub-task"]})]})]}),!p&&(0,d.jsx)(g.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,d.jsx)(ai.Z,{active:a,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,d.jsxs)(g.Zk,{position:"top-right",className:(0,F.cn)("flex items-center gap-1 transition-[margin] duration-200",N&&"!mr-[332px]",p&&"hidden"),children:[(0,d.jsxs)(aj.er,{title:"Search",trigger:(a,b)=>(0,d.jsx)("button",{type:"button",onClick:b,title:"Search features",className:(0,F.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",a?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,d.jsx)(k.A,{className:"size-4"})}),children:[(0,d.jsx)("input",{autoFocus:!0,value:aq,onChange:a=>ar(a.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,d.jsxs)("div",{className:"mt-2 max-h-64 space-y-0.5 overflow-y-auto",children:[aq.trim()&&0===aU.length&&(0,d.jsx)("div",{className:"px-1 py-1 text-[11px] text-muted-foreground",children:"No matches"}),aU.map(a=>(0,d.jsx)("button",{type:"button",onClick:()=>aS(a.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:a.data.title},a.id))]})]}),"ROADMAP"===a&&o&&(0,d.jsx)("button",{type:"button",onClick:()=>aS(o),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,d.jsx)(l.A,{className:"size-4"})}),(0,d.jsxs)(aj.er,{title:"Filters",trigger:(a,b)=>(0,d.jsxs)("button",{type:"button",onClick:b,title:"Filters",className:(0,F.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",a||aC>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,d.jsx)(m.A,{className:"size-4"}),aC>0&&(0,d.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:aC})]}),children:[ay.length>0&&(0,d.jsx)(aj.r1,{title:"Status",children:ay.map(a=>(0,d.jsx)(aj.vu,{on:as.has(a),onClick:()=>aV(a,at),children:A[a]?.label??a},a))}),az.length>0&&(0,d.jsx)(aj.r1,{title:"Cluster",children:az.map(a=>(0,d.jsx)(aj.vu,{on:au.has(a),onClick:()=>aV(a,av),children:a},a))}),aA.length>0&&(0,d.jsx)(aj.r1,{title:"Priority",children:aA.map(a=>(0,d.jsxs)(aj.vu,{on:aw.has(a),onClick:()=>aV(a,ax),children:["P",a]},a))}),aC>0&&(0,d.jsx)("button",{type:"button",onClick:aD,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"})]}),!N&&(0,d.jsx)("button",{onClick:()=>{O(!0),Q("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,d.jsx)(n.A,{className:"size-4"})})]})]}),N&&(0,d.jsx)(ac,{view:a,selected:aQ,allNodes:b,onClose:()=>{O(!1),Q("details")},commentsContent:q,commentsCount:r,activeTab:P,onTabChange:Q,onAddComment:u,topOffset:p?64:void 0})]})})}},80941:(a,b,c)=>{c.d(b,{Nx:()=>i,UP:()=>j,p1:()=>l});var d=c(16698);c(31421),c(77598);var e=c(73024),f=c(48161),g=c(76760);function h(){return process.env.BEACON_HOME||(0,g.join)((0,f.homedir)(),".beacon")}function i(a){return`file:${(0,g.join)((0,g.join)(h(),a),"db.sqlite")}`}function j(){try{return(0,e.readFileSync)((0,g.join)(h(),"active"),"utf8").trim()||null}catch{return null}}let k=new d.AsyncLocalStorage;function l(){return k.getStore()??null}},82145:(a,b,c)=>{c.d(b,{I:()=>k});var d=c(48249),e=c(56024),f=c(55030),g=c(57684);function h(a){let{x:b,y:c}=a.internals.positionAbsolute,d=a.measured?.width??0,e=a.measured?.height??0;return{x:b,y:c,w:d,h:e,cx:b+d/2,cy:c+e/2}}function i(a,b){let c=h(a),d=h(b),e=c.w/2||1,f=c.h/2||1,g=(d.cx-c.cx)/(2*e)-(d.cy-c.cy)/(2*f),i=(d.cx-c.cx)/(2*e)+(d.cy-c.cy)/(2*f),j=1/(Math.abs(g)+Math.abs(i)||1);return{x:e*j*(g+i)+c.cx,y:f*j*(-g+i)+c.cy}}function j(a,b){let c=h(a),d=Math.round(b.x),e=Math.round(b.y);return d<=Math.round(c.x)+1?f.yX.Left:d>=Math.round(c.x+c.w)-1?f.yX.Right:e<=Math.round(c.y)+1?f.yX.Top:f.yX.Bottom}function k(a){let b,c,{deleteElements:h}=(0,e.VH)(),k=(0,e.JY)(a.source),l=(0,e.JY)(a.target),m=k&&l?(b=i(k,l),c=i(l,k),{sx:b.x,sy:b.y,tx:c.x,ty:c.y,sourcePos:j(k,b),targetPos:j(l,c)}):null,[n,o,p]=(0,f.Fp)(m?{sourceX:m.sx,sourceY:m.sy,sourcePosition:m.sourcePos,targetX:m.tx,targetY:m.ty,targetPosition:m.targetPos}:{sourceX:a.sourceX,sourceY:a.sourceY,sourcePosition:a.sourcePosition,targetX:a.targetX,targetY:a.targetY,targetPosition:a.targetPosition});return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.tE,{id:a.id,path:n,style:a.style,markerEnd:a.markerEnd,interactionWidth:20}),a.label&&(0,d.jsx)(e.rV,{children:(0,d.jsx)("div",{style:{position:"absolute",transform:`translate(-50%, -120%) translate(${o}px, ${p}px)`,fontSize:11,color:"#cfcfcf",background:"#161616",padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:a.label})}),a.selected&&(0,d.jsx)(e.rV,{children:(0,d.jsx)("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, 0) translate(${o}px, ${p+14}px)`,pointerEvents:"all",zIndex:1e3},children:(0,d.jsx)("button",{type:"button",onMouseDown:a=>a.stopPropagation(),onClick:b=>{b.stopPropagation(),h({edges:[{id:a.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,d.jsx)(g.A,{className:"size-3.5"})})})})]})}},84853:(a,b,c)=>{c.d(b,{G:()=>f,K:()=>g});var d=c(65573),e=c(6716);async function f(a){let b=(await (0,d.UL)()).get(e.Dk)?.value;return(0,e.X_)(b&&(0,e.K4)(b)?b:null,a)}async function g(a){if(a&&(0,e.K4)(a))return a;let b=(await (0,d.UL)()).get(e.Dk)?.value;return b&&(0,e.K4)(b)?b:null}},86925:(a,b,c)=>{c.d(b,{DbMapClient:()=>_});var d=c(48249),e=c(67484),f=c(19099),g=c(56024),h=c(55030);c(71763);var i=c(90165),j=c(89216),k=c(57684),l=c(45535),m=c(69473),n=c(33191),o=c(38476);let p=(0,e.createContext)(null);function q(){let a=(0,e.useContext)(p);if(!a)throw Error("useDbEdit must be used inside DbEditContext");return a}var r=c(1229);let s={danger:"bg-red-500/15 text-red-300",warn:"bg-amber-500/15 text-amber-300"};function t({badges:a,className:b}){return a.length?(0,d.jsx)("span",{className:(0,n.cn)("flex shrink-0 items-center gap-0.5",b),children:a.map(a=>(0,d.jsx)("span",{title:a.title,className:(0,n.cn)("rounded px-1 text-[8px] font-semibold uppercase tracking-wide",s[a.tone]),children:a.label},a.label))}):null}let u=/pass(word)?|token|secret|api[_-]?key|credential|priv(ate)?[_-]?key|hash|salt/i,v=/auth|login|logout|session|token|password|oauth|sso|credential/i,w="nodrag nopan",x=r.x,y="nodrag nopan",z=["GET","POST","PUT","PATCH","DELETE"];var A=c(49783),B=c(48779),C=c(26284);let D=[{id:"claude",label:"Prompt p/ Claude Code",fn:function(a){let b=["Implement this database schema in this project, following its existing stack and conventions:",""];for(let c of a.tables){let a=`Table \`${c.name}\``+(c.domain?` (domain: ${c.domain})`:"")+(c.description?` — ${c.description}`:"");for(let d of(b.push(a),c.columns)){let a=[d.isPk&&"PK",d.isFk&&"FK",!1===d.nullable&&"NOT NULL"].filter(Boolean).join(", ");b.push(` - ${d.name}: ${d.type}`+(a?` [${a}]`:"")+(d.note?` — ${d.note}`:""))}b.push("")}if(a.relations.length){for(let c of(b.push("Foreign keys:"),a.relations))b.push(` - ${c.fromTable}.${c.fromColumn} -> ${c.toTable}.${c.toColumn}`);b.push("")}return b.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."),b.join("\n")}},{id:"dbml",label:"DBML",fn:function(a){let b=[];for(let c of a.tables){for(let a of(b.push(`Table ${c.name} {`),c.columns)){let c=[a.isPk&&"pk",!1===a.nullable&&!a.isPk&&"not null",a.note&&`note: '${a.note.replace(/'/g,"")}'`].filter(Boolean).join(", ");b.push(` ${a.name} ${a.type}`+(c?` [${c}]`:""))}b.push("}","")}for(let c of a.relations)b.push(`Ref: ${c.fromTable}.${c.fromColumn} > ${c.toTable}.${c.toColumn}`);return b.join("\n").trim()}},{id:"sql",label:"SQL DDL",fn:function(a){let b=[];for(let c of a.tables){b.push(`CREATE TABLE ${c.name} (`);let d=c.columns.map(a=>{let b=[` ${a.name} ${a.type}`];return a.isPk?b.push("PRIMARY KEY"):!1===a.nullable&&b.push("NOT NULL"),b.join(" ")}),e=a.relations.filter(a=>a.fromTable===c.name).map(a=>` FOREIGN KEY (${a.fromColumn}) REFERENCES ${a.toTable}(${a.toColumn})`);b.push([...d,...e].join(",\n")),b.push(");","")}return b.join("\n").trim()}}];function E({draftGraph:a}){let[b,c]=(0,e.useState)(null);if(0===a.tables.length)return null;async function f(b){await navigator.clipboard.writeText(b.fn(a)).catch(()=>{}),c(b.id),setTimeout(()=>c(null),1500)}return(0,d.jsxs)("div",{className:"space-y-2 rounded-xl border border-sky-400/20 bg-sky-500/[0.04] p-3",children:[(0,d.jsxs)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-sky-300",children:["Rascunho \xb7 ",a.tables.length," tabelas"]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"copiar:"}),D.map(a=>(0,d.jsx)(C.$,{size:"sm",variant:"outline",className:"h-6 px-2 text-[11px]",onClick:()=>f(a),children:b===a.id?"✓":a.label},a.id))]})]})}function F({selected:a,tables:b,relations:c,endpoints:e,draftGraph:f,onClose:g,commentsContent:h,commentsCount:i=0,activeTab:j,onTabChange:k,onAddComment:m,topOffset:n}){let o,p,q=new Map(b.map(a=>[a.id,a.name])),r=!!h,s=j??"details",t=a?.kind==="table"?b.find(b=>b.id===a.id)?.name??null:a?.kind==="endpoint"&&(p=e.find(b=>b.id===a.id))?`${p.method} ${p.path}`:null;if(a?.kind==="table"){let f=b.find(b=>b.id===a.id);o=f?(0,d.jsx)(H,{table:f,relations:c,endpoints:e,nameById:q}):null}else if(a?.kind==="endpoint"){let b=e.find(b=>b.id===a.id);o=b?(0,d.jsx)(I,{ep:b,nameById:q}):null}else o=(0,d.jsx)(J,{tables:b,relations:c,endpoints:e});return(0,d.jsxs)(B.b,{className:"absolute bottom-3 right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:n??12},children:[r?(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)(G,{active:"details"===s,onClick:()=>k?.("details"),children:"Details"}),(0,d.jsxs)(G,{active:"comments"===s,onClick:()=>k?.("comments"),children:["Comments",i>0&&(0,d.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:i})]})]}),(0,d.jsx)("button",{onClick:g,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,d.jsx)(l.A,{className:"size-4"})})]}):(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Panel"}),(0,d.jsx)("button",{onClick:g,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,d.jsx)(l.A,{className:"size-4"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:"comments"===s&&r?(0,d.jsx)("div",{className:"p-3",children:h}):(0,d.jsxs)(d.Fragment,{children:[f.tables.length>0&&(0,d.jsx)("div",{className:"border-b border-white/10 p-3.5",children:(0,d.jsx)(E,{draftGraph:f})}),(0,d.jsxs)("div",{className:"p-4",children:[m&&t&&(0,d.jsxs)("button",{type:"button",onClick:()=>m(t),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,d.jsx)(A.A,{className:"size-3.5"}),"Comment on this ",a?.kind==="endpoint"?"endpoint":"table"]}),o]})]})})]})}function G({active:a,onClick:b,children:c}){return(0,d.jsx)("button",{type:"button",onClick:b,className:(0,n.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",a?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:c})}function H({table:a,relations:b,endpoints:c,nameById:e}){let f=b.filter(b=>b.fromTableId===a.id),g=b.filter(b=>b.toTableId===a.id),h=c.map(b=>({e:b,u:b.tables.find(b=>b.tableId===a.id)})).filter(a=>a.u);return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-xs uppercase tracking-wide",style:{color:(0,o.qA)(a.domain)},children:a.domain??"table"}),(0,d.jsx)("h2",{className:"font-mono text-lg font-semibold",children:a.name}),a.description&&(0,d.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a.description})]}),(0,d.jsx)(K,{title:`Columns (${a.columns.length})`,children:(0,d.jsx)("ul",{className:"space-y-0.5",children:a.columns.map(a=>(0,d.jsxs)("li",{className:"flex items-center gap-1.5 text-xs",children:[a.isPk?(0,d.jsx)(i.A,{className:"size-3 text-amber-400"}):a.isFk?(0,d.jsx)(j.A,{className:"size-3 text-sky-400"}):(0,d.jsx)("span",{className:"size-3"}),(0,d.jsx)("span",{className:"font-mono",children:a.name}),(0,d.jsxs)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground",children:[a.type,!a.nullable&&" \xb7NN"]})]},a.name))})}),f.length>0&&(0,d.jsx)(K,{title:"References (FK out)",children:(0,d.jsx)("ul",{className:"space-y-1 text-xs",children:f.map(a=>(0,d.jsxs)("li",{className:"font-mono text-muted-foreground",children:[a.fromColumn," → ",e.get(a.toTableId),".",a.toColumn]},a.id))})}),g.length>0&&(0,d.jsx)(K,{title:"Referenced by (FK in)",children:(0,d.jsx)("ul",{className:"space-y-1 text-xs",children:g.map(a=>(0,d.jsxs)("li",{className:"font-mono text-muted-foreground",children:[e.get(a.fromTableId),".",a.fromColumn]},a.id))})}),h.length>0&&(0,d.jsx)(K,{title:`Used by endpoints (${h.length})`,children:(0,d.jsx)("ul",{className:"space-y-1 text-xs",children:h.map(({e:a,u:b})=>(0,d.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{style:{color:o.e6[a.method]},className:"font-bold",children:a.method}),(0,d.jsx)("span",{className:"truncate font-mono",children:a.path}),(0,d.jsx)("span",{className:"ml-auto",style:{color:o.ru[b.access]},children:b.access})]},a.id))})})]})}function I({ep:a,nameById:b}){return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-bold",style:{background:`${o.e6[a.method]}22`,color:o.e6[a.method]},children:a.method}),(0,d.jsx)("h2",{className:"mt-2 font-mono text-base font-semibold",children:a.path}),a.description&&(0,d.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a.description})]}),(0,d.jsx)(K,{title:`Tables used (${a.tables.length})`,children:(0,d.jsx)("ul",{className:"space-y-1 text-xs",children:a.tables.map(a=>(0,d.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"font-mono",children:b.get(a.tableId)}),(0,d.jsx)("span",{className:"ml-auto",style:{color:o.ru[a.access]},children:a.access})]},a.tableId))})})]})}function J({tables:a,relations:b,endpoints:c}){return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-sm font-semibold",children:"Database"}),(0,d.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,d.jsxs)("dl",{className:"grid grid-cols-3 gap-2 text-center",children:[(0,d.jsx)(L,{label:"tables",value:a.length}),(0,d.jsx)(L,{label:"FKs",value:b.length}),(0,d.jsx)(L,{label:"endpoints",value:c.length})]}),(0,d.jsx)(K,{title:"Legend",children:(0,d.jsxs)("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(i.A,{className:"size-3 text-amber-400"})," primary key"]}),(0,d.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(j.A,{className:"size-3 text-sky-400"})," foreign key"]}),(0,d.jsx)("li",{children:"— gray line: FK relation between tables"}),(0,d.jsx)("li",{children:"– – dashed line: endpoint uses table (read/write)"})]})})]})}function K({title:a,children:b}){return(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a}),b]})}function L({label:a,value:b}){return(0,d.jsxs)("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] py-2",children:[(0,d.jsx)("div",{className:"text-lg font-semibold",children:b}),(0,d.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:a})]})}var M=c(92994),N=c(55805);let O=new Set(["GET","HEAD","OPTIONS"]),P=a=>a.trim().toLowerCase();var Q=c(30170),R=c(10920),S=c(95744),T=c(10758),U=c(69680),V=c(35471),W=c(82145);let X={dbTable:function({id:a,data:b,selected:c}){var f;let g,h,p="DRAFT"===b.source,r="added"===b.diffStatus?"#7bd389":"modified"===b.diffStatus?"#ffb86b":"#4ea1ff",s="added"===b.diffStatus?"new":"modified"===b.diffStatus?"changed":"draft",v=b.diffChanges?.length?b.diffChanges.join("\n"):"draft",y=p?r:(0,o.qA)(b.domain),z=(f={domain:b.domain,columns:b.columns},g=[],(h=f.columns.filter(a=>u.test(a.name)).map(a=>a.name)).length&&g.push({label:"secrets",tone:"danger",title:`stores credentials: ${h.join(", ")}`}),f.domain&&/auth/i.test(f.domain)&&g.push({label:"auth",tone:"warn",title:"auth-domain table"}),g),A=q(),[B,C]=(0,e.useState)(b.name),[D,E]=(0,e.useState)(b.columns),[F,G]=(0,e.useState)(!1),H=a=>a.stopPropagation(),I=b=>{E(b),A.patchTable(a,{columns:b})};return p?(0,d.jsxs)("div",{className:(0,n.cn)("w-[252px] overflow-hidden rounded-md border border-dashed bg-card text-card-foreground shadow-sm",c&&"ring-2 ring-[var(--accent,#f5b942)]"),style:{borderColor:`${r}88`},children:[(0,d.jsx)(x,{}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1.5",style:{background:`${y}1f`},children:[(0,d.jsx)("span",{title:v,className:"inline-block size-1.5 shrink-0 rounded-full",style:{background:r}}),(0,d.jsx)("input",{value:B,onChange:a=>C(a.target.value),onBlur:()=>{let c=B.trim();c&&c!==b.name&&A.patchTable(a,{name:c})},onKeyDown:a=>{H(a),"Enter"===a.key&&a.currentTarget.blur()},placeholder:"table",className:(0,n.cn)(w,"min-w-0 flex-1 bg-transparent font-mono text-sm font-semibold outline-none")}),(0,d.jsx)(t,{badges:z}),(0,d.jsx)("span",{title:v,className:"shrink-0 rounded px-1 text-[9px] uppercase tracking-wide",style:{background:`${r}26`,color:r},children:s}),(0,d.jsx)("button",{type:"button",onClick:b=>{H(b),F?A.deleteTable(a):G(!0)},onBlur:()=>G(!1),title:"Delete table",className:(0,n.cn)(w,"shrink-0 transition-colors",F?"text-red-300":"text-muted-foreground hover:text-red-300"),children:(0,d.jsx)(k.A,{className:"size-3"})})]}),(0,d.jsxs)("div",{className:"divide-y divide-border/40",children:[D.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 text-[11px]",children:[(0,d.jsx)("button",{type:"button",onClick:a=>{H(a),I(D.map((a,c)=>c===b?{...a,isPk:!a.isPk}:a))},title:"Primary key",className:(0,n.cn)(w,"shrink-0",a.isPk?"text-amber-400":"text-muted-foreground/40 hover:text-amber-400"),children:(0,d.jsx)(i.A,{className:"size-3"})}),(0,d.jsx)("button",{type:"button",onClick:a=>{H(a),I(D.map((a,c)=>c===b?{...a,isFk:!a.isFk}:a))},title:"Foreign key",className:(0,n.cn)(w,"shrink-0",a.isFk?"text-sky-400":"text-muted-foreground/40 hover:text-sky-400"),children:(0,d.jsx)(j.A,{className:"size-3"})}),(0,d.jsx)("input",{value:a.name,onChange:a=>E(c=>c.map((c,d)=>d===b?{...c,name:a.target.value}:c)),onBlur:()=>I(D),onKeyDown:H,placeholder:"column",className:(0,n.cn)(w,"min-w-0 flex-1 bg-transparent font-mono outline-none")}),(0,d.jsx)("input",{value:a.type,onChange:a=>E(c=>c.map((c,d)=>d===b?{...c,type:a.target.value}:c)),onBlur:()=>I(D),onKeyDown:H,placeholder:"type",className:(0,n.cn)(w,"w-16 shrink-0 bg-transparent text-right font-mono text-[10px] text-muted-foreground outline-none")}),(0,d.jsx)("button",{type:"button",onClick:a=>{H(a),I(D.filter((a,c)=>c!==b))},title:"Remove column",className:(0,n.cn)(w,"shrink-0 text-muted-foreground/40 hover:text-red-300"),children:(0,d.jsx)(l.A,{className:"size-3"})})]},b)),(0,d.jsxs)("button",{type:"button",onClick:a=>{H(a),I([...D,{name:"",type:"text",isPk:!1,isFk:!1,nullable:!0,note:null}])},className:(0,n.cn)(w,"flex w-full items-center gap-1 px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground"),children:[(0,d.jsx)(m.A,{className:"size-3"})," column"]})]})]}):(0,d.jsxs)("div",{className:(0,n.cn)("w-[232px] overflow-hidden rounded-md border bg-card text-card-foreground shadow-sm",c&&"ring-2 ring-[var(--accent,#f5b942)]"),style:{borderColor:`${y}55`},children:[(0,d.jsx)(x,{}),(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",style:{background:`${y}1f`},children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-sm font-semibold",children:["INTROSPECTION"===b.source&&(0,d.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 rounded-full bg-emerald-400"}),b.name]}),(0,d.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(t,{badges:z}),b.domain&&(0,d.jsx)("span",{className:"text-[10px] uppercase tracking-wide",style:{color:y},children:b.domain})]})]}),(0,d.jsx)("div",{className:"divide-y divide-border/40",children:b.columns.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 text-[11px]",children:[a.isPk?(0,d.jsx)(i.A,{className:"size-3 shrink-0 text-amber-400"}):a.isFk?(0,d.jsx)(j.A,{className:"size-3 shrink-0 text-sky-400"}):(0,d.jsx)("span",{className:"size-3 shrink-0"}),(0,d.jsx)("span",{className:(0,n.cn)("font-mono",a.isPk&&"font-semibold"),children:a.name}),(0,d.jsx)("span",{className:"ml-auto truncate font-mono text-[10px] text-muted-foreground",children:a.type})]},a.name))})]})},endpoint:function({id:a,data:b,selected:c}){var f;let g,h=o.e6[b.method]??"#8a8a8a",i="DRAFT"===b.source,j="added"===b.diffStatus?"#7bd389":"modified"===b.diffStatus?"#ffb86b":"#4ea1ff",l="added"===b.diffStatus?"new":"modified"===b.diffStatus?"changed":"draft",m=b.diffChanges?.length?b.diffChanges.join("\n"):"draft",p=(f={method:b.method,domain:b.domain,path:b.path},g=[],/^delete$/i.test(f.method.trim())&&g.push({label:"DELETE",tone:"danger",title:"destructive: deletes data"}),(f.domain&&/auth/i.test(f.domain)||v.test(f.path))&&g.push({label:"auth",tone:"warn",title:"auth-related endpoint"}),g),s=q(),[u,w]=(0,e.useState)(b.path),[x,A]=(0,e.useState)(!1),B=a=>a.stopPropagation();return(0,d.jsxs)("div",{className:(0,n.cn)("group flex w-[240px] items-center gap-2 rounded-md border bg-card px-2.5 py-1.5 text-card-foreground shadow-sm",i?"border-dashed":"border-border",c&&"ring-2 ring-[var(--accent,#f5b942)]"),style:i?{borderColor:`${j}88`,background:`${j}0f`}:void 0,children:[(0,d.jsx)(r.x,{}),"INTROSPECTION"===b.source&&(0,d.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),i?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("select",{value:b.method,onChange:b=>s.patchEndpoint(a,{method:b.target.value}),onPointerDown:B,className:(0,n.cn)(y,"shrink-0 rounded bg-transparent text-[10px] font-bold outline-none"),style:{color:h},title:"Method",children:z.map(a=>(0,d.jsx)("option",{value:a,className:"bg-card text-foreground",children:a},a))}),(0,d.jsx)("input",{value:u,onChange:a=>w(a.target.value),onBlur:()=>{let c=u.trim();c&&c!==b.path&&s.patchEndpoint(a,{path:c})},onKeyDown:a=>{B(a),"Enter"===a.key&&a.currentTarget.blur()},className:(0,n.cn)(y,"min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none")}),(0,d.jsx)(t,{badges:p}),(0,d.jsx)("span",{title:m,className:"shrink-0 rounded px-1 py-0.5 text-[8px] font-semibold uppercase",style:{background:`${j}26`,color:j},children:l}),(0,d.jsx)("button",{type:"button",onClick:b=>{B(b),x?s.deleteEndpoint(a):A(!0)},onBlur:()=>A(!1),title:"Delete",className:(0,n.cn)(y,"shrink-0 transition-colors",x?"text-red-300":"text-muted-foreground hover:text-red-300"),children:(0,d.jsx)(k.A,{className:"size-3"})})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-bold",style:{background:`${h}22`,color:h},children:b.method}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px]",children:b.path}),(0,d.jsx)(t,{badges:p}),(0,d.jsx)("button",{type:"button",onClick:b=>{B(b),x?s.deleteRealEndpoint(a):A(!0)},onBlur:()=>A(!1),title:x?"Click again to delete":"Delete endpoint",className:(0,n.cn)(y,"shrink-0 opacity-0 transition-opacity group-hover:opacity-100",x?"text-red-300 opacity-100":"text-muted-foreground hover:text-red-300"),children:(0,d.jsx)(k.A,{className:"size-3"})})]})]})}},Y={deletable:W.I},Z="beacon:db-draft",$={proposedAt:0,status:"pending",tables:[],relations:[],endpoints:[]};function _({tables:a,relations:b,endpoints:c,draft:i,workspaceId:j,embedded:l=!1,draftRef:m,onEdit:q,controlRef:r,commentsContent:s,commentsCount:t=0,onAddComment:u}){let v=(0,f.useRouter)(),[w,x]=(0,e.useState)(!0),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(!1),[E,G]=(0,e.useState)("details"),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(new Set),[L,W]=(0,e.useState)(new Set),[aa,ab]=(0,e.useState)(new Set),[ac,ad]=(0,e.useState)(()=>({past:[],present:i??$,future:[],rev:0,edited:!1})),ae=ac.present,af=(0,e.useCallback)(a=>{ad(b=>{let c=a(b.present);return c===b.present?b:{past:[...b.past,b.present].slice(-100),present:c,future:[],rev:b.rev+1,edited:!0}})},[]),ag=(0,e.useCallback)(a=>{ad(b=>{let c=a(b.present);return c===b.present?b:{...b,present:c}})},[]),ah=(0,e.useCallback)(()=>ad(a=>a.past.length?{past:a.past.slice(0,-1),present:a.past[a.past.length-1],future:[a.present,...a.future],rev:a.rev+1,edited:!0}:a),[]),ai=(0,e.useCallback)(()=>ad(a=>a.future.length?{past:[...a.past,a.present],present:a.future[0],future:a.future.slice(1),rev:a.rev+1,edited:!0}:a),[]),aj=(0,e.useCallback)(a=>ad(b=>({past:[],present:a,future:[],rev:b.rev+1,edited:!1})),[]);(0,e.useRef)(!1),i?.proposedAt,(0,e.useRef)(!1);let ak=(0,e.useMemo)(()=>ae.tables.map(a=>({id:a.id,name:a.name,domain:a.domain,description:a.description,source:"DRAFT",x:a.x,y:a.y,columns:a.columns})),[ae]),al=(0,e.useMemo)(()=>ae.endpoints.map(a=>({id:a.id,method:a.method,path:a.path,domain:a.domain,description:a.description,source:"DRAFT",x:a.x,y:a.y,tables:a.links.map(a=>({tableId:a.tableId,access:a.access}))})),[ae]),am=(0,e.useMemo)(()=>[...a,...ak],[a,ak]),an=(0,e.useMemo)(()=>[...c,...al],[c,al]),ao=(0,e.useMemo)(()=>new Map,[]),ap=(0,e.useMemo)(()=>l?function(a,b){let c=new Map(a.map(a=>[P(a.name),a])),d=new Map;for(let a of b){let b=c.get(P(a.name));if(!b){d.set(a.id,{status:"added",changes:["new table"]});continue}let e=function(a,b){let c=new Map(a.map(a=>[P(a.name),a])),d=new Set(b.map(a=>P(a.name))),e=[];for(let a of b){let b=c.get(P(a.name));if(!b){e.push(`+ column ${a.name} (${a.type})`);continue}let d=[];P(b.type)!==P(a.type)&&d.push(`type ${b.type}→${a.type}`),b.isPk!==a.isPk&&d.push(a.isPk?"now PK":"no longer PK"),b.isFk!==a.isFk&&d.push(a.isFk?"now FK":"no longer FK"),b.nullable!==a.nullable&&d.push(a.nullable?"now nullable":"now required"),d.length&&e.push(`~ column ${a.name}: ${d.join(", ")}`)}for(let b of a)d.has(P(b.name))||e.push(`- column ${b.name}`);return e}(b.columns,a.columns);d.set(a.id,{status:e.length?"modified":"unchanged",changes:e})}return d}(a,ak):ao,[l,a,ak,ao]),aq=(0,e.useMemo)(()=>l?function(a,b){let c=a=>`${P(a.method)} ${P(a.path)}`,d=new Set(a.map(c)),e=new Map;for(let a of b)e.set(a.id,d.has(c(a))?{status:"unchanged",changes:[]}:{status:"added",changes:["new endpoint"]});return e}(c,al):ao,[l,c,al,ao]),ar=(0,e.useMemo)(()=>[...b,...ae.relations.map(a=>({id:a.id,fromTableId:a.fromTableId,toTableId:a.toTableId,fromColumn:a.fromColumn,toColumn:a.toColumn,label:a.label}))],[b,ae.relations]),as=(0,e.useMemo)(()=>{let a=new Map;for(let b of an)for(let c of b.tables)a.set(c.tableId,(a.get(c.tableId)??0)+1);return a},[an]),at=(0,e.useMemo)(()=>{let a=new Map;return am.forEach(b=>a.set(b.id,b.x)),an.forEach(b=>a.set(b.id,b.x)),a},[am,an]),au=(0,e.useCallback)((a,b)=>(at.get(a)??0)<=(at.get(b)??0)?{sourceHandle:"sr",targetHandle:"tl"}:{sourceHandle:"sl",targetHandle:"tr"},[at]),av=(0,e.useMemo)(()=>new Set([...ae.tables.map(a=>a.id),...ae.endpoints.map(a=>a.id)]),[ae]),aw=(0,e.useMemo)(()=>new Set(a.map(a=>a.id)),[a]),ax=(0,e.useCallback)(()=>[...am.map(a=>({id:a.id,type:"dbTable",position:{x:a.x,y:a.y},data:{name:a.name,domain:a.domain,columns:a.columns,usageCount:as.get(a.id)??0,source:a.source,rev:ac.rev,diffStatus:ap.get(a.id)?.status,diffChanges:ap.get(a.id)?.changes}})),...an.map(a=>({id:a.id,type:"endpoint",position:{x:a.x,y:a.y},data:{method:a.method,path:a.path,domain:a.domain,source:a.source,rev:ac.rev,diffStatus:aq.get(a.id)?.status,diffChanges:aq.get(a.id)?.changes}}))],[am,an,as,ac.rev,ap,aq]),[ay,az,aA]=(0,g.ck)(ax()),aB=(0,e.useCallback)((a,b,c,d)=>{fetch("/api/db/position",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:a,id:b,x:c,y:d})})},[]),aC=(0,e.useCallback)((a,b)=>{let{x:c,y:d}=b.position;av.has(b.id)?ag(a=>a.tables.some(a=>a.id===b.id)?{...a,tables:a.tables.map(a=>a.id===b.id?{...a,x:c,y:d}:a)}:a.endpoints.some(a=>a.id===b.id)?{...a,endpoints:a.endpoints.map(a=>a.id===b.id?{...a,x:c,y:d}:a)}:a):aB("endpoint"===b.type?"endpoint":"table",b.id,c,d)},[av,ag,aB]),aD=(0,e.useMemo)(()=>ar.map(a=>({id:`fk-${a.id}`,source:a.fromTableId,target:a.toTableId,...au(a.fromTableId,a.toTableId),type:"deletable",label:a.label??void 0,markerEnd:{type:h.TG.ArrowClosed,color:"#6b6b6b"},style:{stroke:"#6b6b6b"}})),[ar,au]),aE=(0,e.useMemo)(()=>an.flatMap(a=>a.tables.map(b=>{let c=o.ru[b.access]??"#5a5a5a";return{id:`u-${a.id}-${b.tableId}`,source:a.id,target:b.tableId,...au(a.id,b.tableId),type:"default",markerEnd:{type:h.TG.ArrowClosed,color:c},style:{stroke:c,strokeDasharray:"4 4",opacity:.7}}})),[an,au]),aF=(0,e.useMemo)(()=>w?[...aD,...aE]:aD,[aD,aE,w]),aG=(0,e.useMemo)(()=>{if(A){let a=aF.find(a=>a.id===A);return a?new Set([a.source,a.target]):null}return y?(0,o.F1)(y.id,aF):null},[y,A,aF]),aH=(0,e.useMemo)(()=>new Map(am.map(a=>[a.id,{domain:a.domain,source:a.source}])),[am]),aI=(0,e.useMemo)(()=>new Map(an.map(a=>[a.id,{method:a.method,source:a.source}])),[an]),aJ=(0,e.useMemo)(()=>{let a=new Set;if(!w)for(let b of aI.keys())a.add(b);for(let[b,c]of aH)!J.size||c.domain&&J.has(c.domain)||a.add(b),L.size&&!L.has(c.source)&&a.add(b);for(let[b,c]of aI)aa.size&&!aa.has(c.method)&&a.add(b),L.size&&!L.has(c.source)&&a.add(b);return a},[w,aH,aI,J,L,aa]),aK=(0,e.useMemo)(()=>ay.map(a=>{let b=aJ.has(a.id);return aG?{...a,hidden:b,style:{...a.style,opacity:aG.has(a.id)?1:.45,transition:"opacity 120ms"}}:b?{...a,hidden:b}:a}),[ay,aJ,aG]),aL=(0,e.useMemo)(()=>aF.map(a=>{let b=aJ.has(a.source)||aJ.has(a.target);return y||A?(A?a.id===A:y&&(a.source===y.id||a.target===y.id))?{...a,hidden:b,zIndex:20,style:{...a.style,opacity:1,strokeWidth:2.5}}:{...a,hidden:b,selectable:!1,label:void 0,markerEnd:void 0,style:{...a.style,opacity:.08}}:b?{...a,hidden:b}:a}),[aF,y,A,aJ]),aM=(0,e.useMemo)(()=>Array.from(new Set(am.map(a=>a.domain).filter(a=>!!a))).sort(),[am]),aN=(0,e.useMemo)(()=>Array.from(new Set([...am.map(a=>a.source),...an.map(a=>a.source)])).sort(),[am,an]),aO=(0,e.useMemo)(()=>Array.from(new Set(an.map(a=>a.method))).sort(),[an]);function aP(a,b){b(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})}let aQ=+!w+J.size+L.size+aa.size,aR=(0,e.useCallback)(()=>{x(!0),K(new Set),W(new Set),ab(new Set)},[]),aS=(0,e.useCallback)(a=>{let{source:b,target:c}=a;b&&c&&b!==c&&af(a=>{if(!(a.tables.some(a=>a.id===c)||aw.has(c)))return a;let d=a.endpoints.find(a=>a.id===b);return d?d.links.some(a=>a.tableId===c)?a:{...a,endpoints:a.endpoints.map(a=>{var d;return a.id===b?{...a,links:[...a.links,{tableId:c,access:(d=a.method,O.has(d.trim().toUpperCase())?"read":"write")}]}:a})}:a.tables.find(a=>a.id===b)?a.relations.some(a=>a.fromTableId===b&&a.toTableId===c)?a:{...a,relations:[...a.relations,{id:crypto.randomUUID(),fromTableId:b,toTableId:c,fromColumn:"fk",toColumn:"id",label:null}]}:a})},[af,aw]),aT=(0,e.useMemo)(()=>({patchEndpoint:(a,b)=>af(c=>({...c,endpoints:c.endpoints.map(c=>c.id===a?{...c,...b}:c)})),deleteEndpoint:a=>af(b=>({...b,endpoints:b.endpoints.filter(b=>b.id!==a)})),patchTable:(a,b)=>af(c=>({...c,tables:c.tables.map(c=>c.id===a?{...c,...b}:c)})),deleteTable:a=>af(b=>({...b,tables:b.tables.filter(b=>b.id!==a),relations:b.relations.filter(b=>b.fromTableId!==a&&b.toTableId!==a),endpoints:b.endpoints.map(b=>({...b,links:b.links.filter(b=>b.tableId!==a)}))})),deleteRealEndpoint:a=>{fetch(`/api/endpoints/${a}`,{method:"DELETE"}).then(a=>{a.ok&&v.refresh()})}}),[af,v]),aU=(0,e.useCallback)(async()=>{I(!0);try{if((await fetch("/api/draft/approve",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(ae)})).ok){try{localStorage.removeItem(Z)}catch{}aj($),v.refresh()}}finally{I(!1)}},[ae,aj,v]),aV=(0,e.useCallback)(async()=>{I(!0);try{await fetch("/api/draft",{method:"DELETE"})}catch{}try{localStorage.removeItem(Z)}catch{}aj($),v.refresh(),I(!1)},[aj,v]),aW=(0,e.useMemo)(()=>{let a;return a=new Map(ae.tables.map(a=>[a.id,a.name])),{tables:ae.tables.map(a=>({name:a.name,domain:a.domain,description:a.description,columns:a.columns.map(a=>({name:a.name,type:a.type,isPk:a.isPk,isFk:a.isFk,nullable:a.nullable,note:a.note}))})),relations:ae.relations.flatMap(b=>{let c=a.get(b.fromTableId),d=a.get(b.toTableId);return c&&d?[{fromTable:c,fromColumn:b.fromColumn,toTable:d,toColumn:b.toColumn,label:b.label}]:[]}),endpoints:ae.endpoints.map(b=>({method:b.method,path:b.path,domain:b.domain,description:b.description,uses:b.links.flatMap(b=>{let c=a.get(b.tableId);return c?[{table:c,access:b.access}]:[]})}))}},[ae]),aX=ae.tables.length>0||ae.endpoints.length>0,aY=ac.past.length>0,aZ=ac.future.length>0;return(0,d.jsx)(p.Provider,{value:aT,children:(0,d.jsxs)("div",{className:(0,n.cn)("relative w-full",l?"h-full":"h-screen"),children:[(0,d.jsxs)(g.Gc,{nodes:aK,edges:aL,nodeTypes:X,edgeTypes:Y,connectionMode:h.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onNodesChange:aA,onConnect:aS,onNodeClick:(a,b)=>{let c="endpoint"===b.type?"endpoint":"table";z({id:b.id,kind:c}),B(null),D(!0),G("details")},onEdgeClick:(a,b)=>{B(b.id),z(null)},onPaneClick:()=>{z(null),B(null)},onNodeDragStop:aC,onEdgesDelete:a=>{for(let b of a)if(b.id.startsWith("fk-")){let a=b.id.slice(3);fetch(`/api/db/relations/${a}`,{method:"DELETE"})}},onNodesDelete:a=>{for(let b of a)av.has(b.id)||("endpoint"===b.type?fetch(`/api/endpoints/${b.id}`,{method:"DELETE"}):"dbTable"===b.type&&fetch(`/api/db/tables/${b.id}`,{method:"DELETE"}))},deleteKeyCode:["Backspace","Delete"],colorMode:"dark",fitView:!0,minZoom:.15,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,d.jsx)(g.VS,{gap:22,color:"#2a2a32"}),(0,d.jsx)(g.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"}),!l&&(0,d.jsx)(g.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"}),!l&&(0,d.jsx)(g.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,d.jsx)(N.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,d.jsxs)(g.Zk,{position:"top-right",className:(0,n.cn)("flex items-center gap-1 transition-[margin] duration-200",C&&"!mr-[332px]",l&&"hidden"),children:[(0,d.jsxs)(M.er,{title:"Filters",trigger:(a,b)=>(0,d.jsxs)("button",{type:"button",onClick:b,title:"Filters",className:(0,n.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",a||aQ>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,d.jsx)(Q.A,{className:"size-4"}),aQ>0&&(0,d.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:aQ})]}),children:[(0,d.jsx)(M.r1,{title:"Show",children:(0,d.jsx)(M.vu,{tone:"accent",on:w,onClick:()=>x(a=>!a),children:"endpoints"})}),aM.length>0&&(0,d.jsx)(M.r1,{title:"Domain",children:aM.map(a=>(0,d.jsx)(M.vu,{on:J.has(a),onClick:()=>aP(a,K),children:a},a))}),aO.length>0&&(0,d.jsx)(M.r1,{title:"Method",children:aO.map(a=>(0,d.jsx)(M.vu,{on:aa.has(a),onClick:()=>aP(a,ab),children:a},a))}),aN.length>0&&(0,d.jsx)(M.r1,{title:"Source",children:aN.map(a=>(0,d.jsx)(M.vu,{on:L.has(a),onClick:()=>aP(a,W),children:a.toLowerCase()},a))}),aQ>0&&(0,d.jsx)("button",{type:"button",onClick:aR,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,d.jsx)(M.er,{title:"Legend",trigger:(a,b)=>(0,d.jsx)("button",{type:"button",onClick:b,title:"Legend",className:(0,n.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",a?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,d.jsx)(R.A,{className:"size-4"})}),children:(0,d.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#6b6b6b]"}),(0,d.jsx)("span",{children:"foreign key \xb7 drag from a table handle"})]}),(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#4ea1ff"}}),(0,d.jsx)("span",{children:"endpoint read \xb7 GET / POST / etc"})]}),(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#ffb86b"}}),(0,d.jsx)("span",{children:"endpoint write"})]}),(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.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,d.jsx)("span",{children:"agent-proposed \xb7 approve to persist"})]})]})}),!C&&(0,d.jsx)("button",{onClick:()=>D(!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,d.jsx)(S.A,{className:"size-4"})})]}),aX&&(0,d.jsxs)(g.Zk,{position:"bottom-center",className:"glass flex items-center gap-1 rounded-xl p-1.5",children:[(0,d.jsxs)("button",{onClick:ah,disabled:!aY,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,d.jsx)(T.A,{className:"size-3.5"})," undo"]}),(0,d.jsxs)("button",{onClick:ai,disabled:!aZ,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,d.jsx)(U.A,{className:"size-3.5"})," redo"]}),!l&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"mx-1 h-4 w-px bg-white/10"}),(0,d.jsxs)("button",{onClick:aV,disabled:H,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,d.jsx)(k.A,{className:"size-3.5"})," discard"]}),(0,d.jsxs)("button",{onClick:aU,disabled:H,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,d.jsx)(V.A,{className:"size-3.5"})," approve draft"]})]})]})]}),C&&(0,d.jsx)(F,{selected:y,tables:am,relations:ar,endpoints:an,draftGraph:aW,onClose:()=>{D(!1),G("details")},commentsContent:s,commentsCount:t,activeTab:E,onTabChange:G,onAddComment:u,topOffset:l?64:void 0})]})})}},92994:(a,b,c)=>{c.d(b,{er:()=>g,r1:()=>h,vu:()=>i});var d=c(48249),e=c(67484),f=c(33191);function g({trigger:a,title:b,align:c="right",children:h}){let[i,j]=(0,e.useState)(!1),k=(0,e.useRef)(null);return(0,d.jsxs)("div",{ref:k,className:"relative",children:[a(i,()=>j(a=>!a)),i&&(0,d.jsxs)("div",{className:(0,f.cn)("glass absolute top-full z-30 mt-1.5 w-64 rounded-xl p-3 shadow-xl","right"===c?"right-0":"left-0"),children:[b&&(0,d.jsx)("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:b}),h]})]})}function h({title:a,children:b}){return(0,d.jsxs)("div",{className:"mb-2.5 last:mb-0",children:[(0,d.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80",children:a}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:b})]})}function i({on:a,onClick:b,children:c,tone:e="default"}){return(0,d.jsx)("button",{type:"button",onClick:b,className:(0,f.cn)("rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",{default:a?"border-foreground/40 bg-white/10 text-foreground":"border-white/10 text-muted-foreground hover:text-foreground",danger:a?"border-red-500/40 bg-red-500/15 text-red-300":"border-white/10 text-muted-foreground hover:text-foreground",accent:a?"border-sky-500/40 bg-sky-500/15 text-sky-300":"border-white/10 text-muted-foreground hover:text-foreground"}[e]),children:c})}}};