trybeacon 0.1.66 → 0.1.67
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.
- package/.claude-plugin/plugin.json +1 -1
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +8 -8
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +11 -11
- package/.next/server/app/_not-found.segments/_full.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/lesson/close/route.js +1 -1
- package/.next/server/app/api/lesson/questions/route.js +1 -1
- package/.next/server/app/api/lesson/route.js +1 -1
- package/.next/server/app/api/lesson/save/route.js +1 -1
- package/.next/server/app/api/lesson/verdict/route.js +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +11 -11
- package/.next/server/app/docs.segments/_full.segment.rsc +11 -11
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +11 -11
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/feedback/page_client-reference-manifest.js +1 -1
- package/.next/server/app/feedback.html +1 -1
- package/.next/server/app/feedback.rsc +11 -11
- package/.next/server/app/feedback.segments/_full.segment.rsc +11 -11
- package/.next/server/app/feedback.segments/_head.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/_index.segment.rsc +11 -11
- package/.next/server/app/feedback.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/feedback.segments/feedback/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/feedback.segments/feedback.segment.rsc +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.rsc +11 -11
- package/.next/server/app/help.segments/_full.segment.rsc +11 -11
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +11 -11
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +12 -12
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +12 -12
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +11 -11
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/learn/page.js +5 -3
- package/.next/server/app/learn/page.js.nft.json +1 -1
- package/.next/server/app/learn/page_client-reference-manifest.js +1 -1
- package/.next/server/app/map/page.js +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/plan/page.js +2 -2
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/s/[token]/page.js +2 -2
- package/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +1 -1
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +8 -8
- package/.next/server/chunks/2025.js +1 -0
- package/.next/server/chunks/2994.js +2 -0
- package/.next/server/chunks/4046.js +3 -3
- package/.next/server/chunks/5683.js +1 -0
- package/.next/server/chunks/5719.js +1 -0
- package/.next/server/chunks/7720.js +154 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/1276-b84f61ec9c0df862.js +1 -0
- package/.next/static/chunks/1a258343-954e0e6619585d3c.js +2 -0
- package/.next/static/chunks/2059-fba06ba63ba64522.js +62 -0
- package/.next/static/chunks/4607-a668ea431c41e60e.js +1 -0
- package/.next/static/chunks/4853-6dc402b4ce452fa5.js +1 -0
- package/.next/static/chunks/{7043-254590cf9891391f.js → 4888-911c0da3c2d785d2.js} +1 -1
- package/.next/static/chunks/5957-83f611fcd5a08b45.js +1 -0
- package/.next/static/chunks/766-242213d211df0afd.js +1 -0
- package/.next/static/chunks/8997-78a359d0d238622e.js +1 -0
- package/.next/static/chunks/app/{layout-0c993f55d3a798f4.js → layout-9f0f4d8e4534a62e.js} +1 -1
- package/.next/static/chunks/app/learn/page-03acad0a37068966.js +7 -0
- package/.next/static/chunks/app/map/page-5cfad64d5feea695.js +1 -0
- package/.next/static/chunks/app/page-d08947a671077569.js +1 -0
- package/.next/static/chunks/app/plan/page-5eacb6b83bd4873d.js +1 -0
- package/.next/static/chunks/app/s/[token]/page-1a350cf50a45500c.js +1 -0
- package/.next/static/chunks/app/settings/page-7e176d120b1effa9.js +1 -0
- package/.next/static/css/63986592e2be7d62.css +1 -0
- package/.next/trace +43 -43
- package/.next/trace-build +1 -1
- package/dist/bin/beacon.js +14 -12
- package/dist/bin/doctor.js +22 -15
- package/dist/bin/hook.js +18 -11
- package/dist/bin/mcp.js +41 -34
- package/dist/bin/plan.js +21 -14
- package/dist/bin/uninstall.js +26 -19
- package/dist/lib/assets.js +7 -0
- package/dist/lib/codex-install.js +28 -21
- package/dist/lib/global-install.js +27 -20
- package/package.json +1 -1
- package/plugin/skills/beacon-explain/SKILL.md +7 -0
- package/.next/server/chunks/3584.js +0 -154
- package/.next/server/chunks/6024.js +0 -2
- package/.next/server/chunks/7187.js +0 -1
- package/.next/server/chunks/8035.js +0 -1
- package/.next/static/chunks/1936-7fea5225b5bfcfda.js +0 -1
- package/.next/static/chunks/1a258343-6baccd9e573fdfaf.js +0 -2
- package/.next/static/chunks/2019-3be80edc82176878.js +0 -1
- package/.next/static/chunks/3845-6fe7e66d4bf82eb5.js +0 -1
- package/.next/static/chunks/4549-591415d55ca009a3.js +0 -62
- package/.next/static/chunks/6638-4e53879181b1df75.js +0 -1
- package/.next/static/chunks/7643-6c7ff4b9400f68fc.js +0 -1
- package/.next/static/chunks/app/learn/page-797d74e02b98fa88.js +0 -5
- package/.next/static/chunks/app/map/page-634b6d5d98e921b3.js +0 -1
- package/.next/static/chunks/app/page-84dc684d45002cfb.js +0 -1
- package/.next/static/chunks/app/plan/page-df829b2054c40611.js +0 -1
- package/.next/static/chunks/app/s/[token]/page-f97dec75856a7952.js +0 -1
- package/.next/static/chunks/app/settings/page-59d90685cd17fc1f.js +0 -1
- package/.next/static/css/b3d3212da726bbfb.css +0 -1
- /package/.next/static/{P3uXQySdS-m6_bxuiezYe → hkOIw5DQW9WSwBwZrD8_9}/_buildManifest.js +0 -0
- /package/.next/static/{P3uXQySdS-m6_bxuiezYe → hkOIw5DQW9WSwBwZrD8_9}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7643],{2359:(e,t,n)=>{n.d(t,{MapClient:()=>tE});var a=n(95155),s=n(12115),r=n(98112),o=n(6266),l=n(81750);n(53255);var i=n(17356),d=n(85618),c=n(2125),u=n(68319),m=n(15480),p=n(24413),x=n(17494),h=n(80846),f=n(45486),g=n(73321),b=n(95635),y=n(17918),j=n(9339);let v=(0,j.createServerReference)("40d8ad976abdd1ef670d7c6fdb2808f01a73d6a5d9",j.callServer,void 0,j.findSourceMapURL,"acceptSuggestionAction");var w=n(50981),k=n(34306),N=n(49960),C=n(55737),E=n(72974),A=n(83599),S=n(52750),I=n(68426),M=n(48869),T=n(55776),z=n(65377),R=n(71019),D=n(44825),$=n(54154),P=n(19707),O=n(29450),L=n(17082),F=n(76181),Y=n(27700),B=n(12651),U=n(85222),H=n(70299),_=n(22200),G=n(8962),K=n(12363),X=n(32133),Z=n(76721),W=n(84824),V=n(5736),J=n(65738),q=n(40638),Q=n(36483),ee=n(86659),et=n(9751),en=n(86272),ea=n(64577),es=n(9005),er=n(26518),eo=n(43137),el=n(28161),ei=n(12410);let ed=(0,s.createContext)(null);function ec(){let e=(0,s.useContext)(ed);if(!e)throw Error("useNodeEdit must be used inside NodeEditContext");return e}var eu=n(29523),em=n(13439),ep=n(62678),ex=n(95112),eh=n(67357),ef=n(8143),eg=n(58309),eb=n(5497),ey=n(54682),ej=n(56991),ev=n(93492),ew=n(60292),ek=n(91337);function eN({value:e,onChange:t,onBlur:n,autoFocus:r,compact:o,bare:l,className:i,placeholder:d="Description (markdown)… type @ to mention a file, feature, table…",editable:c=!0}){let u=(0,em.hG)({editable:c,extensions:[...ey.Pu,ep.Or.configure({placeholder:d}),ej.tw.configure({suggestion:{char:"@",items:async({query:e})=>{if(!e.trim())return[];try{let t=await fetch(`/api/mention-search?q=${encodeURIComponent(e)}`,{headers:(0,ew.dh)((0,ew.fk)())});if(!t.ok)return[];return(await t.json()).hits}catch{return[]}},command:({editor:e,range:t,props:n})=>{e.chain().focus().insertContentAt(t,[{type:"mention",attrs:{kind:n.kind,ref:n.ref,label:n.label}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,n=e=>{if(!t||!e)return;let n=e();n&&(t.style.left=`${n.left}px`,t.style.top=`${n.bottom+4}px`)};return{onStart:a=>{e=new em.NV(eA,{props:a,editor:a.editor}),(t=document.createElement("div")).style.position="fixed",t.style.zIndex="10000",document.body.appendChild(t),t.appendChild(e.element),n(a.clientRect)},onUpdate:t=>{e?.updateProps(t),n(t.clientRect)},onKeyDown:n=>"Escape"===n.event.key?(t?.remove(),!0):e?.ref?.onKeyDown(n)??!1,onExit:()=>{t?.remove(),t=null,e?.destroy(),e=null}}}}})],content:e?(0,ey.Gd)(e):void 0,immediatelyRender:!1,autofocus:!!r&&"end",editorProps:{attributes:{class:(0,ek.cn)("nodrag nopan node-prose focus:outline-none",i)}},onUpdate:({editor:e})=>t((0,ey.Z2)(e.getJSON())),onBlur:()=>n?.()});return((0,s.useEffect)(()=>{u?.setEditable(c)},[u,c]),(0,s.useEffect)(()=>{!u||u.isFocused||(0,ey.Z2)(u.getJSON())!==e&&u.commands.setContent(e?(0,ey.Gd)(e):"")},[u,e]),u)?(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[c&&(0,a.jsx)(eC,{editor:u,compact:o}),(0,a.jsx)(em.$Z,{editor:u,onKeyDown:e=>e.stopPropagation(),className:(0,ek.cn)("node-editor min-h-[3.5rem] rounded",l?"text-[15px] leading-relaxed":"bg-white/[0.04] px-1.5 py-1 text-xs focus-within:bg-white/[0.08]",o&&"max-h-[24rem] overflow-y-auto")})]}):null}function eC({editor:e,compact:t}){(0,ev.U)(e);let n=()=>e.chain().focus(),s=t?"size-3":"size-3.5";return(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(ev.I,{label:"Bold",active:e.isActive("bold"),onClick:()=>n().toggleBold().run(),children:(0,a.jsx)(ex.A,{className:s})}),(0,a.jsx)(ev.I,{label:"Italic",active:e.isActive("italic"),onClick:()=>n().toggleItalic().run(),children:(0,a.jsx)(eh.A,{className:s})}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-3.5 w-px bg-white/10"}),(0,a.jsx)(ev.I,{label:"Checklist",active:e.isActive("taskList"),onClick:()=>n().toggleTaskList().run(),children:(0,a.jsx)(ef.A,{className:s})}),(0,a.jsx)(ev.I,{label:"Bullet list",active:e.isActive("bulletList"),onClick:()=>n().toggleBulletList().run(),children:(0,a.jsx)(eg.A,{className:s})}),(0,a.jsx)(ev.I,{label:"Numbered list",active:e.isActive("orderedList"),onClick:()=>n().toggleOrderedList().run(),children:(0,a.jsx)(eb.A,{className:s})})]})}let eE={file:"\uD83D\uDCC4",folder:"\uD83D\uDCC1",feature:"\uD83E\uDDE9",table:"⛁",endpoint:"⇄",note:"\uD83D\uDDD2"},eA=(0,s.forwardRef)(function({items:e,command:t},n){let[r,o]=(0,s.useState)(0);return((0,s.useEffect)(()=>o(0),[e]),(0,s.useImperativeHandle)(n,()=>({onKeyDown:({event:n})=>"ArrowDown"===n.key?(o(t=>(t+1)%Math.max(e.length,1)),!0):"ArrowUp"===n.key?(o(t=>(t-1+e.length)%Math.max(e.length,1)),!0):"Enter"===n.key&&(e[r]&&t(e[r]),!0)})),e.length)?(0,a.jsx)("div",{className:"glass max-h-72 min-w-56 max-w-80 overflow-y-auto rounded-lg p-1 shadow-xl",children:e.map((e,n)=>(0,a.jsxs)("button",{type:"button",onMouseDown:n=>{n.preventDefault(),t(e)},onMouseEnter:()=>o(n),className:(0,ek.cn)("flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px]",n===r?"bg-white/[0.1] text-foreground":"text-foreground/85 hover:bg-white/[0.05]"),children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"shrink-0 text-[11px] opacity-80",children:eE[e.kind]??"•"}),(0,a.jsx)("span",{className:"truncate",children:e.label}),e.sublabel&&(0,a.jsx)("span",{className:"ml-auto shrink-0 truncate text-[10px] text-muted-foreground/70",children:e.sublabel})]},`${e.kind}:${e.ref}`))}):(0,a.jsx)("div",{className:"glass min-w-56 rounded-lg p-2 text-[11px] text-muted-foreground shadow-xl",children:"No matches"})}),eS=[{v:0,l:"P0 \xb7 critical"},{v:1,l:"P1 \xb7 high"},{v:2,l:"P2 \xb7 medium"},{v:3,l:"P3 \xb7 low"}],eI=["#ff3860","#ff7a45","#fbbf24","#a1a1aa"],eM=[[/AUTH|SECURIT|LOGIN|SESSION|IDENT/,w.A],[/DATA|\bDB\b|DBMAP|SQL|STORAGE|STORE|CACHE|PERSIST/,k.A],[/\bUI\b|FRONT|VIEW|CANVAS|BOARD|DESIGN/,N.A],[/MCP|\bAPI\b|INTEGRAT/,C.A],[/WEBHOOK|HOOK/,E.A],[/INTEL|GRAPH|\bCODE\b|SYMBOL|SEARCH|FIND/,A.A],[/PLAN|ROADMAP|REVIEW/,S.A],[/INFRA|DEVOPS|CLOUD|DEPLOY|MEDIA/,I.A],[/GAM|PLAY/,M.A],[/NOTE|DOC/,T.A],[/QUERY|SEARCH/,z.A],[/BILL|\bPAY|CHECKOUT|SUBSCRIPT|INVOICE/,R.A],[/LAUNCH|RELEASE|SHIP|ROCKET/,D.A],[/INSTALL|SETUP|BOOTSTRAP|INIT/,$.A],[/CONTEXT|LAYER|BUNDLE/,P.A]],eT=[O.A,L.A,F.A,Y.A,B.A,U.A],ez="nodrag nopan";function eR({layer:e,onSave:t,readOnly:n}){let s=(0,el.jR)(e);return(0,a.jsxs)(er.l6,{value:s??"none",onValueChange:e=>t("none"===e?null:e),disabled:n,children:[(0,a.jsx)(er.bq,{title:"Which side of the stack this lands on",className:(0,ek.cn)(ez,"!h-5 shrink-0 gap-1 rounded !border-0 !bg-white/10 !px-1.5 !py-0 text-[9px] font-semibold uppercase tracking-wide text-zinc-300 [&_svg]:size-2.5 [&>svg]:hidden hover:[&>svg]:block"),children:(0,a.jsx)(er.yv,{children:e=>"none"===e?(0,a.jsx)("span",{className:"text-muted-foreground/70",children:"layer"}):(0,a.jsxs)("span",{className:"flex items-center gap-1",children:["backend"!==e&&(0,a.jsx)(H.A,{className:"size-2.5"}),"frontend"!==e&&(0,a.jsx)(_.A,{className:"size-2.5"}),el.YG[e]?.short??e]})})}),(0,a.jsxs)(er.gC,{alignItemWithTrigger:!1,children:[(0,a.jsx)(er.eb,{value:"none",children:"— no layer"}),Object.entries(el.YG).map(([e,t])=>(0,a.jsx)(er.eb,{value:e,children:t.label},e))]})]})}let eD={DONE:"#34d399",IN_PROGRESS:"#38bdf8",PENDING:"#fbbf24",BLOCKED:"#fb923c",CANCELLED:"#71717a",DEPRIORITIZED:"#52525b",KEEP:"#34d399",REBUILD:"#a78bfa",REPLACE:"#fb7185",DROP:"#71717a"};function e$({status:e}){return(0,a.jsx)("span",{"aria-hidden":!0,title:eo.nR[e]?.label??e,className:"absolute bottom-2 left-1 top-2 w-[3px] rounded-full",style:{background:eD[e]??"#71717a"}})}function eP({priority:e,rank:t}){let n=eI[e]??eI[3];return(0,a.jsxs)("div",{className:"flex w-5 shrink-0 flex-col items-center gap-1 self-stretch border-r border-white/[0.06] py-1.5",title:eS[e]?.l??"priority",children:[null!=t&&(0,a.jsx)("span",{title:`#${t} in the work order`,className:(0,ek.cn)("flex size-4 shrink-0 items-center justify-center rounded text-[10px] font-bold leading-none",1===t?"bg-emerald-400 text-black":"bg-white/10 text-muted-foreground"),children:t}),(0,a.jsx)("span",{className:"w-[3px] flex-1 rounded-full",style:{background:n,opacity:.9}})]})}function eO({onFocus:e,onExpand:t,onDetails:n,expanded:s,className:r}){return(0,a.jsxs)("div",{className:(0,ek.cn)(ez,"absolute z-20 flex items-center gap-0.5 rounded-lg p-0.5 transition-colors group-hover/nc:border group-hover/nc:border-white/10 group-hover/nc:bg-card/90 group-hover/nc:shadow-lg group-hover/nc:backdrop-blur",r??"right-2 top-2"),children:[(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),e()},title:"Edit description in focus mode",className:"flex w-0 items-center justify-center overflow-hidden rounded p-0 text-muted-foreground opacity-0 transition-all hover:text-[#ff7a45] group-hover/nc:w-6 group-hover/nc:p-0.5 group-hover/nc:opacity-100",children:(0,a.jsx)(G.A,{className:"size-3.5"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),t()},title:s?"Collapse":"Expand in place",className:"flex w-0 items-center justify-center overflow-hidden rounded p-0 text-muted-foreground opacity-0 transition-all hover:text-foreground group-hover/nc:w-6 group-hover/nc:p-0.5 group-hover/nc:opacity-100",children:(0,a.jsx)(K.A,{className:(0,ek.cn)("size-3.5 transition-transform",s&&"rotate-180")})}),(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),n()},title:"Open details side panel",className:"flex w-0 items-center justify-center overflow-hidden rounded p-0 text-muted-foreground opacity-0 transition-all hover:text-[#ff7a45] group-hover/nc:w-6 group-hover/nc:p-0.5 group-hover/nc:opacity-100",children:(0,a.jsx)(f.A,{className:"size-3.5"})})]})}function eL({value:e,label:t,Icon:n,danger:s}){return(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:(0,ek.cn)("text-[13px] font-semibold leading-none tracking-tight tabular-nums",s&&"text-rose-300"),children:e}),(0,a.jsxs)("div",{className:"mt-0.5 flex items-center justify-center gap-0.5 text-[8px] font-medium uppercase tracking-wide text-muted-foreground",children:[(0,a.jsx)(n,{className:"size-2.5"}),t]})]})}function eF({importsIn:e}){let t=e>=16?5:e>=8?4:e>=4?3:e>=2?2:+(e>=1);return(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",title:`${e} external file(s) import this component`,children:[(0,a.jsx)("span",{className:"flex items-center gap-0.5",children:[0,1,2,3,4].map(e=>(0,a.jsx)("span",{className:"size-1 rounded-full bg-sky-400",style:{opacity:e<t?.7:.18}},e))}),e>=8?"core dependency":e>=3?"shared":e>=1?"leaf":"isolated"]})}function eY({nodeId:e}){let t=(0,g.useRouter)(),[n,r]=(0,s.useState)(!1),[o,l]=(0,s.useState)(""),[i,d]=(0,s.useState)(!1),c=()=>{r(!1),l("")},m=async()=>{let n=o.trim();if(n&&!i){d(!0);try{(await fetch("/api/bug-flags",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({nodeId:e,by:"user",note:n})})).ok&&(c(),t.refresh())}finally{d(!1)}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",title:"Flag a bug on this component",onClick:e=>{e.stopPropagation(),r(e=>!e)},className:(0,ek.cn)(ez,"absolute -right-3 top-[calc(50%-28px)] z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground shadow-md transition-all hover:border-rose-400/50 hover:text-rose-300",n?"border-rose-400/50 text-rose-300 opacity-100":"opacity-0 group-hover/nc:opacity-100"),children:(0,a.jsx)(u.A,{className:"size-3"})}),n&&(0,a.jsxs)("div",{onClick:e=>e.stopPropagation(),className:(0,ek.cn)(ez,"absolute -right-2 top-[calc(50%-28px)] z-20 w-60 translate-x-full rounded-xl border border-rose-400/25 bg-[#1c1c1f] p-2 shadow-xl"),children:[(0,a.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide text-rose-300",children:[(0,a.jsx)(u.A,{className:"size-3"})," Flag a bug"]}),(0,a.jsx)("button",{type:"button",title:"Cancel",onClick:c,className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)("span",{className:"block px-1 text-[11px] leading-none",children:"✕"})})]}),(0,a.jsx)("textarea",{autoFocus:!0,rows:2,value:o,placeholder:"What did you find?",onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&c(),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m())},className:"field-sizing-content max-h-40 min-h-12 w-full resize-none rounded-md bg-white/[0.04] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.07]"}),(0,a.jsx)("button",{type:"button",disabled:i||!o.trim(),onClick:()=>void m(),className:"mt-1.5 w-full rounded-md bg-rose-500/15 py-1 text-[11px] font-semibold text-rose-300 transition-colors hover:bg-rose-500/25 disabled:opacity-50",children:i?"Flagging…":"Flag bug"})]})]})}let eB=["border-[#ff3860]/60 shadow-[0_0_0_1px_rgba(255,56,96,0.15)]","border-[#ff7a45]/50","border-amber-400/35","border-border"],eU=(0,s.memo)(function({id:e,data:t,selected:n}){let{categories:r,statuses:o,patch:l,isExpanded:i,toggleExpand:d,openDetailed:c,openFocus:m,removeNode:p,editingTitleId:x,onAskAgent:h,hasFrontend:f,readOnly:g}=ec(),j=i(e),[w,k]=(0,s.useState)(!1),[N,C]=(0,s.useState)(t.title),[E,A]=(0,s.useState)(t.cluster??""),[S,I]=(0,s.useState)(t.plain??"");(0,s.useEffect)(()=>I(t.plain??""),[t.plain]);let M="BUG"===t.kind&&"ROADMAP"===t.view,T="ARCHITECTURE"===t.view,z=T?"border-border":eB[t.priority]??"border-border",R=t.openBugs??0,D="CANCELLED"===t.status||"DROP"===t.status,$="DEPRIORITIZED"===t.status,P="DRAFT"===t.source,O="IN_PROGRESS"===t.status,L="INIT"===t.source&&"ROADMAP"===t.view,F=t=>{g||l(e,t,!0)},[Y,B]=(0,s.useTransition)(),U=(0,eu.k)();if("full"!==U)return(0,a.jsxs)("div",{className:(0,ek.cn)("relative rounded-lg border bg-card px-3 py-2.5 text-card-foreground shadow-sm","w-fit max-w-[296px]",t.isChild?"min-w-56":"min-w-64",M?"border-rose-400/50 bg-rose-500/[0.05]":z,O&&"border-sky-400/60",n&&"ring-2 ring-[var(--accent,#f5b942)]",D&&"opacity-60","far"===U&&!g&&"!opacity-0"),children:[(0,a.jsx)(b.x,{}),(0,a.jsx)(e$,{status:t.status}),(0,a.jsx)("div",{className:"break-words text-[15px] font-semibold leading-snug",children:t.title})]});let H=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b.x,{}),T&&(0,a.jsx)(eY,{nodeId:e}),(t.pins?.length??0)>0?(0,a.jsx)(y.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Annotate ${t.title}`,onClick:e=>{e.stopPropagation(),t.onComment?.(t.title)},className:(0,ek.cn)(ez,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover/nc:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(X.A,{className:"size-3"})})]}),_=(t.childCount??0)>0&&(0,a.jsxs)("button",{type:"button",onClick:n=>{n.stopPropagation(),t.onToggleCollapse?.(e)},title:t.collapsed?`Show ${t.childCount} sub-task${1===t.childCount?"":"s"}`:`Hide ${t.childCount} sub-task${1===t.childCount?"":"s"}`,className:(0,ek.cn)(ez,"mt-0.5 flex shrink-0 items-center gap-0.5 rounded px-1 text-[10px] font-semibold transition-colors",t.collapsed?"bg-white/[0.06] text-foreground hover:bg-white/10":"text-muted-foreground hover:bg-white/5 hover:text-foreground"),children:[t.collapsed?(0,a.jsx)(Z.A,{className:"size-3"}):(0,a.jsx)(K.A,{className:"size-3"}),t.childCount]}),G=(0,a.jsx)(eO,{onFocus:()=>m({id:e,title:t.title||"Untitled",value:S,editable:!g,onCommit:e=>F({plain:e.trim()||null})}),onExpand:()=>d(e),onDetails:()=>c(e),expanded:j,className:"top-full right-1 mt-1.5 before:absolute before:inset-x-0 before:bottom-full before:h-2.5 before:content-['']"}),el=(0,a.jsx)("textarea",{rows:1,value:N,readOnly:g,autoFocus:x===e,placeholder:"Title…",onFocus:t=>{x===e&&t.currentTarget.select()},onChange:e=>C(e.target.value),onBlur:()=>{let e=N.trim();e&&e!==t.title&&F({title:e})},onKeyDown:e=>{e.stopPropagation(),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())},className:(0,ek.cn)(ez,"field-sizing-content w-full resize-none bg-transparent text-sm font-medium leading-snug outline-none placeholder:text-muted-foreground/60",D&&"line-through")}),ed=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{list:`cats-${e}`,value:E,readOnly:g,placeholder:T?"domain":"category",title:T?"Architecture domain — the lane this component lives in":void 0,onChange:e=>A(e.target.value),onBlur:()=>{let e=E.trim()||null;e!==(t.cluster??null)&&F({cluster:e})},onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&e.currentTarget.blur()},className:(0,ek.cn)(ez,"field-sizing-content min-w-12 max-w-[60%] rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide outline-none focus:brightness-125 [&::-webkit-calendar-picker-indicator]:hidden",(0,ei.a2)(E))}),(0,a.jsx)("datalist",{id:`cats-${e}`,children:r.map(e=>(0,a.jsx)("option",{value:e},e))})]}),em=(0,a.jsxs)(er.l6,{value:t.status,onValueChange:e=>F({status:e}),disabled:g,children:[(0,a.jsx)(er.bq,{className:(0,ek.cn)(ez,"!h-5 shrink-0 !gap-0.5 rounded border !px-1.5 !py-0 text-[10px] font-medium [&_svg]:size-3",eo.nR[t.status]?.className??"border-white/10"),children:(0,a.jsx)(er.yv,{children:e=>eo.nR[e]?.label??e})}),(0,a.jsx)(er.gC,{alignItemWithTrigger:!1,children:o.map(e=>(0,a.jsx)(er.eb,{value:e,children:eo.nR[e]?.label??e},e))})]}),ep=(R>0||(t.signals?.untested??0)>0||t.signals?.auth)&&(0,a.jsxs)("div",{className:"mt-1.5 flex w-0 min-w-full flex-wrap items-center gap-1",children:[R>0&&(0,a.jsxs)("span",{title:`${R} open bug flag(s)`,className:"flex items-center gap-1 rounded bg-rose-500/15 px-1 text-[9px] font-semibold uppercase tracking-wide text-rose-300",children:[(0,a.jsx)(u.A,{className:"size-2.5"}),R]}),(t.signals?.untested??0)>0&&(0,a.jsxs)("span",{title:`${t.signals.untested} of ${t.signals.total} attached file(s) have no test importing them`,className:"flex items-center gap-1 rounded bg-amber-500/15 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-300",children:[(0,a.jsx)(W.A,{className:"size-2.5"}),t.signals.untested]}),t.signals?.auth&&(0,a.jsxs)("span",{title:"touches auth-sensitive files",className:"flex items-center gap-1 rounded bg-red-500/15 px-1 text-[9px] font-semibold uppercase tracking-wide text-red-300",children:[(0,a.jsx)(V.A,{className:"size-2.5"})," auth"]})]}),ex=j&&(0,a.jsxs)("div",{className:"mt-2 w-0 min-w-full space-y-2 border-t border-white/10 pt-2",children:[(0,a.jsx)(eN,{compact:!0,editable:!g,value:S,onChange:I,onBlur:()=>{let e=S.trim()||null;e!==(t.plain??null)&&F({plain:e})}}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pr-8",children:[(0,a.jsx)("div",{className:"flex items-center gap-1",children:!T&&(0,a.jsxs)(er.l6,{value:String(t.priority),onValueChange:e=>F({priority:Number(e)}),disabled:g,children:[(0,a.jsx)(er.bq,{className:(0,ek.cn)(ez,"!h-6 gap-1 rounded border-white/10 !px-1.5 !py-0 text-[10px] [&_svg]:size-3"),children:(0,a.jsx)(er.yv,{children:e=>eS.find(t=>String(t.v)===e)?.l??e})}),(0,a.jsx)(er.gC,{alignItemWithTrigger:!1,children:eS.map(e=>(0,a.jsx)(er.eb,{value:String(e.v),children:e.l},e.v))})]})}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[!g&&(0,a.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),w?p(e):k(!0)},onBlur:()=>k(!1),title:"Delete node",className:(0,ek.cn)(ez,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] transition-colors",w?"bg-red-500/20 text-red-300":"text-muted-foreground hover:bg-white/5 hover:text-red-300"),children:[(0,a.jsx)(J.A,{className:"size-3"}),w&&"Delete?"]}),h&&(0,a.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),h(`${T?"component":"feature"}: ${t.title}`)},title:"Ask the agent a question about this (answered in its next round)",className:(0,ek.cn)(ez,"flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-sky-300/90 hover:bg-sky-500/15 hover:text-sky-300"),children:[(0,a.jsx)(q.A,{className:"size-3"})," Ask"]})]})]})]});if(T){let e=(0,ei.i3)(t.cluster);return(0,a.jsxs)("div",{className:(0,ek.cn)("group/nc relative rounded-lg border bg-card px-3 py-2.5 text-card-foreground shadow-sm transition","w-fit min-w-60 max-w-72",P?"border-dashed border-sky-400/50 bg-sky-500/[0.06]":"border-border",O&&"border-sky-400/60 shadow-[0_0_0_1px_rgba(56,160,255,0.25)]",n&&"ring-2 ring-[var(--accent,#f5b942)]",D&&"opacity-60",$&&"opacity-70 border-dashed"),children:[H,(0,a.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,a.jsx)("span",{className:"mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg",style:{background:`color-mix(in oklab, ${e} 18%, transparent)`,color:e},children:(0,s.createElement)(function(e){let t=(e??"").toUpperCase();for(let[e,n]of eM)if(e.test(t))return n;if(!t)return eT[0];let n=0;for(let e=0;e<t.length;e++)n=31*n+t.charCodeAt(e)>>>0;return eT[n%eT.length]}(t.cluster),{className:"size-4"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-start gap-1",children:[el,_]}),(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[ed,f&&(0,a.jsx)(eR,{layer:t.layer,onSave:e=>F({layer:e}),readOnly:g})]})]}),(0,a.jsx)("div",{className:"shrink-0",children:em})]}),t.role&&(0,a.jsx)("div",{className:"mt-2 line-clamp-1 text-[10.5px] leading-snug text-muted-foreground",children:t.role}),(0,a.jsxs)("div",{className:"mt-2.5 grid grid-cols-4 gap-1 border-t border-white/[0.07] pt-2",children:[(0,a.jsx)(eL,{value:t.fileCount??0,label:"files",Icon:Q.A}),(0,a.jsx)(eL,{value:t.importsIn??"—",label:"in",Icon:ee.A}),(0,a.jsx)(eL,{value:t.importsOut??"—",label:"out",Icon:et.A}),(0,a.jsx)(eL,{value:R,label:"bug",Icon:u.A,danger:R>0})]}),null!=t.importsIn&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(eF,{importsIn:t.importsIn})}),G,ex]})}let eh=t.childCount??0,ef=t.childDone??0;return(0,a.jsxs)("div",{className:(0,ek.cn)("group/nc relative flex rounded-lg border bg-card text-card-foreground shadow-sm transition","w-fit max-w-96",j?"min-w-80":"min-w-64",P?"border-dashed border-sky-400/50 bg-sky-500/[0.06]":L?"border-dashed border-violet-400/60 bg-violet-500/[0.07] shadow-[0_0_0_1px_rgba(167,139,250,0.18)]":z,M&&!P&&"border-rose-400/50 bg-rose-500/[0.05]",O&&"border-sky-400/60 shadow-[0_0_0_1px_rgba(56,160,255,0.25)]",t.isNext&&"border-emerald-400/70 shadow-[0_0_0_2px_rgba(52,211,153,0.35)]",null!=t.workOrderRank&&t.workOrderRank>1&&"border-emerald-400/25",n&&"ring-2 ring-[var(--accent,#f5b942)]",D&&"opacity-60",$&&"opacity-70 border-dashed"),children:[H,G,(0,a.jsx)(eP,{priority:t.priority,rank:t.workOrderRank}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 px-2.5 py-2.5",children:[(0,a.jsxs)("div",{className:"flex w-0 min-w-full items-start gap-1.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-1",children:[O&&(0,a.jsx)("span",{title:"in progress",className:"mt-1.5 inline-block size-2 shrink-0 animate-pulse rounded-full bg-sky-400"}),t.isCriterion&&!O&&(0,a.jsx)("span",{title:"Success criterion",className:"mt-1.5 inline-block size-1.5 shrink-0 rounded-full bg-[var(--accent,#f5b942)]"}),el,_]}),(0,a.jsx)("div",{className:"shrink-0",children:em})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex w-0 min-w-full flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("span",{title:M?"Bug — something to fix":t.isChild?"Sub-task of a feature":"Feature — top-level roadmap item",className:(0,ek.cn)("flex shrink-0 items-center gap-1 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide",M?"bg-rose-500/15 text-rose-300":t.isChild?"bg-zinc-500/15 text-zinc-300":"bg-sky-500/15 text-sky-300"),children:[M&&(0,a.jsx)(u.A,{className:"size-2.5"}),M?"bug":t.isChild?"sub-task":"feature"]}),f&&(0,a.jsx)(eR,{layer:t.layer,onSave:e=>F({layer:e}),readOnly:g}),L&&(0,a.jsxs)("span",{className:(0,ek.cn)("flex items-center gap-1 rounded bg-violet-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-violet-300",Y&&"opacity-50"),children:[(0,a.jsx)(en.A,{className:"size-2.5"})," IA",(0,a.jsx)("button",{type:"button",title:"Accept suggestion — turn it into your own feature",disabled:Y,onClick:t=>{t.stopPropagation(),B(async()=>v(e))},className:(0,ek.cn)(ez,"-my-0.5 rounded p-0.5 hover:bg-emerald-500/20 hover:text-emerald-300"),children:(0,a.jsx)(ea.A,{className:"size-2.5"})}),(0,a.jsx)("button",{type:"button",title:"Dismiss suggestion (deletes the card)",disabled:Y,onClick:t=>{t.stopPropagation(),p(e)},className:(0,ek.cn)(ez,"-my-0.5 -ml-0.5 rounded p-0.5 hover:bg-red-500/20 hover:text-red-300"),children:(0,a.jsx)(es.A,{className:"size-2.5"})})]}),ed]}),t.role&&(0,a.jsx)("div",{className:(0,ek.cn)("mt-1.5 w-0 min-w-full text-[10px] leading-snug text-muted-foreground",!j&&"line-clamp-1"),children:t.role}),eh>0&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"h-[3px] flex-1 overflow-hidden rounded-full bg-white/[0.08]",title:`${ef}/${eh} sub-tasks done`,children:(0,a.jsx)("span",{className:"block h-full rounded-full bg-sky-400/75",style:{width:`${eh?ef/eh*100:0}%`}})}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",children:[(0,a.jsx)(ea.A,{className:"size-3"}),ef,"/",eh]})]}),ep,ex]})]})});var eH=n(54698),e_=n(24692),eG=n(45437),eK=n(82099),eX=n(47409),eZ=n(4474),eW=n(66616),eV=n(70521),eJ=n(74350);function eq({className:e,type:t,...n}){return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,ek.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function eQ({className:e,...t}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,ek.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var e0=n(61388);function e1({className:e,...t}){return(0,a.jsx)(e0.b,{"data-slot":"label",className:(0,ek.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}let e5=(0,j.createServerReference)("4065f27a469176eb75441bb170023c55f29997f152",j.callServer,void 0,j.findSourceMapURL,"createNodeAction"),e2=(0,j.createServerReference)("6021d7909674d186b366950135af5529c07940ca8c",j.callServer,void 0,j.findSourceMapURL,"updateNodeAction");function e3({open:e,onOpenChange:t,mode:n,view:r,heading:o,nodeId:l,parentId:i,position:d,defaults:c,hasFrontend:u=!1}){let m=(0,g.useRouter)(),[p,x]=(0,s.useState)(c?.title??""),[h,f]=(0,s.useState)(c?.role??""),[b,y]=(0,s.useState)(c?.plain??""),[j,v]=(0,s.useState)(c?.cluster??""),[w,k]=(0,s.useState)(c?.status??("ARCHITECTURE"===r?"REBUILD":"PENDING")),[N,C]=(0,s.useState)(c?.kind==="BUG"?"BUG":"FEATURE"),[E,A]=(0,s.useState)((0,el.jR)(c?.layer)??"none"),[S,I]=(0,s.useState)(!1),M="ARCHITECTURE"===r?eo.m6:eo.yl;async function T(){if(p.trim()){I(!0);try{let e="none"===E?null:E;"create"===n?await e5({view:r,..."ROADMAP"===r?{kind:N}:{},title:p.trim(),role:h.trim()||null,plain:b.trim()||null,cluster:j.trim()||null,...u?{layer:e}:{},parentId:i??null,status:w,x:d?.x??60,y:d?.y??60}):l&&await e2(l,{..."ROADMAP"===r?{kind:N}:{},title:p.trim(),role:h.trim()||null,plain:b.trim()||null,cluster:j.trim()||null,...u?{layer:e}:{},status:w}),t(!1),m.refresh()}finally{I(!1)}}}return(0,a.jsx)(eJ.lG,{open:e,onOpenChange:t,children:(0,a.jsxs)(eJ.Cf,{children:[(0,a.jsx)(eJ.c7,{children:(0,a.jsx)(eJ.L3,{children:o})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{htmlFor:"nf-title",children:"Title"}),(0,a.jsx)(eq,{id:"nf-title",value:p,autoFocus:!0,onChange:e=>x(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{htmlFor:"nf-role",children:"Role (one line)"}),(0,a.jsx)(eq,{id:"nf-role",value:h,onChange:e=>f(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{htmlFor:"nf-plain",children:"Description"}),(0,a.jsx)(eQ,{id:"nf-plain",rows:3,value:b,onChange:e=>y(e.target.value)})]}),"ROADMAP"===r&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{children:"Kind"}),(0,a.jsxs)(er.l6,{value:N,onValueChange:e=>null!=e&&C(e),children:[(0,a.jsx)(er.bq,{children:(0,a.jsx)(er.yv,{children:e=>"BUG"===e?"Bug":"Feature"})}),(0,a.jsxs)(er.gC,{children:[(0,a.jsx)(er.eb,{value:"FEATURE",children:"Feature"}),(0,a.jsx)(er.eb,{value:"BUG",children:"Bug"})]})]})]}),u&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{children:"Layer"}),(0,a.jsxs)(er.l6,{value:E,onValueChange:e=>null!=e&&A(e),children:[(0,a.jsx)(er.bq,{children:(0,a.jsx)(er.yv,{children:e=>"none"===e?"—":el.YG[e]?.label??e})}),(0,a.jsxs)(er.gC,{children:[(0,a.jsx)(er.eb,{value:"none",children:"—"}),Object.keys(el.YG).map(e=>(0,a.jsx)(er.eb,{value:e,children:el.YG[e].label},e))]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{children:"Status"}),(0,a.jsxs)(er.l6,{value:w,onValueChange:e=>null!=e&&k(e),children:[(0,a.jsx)(er.bq,{children:(0,a.jsx)(er.yv,{children:e=>eo.nR[e]?.label??e})}),(0,a.jsx)(er.gC,{children:M.map(e=>(0,a.jsx)(er.eb,{value:e,children:eo.nR[e]?.label??e},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(e1,{htmlFor:"nf-cluster",children:"Cluster / lane"}),(0,a.jsx)(eq,{id:"nf-cluster",value:j,onChange:e=>v(e.target.value)})]})]})]}),(0,a.jsxs)(eJ.Es,{children:[(0,a.jsx)(eZ.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(eZ.$,{onClick:T,disabled:S||!p.trim(),children:S?"Saving…":"Save"})]})]})})}let e4=(0,j.createServerReference)("40bb5125f556d7c5b13af690b1662d182501b0a446",j.callServer,void 0,j.findSourceMapURL,"deleteNodeAction"),e6=(0,j.createServerReference)("60f73b386ce22c1f50551476f24c5a1711dbb39baf",j.callServer,void 0,j.findSourceMapURL,"setStatusAction"),e9=(0,j.createServerReference)("4008a659eefbc314b766083cd50314d58dba140549",j.callServer,void 0,j.findSourceMapURL,"cancelAction"),e7=(0,j.createServerReference)("40f5db10fad14777602eed72fad5db6cdcb1497a95",j.callServer,void 0,j.findSourceMapURL,"deprioritizeAction");function e8({view:e,selected:t,allNodes:n,onClose:s,commentsContent:r,commentsCount:o=0,activeTab:l,onTabChange:i,onAddComment:d,topOffset:c}){let u=!!r,m=l??"details";return(0,a.jsxs)(eK.b,{className:"absolute right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:c??12,maxHeight:`calc(100% - ${(c??12)+12}px)`},children:[u?(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(eW.E,{active:"details"===m,onClick:()=>i?.("details"),children:"Details"}),(0,a.jsxs)(eW.E,{active:"comments"===m,onClick:()=>i?.("comments"),children:["Comments",o>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:o})]})]}),(0,a.jsx)("button",{onClick:s,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(es.A,{className:"size-4"})})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Details"}),(0,a.jsx)("button",{onClick:s,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(es.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,a.jsx)("div",{className:"p-3",children:"comments"===m&&u?r:t?(0,a.jsxs)(a.Fragment,{children:[d&&(0,a.jsxs)("button",{type:"button",onClick:()=>d(t.title),className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(X.A,{className:"size-3.5"}),"Comment on this ","ARCHITECTURE"===e?"component":"feature"]}),(0,a.jsx)(te,{node:t,view:e},t.id)]}):(0,a.jsx)(tn,{view:e,nodes:n})})})]})}function te({node:e,view:t}){let n=(0,g.useRouter)(),[r,o]=(0,s.useTransition)(),[l,i]=(0,s.useState)(!1),[d,c]=(0,s.useState)(!1),[u,m]=(0,s.useState)(e.plain??"");(0,s.useEffect)(()=>m(e.plain??""),[e.id,e.plain]);let{hasFrontend:p,openFocus:x}=ec(),h=(0,el.jR)(e.layer),f="ARCHITECTURE"===t?eo.m6:eo.yl,b=e=>o(async()=>{await e(),n.refresh()});return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:[(0,eo.Xf)(e.cluster),p&&h&&(0,a.jsxs)("span",{className:"ml-2 text-zinc-400",children:["\xb7 ",el.YG[h].label]}),0===e.priority&&(0,a.jsx)("span",{className:"ml-2 text-[#ff7a90]",children:"\xb7 critical path"})]}),(0,a.jsx)("h2",{className:"mt-1 text-lg font-semibold leading-tight",children:e.title})]}),"INIT"===e.source&&"ROADMAP"===t&&(0,a.jsxs)("div",{className:"rounded-lg border border-violet-400/30 bg-violet-500/[0.06] p-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-violet-300",children:[(0,a.jsx)(en.A,{className:"size-3.5"})," AI suggestion"]}),(0,a.jsx)("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:"Suggested direction surfaced when mapping the repo. Accept to turn it into your own feature, or dismiss."}),(0,a.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[(0,a.jsx)(eZ.$,{size:"sm",className:"h-7 px-2.5 text-xs",disabled:r,onClick:()=>b(()=>v(e.id)),children:"Accept"}),(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs text-muted-foreground",disabled:r,onClick:()=>b(()=>e4(e.id)),children:"Dismiss"})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Status"}),(0,a.jsxs)(er.l6,{value:e.status,onValueChange:t=>null!=t&&b(()=>e6(e.id,t)),children:[(0,a.jsx)(er.bq,{className:"h-8",disabled:r,children:(0,a.jsx)(er.yv,{children:e=>eo.nR[e]?.label??e})}),(0,a.jsx)(er.gC,{children:f.map(e=>(0,a.jsx)(er.eb,{value:e,children:eo.nR[e]?.label??e},e))})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Description"}),(0,a.jsx)("button",{type:"button",title:"Edit in focus mode",onClick:()=>x({id:e.id,title:e.title,value:u,editable:!0,onCommit:t=>{m(t);let n=t.trim()||null;n!==(e.plain??null)&&b(()=>e2(e.id,{plain:n}))}}),className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-white/10 hover:text-[#ff7a45]",children:(0,a.jsx)(G.A,{className:"size-3.5"})})]}),(0,a.jsx)("div",{className:"rounded-md border border-white/5 bg-card/40 px-2.5 py-2 text-sm",children:(0,a.jsx)(eN,{value:u,onChange:m,onBlur:()=>{let t=u.trim()||null;t!==(e.plain??null)&&b(()=>e2(e.id,{plain:t}))}})})]}),e.sourceRef&&(0,a.jsx)("div",{className:"rounded-md border border-border bg-card px-2 py-1.5 font-mono text-xs text-muted-foreground",children:e.sourceRef}),e.files.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Files (",e.files.length,")"]}),(0,a.jsx)(eX.h,{files:e.files.map(e=>({path:e}))})]}),"ARCHITECTURE"===t&&(0,a.jsx)(tt,{node:e}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",onClick:()=>i(!0),children:"Edit"}),(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",onClick:()=>c(!0),children:"+ Sub-node"}),(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",disabled:r,onClick:()=>b(()=>e9(e.id)),children:"Cancel"}),(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",disabled:r,onClick:()=>b(()=>e7(e.id)),children:"Deprioritize"}),(0,a.jsxs)(eV.Lt,{children:[(0,a.jsx)(eV.tv,{render:(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",className:"text-red-300",children:"Delete"})}),(0,a.jsxs)(eV.EO,{children:[(0,a.jsxs)(eV.wd,{children:[(0,a.jsxs)(eV.r7,{children:["Delete “",e.title,"”?"]}),(0,a.jsx)(eV.$v,{children:"This removes the node and all its sub-nodes. It can’t be undone."})]}),(0,a.jsxs)(eV.ck,{children:[(0,a.jsx)(eV.Zr,{children:"Cancel"}),(0,a.jsx)(eV.Rx,{onClick:()=>b(()=>e4(e.id)),children:"Delete"})]})]})]})]}),l&&(0,a.jsx)(e3,{open:!0,onOpenChange:i,mode:"edit",view:t,heading:"Edit node",nodeId:e.id,hasFrontend:p,defaults:{title:e.title,role:e.role,plain:e.plain,status:e.status,cluster:e.cluster,kind:e.kind,layer:e.layer}}),d&&(0,a.jsx)(e3,{open:!0,onOpenChange:c,mode:"create",view:t,heading:"New sub-node",parentId:e.id,position:{x:e.x,y:e.y+120},hasFrontend:p,defaults:{cluster:e.cluster,layer:e.layer}})]})}function tt({node:e}){let t=(0,g.useRouter)(),[n,r]=(0,s.useState)(""),[o,l]=(0,s.useState)(!1),i=e.bugFlags.filter(e=>!e.resolved),d=e=>{l(!0),e().then(()=>t.refresh()).finally(()=>l(!1))},c=()=>{let t=n.trim();t&&d(async()=>{(await fetch("/api/bug-flags",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({nodeId:e.id,by:"user",note:t})})).ok&&r("")})};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,a.jsx)(u.A,{className:"size-3.5 text-rose-300"}),"Bug flags",i.length>0&&` (${i.length} open)`]}),e.bugFlags.length>0&&(0,a.jsx)("ul",{className:"space-y-1.5",children:e.bugFlags.map(e=>(0,a.jsxs)("li",{className:(0,ek.cn)("rounded-md border px-2 py-1.5",e.resolved?"border-white/5 bg-card/30 opacity-60":"border-rose-400/25 bg-rose-500/[0.05]"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{title:"agent"===e.by?"Flagged by an agent examining the code":"Flagged by you",className:(0,ek.cn)("rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide","agent"===e.by?"bg-violet-500/15 text-violet-300":"bg-sky-500/15 text-sky-300"),children:"agent"===e.by?"agent":"you"}),(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",disabled:o,onClick:()=>d(()=>fetch(`/api/bug-flags/${e.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({resolved:!e.resolved})})),className:"rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:e.resolved?"Reopen":"Resolve"}),(0,a.jsx)("button",{type:"button",disabled:o,title:"Delete flag",onClick:()=>d(()=>fetch(`/api/bug-flags/${e.id}`,{method:"DELETE"})),className:"rounded p-0.5 text-muted-foreground transition-colors hover:bg-white/10 hover:text-red-300",children:(0,a.jsx)(es.A,{className:"size-3"})})]})]}),(0,a.jsx)("p",{className:(0,ek.cn)("mt-1 text-[11.5px] leading-snug",e.resolved&&"line-through"),children:e.note})]},e.id))}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-start gap-1.5",children:[(0,a.jsx)("textarea",{rows:1,value:n,placeholder:"Flag a bug or something worth investigating…",onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),c())},className:"field-sizing-content min-h-7 w-full resize-none rounded-md border border-white/10 bg-white/[0.03] px-2 py-1 text-[11.5px] outline-none placeholder:text-muted-foreground/60 focus:bg-white/[0.06]"}),(0,a.jsx)(eZ.$,{size:"sm",variant:"outline",className:"h-7 shrink-0 px-2 text-[11px]",disabled:o||!n.trim(),onClick:c,children:"Flag"})]})]})}function tn({view:e,nodes:t}){let n=t.filter(e=>0===e.priority).length;return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"ROADMAP"===e?"Roadmap":"Architecture"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Click a node for details and actions. Drag to rearrange — positions are saved."})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-2 gap-2 text-center",children:[(0,a.jsx)(ta,{label:"nodes",value:t.length}),(0,a.jsx)(ta,{label:"critical",value:n})]})]})}function ta({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-md border border-border bg-card py-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:t}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e})]})}function ts({payload:e,onDismiss:t}){let[n,r]=(0,s.useState)(""),[o,l]=(0,s.useState)(null);if((e?.id??null)!==o&&(l(e?.id??null),r(e?.value??"")),(0,s.useEffect)(()=>{if(!e)return;let a=a=>{("Escape"===a.key||(a.metaKey||a.ctrlKey)&&"Enter"===a.key)&&(a.preventDefault(),e.onCommit(n),t())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[e,n,t]),!e)return null;let i=()=>{e.onCommit(n),t()};return(0,a.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":`Edit description — ${e.title}`,onMouseDown:e=>{e.target===e.currentTarget&&i()},className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/55 backdrop-blur-[5px] animate-in fade-in duration-150",children:(0,a.jsxs)(eK.b,{className:"flex max-h-[82vh] w-[min(720px,92vw)] flex-col rounded-2xl duration-150 animate-in fade-in zoom-in-95",onMouseDown:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-white/10 px-4 py-3",children:[(0,a.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Description"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:e.title}),(0,a.jsxs)("span",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:[n.length," chars"]}),(0,a.jsx)("button",{type:"button",onClick:i,title:"Close (Esc)",className:"shrink-0 rounded-lg p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(es.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-[40vh] flex-1 overflow-y-auto px-6 py-5 text-[15px] leading-relaxed",children:(0,a.jsx)(eN,{bare:!0,autoFocus:e.editable,editable:e.editable,value:n,onChange:r})}),(0,a.jsxs)("div",{className:"flex items-center gap-3 border-t border-white/10 px-4 py-2.5 text-[11.5px] text-muted-foreground",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"size-1.5 rounded-full bg-emerald-400"})," Autosaves"]}),(0,a.jsx)("span",{className:"opacity-70",children:"\xb7 Esc to close"}),e.editable&&(0,a.jsxs)("button",{type:"button",onClick:i,className:"ml-auto flex items-center gap-1.5 rounded-lg bg-[#ff7a45] px-3 py-1.5 text-xs font-semibold text-black transition hover:brightness-110",children:[(0,a.jsx)(ea.A,{className:"size-3.5"}),"Save & close"]})]})]})})}var tr=n(80277),to=n(18874),tl=n(62311),ti=n(9991),td=n(40654),tc=n(14983),tu=n(91157),tm=n(56895),tp=n(16607),tx=n(56614),th=n(98238),tf=n(36849),tg=n(94014),tb=n(44267);function ty(e,t){let n={x:t.x,y:t.y};for(let t=0;t<100&&e.some(e=>200>Math.abs(n.x-e.x)&&150>Math.abs(n.y-e.y));t++)n.y+=150;return n}var tj=n(70947);let tv=[{value:"cluster",label:"Theme"},{value:"status",label:"Status"},{value:"priority",label:"Priority"}],tw=new Set(["title","role","plain","cluster","layer","status","priority"]),tk={roadmapNode:eU,archNode:eU,annotation:y.Sh},tN={deletable:e_.I,annotation:eG.L},tC={CONTAINS:{stroke:"#7c7c8a"},DEPENDS:{stroke:"#f5b942",dash:"6 4"},RELATES:{stroke:"#8a8a95",dash:"4 4"},REPLACES:{stroke:"#ff6b9d"}};function tE({view:e,nodes:t,edges:n,workOrder:g=[],embedded:b=!1,commentsContent:j,commentsCount:v=0,controlRef:w,onAskAgent:k,onAddComment:N,annotations:C,onPinClick:E,onUpdateComment:A,onRemoveComment:S,boardAnnotations:I,initialArrangedBy:M=null,initialCollapsed:T=[],hasFrontend:z=!1,readOnly:R=!1,firstTapHighlightsOnly:D=!1}){let $=g.join(","),P=(0,s.useMemo)(()=>{let e=new Map;return g.forEach((t,n)=>e.set(t,n+1)),e},[$]),O=g[0]??null,L=(0,s.useMemo)(()=>t.map(e=>({id:e.id,type:"ROADMAP"===e.view?"roadmapNode":"archNode",position:{x:e.x,y:e.y},data:{title:e.title,role:e.role,plain:e.plain,status:e.status,priority:e.priority,cluster:e.cluster,layer:e.layer,view:e.view,kind:e.kind,source:e.source,sourceRef:e.sourceRef,isCriterion:e.isCriterion,isChild:null!=e.parentId,parentId:e.parentId,signals:e.signals,fileCount:e.files.length,importsIn:e.importsIn,importsOut:e.importsOut,openBugs:e.bugFlags.filter(e=>!e.resolved).length}})),[t]),F=(0,s.useMemo)(()=>{let e;return e=new Set(t.map(e=>e.id)),[...t.filter(t=>t.parentId&&e.has(t.parentId)).map(e=>({id:`c-${e.id}`,source:e.parentId,sourceHandle:"sb",target:e.id,targetHandle:"tt",type:"smoothstep",style:{stroke:tC.CONTAINS.stroke}})),...n.filter(t=>e.has(t.fromId)&&e.has(t.toId)).map(e=>{let t=tC[e.kind]??tC.RELATES,n="DEPENDS"===e.kind?"depends on":void 0;return{id:e.id,source:e.fromId,sourceHandle:e.sourceHandle??void 0,target:e.toId,targetHandle:e.targetHandle??void 0,label:e.label??n,type:"deletable",markerEnd:{type:o.TG.ArrowClosed,color:t.stroke},style:{stroke:t.stroke,strokeDasharray:t.dash}}})]},[t,n]),[Y,B]=(0,s.useState)(L),[U,H]=(0,s.useState)(F),[_,G]=(0,s.useState)(null),[K,X]=(0,s.useState)(null),[Z,W]=(0,s.useState)(null),[V,J]=(0,s.useState)(!1),[q,Q]=(0,s.useState)("details"),{tool:ee,setTool:et,flowProps:en,paneClass:ea}=(0,tr.e)(),[es,er]=(0,s.useState)(null),[ei,ec]=(0,s.useState)(null),[em,ep]=(0,s.useState)(!1),ex=(0,s.useRef)(!1),eh=(0,s.useRef)("details");(0,s.useEffect)(()=>{ex.current=V},[V]),(0,s.useEffect)(()=>{eh.current=q},[q]),(0,s.useEffect)(()=>{if(w)return w.current={open:()=>{if(ex.current){J(!1),Q("details");return}J(!0),Q("details")},close:()=>{J(!1),Q("details")},openComments:()=>{J(!0),Q("comments")}},()=>{w&&(w.current=null)}},[w]);let[ef,eg]=(0,s.useState)(new Set),[eb,ey]=(0,s.useState)(null),[ej,ev]=(0,s.useState)(!1),ew=(0,s.useRef)(null);(0,s.useEffect)(()=>B(L),[L]),(0,s.useEffect)(()=>H(F),[F]),(0,s.useEffect)(()=>{if(!R)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>ew.current?.fitView({padding:.2,duration:0,minZoom:.38,maxZoom:.9}))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[R,L]);let eN=(0,s.useCallback)((e,t,n)=>{B(n=>n.map(n=>n.id===e?{...n,data:{...n.data,...t}}:n)),n&&fetch(`/api/nodes/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(Object.fromEntries(Object.entries(t).filter(([e])=>tw.has(e))))})},[]),eC=(0,s.useMemo)(()=>JSON.stringify(Array.from(new Set(Y.map(e=>e.data.cluster).filter(e=>!!e))).sort()),[Y]),eE=(0,s.useMemo)(()=>JSON.parse(eC),[eC]),eA=(0,s.useCallback)(e=>eg(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),eS=(0,s.useCallback)(e=>{G(e),J(!0),Q("details")},[]),eI=(0,s.useCallback)(e=>{B(t=>t.filter(t=>t.id!==e)),G(t=>t===e?null:t),fetch(`/api/nodes/${e}`,{method:"DELETE"})},[]),eM=(0,s.useCallback)(async(t,n,a="FEATURE")=>{let s=(0,r.sX)(),o="ARCHITECTURE"===e?"REBUILD":"PENDING",l="BUG"===a?"New bug":"New node";B(r=>[...r,{id:s,type:"ROADMAP"===e?"roadmapNode":"archNode",position:{x:t,y:n},data:{title:l,role:null,plain:null,status:o,priority:2,cluster:null,view:e,kind:a,source:"MANUAL",sourceRef:null,isCriterion:!1,isChild:!1,parentId:null,openBugs:0}}]),eg(e=>new Set(e).add(s)),ey(s),G(s);try{if(!(await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,view:e,kind:a,title:l,status:o,x:t,y:n})})).ok)throw Error("create failed")}catch{B(e=>e.filter(e=>e.id!==s)),eg(e=>{let t=new Set(e);return t.delete(s),t}),ey(e=>e===s?null:e),G(e=>e===s?null:e)}},[e]),eT=(0,s.useCallback)((e,t)=>{if(!es||!ew.current)return;let n=ew.current.screenToFlowPosition({x:e,y:t});eM(n.x,n.y,es),er(null),ec(null)},[es,eM]);(0,s.useEffect)(()=>{if(!es&&!ej)return;let e=e=>ec({x:e.clientX,y:e.clientY}),t=e=>{"Escape"===e.key&&(er(null),ev(!1),ec(null))};return window.addEventListener("mousemove",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("keydown",t)}},[es,ej]),(0,s.useCallback)(()=>{let e=Y.filter(e=>"annotation"!==e.type);return function(e,t,n={}){let a=n.colW??320,s=n.rowH??150,r=n.maxCols??4,o=n.bandGap??90;if(0===e.length){if(0===t.length)return{x:0,y:0};let e=Math.max(...t.map(e=>e.y));return ty(t,{x:0,y:e+s+o})}let l=Math.min(...e.map(e=>e.x)),i=Math.min(...e.map(e=>e.y)),d=e.map(e=>Math.max(0,Math.round((e.x-l)/a))),c=Math.min(r,Math.max(Math.max(...d)+1,Math.ceil(Math.sqrt(e.length+1)))),u=Array(c).fill(i-s);e.forEach((e,t)=>{let n=Math.min(d[t],c-1);u[n]=Math.max(u[n],e.y)});let m=0;for(let e=1;e<c;e++)u[e]<u[m]&&(m=e);return ty(t,{x:l+m*a,y:u[m]+s})}(e.filter(e=>!e.data.parentId&&!(e.data.cluster??"").trim()).map(e=>e.position),e.map(e=>e.position))},[Y]);let ez=(0,s.useCallback)(()=>{ev(!1),er("FEATURE")},[]),eR=(0,s.useCallback)(()=>{ev(!1),er("BUG")},[]),[eD,e$]=(0,s.useState)(null),eP=(0,s.useCallback)(e=>e$(e),[]),eO=(0,s.useMemo)(()=>({view:e,readOnly:R,categories:eE,statuses:"ARCHITECTURE"===e?eo.m6:eo.yl,patch:eN,isExpanded:e=>ef.has(e),toggleExpand:eA,openDetailed:eS,openFocus:eP,removeNode:eI,editingTitleId:eb,onAskAgent:k,hasFrontend:z}),[e,R,eE,eN,ef,eA,eS,eP,eI,eb,k,z]),[eL,eF]=(0,s.useState)(M),[eY,eB]=(0,s.useState)(""),[eU,e_]=(0,s.useState)("full"),[eG,eK]=(0,s.useState)(new Set),[eX,eZ]=(0,s.useState)(new Set),[eW,eV]=(0,s.useState)(new Set),[eJ,eq]=(0,s.useState)(null),eQ=(0,s.useMemo)(()=>Array.from(new Set(t.map(e=>e.status))),[t]),e0=(0,s.useMemo)(()=>Array.from(new Set(t.map(e=>e.cluster).filter(e=>!!e))).sort(),[t]),e1=(0,s.useMemo)(()=>Array.from(new Set(t.map(e=>e.priority))).sort((e,t)=>e-t),[t]),e5=(0,s.useCallback)(e=>(!eG.size||!!eG.has(e.status))&&(!eX.size||!!e.cluster&&!!eX.has(e.cluster))&&(!eW.size||!!eW.has(e.priority)),[eG,eX,eW]),e2=eG.size+eX.size+eW.size+ +!!eJ,e3=(0,s.useCallback)(()=>{eK(new Set),eZ(new Set),eV(new Set),eq(null)},[]),[e4,e6]=(0,s.useState)(()=>new Set(T)),e9=(0,s.useCallback)(t=>{e6(n=>{let a=new Set(n);return a.has(t)?a.delete(t):a.add(t),b||fetch("/api/board-layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({board:"ROADMAP"===e?"roadmap":"architecture",collapsed:[...a]})}).catch(()=>{}),a})},[b,e]),e7=(0,s.useMemo)(()=>(function(e){let t=new Map;for(let n of e)n.parentId&&t.set(n.parentId,(t.get(n.parentId)??0)+1);return t})(t),[t]),te=(0,s.useMemo)(()=>{let e=new Map;for(let n of t)n.parentId&&"DONE"===n.status&&e.set(n.parentId,(e.get(n.parentId)??0)+1);return e},[t]),tt=(0,s.useMemo)(()=>(function(e,t){let n=new Set;if(0===t.size)return n;let a=new Map;for(let t of e){if(!t.parentId)continue;let e=a.get(t.parentId);e?e.push(t.id):a.set(t.parentId,[t.id])}let s=[...t];for(;s.length;){let e=s.pop();for(let t of a.get(e)??[])n.has(t)||(n.add(t),s.push(t))}return n})(t,e4),[t,e4]),tn=(0,s.useMemo)(()=>Y.map(e=>({...e,hidden:!e5(e.data)||tt.has(e.id)})),[Y,e5,tt]),ta=(0,s.useMemo)(()=>new Set(tn.filter(e=>e.hidden).map(e=>e.id)),[tn]),tA=(0,s.useMemo)(()=>U.map(e=>({...e,hidden:ta.has(e.source)||ta.has(e.target)})),[U,ta]),tS=(0,s.useMemo)(()=>{if(K){let e=tA.find(e=>e.id===K);return e?new Set([e.source,e.target]):null}return _?(0,to.F1)(_,tA.filter(e=>!e.hidden)):null},[_,K,tA]),tI=eY.trim().length>0,tM=(0,s.useMemo)(()=>{if(!tI)return null;let e=new Set;for(let t of Y)e5(t.data)&&(0,tc.Qk)((0,tc.$$)(t.data),eY)&&e.add(t.id);return e},[Y,eY,e5,tI]),tT=(0,s.useMemo)(()=>"ARCHITECTURE"===e?(0,tu.d)(t):[],[e,t]),tz=(0,s.useCallback)(e=>{ew.current&&(e.focusIds.length?ew.current.fitView({nodes:e.focusIds.map(e=>({id:e})),duration:700,padding:.3,maxZoom:1.1}):ew.current.fitView({duration:700,padding:.2}))},[]),tR=(0,tm.W)(tT,tz),tD=tR.focusIds,t$=tD??tM??tS,tP=tM??tD??tS,tO=(0,s.useMemo)(()=>eJ?new Set(tn.filter(e=>!e.hidden&&!(0,th.F)(eJ,(0,el.jR)(e.data.layer))).map(e=>e.id)):null,[eJ,tn]),tL=(0,s.useMemo)(()=>tn.map(e=>{let t=P.get(e.id),n=e7.get(e.id)??0,a={...t?{workOrderRank:t,isNext:1===t}:{},...n>0?{childCount:n,childDone:te.get(e.id)??0,collapsed:e4.has(e.id),onToggleCollapse:e9}:{}},s=t||n>0?{...e,data:{...e.data,...a}}:e;if(ef.has(e.id)&&(s={...s,zIndex:25}),s.hidden)return s;if(!t$)return tO?.has(e.id)?{...s,style:{...s.style,opacity:.3,filter:"saturate(0.3)",transition:"opacity 120ms, filter 120ms"}}:s;let r=t$.has(e.id),o=tP?tc.Uy:.45;return{...s,zIndex:r&&tP?24:s.zIndex,style:{...s.style,opacity:r?1:o,boxShadow:r&&tP?tc.RU:s.style?.boxShadow,borderRadius:r&&tP?14:s.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}),[tn,t$,tP,P,ef,tO,e7,te,e4,e9]),tF=(0,s.useMemo)(()=>{if("ROADMAP"===e&&!eL||"ROADMAP"!==e&&"ARCHITECTURE"!==e)return[];let t=new Map(tL.map(e=>[e.id,e])),n=[];for(let s of tL){var a;if(s.hidden||"annotation"===s.type)continue;let r=(s.data.parentId?t.get(s.data.parentId):void 0)??s,o="ROADMAP"===e&&eL?(a=r.data,"status"===eL?eo.nR[a.status]?.label??a.status:"priority"===eL?`P${a.priority}`:a.cluster?.trim()||"—"):r.data.cluster?.trim()||"—";n.push({id:s.id,group:o,x:s.position.x,y:s.position.y,w:s.measured?.width??(s.data.isChild?224:256),h:s.measured?.height??96})}return(0,tb.S)(n)},[tL,eL,e]),tY="ARCHITECTURE"===e||"cluster"===eL?"category":"neutral",tB=(0,s.useMemo)(()=>{if(tD)return tA.map(e=>e.hidden?e:tD.has(e.source)&&tD.has(e.target)?{...e,style:{...e.style,opacity:1}}:{...e,label:void 0,style:{...e.style,opacity:.06}});if(tM)return tA.map(e=>e.hidden?e:tM.has(e.source)&&tM.has(e.target)?{...e,style:{...e.style,opacity:1}}:{...e,label:void 0,style:{...e.style,opacity:.06}});let e=_??Z;return K||e?tA.map(t=>t.hidden?t:(K?t.id===K:t.source===e||t.target===e)?{...t,zIndex:20,style:{...t.style,opacity:1,strokeWidth:2.5}}:{...t,selectable:!1,label:void 0,markerEnd:void 0,style:{...t.style,opacity:.06}}):tA.map(e=>{if(e.hidden)return e;let t=tO&&(tO.has(e.source)||tO.has(e.target));return{...e,label:void 0,style:{...e.style,opacity:t?.06:.18}}})},[tA,_,K,Z,tM,tO,tD]),tU=void 0!==I,[tH,t_]=(0,s.useState)(I??[]);(0,s.useEffect)(()=>{I&&t_(I)},[I]);let tG=(0,s.useMemo)(()=>{if(tU){let e=new Set(t.map(e=>e.id));return tH.filter(t=>"feature"===t.targetKind&&e.has(t.targetId)).map((e,t)=>({id:e.id,n:t+1,targetId:e.targetId,text:e.body,x:e.x,y:e.y}))}let e=new Map((C??[]).map(e=>[e.id,e.comment]));return(0,eH.m)(C??[],{tables:[],features:t.map(e=>({id:e.id,title:e.title}))}).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,text:e.get(t.annotationId)??"",x:null,y:null}))},[tU,tH,C,t]),tK=(0,s.useMemo)(()=>{let e=new Map;for(let t of tG){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:null}),e.set(t.targetId,n)}return e},[tG]),tX=(0,s.useCallback)(async e=>{let n=(0,eH.m)([{id:"_",excerpt:e}],{tables:[],features:t.map(e=>({id:e.id,title:e.title}))})[0];if(!n)return;let a=await fetch("/api/board-annotations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetKind:"feature",targetId:n.targetId})});if(a.ok){let e=await a.json();t_(t=>[...t,e])}},[t]),tZ=(0,s.useCallback)((e,t)=>{t_(n=>n.map(n=>n.id===e?{...n,...t}:n)),fetch(`/api/board-annotations/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)})},[]),tW=(0,s.useCallback)(e=>{t_(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),tV=tU?tX:N,[tJ,tq]=(0,s.useState)(()=>new Map),tQ=(0,s.useMemo)(()=>{let e=new Map(tL.map(e=>[e.id,e])),t=new Map,n=tG.flatMap(n=>{let a=e.get(n.targetId);if(!a||a.hidden)return[];let s=t.get(n.targetId)??0;t.set(n.targetId,s+1);let r=a.measured?.height??96;return[{id:`anno-${n.id}`,type:"annotation",position:{x:n.x??a.position.x+26,y:n.y??a.position.y+r+56+112*s},measured:tJ.get(`anno-${n.id}`),draggable:tU,data:{n:n.n,text:n.text,annotationId:n.id,onClick:tU||A?void 0:E,editable:tU||!!A,onChangeText:tU?(e,t)=>tZ(e,{body:t}):A,onDelete:tU?tW:S}}]});return[...tL.map(e=>{let t=tK.get(e.id);return t||tV?{...e,data:{...e.data,pins:t,onPinClick:tU?void 0:E,onComment:tV}}:e}),...n]},[tL,tG,tK,tU,E,A,S,tV,tZ,tW,tJ]),t0=(0,s.useMemo)(()=>tG.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"annotation",selectable:!1,zIndex:30,style:{stroke:y.V5,strokeWidth:1.5,opacity:.9}})),[tG]),t1=(0,s.useCallback)(e=>{let t=[];for(let n of e)if("position"===n.type&&n.id.startsWith("anno-")&&n.position){let e=n.id.slice(5),{x:t,y:a}=n.position;t_(n=>n.map(n=>n.id===e?{...n,x:t,y:a}:n))}else if("dimensions"===n.type&&n.id.startsWith("anno-")){let e=n.dimensions;e&&tq(t=>{let a=t.get(n.id);if(a&&a.width===e.width&&a.height===e.height)return t;let s=new Map(t);return s.set(n.id,e),s})}else t.push(n);t.length&&B(e=>(0,l._0)(t,e))},[]),t5=(0,s.useCallback)(e=>H(t=>(0,l.zW)(e,t)),[]),t2=(0,s.useCallback)(async e=>{if(!e.source||!e.target||e.source===e.target)return;let t=await fetch("/api/edges",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:e.source,toId:e.target,kind:"DEPENDS",sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null})});if(!t.ok)return;let n=await t.json(),a=tC.DEPENDS;H(t=>t.some(e=>e.id===n.id)?t:[...t,{id:n.id,source:n.fromId,sourceHandle:e.sourceHandle??void 0,target:n.toId,targetHandle:e.targetHandle??void 0,label:"depends on",type:"deletable",markerEnd:{type:o.TG.ArrowClosed,color:a.stroke},style:{stroke:a.stroke,strokeDasharray:a.dash}}])},[]),t3=(0,s.useCallback)(async(t,n,a)=>{let s=await fetch("/api/nodes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({view:e,title:"New node",parentId:t.id,cluster:t.data.cluster??null,status:"ARCHITECTURE"===e?"REBUILD":"PENDING",x:n,y:a})});if(!s.ok)return;let r=await s.json();B(s=>[...s,{id:r.id,type:"ROADMAP"===e?"roadmapNode":"archNode",position:{x:n,y:a},data:{title:r.title,role:r.role,plain:r.plain,status:r.status,priority:r.priority,cluster:r.cluster,view:r.view,source:r.source,sourceRef:r.sourceRef,kind:r.kind,isCriterion:!1,isChild:!0,parentId:t.id,openBugs:0}}]),H(e=>[...e,{id:`c-${r.id}`,source:t.id,sourceHandle:"sb",target:r.id,targetHandle:"tt",type:"smoothstep",style:{stroke:tC.CONTAINS.stroke}}]),eg(e=>new Set(e).add(r.id)),ey(r.id),G(r.id)},[e]),t4=(0,s.useCallback)(async(e,t)=>{if(t.isValid||!t.fromNode||!ew.current)return;let n=e.changedTouches,a=n?.[0]?.clientX??e.clientX,s=n?.[0]?.clientY??e.clientY,{x:r,y:o}=ew.current.screenToFlowPosition({x:a,y:s});await t3(t.fromNode,r,o)},[t3]);(0,s.useEffect)(()=>{if(!ej)return;let e=e=>{"Escape"===e.key&&ev(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ej]);let t6=(0,s.useMemo)(()=>t.find(e=>e.id===_)??null,[t,_]),t9=(0,s.useCallback)((e,t,n)=>{fetch(`/api/nodes/${e}/position`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({x:t,y:n})})},[]),t7=(0,s.useCallback)(e=>{G(e),X(null);let t=ew.current?.getNode(e);if(!t||!ew.current)return;let n=t.measured?.width??128,a=t.measured?.height??48;ew.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:1.2,duration:600})},[]),t8=(0,s.useCallback)(e=>{let t=(0,tf.VI)(Y.map(e=>({id:e.id,parentId:e.data.parentId??null,cluster:e.data.cluster,status:e.data.status,priority:e.data.priority,title:e.data.title,role:e.data.role})),e,{viewportAspect:window.innerWidth/window.innerHeight});B(e=>e.map(e=>{let n=t.get(e.id);return n?{...e,position:n}:e}));let n=Array.from(t,([e,t])=>({id:e,x:t.x,y:t.y}));n.length&&fetch("/api/nodes/positions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({batch:n})}),eF(e),fetch("/api/board-layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({board:"roadmap",arrangedBy:e})}),requestAnimationFrame(()=>ew.current?.fitView({duration:600,padding:.2}))},[Y]),ne=(0,s.useMemo)(()=>{let t=new Map;if("ROADMAP"!==e||!eL)return t;let n=e=>"status"===eL?e.status:"priority"===eL?`P${e.priority}`:e.cluster??"—";for(let e of Y)"annotation"!==e.type&&t.set(e.id,n(e.data));return t},[Y,eL,e]),nt=(0,s.useRef)(null);(0,s.useEffect)(()=>{let t=nt.current;if(nt.current=ne,!t||"ROADMAP"!==e||!eL)return;let n=!1;for(let[e,a]of ne)if(t.has(e)&&t.get(e)!==a){n=!0;break}n&&t8(eL)},[ne,eL,e,t8]);let nn=(0,s.useCallback)(()=>{let e=function(e,t,n={}){if(0===e.length)return new Map;let a=function(e,t){let n=e.map(e=>e.id).sort(),a=new Map(n.map(e=>[e,[]]));for(let e of[...t].sort((e,t)=>e.fromId.localeCompare(t.fromId)||e.toId.localeCompare(t.toId)))a.get(e.fromId)?.push(e);let s=new Map,r=[],o=e=>{for(let t of(s.set(e,"visiting"),a.get(e)??[])){let e=s.get(t.toId);"visiting"!==e&&(r.push(t),"done"!==e&&o(t.toId))}s.set(e,"done")};for(let e of n)s.has(e)||o(e);return r}(e,t),s=function(e,t){let n=new Map(e.map(e=>[e.id,[]]));for(let e of t)n.get(e.fromId)?.push(e.toId);let a=new Map,s=e=>{let t=a.get(e);if(void 0!==t)return t;a.set(e,0);let r=n.get(e)??[],o=r.length?1+Math.max(...r.map(s)):0;return a.set(e,o),o};for(let t of e)s(t.id);return a}(e,a),r=new Map(e.map(e=>[e.id,[]]));for(let e of a)r.get(e.fromId)?.push(e.toId);let o=Array.from(new Set(e.map(e=>e.group))),l=o.filter(e=>"—"!==e).sort(),i=o.includes("—")?[...l,"—"]:l,d=[];for(let t of i){let n=e.filter(e=>e.group===t),a=Math.min(...n.map(e=>s.get(e.id)??0)),o=Math.max(...n.map(e=>s.get(e.id)??0)),l=new Map,i=new Map,c=0,u=1;for(let e=a;e<=o;e++){let t=n.filter(t=>s.get(t.id)===e);if(!t.length)continue;let a=e=>{let t=(r.get(e.id)??[]).map(e=>i.get(e)).filter(e=>void 0!==e);return t.length?t.reduce((e,t)=>e+t,0)/t.length:1/0};t.sort((e,t)=>a(e)-a(t)||e.id.localeCompare(t.id));let o=Math.max(1,Math.ceil(Math.sqrt(2*t.length)));t.forEach((e,t)=>{let n=Math.floor(t/o),a=t%o;i.set(e.id,a),l.set(e.id,{x:c+360*n,y:150*a}),u=Math.max(u,a+1)}),c+=360*Math.ceil(t.length/o)}d.push({d:t,w:c,h:150*u,local:l})}let c=(0,tg.Xi)(d.map(e=>({id:e.d,w:e.w,h:e.h})),{gapX:84,gapY:80,viewportAspect:n.viewportAspect,minBandW:1080,aspectSlack:1.5}),u=new Map;for(let e of d){let t=c.get(e.d);for(let[n,a]of e.local)u.set(n,{x:t.x+a.x,y:t.y+a.y})}return u}(Y.filter(e=>"annotation"!==e.type).map(e=>({id:e.id,group:(e.data.cluster??"").trim()||"—"})),n.filter(e=>"DEPENDS"===e.kind).map(e=>({fromId:e.fromId,toId:e.toId})),{viewportAspect:window.innerWidth/window.innerHeight});B(t=>t.map(t=>{let n=e.get(t.id);return n?{...t,position:n}:t}));let t=Array.from(e,([e,t])=>({id:e,x:t.x,y:t.y}));t.length&&fetch("/api/nodes/positions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({batch:t})}),requestAnimationFrame(()=>ew.current?.fitView({duration:600,padding:.2}))},[Y,n]),na=(0,s.useMemo)(()=>tI?(0,tc.r2)(Y.filter(e=>e5(e.data)),eY,e=>(0,tc.$$)(e.data),e=>({id:e.id,label:e.data.title,sublabel:e.data.cluster??e.data.status,kind:"feature"})):[],[Y,eY,e5,tI]);function ns(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,a.jsx)(ed.Provider,{value:eO,children:(0,a.jsxs)("div",{className:(0,ek.cn)("canvas-dots relative w-full",b?"h-full":"h-screen",em&&"rf-panning"),onDragOver:e=>{e.dataTransfer.types.includes("application/beacon-node")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDrop:e=>{if(!e.dataTransfer.getData("application/beacon-node")||!ew.current)return;e.preventDefault();let{x:t,y:n}=ew.current.screenToFlowPosition({x:e.clientX,y:e.clientY});eM(t,n,"BUG"===e.dataTransfer.getData("application/beacon-node-kind")?"BUG":"FEATURE")},children:[(0,a.jsxs)(l.Gc,{...en,className:(0,ek.cn)(ea,(es||ej)&&"rf-placing"),nodes:tQ,edges:"far"===eU?[...tB,...t0].map(e=>({...e,hidden:!0})):[...tB,...t0],nodeTypes:tk,edgeTypes:tN,nodesConnectable:!R,connectionMode:o.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{ew.current=e},onNodesChange:t1,onEdgesChange:t5,onMoveStart:()=>ep(!0),onMoveEnd:()=>ep(!1),onConnect:t2,onConnectEnd:t4,onNodeMouseEnter:(e,t)=>W(t.id),onNodeMouseLeave:()=>W(null),onEdgesDelete:e=>{for(let t of e)t.id.startsWith("c-")||fetch(`/api/edges/${t.id}`,{method:"DELETE"})},onNodesDelete:e=>{for(let t of e)t.id.startsWith("anno-")||(fetch(`/api/nodes/${t.id}`,{method:"DELETE"}),G(e=>e===t.id?null:e))},onNodeClick:(e,t)=>{if(es)return void eT(e.clientX,e.clientY);if("annotation"===t.type){let e=t.data;e.editable||E?.(e.annotationId);return}if(ej){if(ev(!1),t.data.isChild)return;t3(t,t.position.x+300,t.position.y+60);return}let n=_===t.id;if(G(t.id),X(null),Q("details"),b){let t=e.target,a=t?.closest("input, textarea, select, button, [role='combobox']"),s=D&&!n&&!ex.current;a||s||J(!0)}},onEdgeClick:(e,t)=>{X(t.id),G(null),Q("details")},onPaneClick:e=>{es?eT(e.clientX,e.clientY):ej?ev(!1):(J(!1),G(null),X(null))},onNodeDragStop:(e,t)=>{if(t.id.startsWith("anno-")){tU&&tZ(t.id.slice(5),{x:t.position.x,y:t.position.y});return}R||t9(t.id,t.position.x,t.position.y)},deleteKeyCode:R?null:["Backspace","Delete"],colorMode:"dark",fitView:!0,fitViewOptions:{padding:.15,minZoom:.38,maxZoom:.9},minZoom:.2,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,a.jsx)(tj.Z,{regions:tF,tone:tY,lod:eU}),(0,a.jsx)(eu.J,{onLod:e_}),(0,a.jsx)(l.H2,{position:"bottom-right",className:"!overflow-hidden !rounded-xl !border !border-white/10 [&_button]:!border-white/10 [&_button]:!bg-card/70 [&_button]:!text-foreground [&_button]:!backdrop-blur"}),(0,a.jsx)(l.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,a.jsx)(tr.H,{tool:ee,onChange:et})}),(0,a.jsx)(l.Zk,{position:"bottom-right",style:{marginBottom:152},children:(0,a.jsx)(tx.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,ek.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(i.A,{className:"size-4"})}),children:(0,a.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:["ROADMAP"===e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-sky-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"feature"}),(0,a.jsx)("span",{children:"top-level card \xb7 can have sub-tasks"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-zinc-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-zinc-300",children:"sub-task"}),(0,a.jsx)("span",{children:"child of a feature"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-rose-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-rose-300",children:"bug"}),(0,a.jsx)("span",{children:"a bug to fix \xb7 not a feature"})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-sky-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"component"}),(0,a.jsx)("span",{children:"a subsystem \xb7 can have sub-components"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-zinc-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-zinc-300",children:"sub-component"}),(0,a.jsx)("span",{children:"part of a component"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded bg-rose-500/15 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-rose-300",children:"bug"}),(0,a.jsx)("span",{children:"a flagged issue on a component"})]})]}),z&&(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-3 w-1 shrink-0 rounded-sm",style:{background:(0,el.A6)("fullstack")}}),(0,a.jsx)("span",{children:"left stripe \xb7 frontend / backend layer"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#33333a]"}),(0,a.jsx)("span",{children:"contains \xb7 drag the bottom handle to empty canvas"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#f5b942"}}),(0,a.jsxs)("span",{children:["depends on \xb7 drag between two ","ROADMAP"===e?"cards":"components"]})]})]})})}),!b&&(0,a.jsx)(l.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:e=>e.data?.priority===0?"#ff3860":"#555"}),!b&&(0,a.jsxs)(l.Zk,{position:"bottom-center",className:"!mb-4 flex flex-col items-center gap-2",children:[ej&&(0,a.jsxs)("div",{className:"glass rounded-full px-3 py-1 text-[11px] text-muted-foreground",children:["Click a ","ARCHITECTURE"===e?"component":"feature"," to attach the"," ","ARCHITECTURE"===e?"sub-component":"sub-task"," \xb7 Esc to cancel"]}),"ARCHITECTURE"===e&&(0,a.jsx)("div",{className:"glass flex items-center rounded-full p-0.5",children:(0,a.jsxs)("button",{onClick:nn,title:"Arrange components into a left→right dependency flow, grouped by domain",className:"flex h-6 items-center gap-1.5 rounded-full px-3 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:"size-3"}),"Arrange"]})}),"ROADMAP"===e&&(0,a.jsxs)("div",{className:"glass flex items-center gap-1 rounded-full p-1",children:[(0,a.jsx)("span",{className:"pl-2 pr-0.5 text-[11px] text-muted-foreground",children:"Group by"}),tv.map(e=>(0,a.jsx)("button",{onClick:()=>t8(e.value),title:`Arrange features into lanes by ${e.label.toLowerCase()}`,className:(0,ek.cn)("h-7 rounded-full px-2.5 text-[11px] font-medium transition-colors",eL===e.value?"bg-white/[0.12] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:e.label},e.value))]}),(0,a.jsxs)("div",{className:"glass flex items-center gap-1 rounded-full p-1",children:[(0,a.jsxs)("button",{onClick:ez,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("application/beacon-node",e),t.dataTransfer.effectAllowed="copy"},title:"ARCHITECTURE"===e?"Add component (click, or drag onto the board to place it)":"Add feature (click, or drag onto the board to place it)",className:"flex h-8 cursor-grab items-center gap-1.5 rounded-full px-3 text-[12px] font-medium text-foreground transition-colors hover:bg-white/[0.06] active:cursor-grabbing",children:[(0,a.jsx)(c.A,{className:"size-3.5 text-[var(--accent-2,#ff7a45)]"}),"ARCHITECTURE"===e?"Component":"Feature"]}),"ROADMAP"===e&&(0,a.jsxs)("button",{onClick:eR,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("application/beacon-node",e),t.dataTransfer.setData("application/beacon-node-kind","BUG"),t.dataTransfer.effectAllowed="copy"},title:"Add bug (click, or drag onto the board to place it)",className:"flex h-8 cursor-grab items-center gap-1.5 rounded-full px-3 text-[12px] font-medium text-foreground transition-colors hover:bg-white/[0.06] active:cursor-grabbing",children:[(0,a.jsx)(u.A,{className:"size-3.5 text-rose-400"}),"Bug"]}),(0,a.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-5 w-px bg-white/10"}),(0,a.jsxs)("button",{onClick:()=>{er(null),ev(e=>!e)},title:"ARCHITECTURE"===e?"Add sub-component (click a component next)":"Add sub-task (click a feature next)",className:(0,ek.cn)("flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-medium transition-colors",ej?"bg-white/[0.1] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,a.jsx)(m.A,{className:"size-3.5"}),"ARCHITECTURE"===e?"Sub-component":"Sub-task"]})]})]}),!b&&tT.length>0&&!tR.active&&(0,a.jsx)(l.Zk,{position:"top-left",className:"!mt-14",children:(0,a.jsxs)("button",{type:"button",onClick:tR.start,title:"Guided, domain-by-domain walkthrough of the architecture",className:"glass flex items-center gap-1.5 rounded-xl px-3 py-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:[(0,a.jsx)(p.A,{className:"size-3.5"}),"Start tour"]})}),!b&&(0,a.jsx)(l.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,a.jsx)(tl.Z,{active:e,tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,a.jsxs)(l.Zk,{position:"top-right",className:(0,ek.cn)("flex items-center gap-1 transition-[margin] duration-200",V&&"!mr-[332px]",b&&"hidden"),children:[(0,a.jsx)(ti.X,{query:eY,onQuery:eB,hits:na,placeholder:"Find a feature…",onPick:e=>{eB(""),t7(e)},onZoomToMatches:()=>{tM?.size&&ew.current?.fitView({nodes:[...tM].map(e=>({id:e})),duration:600,padding:.2})}}),"ROADMAP"===e&&O&&(0,a.jsx)("button",{type:"button",onClick:()=>t7(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,a.jsx)(x.A,{className:"size-4"})}),(0,a.jsx)(td.e,{defaultSelection:e}),(0,a.jsxs)(tx.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,ek.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||e2>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(h.A,{className:"size-4"}),e2>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)] px-1 text-[9px] font-semibold text-white",children:e2})]}),children:[z&&(0,a.jsx)(tx.r1,{title:"Layer",children:(0,a.jsx)(th.o,{bare:!0,value:eJ,onChange:eq})}),eQ.length>0&&(0,a.jsx)(tx.r1,{title:"Status",children:eQ.map(e=>(0,a.jsx)(tx.vu,{on:eG.has(e),onClick:()=>ns(e,eK),children:eo.nR[e]?.label??e},e))}),e0.length>0&&(0,a.jsx)(tx.r1,{title:"Cluster",children:e0.map(e=>(0,a.jsx)(tx.vu,{on:eX.has(e),onClick:()=>ns(e,eZ),children:e},e))}),e1.length>0&&(0,a.jsx)(tx.r1,{title:"Priority",children:e1.map(e=>(0,a.jsxs)(tx.vu,{on:eW.has(e),onClick:()=>ns(e,eV),children:["P",e]},e))}),e2>0&&(0,a.jsx)("button",{type:"button",onClick:e3,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"})]}),!V&&(0,a.jsx)("button",{onClick:()=>{J(!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,a.jsx)(f.A,{className:"size-4"})})]})]}),V&&(0,a.jsx)(e8,{view:e,selected:t6,allNodes:t,onClose:()=>{J(!1),Q("details")},commentsContent:j,commentsCount:v,activeTab:q,onTabChange:Q,onAddComment:tV,topOffset:b?64:void 0}),(0,a.jsx)(ts,{payload:eD,onDismiss:()=>e$(null)}),(es||ej)&&ei&&(0,a.jsxs)("div",{className:"pointer-events-none fixed z-50 flex translate-x-3 translate-y-3 items-center gap-1.5 rounded-lg border border-white/15 bg-card/95 px-2.5 py-1.5 text-xs shadow-xl backdrop-blur",style:{left:ei.x,top:ei.y},children:[(0,a.jsx)("span",{className:(0,ek.cn)("rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide","BUG"===es?"bg-rose-500/15 text-rose-300":"FEATURE"===es?"bg-sky-500/15 text-sky-300":"bg-zinc-500/15 text-zinc-300"),children:"BUG"===es?"Bug":"FEATURE"===es?"ARCHITECTURE"===e?"Component":"Feature":"Sub-task"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:es?"click to place \xb7 Esc":"click a feature to attach \xb7 Esc"})]}),tR.active&&tR.step&&(0,a.jsx)(tp.d,{steps:tT,index:tR.index,onPrev:tR.prev,onNext:tR.next,onExit:tR.stop,onGoto:tR.goto})]})})}},4474:(e,t,n)=>{n.d(t,{$:()=>i});var a=n(95155),s=n(6539),r=n(18460),o=n(91337);let l=(0,r.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function i({className:e,variant:t="default",size:n="default",...r}){return(0,a.jsx)(s.Button,{"data-slot":"button",className:(0,o.cn)(l({variant:t,size:n,className:e})),...r})}},9991:(e,t,n)=>{n.d(t,{X:()=>c});var a=n(95155),s=n(12115),r=n(65377),o=n(9005),l=n(91337),i=n(56614);function d(e){if(!e||!e.tagName)return!1;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t||e.isContentEditable}function c({query:e,onQuery:t,hits:n,onPick:u,onZoomToMatches:m,placeholder:p="Search…"}){let[x,h]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let e=e=>{x||e.metaKey||e.ctrlKey||e.altKey||1!==e.key.length||" "===e.key||d(e.target)||d(document.activeElement)||(e.preventDefault(),h(!0),t(e.key))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,t]),(0,a.jsxs)(i.er,{title:"Search",open:x,onOpenChange:e=>e?h(!0):void(h(!1),t("")),outsideClicksToClose:2,trigger:(t,n)=>(0,a.jsx)("button",{type:"button",onClick:n,title:"Search this canvas",className:(0,l.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",t||e.trim()?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(r.A,{className:"size-4"})}),children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{autoFocus:!0,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{"Enter"===e.key&&m&&(e.preventDefault(),m())},placeholder:p,className:"w-full rounded-md border border-white/10 bg-white/[0.04] py-1 pl-2 pr-7 text-[12px] outline-none placeholder:text-muted-foreground/50 focus:bg-white/[0.08]"}),e&&(0,a.jsx)("button",{type:"button",onClick:()=>t(""),title:"Clear search",className:"absolute right-1 top-1/2 flex size-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(o.A,{className:"size-3.5"})})]}),(0,a.jsxs)("div",{className:"mt-2 max-h-64 space-y-0.5 overflow-y-auto",children:[e.trim()&&0===n.length&&(0,a.jsx)("div",{className:"px-1 py-1 text-[11px] text-muted-foreground",children:"No matches"}),n.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{u(e.id),h(!1)},className:"group flex w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors hover:bg-white/5",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] text-muted-foreground transition-colors group-hover:text-foreground",children:e.label}),e.sublabel&&(0,a.jsx)("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground/50",children:e.sublabel})]},e.id))]})]})}},12410:(e,t,n)=>{n.d(t,{a2:()=>o,i3:()=>d,xZ:()=>l});let a=["bg-emerald-500/15 text-emerald-300","bg-sky-500/15 text-sky-300","bg-violet-500/15 text-violet-300","bg-amber-500/15 text-amber-200","bg-rose-500/15 text-rose-300","bg-cyan-500/15 text-cyan-300","bg-fuchsia-500/15 text-fuchsia-300","bg-lime-500/15 text-lime-300","bg-orange-500/15 text-orange-300","bg-teal-500/15 text-teal-300","bg-indigo-500/15 text-indigo-300","bg-pink-500/15 text-pink-300"],s=["border-emerald-500/20 bg-emerald-500/[0.04]","border-sky-500/20 bg-sky-500/[0.04]","border-violet-500/20 bg-violet-500/[0.04]","border-amber-500/20 bg-amber-500/[0.04]","border-rose-500/20 bg-rose-500/[0.04]","border-cyan-500/20 bg-cyan-500/[0.04]","border-fuchsia-500/20 bg-fuchsia-500/[0.04]","border-lime-500/20 bg-lime-500/[0.04]","border-orange-500/20 bg-orange-500/[0.04]","border-teal-500/20 bg-teal-500/[0.04]","border-indigo-500/20 bg-indigo-500/[0.04]","border-pink-500/20 bg-pink-500/[0.04]"];function r(e){let t=(e??"").trim().toUpperCase();if(!t)return null;let n=0;for(let e=0;e<t.length;e++)n=31*n+t.charCodeAt(e)>>>0;return n%a.length}function o(e){let t=r(e);return null===t?"bg-white/[0.06] text-muted-foreground":a[t]}function l(e){let t=r(e);return null===t?"border-white/10 bg-white/[0.02]":s[t]}let i=["#34d399","#38bdf8","#a78bfa","#fbbf24","#fb7185","#22d3ee","#e879f9","#a3e635","#fb923c","#2dd4bf","#818cf8","#f472b6"];function d(e){let t=r(e);return null===t?"#9ca3af":i[t]}},14983:(e,t,n)=>{n.d(t,{$$:()=>o,Qk:()=>r,RU:()=>a,Uy:()=>s,jF:()=>l,r2:()=>c,sQ:()=>i,zn:()=>d});let a="0 0 0 3px var(--accent-2,#ff7a45), 0 0 32px -2px var(--accent-2,#ff7a45)",s=.14;function r(e,t){let n=t.trim().toLowerCase();if(!n)return!1;for(let t of e)if(t&&t.toLowerCase().includes(n))return!0;return!1}function o(e){return[e.title,e.role,e.plain,e.cluster,e.status].filter(Boolean)}function l(e){let t=[e.name,e.domain,e.description];for(let n of e.columns??[])t.push(n.name,n.type,n.note);return t.filter(Boolean)}function i(e){return[e.method,e.path,e.domain,e.description].filter(Boolean)}function d(e){return[e.path,e.lang].filter(Boolean)}function c(e,t,n,a,s=12){let o=t.trim().toLowerCase();if(!o)return[];let l=[];for(let t of e){if(!r(n(t),o))continue;let e=a(t);l.push({hit:e,score:function(e,t){let n=e.toLowerCase();return n===t?0:n.startsWith(t)?1:RegExp(`(^|[^a-z0-9])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"i").test(e)?2:n.includes(t)?3:4}(e.label,o)})}return l.sort((e,t)=>e.score-t.score||e.hit.label.length-t.hit.label.length),l.slice(0,s).map(e=>e.hit)}},16607:(e,t,n)=>{n.d(t,{d:()=>c});var a=n(95155),s=n(24413),r=n(9005),o=n(78780),l=n(76721),i=n(82099),d=n(91337);function c({steps:e,index:t,onPrev:n,onNext:u,onExit:m,onGoto:p}){let x=e[t];if(!x)return null;let h=t===e.length-1;return(0,a.jsxs)(i.b,{className:"absolute bottom-3 left-3 top-16 z-10 flex w-72 flex-col rounded-2xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,a.jsx)(s.A,{className:"size-3.5"}),"Guided tour"]}),(0,a.jsx)("button",{onClick:m,title:"End tour (Esc)",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(r.A,{className:"size-4"})})]}),(0,a.jsxs)("div",{className:"border-b border-white/10 px-3.5 py-3",children:[(0,a.jsxs)("div",{className:"text-[10px] font-medium uppercase tracking-wide text-[var(--accent-2,#ff7a45)]",children:["Step ",t+1," / ",e.length]}),(0,a.jsx)("h2",{className:"mt-1 break-words text-sm font-semibold leading-tight",children:x.title}),(0,a.jsx)("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:x.summary})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:(0,a.jsx)("ol",{className:"space-y-0.5",children:e.map((e,n)=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{onClick:()=>p(n),title:e.title,className:(0,d.cn)("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",n===t?"bg-white/[0.08] text-foreground":"text-muted-foreground hover:bg-white/[0.04] hover:text-foreground"),children:[(0,a.jsx)("span",{className:(0,d.cn)("flex size-4 shrink-0 items-center justify-center rounded-full text-[9px] font-bold",n===t?"bg-[var(--accent-2,#ff7a45)] text-background":"bg-white/10 text-muted-foreground"),children:n+1}),(0,a.jsx)("span",{className:"truncate text-[11px]",children:e.title})]})},e.id))})}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-white/10 p-2",children:[(0,a.jsxs)("button",{onClick:n,disabled:0===t,className:"flex items-center gap-1 rounded-md px-2 py-1.5 text-[11px] text-muted-foreground transition-colors enabled:hover:bg-white/[0.06] enabled:hover:text-foreground disabled:opacity-40",children:[(0,a.jsx)(o.A,{className:"size-3.5"})," Prev"]}),h?(0,a.jsx)("button",{onClick:m,className:"rounded-md bg-[var(--accent-2,#ff7a45)]/90 px-3 py-1.5 text-[11px] font-semibold text-background transition-colors hover:bg-[var(--accent-2,#ff7a45)]",children:"Done"}):(0,a.jsxs)("button",{onClick:u,className:"flex items-center gap-1 rounded-md bg-white/10 px-3 py-1.5 text-[11px] font-semibold text-foreground transition-colors hover:bg-white/[0.16]",children:["Next ",(0,a.jsx)(l.A,{className:"size-3.5"})]})]})]})}},17918:(e,t,n)=>{n.d(t,{Sh:()=>c,V5:()=>d,e0:()=>m});var a=n(95155),s=n(12115),r=n(81750),o=n(6266),l=n(9005),i=n(91337);let d="#ff7a45";function c({data:e,selected:t}){let[n,u]=(0,s.useState)(e.text);return(0,s.useEffect)(()=>{u(e.text)},[e.text]),(0,a.jsxs)("div",{onClick:()=>e.onClick?.(e.annotationId),className:(0,i.cn)("group/anno relative w-[270px] rounded-xl border border-white/10 bg-[#1b1b1e]/95 px-4 py-3 shadow-[0_18px_50px_-20px_rgba(0,0,0,0.9)] backdrop-blur transition-colors hover:border-white/20",!e.editable&&"cursor-pointer",t&&"border-[#ff7a45]/50"),children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute -left-px bottom-2 top-2 w-[3px] rounded-full",style:{background:d}}),(0,a.jsx)(r.h7,{type:"target",id:"in",position:o.yX.Top,isConnectable:!1,className:"!pointer-events-none !size-1 !min-h-0 !min-w-0 !border-0 !bg-transparent",style:{left:"auto",right:22,top:0}}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.22em]",style:{color:d},children:"Annotation \xb7 You"}),e.editable&&e.onDelete&&(0,a.jsx)("button",{type:"button",title:"Delete annotation",onClick:t=>{t.stopPropagation(),e.onDelete?.(e.annotationId)},className:"nodrag nopan -mr-1 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity hover:text-red-300 group-hover/anno:opacity-100",children:(0,a.jsx)(l.A,{className:"size-3"})})]}),e.editable?(0,a.jsx)("textarea",{value:n,autoFocus:!e.text.trim(),placeholder:"Type your annotation…",onChange:e=>u(e.target.value),onBlur:()=>{n!==e.text&&e.onChangeText?.(e.annotationId,n)},onKeyDown:e=>e.stopPropagation(),className:"nodrag nopan field-sizing-content mt-1.5 max-h-40 min-h-[2.25rem] w-full resize-none overflow-y-auto bg-transparent text-[13px] leading-snug text-foreground/95 outline-none placeholder:text-muted-foreground/60"}):(0,a.jsx)("div",{className:"mt-1.5 max-h-40 overflow-y-auto text-[13px] leading-snug text-foreground/95",children:e.text.trim()?e.text:(0,a.jsx)("span",{className:"text-muted-foreground",children:"…"})})]})}function u({n:e,annotationId:t,onClick:n}){return(0,a.jsxs)("button",{type:"button",title:`Annotation ${e} — view comment`,onClick:e=>{e.stopPropagation(),n?.(t)},className:"nodrag nopan relative flex size-6 items-center justify-center rounded-full font-mono text-[11px] font-bold text-[#181818] shadow-[0_0_0_3px_rgba(255,122,69,0.22),0_0_16px_2px_rgba(255,122,69,0.4)] transition-transform hover:scale-110",style:{background:d},children:[e,(0,a.jsx)(r.h7,{type:"source",id:`pin-${t}`,position:o.yX.Bottom,isConnectable:!1,className:"!pointer-events-none !size-1 !min-h-0 !min-w-0 !border-0 !bg-transparent",style:{left:"50%",bottom:2}})]})}function m({pins:e,onPinClick:t}){return e.length?(0,a.jsx)("span",{className:"absolute -right-3 top-1/2 z-10 flex -translate-y-1/2 flex-row-reverse gap-1",children:e.map(e=>(0,a.jsx)(u,{n:e.n,annotationId:e.id,onClick:t},e.id))}):null}},18874:(e,t,n)=>{n.d(t,{F1:()=>l,e6:()=>r,qA:()=>s,ru:()=>o});let a={auth:"#4ea1ff",firms:"#c792ea",search:"#7bd389",storage:"#ffb86b",petitions:"#ff7a45",monitoring:"#f5b942",admin:"#ff6b9d"};function s(e){return e&&a[e]||"#8a8a8a"}let r={GET:"#7bd389",POST:"#4ea1ff",PUT:"#ffb86b",PATCH:"#ffb86b",DELETE:"#ff3860"},o={read:"#4ea1ff",write:"#ffb86b","read-write":"#c792ea"};function l(e,t){let n=new Set([e]);for(let a of t)a.source===e&&n.add(a.target),a.target===e&&n.add(a.source);return n}},24692:(e,t,n)=>{n.d(t,{I:()=>i});var a=n(95155),s=n(81750),r=n(6266),o=n(65738),l=n(28736);function i(e){let{deleteElements:t}=(0,s.VH)(),n=(0,s.JY)(e.source),i=(0,s.JY)(e.target),d=n&&i?(0,l.U)(n,i):null,[c,u,m]=(0,r.Fp)(d?{sourceX:d.sx,sourceY:d.sy,sourcePosition:d.sourcePos,targetX:d.tx,targetY:d.ty,targetPosition:d.targetPos}:{sourceX:e.sourceX,sourceY:e.sourceY,sourcePosition:e.sourcePosition,targetX:e.targetX,targetY:e.targetY,targetPosition:e.targetPosition});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.tE,{id:e.id,path:c,style:e.style,markerEnd:e.markerEnd,interactionWidth:20}),e.label&&(0,a.jsx)(s.rV,{children:(0,a.jsx)("div",{style:{position:"absolute",transform:`translate(-50%, -120%) translate(${u}px, ${m}px)`,fontSize:11,color:"#cfcfcf",background:"#161616",padding:"1px 4px",borderRadius:4,pointerEvents:"none",zIndex:1e3},children:e.label})}),e.selected&&(0,a.jsx)(s.rV,{children:(0,a.jsx)("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, 0) translate(${u}px, ${m+14}px)`,pointerEvents:"all",zIndex:1e3},children:(0,a.jsx)("button",{type:"button",onMouseDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),t({edges:[{id:e.id}]})},title:"Delete (or press Backspace)",className:"flex size-7 items-center justify-center rounded-full border border-white/20 bg-card/95 text-red-300 shadow-lg backdrop-blur-md transition-colors hover:bg-red-500/25 hover:text-red-200",children:(0,a.jsx)(o.A,{className:"size-3.5"})})})})]})}},28161:(e,t,n)=>{n.d(t,{A6:()=>i,An:()=>d,RR:()=>a,YG:()=>o,ZD:()=>l,jR:()=>r});let a=["frontend","backend","fullstack"],s={fe:"frontend",front:"frontend",be:"backend",back:"backend",fs:"fullstack","full-stack":"fullstack","full stack":"fullstack"};function r(e){let t=(e??"").trim().toLowerCase();return t?a.includes(t)?t:s[t]??null:null}let o={frontend:{label:"Frontend",short:"FE"},backend:{label:"Backend",short:"BE"},fullstack:{label:"Fullstack",short:"FS"}},l={frontend:"#5AC8FA",backend:"#3ECF8E",fullstack:"#5AC8FA"};function i(e){return"fullstack"!==e?l[e]:`linear-gradient(to bottom, ${l.frontend} 0%, ${l.frontend} 50%, ${l.backend} 50%, ${l.backend} 100%)`}let d=/\.(tsx|jsx|vue|svelte)$/i},28736:(e,t,n)=>{n.d(t,{U:()=>l,u:()=>i});var a=n(6266);function s(e){let{x:t,y:n}=e.internals.positionAbsolute,a=e.measured?.width??0,s=e.measured?.height??0;return{x:t,y:n,w:a,h:s,cx:t+a/2,cy:n+s/2}}function r(e,t){let n=s(e),a=s(t),r=n.w/2||1,o=n.h/2||1,l=(a.cx-n.cx)/(2*r)-(a.cy-n.cy)/(2*o),i=(a.cx-n.cx)/(2*r)+(a.cy-n.cy)/(2*o),d=1/(Math.abs(l)+Math.abs(i)||1);return{x:r*d*(l+i)+n.cx,y:o*d*(-l+i)+n.cy}}function o(e,t){let n=s(e),r=Math.round(t.x),o=Math.round(t.y);return r<=Math.round(n.x)+1?a.yX.Left:r>=Math.round(n.x+n.w)-1?a.yX.Right:o<=Math.round(n.y)+1?a.yX.Top:a.yX.Bottom}function l(e,t){let n=r(e,t),a=r(t,e);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o(e,n),targetPos:o(t,a)}}function i(e,t){let n=e.x+e.w/2,a=e.y+e.h/2,s=t.x-n,r=t.y-a;if(0===s&&0===r)return{x:n,y:a};let o=1/Math.max(Math.abs(s)/(e.w/2||1),Math.abs(r)/(e.h/2||1));return{x:n+s*o,y:a+r*o}}},29523:(e,t,n)=>{n.d(t,{J:()=>l,k:()=>o});var a=n(12115),s=n(81750),r=n(70221);function o(e){let[t,n]=(0,a.useState)("full"),o=(0,s.Pj)(n=>(0,r.gt)(n.transform[2],t,e));return o!==t&&n(o),o}function l({onLod:e,thresholds:t}){let n=o(t),s=(0,a.useRef)(null);return(0,a.useEffect)(()=>{s.current!==n&&(s.current=n,e(n))},[n,e]),null}},36849:(e,t,n)=>{n.d(t,{VI:()=>o});var a=n(43137),s=n(94014);function r(e,t,n){let a,s;return null==e.title?n:Math.max(n,(s=66+(((a=(e.title??"").trim())?Math.max(1,Math.ceil(a.length/17)):1)-1)*19,e.role&&e.role.trim()&&(s+=16),t>0&&(s+=22),s+24))}function o(e,t,n={}){let l=n.colW??320,i=n.rowH??150,d=n.childIndent??24,c=n.laneGap??56,u=n.bandGap??110,m=n.maxCols??10,p=n.minBandW??3*l,x=new Set(e.map(e=>e.id)),h=e=>!e.parentId||!x.has(e.parentId),f=e.filter(h),g=new Map;for(let t of e){if(h(t))continue;let e=g.get(t.parentId);e?e.push(t):g.set(t.parentId,[t])}let b="status"===t?e=>e.status:"priority"===t?e=>String(e.priority):e=>(e.cluster??"").trim()||"—",y=new Map;for(let e of f){let t=b(e),n=y.get(t);n?n.push(e):y.set(t,[e])}let j=(function(e,t,n){if("status"===e)return[...a.TT];if("priority"===e)return["0","1","2","3"];let s=Array.from(new Set(t.map(n))),r=s.filter(e=>"—"!==e).sort();return s.includes("—")?[...r,"—"]:r})(t,f,b).filter(e=>y.has(e)),v=[];for(let e of j){let t=y.get(e),n=t.reduce((e,t)=>e+1+(g.get(t.id)?.length??0),0),a=Math.max(1,Math.min(m,t.length,Math.round(Math.sqrt(.85*n))||1)),s=Array(a).fill(0),o=new Map;for(let e of t){let t=0;for(let e=1;e<a;e++)s[e]<s[t]&&(t=e);let n=t*l,c=s[t];o.set(e.id,{x:n,y:c});let u=g.get(e.id)??[],m=c+r(e,u.length,i);for(let e of u)o.set(e.id,{x:n+d,y:m}),m+=r(e,0,i);s[t]=m}let c=s.reduce((e,t)=>Math.max(e,t),0);v.push({id:e,w:a*l,h:c,local:o})}let w=(0,s.Xi)(v.map(e=>({id:e.id,w:e.w,h:e.h})),{gapX:c,gapY:u,viewportAspect:n.viewportAspect,minBandW:p,aspectSlack:1.5}),k=new Map;for(let e of v){let t=w.get(e.id);for(let[n,a]of e.local)k.set(n,{x:t.x+a.x,y:t.y+a.y})}return k}},40654:(e,t,n)=>{n.d(t,{e:()=>A});var a=n(95155),s=n(12115),r=n(5937),o=n(92571),l=n(74350),i=n(4474),d=n(91337),c=n(5989);let u=["ROADMAP","ARCHITECTURE","DATABASE"],m=c.k5(u),p=c.Ik({name:c.Yj(),type:c.Yj(),isPk:c.zM(),isFk:c.zM(),nullable:c.zM(),note:c.Yj().nullable()}),x=c.Ik({id:c.Yj(),view:c.Yj(),kind:c.Yj(),cluster:c.Yj().nullable(),layer:c.Yj().nullable(),title:c.Yj(),role:c.Yj().nullable(),plain:c.Yj().nullable(),status:c.Yj(),priority:c.ai(),x:c.ai(),y:c.ai(),source:c.Yj(),sourceRef:c.Yj().nullable(),parentId:c.Yj().nullable(),isCriterion:c.zM(),files:c.YO(c.Yj()),signals:c.bz().optional(),bugFlags:c.YO(c.bz())}),h=c.Ik({id:c.Yj(),fromId:c.Yj(),toId:c.Yj(),kind:c.Yj(),label:c.Yj().nullable(),sourceHandle:c.Yj().nullable(),targetHandle:c.Yj().nullable()}),f=c.Ik({nodes:c.YO(x),edges:c.YO(h),hasFrontend:c.zM()}),g=c.Ik({id:c.Yj(),name:c.Yj(),domain:c.Yj().nullable(),description:c.Yj().nullable(),source:c.Yj(),x:c.ai(),y:c.ai(),columns:c.YO(p)}),b=c.Ik({id:c.Yj(),fromTableId:c.Yj(),toTableId:c.Yj(),fromColumn:c.Yj(),toColumn:c.Yj(),label:c.Yj().nullable()}),y=c.Ik({id:c.Yj(),method:c.Yj(),path:c.Yj(),domain:c.Yj().nullable(),description:c.Yj().nullable(),source:c.Yj(),x:c.ai(),y:c.ai(),tables:c.YO(c.Ik({tableId:c.Yj(),access:c.Yj()}))}),j=c.Ik({proposedAt:c.ai(),status:c.Yj(),tables:c.YO(c.bz()),relations:c.YO(c.bz()),endpoints:c.YO(c.bz())}).nullable(),v=c.Ik({tables:c.YO(g),relations:c.YO(b),endpoints:c.YO(y),draft:j}),w=c.Ik({kind:c.eu("boards"),version:c.eu(1),createdAt:c.ai(),workspaceLabel:c.Yj(),selectedTabs:c.YO(m).min(1),roadmap:f.optional(),architecture:f.optional(),database:v.optional()}),k=c.Ik({kind:c.eu("plan"),version:c.eu(1),createdAt:c.ai(),workspaceLabel:c.Yj(),title:c.Yj(),markdown:c.Yj(),verdict:c.k5(["approved","discarded"]).nullable(),roadmap:f.optional(),draft:j.optional()});c.gM("kind",[w,k]);var N=n(89793),C=n(96719);let E=[{value:"ALL",label:"All"},{value:"ROADMAP",label:"Roadmap"},{value:"ARCHITECTURE",label:"Architecture"},{value:"DATABASE",label:"Database"}];function A({defaultSelection:e="ALL"}){let[t,n]=(0,s.useState)(!1),[c,m]=(0,s.useState)(e),{status:p,url:x,error:h,copied:f,mint:g,copy:b,reset:y}=(0,N.b)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",title:"Share a read-only link to these boards",onClick:function(){m(e),y(),n(!0)},className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(r.A,{className:"size-4"})}),(0,a.jsx)(l.lG,{open:t,onOpenChange:n,children:(0,a.jsxs)(l.Cf,{children:[(0,a.jsxs)(l.c7,{children:[(0,a.jsx)(l.L3,{children:"Share a read-only link"}),(0,a.jsx)(l.rr,{children:"Anyone with the link can view these boards — no Beacon needed. Links expire after 7 days."})]}),"done"===p?(0,a.jsx)(C.F,{url:x,copied:f,onCopy:b}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex rounded-lg border border-white/10 bg-background/40 p-0.5",children:E.map(e=>(0,a.jsx)("button",{onClick:()=>m(e.value),className:(0,d.cn)("flex-1 rounded-md px-1.5 py-1.5 text-[11px] font-medium transition-colors",c===e.value?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:e.label},e.value))}),"error"===p&&(0,a.jsx)("p",{className:"text-[12px] text-red-400",children:h}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(i.$,{size:"sm",onClick:function(){g({kind:"boards",tabs:"ALL"===c?[...u]:[c]})},disabled:"loading"===p,children:"loading"===p?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.A,{className:"size-3.5 animate-spin"})," Creating…"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.A,{className:"size-3.5"})," Create link"]})})})]})]})})]})}},43137:(e,t,n)=>{n.d(t,{TT:()=>r,Xf:()=>l,m6:()=>s,nR:()=>o,yl:()=>a});let a=["PENDING","IN_PROGRESS","DONE","BLOCKED","CANCELLED","DEPRIORITIZED"],s=["KEEP","REBUILD","REPLACE","DROP"],r=["IN_PROGRESS","PENDING","BLOCKED","DONE","DEPRIORITIZED","CANCELLED"],o={DONE:{label:"Done",className:"border-emerald-500/30 bg-emerald-500/15 text-emerald-300"},IN_PROGRESS:{label:"In progress",className:"border-sky-500/30 bg-sky-500/15 text-sky-300"},PENDING:{label:"Pending",className:"border-amber-500/30 bg-amber-500/10 text-amber-200"},BLOCKED:{label:"Blocked",className:"border-orange-500/30 bg-orange-500/15 text-orange-300"},CANCELLED:{label:"Cancelled",className:"border-zinc-500/30 bg-zinc-500/10 text-zinc-400 line-through"},DEPRIORITIZED:{label:"Deprioritized",className:"border-zinc-600/40 bg-zinc-600/10 text-zinc-400"},KEEP:{label:"Keep",className:"border-emerald-500/30 bg-emerald-500/15 text-emerald-300"},REBUILD:{label:"Rebuild",className:"border-violet-500/30 bg-violet-500/15 text-violet-300"},REPLACE:{label:"Replace",className:"border-rose-500/30 bg-rose-500/15 text-rose-300"},DROP:{label:"Drop",className:"border-zinc-500/30 bg-zinc-500/10 text-zinc-400 line-through"}};function l(e){return e?.trim()||"—"}},44267:(e,t,n)=>{n.d(t,{S:()=>a});function a(e,t={}){let n=t.pad??20,s=t.header??26,r=new Map;for(let t of e){let e=r.get(t.group);e?(e.minX=Math.min(e.minX,t.x),e.minY=Math.min(e.minY,t.y),e.maxX=Math.max(e.maxX,t.x+t.w),e.maxY=Math.max(e.maxY,t.y+t.h),e.count++):r.set(t.group,{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h,count:1})}return Array.from(r.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:e,label:e,x:t.minX-n,y:t.minY-n-s,w:t.maxX-t.minX+2*n,h:t.maxY-t.minY+2*n+s,count:t.count}))}},44853:(e,t,n)=>{n.d(t,{DbMapClient:()=>ev});var a=n(95155),s=n(12115),r=n(80277),o=n(73321),l=n(81750),i=n(6266);n(53255);var d=n(32133),c=n(81499),u=n(51128),m=n(65738),p=n(9005),x=n(2125),h=n(91337),f=n(18874);let g=(0,s.createContext)(null);function b(){let e=(0,s.useContext)(g);if(!e)throw Error("useDbEdit must be used inside DbEditContext");return e}var y=n(29523),j=n(70221),v=n(95635),w=n(17918);let k={danger:"bg-red-500/15 text-red-300",warn:"bg-amber-500/15 text-amber-300"};function N({badges:e,className:t}){return e.length?(0,a.jsx)("span",{className:(0,h.cn)("flex shrink-0 items-center gap-0.5",t),children:e.map(e=>(0,a.jsx)("span",{title:e.title,className:(0,h.cn)("rounded px-1 text-[8px] font-semibold uppercase tracking-wide",k[e.tone]),children:e.label},e.label))}):null}let C=/pass(word)?|token|secret|api[_-]?key|credential|priv(ate)?[_-]?key|hash|salt/i,E=/auth|login|logout|session|token|password|oauth|sso|credential/i,A="nodrag nopan",S=v.x;function I({onClick:e,title:t}){return(0,a.jsx)("button",{type:"button",title:t,onClick:t=>{t.stopPropagation(),e()},className:(0,h.cn)(A,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover/row:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})}function M({c:e,fkTargets:t}){let n=t?.[e.name];return(0,a.jsx)("span",{title:n?`→ ${n}`:e.type,className:"ml-auto min-w-0 truncate font-mono text-[11px] text-muted-foreground/80",children:n?(0,a.jsxs)(a.Fragment,{children:["→\xa0",n]}):e.type})}let T=(0,s.memo)(function({id:e,data:t,selected:n}){var r;let o,l,i="DRAFT"===t.source,d="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",g="added"===t.diffStatus||"modified"===t.diffStatus,k="added"===t.diffStatus?"new":"modified"===t.diffStatus?"modify":"in plan",E=t.diffChanges?.length?t.diffChanges.join("\n"):"in this plan — no column change",T=i?d:(0,f.qA)(t.domain),z=(r={domain:t.domain,columns:t.columns},o=[],(l=r.columns.filter(e=>C.test(e.name)).map(e=>e.name)).length&&o.push({label:"secrets",tone:"danger",title:`stores credentials: ${l.join(", ")}`}),r.domain&&/auth/i.test(r.domain)&&o.push({label:"auth",tone:"warn",title:"auth-domain table"}),o),R=b(),[D,$]=(0,s.useState)(t.name),[P,O]=(0,s.useState)(t.columns),[L,F]=(0,s.useState)(!1);(0,s.useEffect)(()=>{$(t.name),O(t.columns)},[t.rev]);let Y=e=>e.stopPropagation(),B=t=>{O(t),R.patchTable(e,{columns:t})},U=(t.pins??[]).filter(e=>null===e.column),H=e=>(t.pins??[]).filter(t=>t.column===e),_=function(e,t,n,a=!1,s){return Math.min(312,Math.max(240,Math.round(8*e.length)+90,...t.map(e=>{if(a){let t=s?.[e.name];return Math.round(7.3*Math.max(6,e.name.length+1)+(t?.kind==="modified"?8*t.detail.length:64))+94}let t=n?.[e.name]?n[e.name].length+2:e.type.length;return Math.round(7.3*e.name.length+6.7*t)+64})))}(t.name,i?P:t.columns,t.fkTargets,i,t.diffColumns),G=(0,h.cn)("relative rounded-xl border bg-[#161618]/95 text-card-foreground shadow-[0_18px_50px_-22px_rgba(0,0,0,0.9)] backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]"),K=(0,y.k)(j.fE);return"full"!==K?(0,a.jsxs)("div",{className:(0,h.cn)(G,"border-white/10 px-3 py-2.5","far"===K&&!R.readOnly&&"!opacity-0"),style:{width:_},children:[(0,a.jsx)(v.x,{}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{background:T}}),(0,a.jsx)("span",{className:"truncate font-mono text-[15px] font-semibold",children:t.name})]})]}):i?(0,a.jsxs)("div",{className:(0,h.cn)(G,"group/card"),style:{width:_,borderColor:`${d}59`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-1.5 rounded-t-[11px] px-3 py-2",style:{background:`${d}14`},children:[(0,a.jsx)("input",{value:D,onChange:e=>$(e.target.value),onBlur:()=>{let n=D.trim();n&&n!==t.name&&R.patchTable(e,{name:n})},onKeyDown:e=>{Y(e),"Enter"===e.key&&e.currentTarget.blur()},placeholder:"table",className:(0,h.cn)(A,"min-w-0 flex-1 bg-transparent font-mono text-[13px] font-semibold tracking-tight outline-none")}),(0,a.jsx)(N,{badges:z}),(0,a.jsx)("span",{title:E,className:(0,h.cn)("shrink-0 rounded-md border px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em]",!g&&"border-white/15 bg-white/5 text-muted-foreground"),style:g?{background:`${d}1f`,borderColor:`${d}55`,color:d}:void 0,children:k}),(0,a.jsx)("button",{type:"button",onClick:t=>{Y(t),L?R.deleteTable(e):F(!0)},onBlur:()=>F(!1),title:"Delete table",className:(0,h.cn)(A,"shrink-0 transition-all",L?"text-red-300":"text-muted-foreground opacity-0 hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(m.A,{className:"size-3"})}),U.length>0?(0,a.jsx)(w.e0,{pins:U,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(I,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsxs)("div",{className:"divide-y divide-white/[0.05]",children:[P.map((e,n)=>{let s=H(e.name),r=t.diffColumns?.[e.name],o=r?.kind==="added"?{background:"#7bd38914",boxShadow:"inset 2px 0 0 #7bd389"}:r?.kind==="modified"?{background:"#ffb86b14",boxShadow:"inset 2px 0 0 #ffb86b"}:void 0;return(0,a.jsxs)("div",{style:o,className:"group/row relative flex items-center gap-1.5 px-3 py-[5px] text-[12px]",children:[(0,a.jsx)("button",{type:"button",onClick:e=>{Y(e),B(P.map((e,t)=>t===n?{...e,isPk:!e.isPk}:e))},title:"Primary key",className:(0,h.cn)(A,"shrink-0",e.isPk?"text-amber-300/90":"text-muted-foreground/40 hover:text-amber-300"),children:(0,a.jsx)(c.A,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:e=>{Y(e),B(P.map((e,t)=>t===n?{...e,isFk:!e.isFk}:e))},title:"Foreign key",className:(0,h.cn)(A,"shrink-0",e.isFk?"text-sky-400/80":"text-muted-foreground/40 hover:text-sky-400"),children:(0,a.jsx)(u.A,{className:"size-3"})}),(0,a.jsx)("input",{value:e.name,onChange:e=>O(t=>t.map((t,a)=>a===n?{...t,name:e.target.value}:t)),onBlur:()=>B(P),onKeyDown:Y,placeholder:"column",style:{width:`${Math.max(6,e.name.length+1)}ch`},className:(0,h.cn)(A,"shrink-0 bg-transparent font-mono outline-none")}),(0,a.jsx)("span",{"aria-hidden":!0,className:"flex-1"}),t.fkTargets?.[e.name]?(0,a.jsxs)("span",{title:`→ ${t.fkTargets[e.name]}`,className:"min-w-0 shrink truncate text-right font-mono text-[11px] text-muted-foreground/80",children:["→\xa0",t.fkTargets[e.name]]}):r?.kind==="modified"?(0,a.jsx)("span",{title:`was changed — ${r.detail}`,className:(0,h.cn)(A,"min-w-0 shrink truncate text-right font-mono text-[11px] font-medium text-[#ffb86b]"),children:r.detail}):(0,a.jsx)("input",{value:e.type,onChange:e=>O(t=>t.map((t,a)=>a===n?{...t,type:e.target.value}:t)),onBlur:()=>B(P),onKeyDown:Y,placeholder:"type",title:e.type,className:(0,h.cn)(A,"w-16 min-w-0 shrink bg-transparent text-right font-mono text-[11px] outline-none",r?.kind==="added"?"text-[#7bd389]":"text-muted-foreground/80")}),(0,a.jsx)("button",{type:"button",onClick:e=>{Y(e),B(P.filter((e,t)=>t!==n))},title:"Remove column",className:(0,h.cn)(A,"shrink-0 text-muted-foreground/40 opacity-0 transition-opacity hover:text-red-300 group-hover/card:opacity-100"),children:(0,a.jsx)(p.A,{className:"size-3"})}),s.length>0?(0,a.jsx)(w.e0,{pins:s,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(I,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},n)}),(0,a.jsxs)("button",{type:"button",onClick:e=>{Y(e),B([...P,{name:"",type:"text",isPk:!1,isFk:!1,nullable:!0,note:null}])},className:(0,h.cn)(A,"flex w-full items-center gap-1 px-3 py-1.5 text-[10px] text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(x.A,{className:"size-3"})," column"]})]})]}):(0,a.jsxs)("div",{className:G,style:{width:_,borderColor:`${T}3d`},children:[(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"group/row relative flex items-center justify-between rounded-t-[11px] px-3 py-2",style:{background:`${T}14`},children:[(0,a.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 font-mono text-[13px] font-semibold tracking-tight",children:["INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),(0,a.jsx)("span",{className:"truncate",title:t.name,children:t.name})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5",children:["INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(N,{badges:z}),t.domain&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-[0.14em]",style:{color:T},children:t.domain})]}),U.length>0?(0,a.jsx)(w.e0,{pins:U,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(I,{title:`Comment on ${t.name}`,onClick:()=>t.onComment?.(t.name)})]}),(0,a.jsx)("div",{className:"divide-y divide-white/[0.05]",children:t.columns.map(e=>{let n=H(e.name);return(0,a.jsxs)("div",{className:"group/row relative flex items-center gap-2 px-3 py-[7px] text-[12px]",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 shrink-0 text-amber-300/90"}):e.isFk?(0,a.jsx)(u.A,{className:"size-3 shrink-0 text-sky-400/80"}):(0,a.jsx)("span",{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"shrink-0 whitespace-nowrap font-mono",children:e.name}),(0,a.jsx)(M,{c:e,fkTargets:t.fkTargets}),n.length>0?(0,a.jsx)(w.e0,{pins:n,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)(I,{title:`Comment on ${t.name}.${e.name}`,onClick:()=>t.onComment?.(`${t.name}.${e.name}`)})]},e.name)})})]})}),z="nodrag nopan",R=["GET","POST","PUT","PATCH","DELETE"],D=(0,s.memo)(function({id:e,data:t,selected:n}){var r;let o,l=f.e6[t.method]??"#8a8a8a",i="DRAFT"===t.source,c="added"===t.diffStatus?"#7bd389":"modified"===t.diffStatus?"#ffb86b":"#4ea1ff",u="added"===t.diffStatus?"new":"modified"===t.diffStatus?"changed":"draft",p=t.diffChanges?.length?t.diffChanges.join("\n"):"draft",x=(r={method:t.method,domain:t.domain,path:t.path},o=[],/^delete$/i.test(r.method.trim())&&o.push({label:"DELETE",tone:"danger",title:"destructive: deletes data"}),(r.domain&&/auth/i.test(r.domain)||E.test(r.path))&&o.push({label:"auth",tone:"warn",title:"auth-related endpoint"}),o),g=b(),[k,C]=(0,s.useState)(t.path),[A,S]=(0,s.useState)(!1);(0,s.useEffect)(()=>{C(t.path)},[t.rev]);let I=e=>e.stopPropagation(),M=(0,y.k)(j.fE);return"full"!==M?(0,a.jsxs)("div",{className:(0,h.cn)("relative flex w-[300px] items-center gap-2 rounded-lg border border-white/10 bg-[#161618]/95 px-2.5 py-2 text-card-foreground backdrop-blur",n&&"ring-2 ring-[var(--accent,#f5b942)]","far"===M&&!g.readOnly&&"!opacity-0"),children:[(0,a.jsx)(v.x,{}),(0,a.jsx)("span",{className:"shrink-0 font-mono text-[12px] font-bold",style:{color:l},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"truncate font-mono text-[13px]",children:t.path})]}):(0,a.jsxs)("div",{className:(0,h.cn)("group relative flex w-[300px] items-center gap-2 rounded-lg border bg-[#161618]/95 px-2.5 py-1.5 text-card-foreground shadow-[0_12px_36px_-18px_rgba(0,0,0,0.9)] backdrop-blur",i?"border-dashed":"border-white/10",n&&"ring-2 ring-[var(--accent,#f5b942)]"),style:i?{borderColor:`${c}66`,background:`${c}0f`}:void 0,children:[(0,a.jsx)(v.x,{}),"INTROSPECTION"===t.source&&(0,a.jsx)("span",{title:"live — derived from your code",className:"inline-block size-1.5 shrink-0 rounded-full bg-emerald-400"}),i?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:t.method,onChange:t=>g.patchEndpoint(e,{method:t.target.value}),onPointerDown:I,className:(0,h.cn)(z,"shrink-0 rounded bg-transparent text-[10px] font-bold outline-none"),style:{color:l},title:"Method",children:R.map(e=>(0,a.jsx)("option",{value:e,className:"bg-card text-foreground",children:e},e))}),(0,a.jsx)("input",{value:k,title:k,onChange:e=>C(e.target.value),onBlur:()=>{let n=k.trim();n&&n!==t.path&&g.patchEndpoint(e,{path:n})},onKeyDown:e=>{I(e),"Enter"===e.key&&e.currentTarget.blur()},className:(0,h.cn)(z,"min-w-0 flex-1 bg-transparent font-mono text-[11px] outline-none")}),(0,a.jsx)(N,{badges:x}),(0,a.jsx)("span",{title:p,className:"shrink-0 rounded px-1 py-0.5 text-[8px] font-semibold uppercase",style:{background:`${c}26`,color:c},children:u}),(0,a.jsx)("button",{type:"button",onClick:t=>{I(t),A?g.deleteEndpoint(e):S(!0)},onBlur:()=>S(!1),title:"Delete",className:(0,h.cn)(z,"shrink-0 transition-colors",A?"text-red-300":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(m.A,{className:"size-3"})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-bold",style:{background:`${l}22`,color:l},children:t.method}),(0,a.jsx)("span",{title:t.path,className:"min-w-0 flex-1 break-all font-mono text-[11px] leading-tight [-webkit-box-orient:vertical] [-webkit-line-clamp:2] [display:-webkit-box] overflow-hidden",children:t.path}),"INTROSPECTION"!==t.source&&(0,a.jsx)("span",{title:"planned — not yet detected in code",className:"shrink-0 rounded-md border border-[#f5b942]/35 bg-[#f5b942]/10 px-1.5 py-px font-mono text-[8px] font-semibold uppercase tracking-[0.14em] text-[#f5b942]",children:"planned"}),(0,a.jsx)(N,{badges:x}),(0,a.jsx)("button",{type:"button",onClick:t=>{I(t),A?g.deleteRealEndpoint(e):S(!0)},onBlur:()=>S(!1),title:A?"Click again to delete":"Delete endpoint",className:(0,h.cn)(z,"shrink-0 opacity-0 transition-opacity group-hover:opacity-100",A?"text-red-300 opacity-100":"text-muted-foreground hover:text-red-300"),children:(0,a.jsx)(m.A,{className:"size-3"})})]}),(t.pins?.length??0)>0?(0,a.jsx)(w.e0,{pins:t.pins,onPinClick:t.onPinClick}):t.onComment&&(0,a.jsx)("button",{type:"button",title:`Comment on ${t.method} ${t.path}`,onClick:e=>{I(e),t.onComment?.(`${t.method} ${t.path}`)},className:(0,h.cn)(z,"absolute -right-3 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-full border border-white/15 bg-[#242428] text-muted-foreground opacity-0 shadow-md transition-all group-hover:opacity-100 hover:border-[#ff7a45]/50 hover:text-[#ff7a45]"),children:(0,a.jsx)(d.A,{className:"size-3"})})]})});var $=n(54698),P=n(82099),O=n(4474);let L=[{id:"claude",label:"Prompt p/ Claude Code",fn:function(e){let t=["Implement this database schema in this project, following its existing stack and conventions:",""];for(let n of e.tables){let e=`Table \`${n.name}\``+(n.domain?` (domain: ${n.domain})`:"")+(n.description?` — ${n.description}`:"");for(let a of(t.push(e),n.columns)){let e=[a.isPk&&"PK",a.isFk&&"FK",!1===a.nullable&&"NOT NULL"].filter(Boolean).join(", ");t.push(` - ${a.name}: ${a.type}`+(e?` [${e}]`:"")+(a.note?` — ${a.note}`:""))}t.push("")}if(e.relations.length){for(let n of(t.push("Foreign keys:"),e.relations))t.push(` - ${n.fromTable}.${n.fromColumn} -> ${n.toTable}.${n.toColumn}`);t.push("")}return t.push("Create the models/migrations using the project's existing ORM and patterns, wire the relationships, and keep table and column names exactly as given."),t.join("\n")}},{id:"dbml",label:"DBML",fn:function(e){let t=[];for(let n of e.tables){for(let e of(t.push(`Table ${n.name} {`),n.columns)){let n=[e.isPk&&"pk",!1===e.nullable&&!e.isPk&&"not null",e.note&&`note: '${e.note.replace(/'/g,"")}'`].filter(Boolean).join(", ");t.push(` ${e.name} ${e.type}`+(n?` [${n}]`:""))}t.push("}","")}for(let n of e.relations)t.push(`Ref: ${n.fromTable}.${n.fromColumn} > ${n.toTable}.${n.toColumn}`);return t.join("\n").trim()}},{id:"sql",label:"SQL DDL",fn:function(e){let t=[];for(let n of e.tables){t.push(`CREATE TABLE ${n.name} (`);let a=n.columns.map(e=>{let t=[` ${e.name} ${e.type}`];return e.isPk?t.push("PRIMARY KEY"):!1===e.nullable&&t.push("NOT NULL"),t.join(" ")}),s=e.relations.filter(e=>e.fromTable===n.name).map(e=>` FOREIGN KEY (${e.fromColumn}) REFERENCES ${e.toTable}(${e.toColumn})`);t.push([...a,...s].join(",\n")),t.push(");","")}return t.join("\n").trim()}}];function F({draftGraph:e}){let[t,n]=(0,s.useState)(null);if(0===e.tables.length)return null;async function r(t){await navigator.clipboard.writeText(t.fn(e)).catch(()=>{}),n(t.id),setTimeout(()=>n(null),1500)}return(0,a.jsxs)("div",{className:"space-y-2 rounded-xl border border-sky-400/20 bg-sky-500/[0.04] p-3",children:[(0,a.jsxs)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-sky-300",children:["Rascunho \xb7 ",e.tables.length," tabelas"]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"copiar:"}),L.map(e=>(0,a.jsx)(O.$,{size:"sm",variant:"outline",className:"h-6 px-2 text-[11px]",onClick:()=>r(e),children:t===e.id?"✓":e.label},e.id))]})]})}function Y({selected:e,tables:t,relations:n,endpoints:s,draftGraph:r,onClose:o,commentsContent:l,commentsCount:i=0,activeTab:c,onTabChange:u,onAddComment:m,topOffset:x}){let h,f,g=new Map(t.map(e=>[e.id,e.name])),b=!!l,y=c??"details",j=e?.kind==="table"?t.find(t=>t.id===e.id)?.name??null:e?.kind==="endpoint"&&(f=s.find(t=>t.id===e.id))?`${f.method} ${f.path}`:null;if(e?.kind==="table"){let r=t.find(t=>t.id===e.id);h=r?(0,a.jsx)(U,{table:r,relations:n,endpoints:s,nameById:g}):null}else if(e?.kind==="endpoint"){let t=s.find(t=>t.id===e.id);h=t?(0,a.jsx)(H,{ep:t,nameById:g}):null}else h=(0,a.jsx)(_,{tables:t,relations:n,endpoints:s});return(0,a.jsxs)(P.b,{className:"absolute right-3 z-10 flex w-80 flex-col rounded-2xl",style:{top:x??12,maxHeight:`calc(100% - ${(x??12)+12}px)`},children:[b?(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-1 py-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(B,{active:"details"===y,onClick:()=>u?.("details"),children:"Details"}),(0,a.jsxs)(B,{active:"comments"===y,onClick:()=>u?.("comments"),children:["Comments",i>0&&(0,a.jsx)("span",{className:"ml-1 rounded-full bg-white/10 px-1 text-[9px] font-semibold leading-4",children:i})]})]}),(0,a.jsx)("button",{onClick:o,title:"Close panel",className:"mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-3.5 py-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Panel"}),(0,a.jsx)("button",{onClick:o,title:"Close panel",className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground",children:(0,a.jsx)(p.A,{className:"size-4"})})]}),(0,a.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:"comments"===y&&b?(0,a.jsx)("div",{className:"p-3",children:l}):(0,a.jsxs)(a.Fragment,{children:[r.tables.length>0&&(0,a.jsx)("div",{className:"border-b border-white/10 p-3.5",children:(0,a.jsx)(F,{draftGraph:r})}),(0,a.jsxs)("div",{className:"p-4",children:[m&&j&&(0,a.jsxs)("button",{type:"button",onClick:()=>m(j),className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:"size-3.5"}),"Comment on this ",e?.kind==="endpoint"?"endpoint":"table"]}),h]})]})})]})}function B({active:e,onClick:t,children:n}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,h.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:n})}function U({table:e,relations:t,endpoints:n,nameById:s}){let r=t.filter(t=>t.fromTableId===e.id),o=t.filter(t=>t.toTableId===e.id),l=n.map(t=>({e:t,u:t.tables.find(t=>t.tableId===e.id)})).filter(e=>e.u);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs uppercase tracking-wide",style:{color:(0,f.qA)(e.domain)},children:e.domain??"table"}),(0,a.jsx)("h2",{className:"font-mono text-lg font-semibold",children:e.name}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(G,{title:`Columns (${e.columns.length})`,children:(0,a.jsx)("ul",{className:"space-y-0.5",children:e.columns.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5 text-xs",children:[e.isPk?(0,a.jsx)(c.A,{className:"size-3 text-amber-400"}):e.isFk?(0,a.jsx)(u.A,{className:"size-3 text-sky-400"}):(0,a.jsx)("span",{className:"size-3"}),(0,a.jsx)("span",{className:"font-mono",children:e.name}),(0,a.jsxs)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground",children:[e.type,!e.nullable&&" \xb7NN"]})]},e.name))})}),r.length>0&&(0,a.jsx)(G,{title:"References (FK out)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:r.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[e.fromColumn," → ",s.get(e.toTableId),".",e.toColumn]},e.id))})}),o.length>0&&(0,a.jsx)(G,{title:"Referenced by (FK in)",children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:o.map(e=>(0,a.jsxs)("li",{className:"font-mono text-muted-foreground",children:[s.get(e.fromTableId),".",e.fromColumn]},e.id))})}),l.length>0&&(0,a.jsx)(G,{title:`Used by endpoints (${l.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:l.map(({e,u:t})=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{style:{color:f.e6[e.method]},className:"font-bold",children:e.method}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.path}),(0,a.jsx)("span",{className:"ml-auto",style:{color:f.ru[t.access]},children:t.access})]},e.id))})})]})}function H({ep:e,nameById:t}){return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-bold",style:{background:`${f.e6[e.method]}22`,color:f.e6[e.method]},children:e.method}),(0,a.jsx)("h2",{className:"mt-2 font-mono text-base font-semibold",children:e.path}),e.description&&(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(G,{title:`Tables used (${e.tables.length})`,children:(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:e.tables.map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono",children:t.get(e.tableId)}),(0,a.jsx)("span",{className:"ml-auto",style:{color:f.ru[e.access]},children:e.access})]},e.tableId))})})]})}function _({tables:e,relations:t,endpoints:n}){return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Database"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Live schema derived from your code. Click a table or endpoint to see details. Drag to rearrange — positions are saved."})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-3 gap-2 text-center",children:[(0,a.jsx)(K,{label:"tables",value:e.length}),(0,a.jsx)(K,{label:"FKs",value:t.length}),(0,a.jsx)(K,{label:"endpoints",value:n.length})]}),(0,a.jsx)(G,{title:"Legend",children:(0,a.jsxs)("ul",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(c.A,{className:"size-3 text-amber-400"})," primary key"]}),(0,a.jsxs)("li",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(u.A,{className:"size-3 text-sky-400"})," foreign key"]}),(0,a.jsx)("li",{children:"— gray line: FK relation between tables"}),(0,a.jsx)("li",{children:"– – dashed line: endpoint uses table (read/write)"})]})})]})}function G({title:e,children:t}){return(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e}),t]})}function K({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] py-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:t}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e})]})}var X=n(56614),Z=n(9991),W=n(40654),V=n(14983),J=n(62311);let q=new Set(["GET","HEAD","OPTIONS"]);var Q=n(44267),ee=n(94014);function et(e){return 36+30*Math.max(0,e)+16}let en="Unattached",ea=e=>(e??"").trim()||"—";function es(e,t){let n=new Map(e.map(e=>[e.id,e.name])),a=new Map;for(let e of t)for(let t of e.uses)n.has(t.tableId)&&a.set(t.tableId,(a.get(t.tableId)??0)+1);return new Map(t.map(e=>[e.id,function(e,t,n){let a=new Map;for(let n of e.uses)t.has(n.tableId)&&a.set(n.tableId,(a.get(n.tableId)??0)+1);let s=null;for(let[e,r]of a){if(null===s){s=e;continue}let o=a.get(s);if(r>o){s=e;continue}if(r<o)continue;let l=n?.get(e)??0,i=n?.get(s)??0;l<i?s=e:l===i&&0>t.get(e).localeCompare(t.get(s))&&(s=e)}return s}(e,n,a)]))}let er=(e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.id.localeCompare(t.id);var eo=n(70947);let el=e=>e.trim().toLowerCase();var ei=n(85618),ed=n(80846),ec=n(17356),eu=n(45486),em=n(15330),ep=n(60976),ex=n(64577),eh=n(24692),ef=n(45437);let eg={dbTable:T,endpoint:D,annotation:w.Sh},eb={deletable:eh.I,annotation:ef.L},ey="beacon:db-draft",ej={proposedAt:0,status:"pending",tables:[],relations:[],endpoints:[]};function ev({tables:e,relations:t,endpoints:n,draft:d,workspaceId:c,embedded:u=!1,diffBase:p,draftRef:x,onEdit:b,controlRef:v,commentsContent:k,commentsCount:N=0,onAddComment:C,annotations:E,onPinClick:A,onUpdateComment:S,onRemoveComment:I,boardAnnotations:M,readOnly:T=!1}){let z=(0,o.useRouter)(),R=e.length+(d?.tables.length??0),D=n.length+(d?.endpoints.length??0),[P,O]=(0,s.useState)(D>0&&(u||0===R)),[L,F]=(0,s.useState)(null),[B,U]=(0,s.useState)(null),[H,_]=(0,s.useState)(null),[G,K]=(0,s.useState)(!1),[eh,ef]=(0,s.useState)(!1),[ew,ek]=(0,s.useState)("details"),[eN,eC]=(0,s.useState)(!1),[eE,eA]=(0,s.useState)(""),eS=(0,s.useRef)(null),{tool:eI,setTool:eM,flowProps:eT}=(0,r.e)();(0,s.useEffect)(()=>{if(!T)return;let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>eS.current?.fitView({padding:.2,duration:0}))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[T,d,P]),(0,s.useEffect)(()=>{if(v)return v.current={open:()=>{K(!0),ek("details")},close:()=>{K(!1),ek("details")},openComments:()=>{K(!0),ek("comments")}},()=>{v&&(v.current=null)}},[v]);let[ez,eR]=(0,s.useState)(new Set),[eD,e$]=(0,s.useState)("full"),[eP,eO]=(0,s.useState)(new Set),[eL,eF]=(0,s.useState)(new Set),[eY,eB]=(0,s.useState)(()=>({past:[],present:d??ej,future:[],rev:0,edited:!1})),eU=eY.present,eH=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{past:[...t.past,t.present].slice(-100),present:n,future:[],rev:t.rev+1,edited:!0}})},[]),e_=(0,s.useCallback)(e=>{eB(t=>{let n=e(t.present);return n===t.present?t:{...t,present:n}})},[]),eG=(0,s.useCallback)(()=>eB(e=>e.past.length?{past:e.past.slice(0,-1),present:e.past[e.past.length-1],future:[e.present,...e.future],rev:e.rev+1,edited:!0}:e),[]),eK=(0,s.useCallback)(()=>eB(e=>e.future.length?{past:[...e.past,e.present],present:e.future[0],future:e.future.slice(1),rev:e.rev+1,edited:!0}:e),[]),eX=(0,s.useCallback)(e=>eB(t=>({past:[],present:e,future:[],rev:t.rev+1,edited:!1})),[]),eZ=(0,s.useRef)(!1),eW=d?.proposedAt??0;(0,s.useEffect)(()=>{let e=null;if(eZ.current)d&&d.proposedAt!==eU.proposedAt?e=d:!d&&(eU.tables.length>0||eU.endpoints.length>0)&&(e=ej);else{eZ.current=!0;let t=null;try{let e=localStorage.getItem(ey);if(e){let n=JSON.parse(e);n.workspaceId===c&&n.doc&&d&&n.doc.proposedAt===d.proposedAt&&(t=n.doc)}}catch{}e=t??d??null}e&&eX(e)},[eW]),(0,s.useEffect)(()=>{try{eU.tables.length>0||eU.endpoints.length>0?localStorage.setItem(ey,JSON.stringify({workspaceId:c,doc:eU})):localStorage.removeItem(ey)}catch{}},[eU,c]),(0,s.useEffect)(()=>{x&&(x.current=eU)},[x,eU]);let eV=(0,s.useRef)(!1);(0,s.useEffect)(()=>{eY.edited&&!eV.current&&(eV.current=!0,b?.())},[eY.edited,b]);let eJ=(0,s.useMemo)(()=>eU.tables.map(e=>({id:e.id,name:e.name,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,columns:e.columns})),[eU]),eq=(0,s.useMemo)(()=>eU.endpoints.map(e=>({id:e.id,method:e.method,path:e.path,domain:e.domain,description:e.description,source:"DRAFT",x:e.x,y:e.y,tables:e.links.map(e=>({tableId:e.tableId,access:e.access}))})),[eU]),eQ=(0,s.useMemo)(()=>[...e,...eJ],[e,eJ]),e0=(0,s.useMemo)(()=>[...n,...eq],[n,eq]),e1=(0,s.useMemo)(()=>(function(e,t,n={}){let a=es(e,t),s=new Map,r=[];for(let e of[...t].sort(er)){let t=a.get(e.id)??null;if(t){let n=s.get(t);n?n.push(e):s.set(t,[e])}else r.push(e)}let o=e=>{let t=s.get(e.id)?.length??0;return et(e.columnCount)+(t?10+60*t:0)+30},l=Array.from(new Set(e.map(e=>ea(e.domain)))),i=l.filter(e=>"—"!==e).sort(),d=l.includes("—")?[...i,"—"]:i,c=[];for(let t of d){let n=e.filter(e=>ea(e.domain)===t).sort((e,t)=>e.name.localeCompare(t.name)),a=n.reduce((e,t)=>e+o(t),0),s=Math.max(1,Math.min(12,n.length,Math.round(Math.sqrt(a/320)))),r=Array(s).fill(0),l=new Map;for(let e of n){let t=0;for(let e=1;e<s;e++)r[e]<r[t]&&(t=e);l.set(e.id,{x:320*t,y:r[t]}),r[t]+=o(e)}c.push({d:t,w:320*s,h:Math.max(...r,0),tableLocal:l})}let u=(0,ee.Xi)(c.map(e=>({id:e.d,w:e.w,h:e.h})),{gapX:84,gapY:72,viewportAspect:n.viewportAspect,minBandW:960,aspectSlack:1.7}),m=new Map,p=new Map,x=0;for(let t of c){let n=u.get(t.d);for(let a of e.filter(e=>t.tableLocal.has(e.id))){let e=t.tableLocal.get(a.id),r=n.x+e.x,o=n.y+e.y;m.set(a.id,{x:r,y:o}),(s.get(a.id)??[]).forEach((e,t)=>{p.set(e.id,{x:r,y:o+et(a.columnCount)+10+60*t})})}x=Math.max(x,n.y+t.h)}if(r.length){let e=x+72,t=Math.max(1,Math.min(4,Math.ceil(Math.sqrt(r.length/2))));r.forEach((n,a)=>{p.set(n.id,{x:a%t*300,y:e+60*Math.floor(a/t)})})}return{tables:m,endpoints:p}})(eQ.map(e=>({id:e.id,name:e.name,domain:e.domain,columnCount:e.columns.length})),[]).tables,[eQ]),e5=(0,s.useMemo)(()=>new Map,[]),e2=(0,s.useMemo)(()=>u?function(e,t){let n=new Map(e.map(e=>[el(e.name),e])),a=new Map;for(let e of t){let t=n.get(el(e.name));if(!t){a.set(e.id,{status:"added",changes:["new table"],columns:{}});continue}let{changes:s,columns:r}=function(e,t){let n=new Map(e.map(e=>[el(e.name),e])),a=new Set(t.map(e=>el(e.name))),s=[],r={};for(let e of t){let t=n.get(el(e.name));if(!t){s.push(`+ column ${e.name} (${e.type})`),r[e.name]={kind:"added",detail:"new column"};continue}let a=[],o=[];if(el(t.type)!==el(e.type)&&(a.push(`type ${t.type}→${e.type}`),o.push(`${t.type}→${e.type}`)),t.isPk!==e.isPk){let t=e.isPk?"now PK":"no longer PK";a.push(t),o.push(t)}if(t.isFk!==e.isFk){let t=e.isFk?"now FK":"no longer FK";a.push(t),o.push(t)}if(t.nullable!==e.nullable){let t=e.nullable?"now nullable":"now required";a.push(t),o.push(t)}a.length&&(s.push(`~ column ${e.name}: ${a.join(", ")}`),r[e.name]={kind:"modified",detail:o.join(" \xb7 ")})}for(let t of e)a.has(el(t.name))||s.push(`- column ${t.name}`);return{changes:s,columns:r}}(t.columns,e.columns);a.set(e.id,{status:s.length?"modified":"unchanged",changes:s,columns:r})}return a}(p?.tables??e,eJ):e5,[u,p,e,eJ,e5]),e3=(0,s.useMemo)(()=>u?function(e,t){let n=e=>`${el(e.method)} ${el(e.path)}`,a=new Set(e.map(n)),s=new Map;for(let e of t)s.set(e.id,a.has(n(e))?{status:"unchanged",changes:[],columns:{}}:{status:"added",changes:["new endpoint"],columns:{}});return s}(p?.endpoints??n,eq):e5,[u,p,n,eq,e5]),e4=(0,s.useMemo)(()=>[...t,...eU.relations.map(e=>({id:e.id,fromTableId:e.fromTableId,toTableId:e.toTableId,fromColumn:e.fromColumn,toColumn:e.toColumn,label:e.label}))],[t,eU.relations]),e6=(0,s.useMemo)(()=>{let e=new Map;for(let t of e0)for(let n of t.tables)e.set(n.tableId,(e.get(n.tableId)??0)+1);return e},[e0]),e9=(0,s.useMemo)(()=>{let e=new Map;return eQ.forEach(t=>e.set(t.id,t.x)),e0.forEach(t=>e.set(t.id,t.x)),e},[eQ,e0]),e7=(0,s.useMemo)(()=>{let e=new Map;return eQ.forEach(t=>e.set(t.id,t.y)),e0.forEach(t=>e.set(t.id,t.y)),e},[eQ,e0]),e8=(0,s.useMemo)(()=>{let e=new Map(eQ.map(e=>[e.id,e.name])),t=new Map;for(let n of e4){let a=e.get(n.toTableId);if(!a)continue;let s=t.get(n.fromTableId)??{};s[n.fromColumn]=a,t.set(n.fromTableId,s)}return t},[e4,eQ]),te=void 0!==M,[tt,tn]=(0,s.useState)(M??[]);(0,s.useEffect)(()=>{M&&tn(M)},[M]);let ta=(0,s.useMemo)(()=>({tables:eQ.map(e=>({id:e.id,name:e.name,columns:e.columns.map(e=>e.name)})),endpoints:e0.map(e=>({id:e.id,method:e.method,path:e.path}))}),[eQ,e0]),ts=(0,s.useMemo)(()=>{if(te){let e=new Set([...eQ.map(e=>e.id),...e0.map(e=>e.id)]);return tt.filter(t=>e.has(t.targetId)).map((e,t)=>({id:e.id,n:t+1,targetId:e.targetId,column:e.columnName,text:e.body,x:e.x,y:e.y}))}let e=new Map((E??[]).map(e=>[e.id,e.comment]));return(0,$.m)(E??[],ta).map(t=>({id:t.annotationId,n:t.n,targetId:t.targetId,column:t.column,text:e.get(t.annotationId)??"",x:null,y:null}))},[te,tt,E,ta,eQ,e0]),tr=(0,s.useMemo)(()=>{let e=new Map;for(let t of ts){let n=e.get(t.targetId)??[];n.push({id:t.id,n:t.n,column:t.column}),e.set(t.targetId,n)}return e},[ts]),to=(0,s.useMemo)(()=>new Map(ts.map(e=>[`anno-${e.id}`,e.targetId])),[ts]),tl=(0,s.useCallback)(async e=>{let t=(0,$.m)([{id:"_",excerpt:e}],ta)[0];if(!t)return;let n=await fetch("/api/board-annotations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({targetKind:t.kind,targetId:t.targetId,columnName:t.column??void 0})});if(n.ok){let e=await n.json();tn(t=>[...t,e])}},[ta]),ti=(0,s.useCallback)((e,t)=>{tn(n=>n.map(n=>n.id===e?{...n,...t}:n)),fetch(`/api/board-annotations/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t)})},[]),td=(0,s.useCallback)(e=>{tn(t=>t.filter(t=>t.id!==e)),fetch(`/api/board-annotations/${e}`,{method:"DELETE"})},[]),tc=te?tl:C,tu=(0,s.useCallback)((e,t)=>{let n=(e9.get(t)??0)-(e9.get(e)??0),a=(e7.get(t)??0)-(e7.get(e)??0);return Math.abs(n)>=Math.abs(a)?n>=0?{sourceHandle:"sr",targetHandle:"tl"}:{sourceHandle:"sl",targetHandle:"tr"}:a>=0?{sourceHandle:"sb",targetHandle:"tt"}:{sourceHandle:"st",targetHandle:"tb"}},[e9,e7]),tm=(0,s.useMemo)(()=>new Set([...eU.tables.map(e=>e.id),...eU.endpoints.map(e=>e.id)]),[eU]),tp=(0,s.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),tx=(0,s.useCallback)(()=>{let e=eQ.map(e=>({id:e.id,type:"dbTable",position:P?{x:e.x,y:e.y}:e1.get(e.id)??{x:e.x,y:e.y},data:{name:e.name,domain:e.domain,columns:e.columns,usageCount:e6.get(e.id)??0,source:e.source,rev:eY.rev,diffStatus:e2.get(e.id)?.status,diffChanges:e2.get(e.id)?.changes,diffColumns:e2.get(e.id)?.columns,fkTargets:e8.get(e.id),pins:tr.get(e.id),onPinClick:A,onComment:tc}})),t=e0.map(e=>({id:e.id,type:"endpoint",position:{x:e.x,y:e.y},data:{method:e.method,path:e.path,domain:e.domain,source:e.source,rev:eY.rev,diffStatus:e3.get(e.id)?.status,diffChanges:e3.get(e.id)?.changes,pins:tr.get(e.id),onPinClick:A,onComment:tc}})),n=new Map,a=new Map(eQ.map(e=>[e.id,e])),s=new Map(e0.map(e=>[e.id,e]));return[...e,...t,...ts.map(e=>{let t=a.get(e.targetId),r=s.get(e.targetId),o=t?.x??r?.x??0,l=t?.y??r?.y??0,i=t?38+28*t.columns.length:42,d=n.get(e.targetId)??0;return n.set(e.targetId,d+1),{id:`anno-${e.id}`,type:"annotation",position:{x:e.x??o+26,y:e.y??l+i+64+112*d},data:{n:e.n,text:e.text,annotationId:e.id,onClick:te||S?void 0:A,editable:te||!!S,onChangeText:te?(e,t)=>ti(e,{body:t}):S,onDelete:te?td:I}}})]},[eQ,e0,P,e1,e6,eY.rev,e2,e3,e8,tr,ts,te,A,S,I,tc,ti,td]),[th,tf,tg]=(0,l.ck)(tx()),tb=(0,s.useRef)(P);(0,s.useEffect)(()=>{let e=tb.current!==P;tb.current=P,tf(t=>{let n=new Map(t.map(e=>[e.id,e.position]));return tx().map(t=>e&&"dbTable"===t.type?t:{...t,position:n.get(t.id)??t.position})}),e&&requestAnimationFrame(()=>eS.current?.fitView({duration:500,padding:.15,minZoom:.2,maxZoom:.9}))},[tx,tf,P]);let ty=(0,s.useCallback)((e,t,n,a)=>{fetch("/api/db/position",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:e,id:t,x:n,y:a})})},[]),tj=(0,s.useCallback)((e,t)=>{var n;let{x:a,y:s}=t.position,r=(n={readOnly:T,nodeId:t.id,isDraft:tm.has(t.id),boardMode:te}).readOnly?"none":n.nodeId.startsWith("anno-")?n.boardMode?"annotation":"none":n.isDraft?"draft":"real";"annotation"===r?ti(t.id.slice(5),{x:a,y:s}):"draft"===r?e_(e=>e.tables.some(e=>e.id===t.id)?{...e,tables:e.tables.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e.endpoints.some(e=>e.id===t.id)?{...e,endpoints:e.endpoints.map(e=>e.id===t.id?{...e,x:a,y:s}:e)}:e):"real"===r&&ty("endpoint"===t.type?"endpoint":"table",t.id,a,s)},[T,tm,e_,ty,te,ti]),tv=(0,s.useMemo)(()=>e4.map(e=>({id:`fk-${e.id}`,source:e.fromTableId,target:e.toTableId,...tu(e.fromTableId,e.toTableId),type:"deletable",label:e.label??void 0,markerEnd:{type:i.TG.ArrowClosed,color:"#6b6b6b"},style:{stroke:"#6b6b6b"}})),[e4,tu]),tw=(0,s.useMemo)(()=>e0.flatMap(e=>e.tables.map(t=>{let n=f.ru[t.access]??"#5a5a5a";return{id:`u-${e.id}-${t.tableId}`,source:e.id,target:t.tableId,...tu(e.id,t.tableId),type:"default",markerEnd:{type:i.TG.ArrowClosed,color:n},style:{stroke:n,strokeDasharray:"4 4",opacity:.7}}})),[e0,tu]),tk=(0,s.useMemo)(()=>P?[...tv,...tw]:tv,[tv,tw,P]),tN=(0,s.useMemo)(()=>ts.map(e=>({id:`annoe-${e.id}`,source:e.targetId,sourceHandle:`pin-${e.id}`,target:`anno-${e.id}`,targetHandle:"in",type:"annotation",selectable:!1,zIndex:30,style:{stroke:w.V5,strokeWidth:1.5,opacity:.9}})),[ts]),tC=L?.id??H,tE=(0,s.useMemo)(()=>{if(B){let e=tk.find(e=>e.id===B);return e?new Set([e.source,e.target]):null}return tC?(0,f.F1)(tC,tk):null},[tC,B,tk]),tA=(0,s.useMemo)(()=>new Map(eQ.map(e=>[e.id,{domain:e.domain,source:e.source}])),[eQ]),tS=(0,s.useMemo)(()=>new Map(e0.map(e=>[e.id,{method:e.method,source:e.source}])),[e0]),tI=(0,s.useMemo)(()=>{let e=new Set;if(!P)for(let t of tS.keys())e.add(t);for(let[t,n]of tA)!ez.size||n.domain&&ez.has(n.domain)||e.add(t),eP.size&&!eP.has(n.source)&&e.add(t);for(let[t,n]of tS)eL.size&&!eL.has(n.method)&&e.add(t),eP.size&&!eP.has(n.source)&&e.add(t);return e},[P,tA,tS,ez,eP,eL]),tM=eE.trim().length>0,tT=(0,s.useMemo)(()=>{if(!tM)return null;let e=new Set;for(let t of eQ)!tI.has(t.id)&&(0,V.Qk)((0,V.jF)(t),eE)&&e.add(t.id);for(let t of e0)!tI.has(t.id)&&(0,V.Qk)((0,V.sQ)(t),eE)&&e.add(t.id);return e},[eQ,e0,tI,eE,tM]),tz=(0,s.useMemo)(()=>tM?[...(0,V.r2)(eQ.filter(e=>!tI.has(e.id)),eE,e=>(0,V.jF)(e),e=>({id:e.id,label:e.name,sublabel:e.domain??"table",kind:"table"})),...(0,V.r2)(e0.filter(e=>!tI.has(e.id)),eE,e=>(0,V.sQ)(e),e=>({id:e.id,label:e.path,sublabel:e.method,kind:"endpoint"}))].slice(0,12):[],[eQ,e0,tI,eE,tM]),tR=(0,s.useCallback)(e=>{eA(""),F(tS.has(e)?{id:e,kind:"endpoint"}:{id:e,kind:"table"}),U(null),K(!0),ek("details");let t=eS.current?.getNode(e);if(!t||!eS.current)return;let n=t.measured?.width??220,a=t.measured?.height??80;eS.current.setCenter(t.position.x+n/2,t.position.y+a/2,{zoom:.9,duration:600})},[tS]),tD=tT??tE,t$=(0,s.useMemo)(()=>th.map(e=>{if(e.id.startsWith("anno-")){let t=to.get(e.id),n=!!t&&tI.has(t);return!!e.hidden!==n?{...e,hidden:n}:e}let t=tI.has(e.id);if(!tD)return t?{...e,hidden:t}:e;let n=tD.has(e.id),a=tT?V.Uy:.45;return{...e,hidden:t,style:{...e.style,opacity:n?1:a,boxShadow:n&&tT?V.RU:e.style?.boxShadow,borderRadius:n&&tT?12:e.style?.borderRadius,transition:"opacity 120ms, box-shadow 120ms"}}}),[th,tI,tD,tT,to]),tP=(0,s.useMemo)(()=>{let e=new Map(eQ.map(e=>[e.id,(e.domain??"").trim()||"—"])),t=es(eQ,e0.map(e=>({id:e.id,method:e.method,path:e.path,uses:e.tables.map(e=>({tableId:e.tableId}))})));return new Map(e0.map(n=>{let a=t.get(n.id);return[n.id,a?e.get(a):en]}))},[eQ,e0]),tO=(0,s.useMemo)(()=>{let e=[];for(let t of th)if(!tI.has(t.id))if("dbTable"===t.type){let n=t.data;e.push({id:t.id,group:(n.domain??"").trim()||"—",x:t.position.x,y:t.position.y,w:t.measured?.width??280,h:t.measured?.height??38+28*n.columns.length})}else"endpoint"===t.type&&e.push({id:t.id,group:tP.get(t.id)??en,x:t.position.x,y:t.position.y,w:t.measured?.width??240,h:t.measured?.height??50});return(0,Q.S)(e)},[th,tI,tP]),tL=(0,s.useMemo)(()=>tT?tk.map(e=>{let t=tI.has(e.source)||tI.has(e.target);return tT.has(e.source)&&tT.has(e.target)?{...e,hidden:t,style:{...e.style,opacity:1}}:{...e,hidden:t,label:void 0,style:{...e.style,opacity:.08}}}):tk.map(e=>{let t=tI.has(e.source)||tI.has(e.target);return tC||B?(B?e.id===B:tC&&(e.source===tC||e.target===tC))?{...e,hidden:t,zIndex:20,style:{...e.style,opacity:1,strokeWidth:2.5}}:{...e,hidden:t,selectable:!1,label:void 0,markerEnd:void 0,style:{...e.style,opacity:.08}}:{...e,hidden:t,label:void 0}}),[tk,tC,B,tI,tT]),tF=(0,s.useMemo)(()=>Array.from(new Set(eQ.map(e=>e.domain).filter(e=>!!e))).sort(),[eQ]),tY=(0,s.useMemo)(()=>Array.from(new Set([...eQ.map(e=>e.source),...e0.map(e=>e.source)])).sort(),[eQ,e0]),tB=(0,s.useMemo)(()=>Array.from(new Set(e0.map(e=>e.method))).sort(),[e0]);function tU(e,t){t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let tH=+!P+ez.size+eP.size+eL.size,t_=(0,s.useCallback)(()=>{O(!0),eR(new Set),eO(new Set),eF(new Set)},[]),tG=(0,s.useCallback)(e=>{let{source:t,target:n}=e;t&&n&&t!==n&&eH(e=>{if(!(e.tables.some(e=>e.id===n)||tp.has(n)))return e;let a=e.endpoints.find(e=>e.id===t);return a?a.links.some(e=>e.tableId===n)?e:{...e,endpoints:e.endpoints.map(e=>{var a;return e.id===t?{...e,links:[...e.links,{tableId:n,access:(a=e.method,q.has(a.trim().toUpperCase())?"read":"write")}]}:e})}:e.tables.find(e=>e.id===t)?e.relations.some(e=>e.fromTableId===t&&e.toTableId===n)?e:{...e,relations:[...e.relations,{id:crypto.randomUUID(),fromTableId:t,toTableId:n,fromColumn:"fk",toColumn:"id",label:null}]}:e})},[eH,tp]),tK=(0,s.useMemo)(()=>({readOnly:T,patchEndpoint:(e,t)=>eH(n=>({...n,endpoints:n.endpoints.map(n=>n.id===e?{...n,...t}:n)})),deleteEndpoint:e=>eH(t=>({...t,endpoints:t.endpoints.filter(t=>t.id!==e)})),patchTable:(e,t)=>eH(n=>({...n,tables:n.tables.map(n=>n.id===e?{...n,...t}:n)})),deleteTable:e=>eH(t=>({...t,tables:t.tables.filter(t=>t.id!==e),relations:t.relations.filter(t=>t.fromTableId!==e&&t.toTableId!==e),endpoints:t.endpoints.map(t=>({...t,links:t.links.filter(t=>t.tableId!==e)}))})),deleteRealEndpoint:e=>{fetch(`/api/endpoints/${e}`,{method:"DELETE"}).then(e=>{e.ok&&z.refresh()})}}),[T,eH,z]);(0,s.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.target;if(t&&/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))return;let n=e.key.toLowerCase();"z"===n?(e.preventDefault(),e.shiftKey?eK():eG()):"y"===n&&(e.preventDefault(),eK())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eG,eK]);let tX=(0,s.useCallback)(async()=>{eC(!0);try{if((await fetch("/api/draft/approve",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(eU)})).ok){try{localStorage.removeItem(ey)}catch{}eX(ej),z.refresh()}}finally{eC(!1)}},[eU,eX,z]),tZ=(0,s.useCallback)(async()=>{eC(!0);try{await fetch("/api/draft",{method:"DELETE"})}catch{}try{localStorage.removeItem(ey)}catch{}eX(ej),z.refresh(),eC(!1)},[eX,z]),tW=(0,s.useMemo)(()=>{let e;return e=new Map(eU.tables.map(e=>[e.id,e.name])),{tables:eU.tables.map(e=>({name:e.name,domain:e.domain,description:e.description,columns:e.columns.map(e=>({name:e.name,type:e.type,isPk:e.isPk,isFk:e.isFk,nullable:e.nullable,note:e.note}))})),relations:eU.relations.flatMap(t=>{let n=e.get(t.fromTableId),a=e.get(t.toTableId);return n&&a?[{fromTable:n,fromColumn:t.fromColumn,toTable:a,toColumn:t.toColumn,label:t.label}]:[]}),endpoints:eU.endpoints.map(t=>({method:t.method,path:t.path,domain:t.domain,description:t.description,uses:t.links.flatMap(t=>{let n=e.get(t.tableId);return n?[{table:n,access:t.access}]:[]})}))}},[eU]),tV=eU.tables.length>0||eU.endpoints.length>0,tJ=eY.past.length>0,tq=eY.future.length>0;return(0,a.jsx)(g.Provider,{value:tK,children:(0,a.jsxs)("div",{className:(0,h.cn)("canvas-dots relative w-full",u?"h-full":"h-screen",eh&&"rf-panning"),children:[(0,a.jsxs)(l.Gc,{...eT,nodes:t$,edges:"far"===eD?[...tL,...tN].map(e=>({...e,hidden:!0})):[...tL,...tN.map(e=>({...e,hidden:tI.has(e.source)}))],nodeTypes:eg,edgeTypes:eb,nodesConnectable:!T,connectionMode:i.WZ.Loose,connectionLineStyle:{stroke:"var(--accent-2,#ff7a45)",strokeWidth:1.5,strokeDasharray:"4 4"},onInit:e=>{eS.current=e},onNodesChange:tg,onMoveStart:()=>ef(!0),onMoveEnd:()=>ef(!1),onConnect:tG,onNodeMouseEnter:(e,t)=>{"annotation"!==t.type&&_(t.id)},onNodeMouseLeave:()=>_(null),onNodeClick:(e,t)=>{if("annotation"===t.type){let e=t.data;e.editable||A?.(e.annotationId);return}let n="endpoint"===t.type?"endpoint":"table";F({id:t.id,kind:n}),U(null),K(!0),ek("details")},onEdgeClick:(e,t)=>{U(t.id),F(null)},onPaneClick:()=>{F(null),U(null),K(!1)},onNodeDragStop:tj,onEdgesDelete:e=>{for(let t of e)if(t.id.startsWith("fk-")){let e=t.id.slice(3);fetch(`/api/db/relations/${e}`,{method:"DELETE"})}},onNodesDelete:e=>{for(let t of e)t.id.startsWith("anno-")||tm.has(t.id)||("endpoint"===t.type?fetch(`/api/endpoints/${t.id}`,{method:"DELETE"}):"dbTable"===t.type&&fetch(`/api/db/tables/${t.id}`,{method:"DELETE"}))},deleteKeyCode:T?null:["Backspace","Delete"],colorMode:"dark",fitView:!0,fitViewOptions:{padding:.15,minZoom:.38,maxZoom:.9},minZoom:.15,panOnScroll:!0,zoomActivationKeyCode:["Meta","Control"],proOptions:{hideAttribution:!0},children:[(0,a.jsx)(eo.Z,{regions:tO,tone:"category",lod:eD}),(0,a.jsx)(y.J,{onLod:e$,thresholds:j.fE}),(0,a.jsx)(l.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"}),!u&&(0,a.jsx)(l.of,{pannable:!0,zoomable:!0,position:"bottom-left",style:{width:140,height:90},className:"!overflow-hidden !rounded-xl !border !border-white/10 !bg-card/50 !backdrop-blur",nodeColor:"#555"}),(0,a.jsx)(l.Zk,{position:"bottom-left",style:{marginBottom:118},children:(0,a.jsx)(r.H,{tool:eI,onChange:eM})}),!u&&(0,a.jsx)(l.Zk,{position:"bottom-center",className:"!mb-4",children:(0,a.jsx)("div",{className:"glass flex items-center rounded-full p-0.5",children:(0,a.jsxs)("button",{type:"button",disabled:eN,title:"Re-arrange the board — domain clusters with endpoints docked under their tables",onClick:async()=>{eC(!0);try{let e=window.innerWidth/window.innerHeight;await fetch("/api/db/arrange",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewportAspect:e})}),z.refresh()}finally{eC(!1)}},className:"flex h-6 items-center gap-1.5 rounded-full px-3 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground disabled:opacity-40",children:[(0,a.jsx)(ei.A,{className:"size-3"}),eN?"Arranging…":"Arrange"]})})}),!u&&(0,a.jsx)(l.Zk,{position:"top-center",className:"glass rounded-full px-1 py-0.5",children:(0,a.jsx)(J.Z,{active:"DATABASE",tabs:[{value:"ROADMAP",label:"Roadmap",href:"/map?view=ROADMAP"},{value:"ARCHITECTURE",label:"Architecture",href:"/map?view=ARCHITECTURE"},{value:"DATABASE",label:"Database",href:"/map?view=DATABASE"},{value:"FILES",label:"Files",href:"/map?view=FILES"}]})}),(0,a.jsxs)(l.Zk,{position:"top-right",className:(0,h.cn)("flex items-center gap-1 transition-[margin] duration-200",G&&"!mr-[332px]",u&&"hidden"),children:[(0,a.jsx)(Z.X,{query:eE,onQuery:eA,hits:tz,placeholder:"Find a table, column, endpoint…",onPick:tR,onZoomToMatches:()=>{tT?.size&&eS.current?.fitView({nodes:[...tT].map(e=>({id:e})),duration:600,padding:.2})}}),(0,a.jsx)(W.e,{defaultSelection:"DATABASE"}),(0,a.jsxs)(X.er,{title:"Filters",trigger:(e,t)=>(0,a.jsxs)("button",{type:"button",onClick:t,title:"Filters",className:(0,h.cn)("glass relative flex size-8 items-center justify-center rounded-lg transition-colors",e||tH>0?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,a.jsx)(ed.A,{className:"size-4"}),tH>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-[var(--accent-2,#ff7a45)] px-1 text-[9px] font-semibold text-white",children:tH})]}),children:[(0,a.jsx)(X.r1,{title:"Show",children:(0,a.jsx)(X.vu,{tone:"accent",on:P,onClick:()=>O(e=>!e),children:"endpoints"})}),tF.length>0&&(0,a.jsx)(X.r1,{title:"Domain",children:tF.map(e=>(0,a.jsx)(X.vu,{on:ez.has(e),onClick:()=>tU(e,eR),children:e},e))}),tB.length>0&&(0,a.jsx)(X.r1,{title:"Method",children:tB.map(e=>(0,a.jsx)(X.vu,{on:eL.has(e),onClick:()=>tU(e,eF),children:e},e))}),tY.length>0&&(0,a.jsx)(X.r1,{title:"Source",children:tY.map(e=>(0,a.jsx)(X.vu,{on:eP.has(e),onClick:()=>tU(e,eO),children:e.toLowerCase()},e))}),tH>0&&(0,a.jsx)("button",{type:"button",onClick:t_,className:"mt-1 w-full rounded-md border border-white/10 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/5 hover:text-foreground",children:"clear filters"})]}),(0,a.jsx)(X.er,{title:"Legend",trigger:(e,t)=>(0,a.jsx)("button",{type:"button",onClick:t,title:"Legend",className:(0,h.cn)("glass flex size-8 items-center justify-center rounded-lg transition-colors",e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(ec.A,{className:"size-4"})}),children:(0,a.jsxs)("ul",{className:"space-y-1.5 text-[10.5px] text-muted-foreground",children:[(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"table"}),(0,a.jsx)("span",{children:"a database table \xb7 its columns"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-white/15 bg-white/[0.06] px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-foreground/80",children:"endpoint"}),(0,a.jsx)("span",{children:"an API route \xb7 reads / writes tables"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-px w-6 bg-[#6b6b6b]"}),(0,a.jsx)("span",{children:"foreign key \xb7 drag from a table handle"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#4ea1ff"}}),(0,a.jsx)("span",{children:"endpoint read \xb7 GET / POST / etc"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-0 w-6 border-t border-dashed",style:{borderColor:"#ffb86b"}}),(0,a.jsx)("span",{children:"endpoint write"})]}),(0,a.jsxs)("li",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block rounded border border-dashed border-sky-400/50 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-sky-300",children:"draft"}),(0,a.jsx)("span",{children:"agent-proposed \xb7 approve to persist"})]})]})}),!G&&(0,a.jsx)("button",{onClick:()=>K(!0),title:"Show panel",className:"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,a.jsx)(eu.A,{className:"size-4"})})]}),tV&&(0,a.jsxs)(l.Zk,{position:"bottom-center",className:"glass flex items-center gap-1 rounded-xl p-1.5",children:[(0,a.jsxs)("button",{onClick:eG,disabled:!tJ,title:"Undo (⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(em.A,{className:"size-3.5"})," undo"]}),(0,a.jsxs)("button",{onClick:eK,disabled:!tq,title:"Redo (⇧⌘Z)",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-white/10 hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent",children:[(0,a.jsx)(ep.A,{className:"size-3.5"})," redo"]}),!u&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-1 h-4 w-px bg-white/10"}),(0,a.jsxs)("button",{onClick:tZ,disabled:eN,title:"Discard draft",className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300 disabled:opacity-40",children:[(0,a.jsx)(m.A,{className:"size-3.5"})," discard"]}),(0,a.jsxs)("button",{onClick:tX,disabled:eN,title:"Approve and persist to the schema",className:"flex items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25 disabled:opacity-40",children:[(0,a.jsx)(ex.A,{className:"size-3.5"})," approve draft"]})]})]})]}),G&&(0,a.jsx)(Y,{selected:L,tables:eQ,relations:e4,endpoints:e0,draftGraph:tW,onClose:()=>{K(!1),ek("details")},commentsContent:k,commentsCount:N,activeTab:ew,onTabChange:ek,onAddComment:tc,topOffset:u?64:void 0})]})})}},45437:(e,t,n)=>{n.d(t,{L:()=>o});var a=n(95155),s=n(81750),r=n(28736);function o(e){let t=(0,s.JY)(e.target),n=e.targetX,o=e.targetY,l=t?.measured?.width,i=t?.measured?.height;if(t&&l&&i){let a=(0,r.u)({x:t.internals.positionAbsolute.x,y:t.internals.positionAbsolute.y,w:l,h:i},{x:e.sourceX,y:e.sourceY});n=a.x,o=a.y}let d=e.sourceX,c=e.sourceY,u=n-d,m=o-c,p=Math.hypot(u,m)||1,x=Math.min(.18*p,42),h=(d+n)/2+-m/p*x,f=(c+o)/2+u/p*x,g=`M${d},${c} Q${h},${f} ${n},${o}`;return(0,a.jsx)(s.tE,{id:e.id,path:g,style:e.style,markerEnd:e.markerEnd})}},47409:(e,t,n)=>{n.d(t,{h:()=>y});var a=n(95155),s=n(12115),r=n(25583),o=n(874),l=n(36483),i=n(9107),d=n(76721),c=n(14225),u=n(95660);function m(e,t){return{name:e,path:t,folders:new Map,files:new Map}}function p(e,t){return e.kind!==t.kind?"folder"===e.kind?-1:1:e.name.localeCompare(t.name,void 0,{sensitivity:"base"})}var x=n(91337);let h={added:"text-emerald-400",modified:"text-amber-300",deleted:"text-rose-400 line-through"},f={added:"bg-emerald-400",modified:"bg-amber-300",deleted:"bg-rose-400"};function g({name:e,className:t}){let n=e.slice(e.lastIndexOf(".")+1).toLowerCase();return["ts","tsx","js","jsx","mjs","cjs"].includes(n)?(0,a.jsx)(r.A,{className:t}):"json"===n?(0,a.jsx)(o.A,{className:t}):["md","mdx","txt","css","scss"].includes(n)?(0,a.jsx)(l.A,{className:t}):(0,a.jsx)(i.A,{className:t})}function b({nodes:e,depth:t,collapsed:n,onToggle:s,onSelect:r}){return(0,a.jsx)("ul",{className:(0,x.cn)(t>0&&"ml-[7px] border-l border-white/10 pl-1.5"),children:e.map(e=>"folder"===e.kind?(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s(e.path),title:e.path,className:"flex w-full items-center gap-1 rounded px-1.5 py-1 text-left text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",children:[(0,a.jsx)(d.A,{className:(0,x.cn)("size-3 shrink-0 transition-transform",!n.has(e.path)&&"rotate-90")}),n.has(e.path)?(0,a.jsx)(c.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,a.jsx)(u.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("span",{className:"truncate text-[11px] font-medium",children:e.name})]}),!n.has(e.path)&&(0,a.jsx)(b,{nodes:e.children,depth:t+1,collapsed:n,onToggle:s,onSelect:r})]},`d:${e.path}`):(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onClick:()=>r(e),title:e.path,className:"flex w-full items-center gap-1.5 rounded py-1 pl-[18px] pr-1.5 text-left transition-colors hover:bg-white/[0.06]",children:[(0,a.jsx)(g,{name:e.name,className:(0,x.cn)("size-3.5 shrink-0",e.status?h[e.status]:"text-muted-foreground")}),(0,a.jsx)("span",{className:(0,x.cn)("truncate text-[11px]",e.status?h[e.status]:"text-foreground/90"),children:e.name}),(0,a.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[e.meta&&(0,a.jsx)("span",{className:"text-[9px] text-teal-300/80",children:e.meta}),e.status&&(0,a.jsx)("span",{className:(0,x.cn)("size-1.5 rounded-full",f[e.status])})]})]})},`f:${e.path}`))})}function y({files:e,onSelect:t,collapse:n=!0,emptyLabel:r,className:o}){let l=(0,s.useMemo)(()=>(function(e,t={}){let n=t.collapseSingleChildFolders??!0,a=m("","");for(let t of e){let e=t.path.split("\\").join("/").trim().replace(/^\/+/,"").replace(/\/+$/,"");if(!e)continue;let n=e.split("/").filter(Boolean);if(!n.length)continue;let s=a;for(let e=0;e<n.length-1;e++){let t=n[e],a=s.path?`${s.path}/${t}`:t,r=s.folders.get(t);r||(r=m(t,a),s.folders.set(t,r)),s=r}let r=n[n.length-1];s.files.set(r,{kind:"file",name:r,path:e,status:t.status,meta:t.meta})}return function e(t,n){let a=[];for(let s of t.folders.values())a.push(function(t,n){let a=t.name,s=t;for(;n&&0===s.files.size&&1===s.folders.size;){let e=s.folders.values().next().value;a=`${a}/${e.name}`,s=e}return{kind:"folder",name:a,path:s.path,children:e(s,n)}}(s,n));for(let e of t.files.values())a.push(e);return a.sort(p)}(a,n)})(e,{collapseSingleChildFolders:n}),[e,n]),[i,d]=(0,s.useState)(()=>new Set);return l.length?(0,a.jsx)("div",{className:o,children:(0,a.jsx)(b,{nodes:l,depth:0,collapsed:i,onToggle:e=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{var n;return t?t(e.path):(n=e.path,void fetch(`/api/open?path=${encodeURIComponent(n)}`).catch(()=>{}))}})}):r?(0,a.jsx)("p",{className:(0,x.cn)("px-2 py-1 text-[11px] text-muted-foreground",o),children:r}):null}},54698:(e,t,n)=>{n.d(t,{m:()=>a});function a(e,t){let n=[];return e.forEach((e,a)=>{let s=e.excerpt.trim();if(!s)return;let r={annotationId:e.id,n:a+1};for(let e of t.tables){if(s===e.name)return void n.push({...r,kind:"table",targetId:e.id,column:null});if(s.startsWith(`${e.name}.`)){let t=s.slice(e.name.length+1);if(e.columns.includes(t))return void n.push({...r,kind:"column",targetId:e.id,column:t})}}for(let e of t.endpoints??[])if(s===`${e.method} ${e.path}`)return void n.push({...r,kind:"endpoint",targetId:e.id,column:null});for(let e of t.features??[])if(s===e.title||s===`feature: ${e.title}`)return void n.push({...r,kind:"feature",targetId:e.id,column:null})}),n}},56614:(e,t,n)=>{n.d(t,{er:()=>o,r1:()=>l,vu:()=>i});var a=n(95155),s=n(12115),r=n(91337);function o({trigger:e,title:t,align:n="right",children:l,open:i,onOpenChange:d,outsideClicksToClose:c=1}){let[u,m]=(0,s.useState)(!1),[p,x]=(0,s.useState)("down"),h=i??u,f=e=>{void 0===i&&m(e),d?.(e)},g=(0,s.useRef)(null),b=(0,s.useRef)(()=>{});return(0,s.useEffect)(()=>{b.current=()=>f(!1)}),(0,s.useEffect)(()=>{if(!h)return;let e=g.current?.firstElementChild?.getBoundingClientRect();e&&x(window.innerHeight-e.bottom<260?"up":"down")},[h]),(0,s.useEffect)(()=>{if(!h)return;let e=0,t=null,n=()=>{t&&clearTimeout(t),t=null},a=a=>{if(g.current?.contains(a.target)){e=0,n();return}c<=1?b.current():(e+=1)>=c?(e=0,n(),b.current()):(n(),t=setTimeout(()=>{e=0},1500))},s=e=>{"Escape"===e.key&&b.current()};return window.addEventListener("mousedown",a,!0),window.addEventListener("keydown",s),()=>{n(),window.removeEventListener("mousedown",a,!0),window.removeEventListener("keydown",s)}},[h,c]),(0,a.jsxs)("div",{ref:g,className:"relative",children:[e(h,()=>f(!h)),h&&(0,a.jsxs)("div",{className:(0,r.cn)("glass absolute z-30 w-64 rounded-xl p-3 shadow-xl","up"===p?"bottom-full mb-1.5":"top-full mt-1.5","right"===n?"right-0":"left-0"),children:[t&&(0,a.jsx)("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),l]})]})}function l({title:e,children:t}){return(0,a.jsxs)("div",{className:"mb-2.5 last:mb-0",children:[(0,a.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80",children:e}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:t})]})}function i({on:e,onClick:t,children:n,tone:s="default"}){return(0,a.jsx)("button",{type:"button",onClick:t,className:(0,r.cn)("rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",{default:e?"border-foreground/40 bg-white/10 text-foreground":"border-white/10 text-muted-foreground hover:text-foreground",danger:e?"border-red-500/40 bg-red-500/15 text-red-300":"border-white/10 text-muted-foreground hover:text-foreground",accent:e?"border-sky-500/40 bg-sky-500/15 text-sky-300":"border-white/10 text-muted-foreground hover:text-foreground"}[s]),children:n})}},56895:(e,t,n)=>{n.d(t,{W:()=>s});var a=n(12115);function s(e,t){let[n,s]=(0,a.useState)(!1),[r,o]=(0,a.useState)(0),l=n?e[r]??null:null,i=(0,a.useCallback)(()=>{o(0),s(!0)},[]),d=(0,a.useCallback)(()=>s(!1),[]),c=(0,a.useCallback)(()=>o(t=>Math.min(t+1,e.length-1)),[e.length]),u=(0,a.useCallback)(()=>o(e=>Math.max(e-1,0)),[]),m=(0,a.useCallback)(t=>{t>=0&&t<e.length&&o(t)},[e.length]);(0,a.useEffect)(()=>{if(!n)return;let a=e[r];a&&t(a)},[n,r]),(0,a.useEffect)(()=>{if(!n)return;let e=e=>{"ArrowRight"===e.key?(e.preventDefault(),c()):"ArrowLeft"===e.key?(e.preventDefault(),u()):"Escape"===e.key&&(e.preventDefault(),d())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,c,u,d]);let p=(0,a.useMemo)(()=>l&&l.focusIds.length?new Set(l.focusIds):null,[l]);return{active:n,index:r,step:l,start:i,stop:d,next:c,prev:u,goto:m,focusIds:p}}},62311:(e,t,n)=>{n.d(t,{Z:()=>h});var a=n(95155),s=n(12115),r=n(98500),o=n.n(r),l=n(25640),i=n(83599),d=n(94192),c=n(34306),u=n(60292),m=n(75514),p=n(91337);let x={ROADMAP:l.A,ARCHITECTURE:i.A,FILES:d.A,DATABASE:c.A};function h({tabs:e,active:t}){let[n,r]=(0,s.useState)(null);(0,s.useEffect)(()=>{r((0,u.fk)())},[]);let l=(0,m.$2)();return(0,a.jsx)("div",{className:"flex items-center gap-0.5",children:e.map(e=>{let s,r=e.value===t,i=e.Icon??x[e.value],d=(0,p.cn)("flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[12px] font-medium tracking-tight transition-colors",r?"border-white/10 bg-white/[0.07] text-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]":"border-transparent text-muted-foreground/80 hover:bg-white/5 hover:text-foreground"),c=(0,a.jsxs)(a.Fragment,{children:[i?(0,a.jsx)(i,{className:(0,p.cn)("size-3",r&&"text-[#ff7a45]")}):null,(0,a.jsx)("span",{children:e.label})]});return l?.views.has(e.value)?(0,a.jsx)("button",{type:"button",onClick:()=>l.switchTo(e.value),className:d,children:c},e.value):(0,a.jsx)(o(),{href:(s=e.href,n?`${s}${s.includes("?")?"&":"?"}ws=${n}`:s),className:d,children:c},e.value)})})}},66616:(e,t,n)=>{n.d(t,{E:()=>r});var a=n(95155),s=n(91337);function r({active:e,onClick:t,icon:n,children:o}){return(0,a.jsxs)("button",{type:"button",onClick:t,className:(0,s.cn)("flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",e?"bg-white/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:[n,o]})}},70221:(e,t,n)=>{n.d(t,{fE:()=>r,gt:()=>o,kz:()=>s});let a={far:.3,farExit:.34,mid:.55,midExit:.6},s={far:.12,farExit:.15,mid:.45,midExit:.5},r={far:.2,farExit:.24,mid:.32,midExit:.36};function o(e,t="full",n=a){return e<n.far||"far"===t&&e<n.farExit?"far":e<n.mid||"mid"===t&&e<n.midExit?"mid":"full"}},70521:(e,t,n)=>{n.d(t,{$v:()=>w,EO:()=>b,Lt:()=>x,Rx:()=>k,Zr:()=>N,ck:()=>j,r7:()=>v,tv:()=>h,wd:()=>y});var a=n(95155);n(12115);var s=n(25381),r=n(7121),o=n(51880),l=n(35176),i=n(11248),d=n(82022),c=n(98758),u=n(45362),m=n(91337),p=n(4474);function x({...e}){return(0,a.jsx)(s.V,{"data-slot":"alert-dialog",...e})}function h({...e}){return(0,a.jsx)(r.t,{"data-slot":"alert-dialog-trigger",...e})}function f({...e}){return(0,a.jsx)(o.Z,{"data-slot":"alert-dialog-portal",...e})}function g({className:e,...t}){return(0,a.jsx)(l.X,{"data-slot":"alert-dialog-overlay",className:(0,m.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function b({className:e,size:t="default",...n}){return(0,a.jsxs)(f,{children:[(0,a.jsx)(g,{}),(0,a.jsx)(i.h,{"data-slot":"alert-dialog-content","data-size":t,className:(0,m.cn)("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function y({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,m.cn)("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function j({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,m.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function v({className:e,...t}){return(0,a.jsx)(d.L,{"data-slot":"alert-dialog-title",className:(0,m.cn)("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function w({className:e,...t}){return(0,a.jsx)(c.r,{"data-slot":"alert-dialog-description",className:(0,m.cn)("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function k({className:e,variant:t,size:n,...s}){return(0,a.jsx)(u.H,{"data-slot":"alert-dialog-action",className:(0,m.cn)(e),render:(0,a.jsx)(p.$,{variant:t,size:n}),...s})}function N({className:e,variant:t="outline",size:n="default",...s}){return(0,a.jsx)(u.H,{"data-slot":"alert-dialog-cancel",className:(0,m.cn)(e),render:(0,a.jsx)(p.$,{variant:t,size:n}),...s})}},70947:(e,t,n)=>{n.d(t,{Z:()=>l});var a=n(95155),s=n(81750),r=n(12410),o=n(91337);function l({regions:e,tone:t="neutral",lod:n="full"}){let i=(0,s.Pj)(e=>e.transform[2]);if(0===e.length)return null;let d="far"===n,c=Math.min(150,26/Math.max(i,.05)),u=Math.min(80,13/Math.max(i,.05));return(0,a.jsx)(s.DX,{children:e.map(e=>(0,a.jsx)("div",{style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none",zIndex:0},className:(0,o.cn)("rounded-2xl border","category"===t?(0,r.xZ)(e.key):"border-white/[0.08] bg-white/[0.015]",d&&"bg-card/80"),children:d?(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-[0.3em] px-2",children:[(0,a.jsx)("span",{className:"whitespace-nowrap text-center font-semibold tracking-tight text-foreground",style:{fontSize:Math.min(c,.34*e.h,(e.w-16)/(.74*Math.max(e.label.length,1))),lineHeight:1.1},children:e.label}),(0,a.jsxs)("span",{className:"tabular-nums text-muted-foreground",style:{fontSize:Math.min(u,.18*e.h)},children:[e.count," ",1===e.count?"card":"cards"]})]}):(0,a.jsxs)("div",{className:"flex items-baseline gap-2 px-3 py-1",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.label}),(0,a.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground/50",children:e.count})]})},e.key))})}},74350:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>y,L3:()=>j,c7:()=>b,lG:()=>x,rr:()=>v});var a=n(95155);n(12115);var s=n(17112),r=n(51880),o=n(35176),l=n(11248),i=n(45362),d=n(82022),c=n(98758),u=n(91337),m=n(4474),p=n(9005);function x({...e}){return(0,a.jsx)(s.D,{"data-slot":"dialog",...e})}function h({...e}){return(0,a.jsx)(r.Z,{"data-slot":"dialog-portal",...e})}function f({className:e,...t}){return(0,a.jsx)(o.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function g({className:e,children:t,showCloseButton:n=!0,...s}){return(0,a.jsxs)(h,{children:[(0,a.jsx)(f,{}),(0,a.jsxs)(l.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s,children:[t,n&&(0,a.jsxs)(i.H,{"data-slot":"dialog-close",render:(0,a.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,a.jsx)(p.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",e),...t})}function y({className:e,showCloseButton:t=!1,children:n,...s}){return(0,a.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...s,children:[n,t&&(0,a.jsx)(i.H,{render:(0,a.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function j({className:e,...t}){return(0,a.jsx)(d.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",e),...t})}function v({className:e,...t}){return(0,a.jsx)(c.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}},75514:(e,t,n)=>{n.d(t,{$2:()=>o,a4:()=>s,no:()=>r});var a=n(12115);let s=new Set(["ROADMAP","ARCHITECTURE","DATABASE"]),r=(0,a.createContext)(null);function o(){return(0,a.useContext)(r)}},80277:(e,t,n)=>{n.d(t,{H:()=>c,e:()=>d});var a=n(95155),s=n(12115),r=n(6266),o=n(61285),l=n(91906),i=n(91337);function d(e="pan"){let[t,n]=(0,s.useState)(e);(0,s.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))||("v"===e.key||"V"===e.key?n("select"):("h"===e.key||"H"===e.key)&&n("pan"))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let a="pan"===t?{panOnDrag:!0,selectionOnDrag:!1,selectionMode:r.Qc.Partial,selectNodesOnDrag:!1}:{panOnDrag:[1,2],selectionOnDrag:!0,selectionMode:r.Qc.Partial,selectNodesOnDrag:!1};return{tool:t,setTool:n,flowProps:a,paneClass:"select"===t?"rf-tool-select":void 0}}function c({tool:e,onChange:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-0.5 rounded-xl border border-white/15 bg-[#202024]/95 p-1 shadow-lg backdrop-blur",children:[(0,a.jsx)(u,{active:"select"===e,label:"Select tool (V) — drag to box-select; move many nodes at once",onClick:()=>t("select"),children:(0,a.jsx)(o.A,{className:"size-4"})}),(0,a.jsx)(u,{active:"pan"===e,label:"Hand tool (H) — drag to pan the board",onClick:()=>t("pan"),children:(0,a.jsx)(l.A,{className:"size-4"})})]})}function u({active:e,label:t,onClick:n,children:s}){return(0,a.jsx)("button",{type:"button",title:t,"aria-pressed":e,onClick:n,className:(0,i.cn)("flex size-7 items-center justify-center rounded-lg transition-colors",e?"bg-[#ff7a45]/15 text-[#ff7a45]":"text-muted-foreground hover:bg-white/8 hover:text-foreground"),children:s})}},89793:(e,t,n)=>{n.d(t,{b:()=>s});var a=n(12115);function s(){let[e,t]=(0,a.useState)("idle"),[n,s]=(0,a.useState)(""),[r,o]=(0,a.useState)(""),[l,i]=(0,a.useState)(!1);async function d(){try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)}catch{}}return{status:e,url:n,error:r,copied:l,mint:async function e(e){t("loading"),o(""),i(!1);try{let n=await fetch("/api/share/create",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),a=await n.json();if(!n.ok||!a.url){o(a.error??"Could not create the link."),t("error");return}s(a.url),t("done")}catch{o("Could not reach the local Beacon daemon."),t("error")}},copy:d,reset:function(){t("idle"),s(""),o(""),i(!1)}}}},91157:(e,t,n)=>{n.d(t,{b:()=>o,d:()=>l});let a=e=>e.slice(e.lastIndexOf("/")+1),s=(e,t)=>t>e?", …":"";function r(e){let t=new Map;for(let n of e)t.set(a(n),(t.get(a(n))??0)+1);return e.map(e=>{let n=a(e);if((t.get(n)??0)<=1)return n;let s=e.slice(0,e.lastIndexOf("/")),r=s.slice(s.lastIndexOf("/")+1);return r?`${r}/${n}`:n})}function o(e,t,n){if(0===e.length)return[];let a=e=>n.get(e)??"(root)",o=new Map;for(let t of e){let e=a(t.path),n=o.get(e);n?n.push(t):o.set(e,[t])}let l=[...o.keys()],i=e=>o.get(e)?.length??0,d=new Map,c=new Map;for(let e of l)d.set(e,new Set),c.set(e,0);let u=new Set;for(let e of t){if(e.circular)continue;let t=a(e.from),n=a(e.to);if(t===n||!d.has(t)||!d.has(n))continue;let s=`${t}\0${n}`;u.has(s)||(u.add(s),d.get(t).add(n),c.set(n,(c.get(n)??0)+1))}let m=(e,t)=>i(t)-i(e)||e.localeCompare(t),p=new Map(c),x=new Set,h=[];for(;h.length<l.length;){let e=l.filter(e=>!x.has(e)&&(p.get(e)??0)===0).sort(m);if(0===e.length){for(let e of l.filter(e=>!x.has(e)).sort((e,t)=>(p.get(e)??0)-(p.get(t)??0)||i(t)-i(e)||e.localeCompare(t)))h.push(e),x.add(e);break}for(let t of e)for(let e of(h.push(t),x.add(t),d.get(t)))p.set(e,(p.get(e)??0)-1)}let f=e.filter(e=>(e.inDegree??0)===0).sort((e,t)=>(t.outDegree??0)-(e.outDegree??0)||e.path.localeCompare(t.path)),g=[];if(g.push({id:"tour:overview",kind:"overview",title:"Project overview",summary:`${e.length} files across ${l.length} ${1===l.length?"area":"areas"} \xb7 ${t.length} imports. Step through the architecture in dependency order — entry points first.`,focusIds:[]}),f.length){let e=r(f.slice(0,4).map(e=>e.path));g.push({id:"tour:entry",kind:"entry",title:"Entry points",summary:`${f.length} file${1===f.length?"":"s"} nothing imports — where execution starts: ${e.join(", ")}${s(4,f.length)}.`,focusIds:f.slice(0,12).map(e=>e.path)})}for(let e of h){let t=o.get(e),n=r([...t].sort((e,t)=>(t.inDegree??0)-(e.inDegree??0)||e.path.localeCompare(t.path)).slice(0,3).map(e=>e.path)),a=[...d.get(e)].sort(m),l=a.length?` \xb7 imports ${a.slice(0,3).join(", ")}${s(3,a.length)}`:" \xb7 no cross-area imports";g.push({id:`tour:group:${e}`,kind:"group",title:e,summary:`${t.length} file${1===t.length?"":"s"}${l} \xb7 top hubs: ${n.join(", ")}.`,focusIds:t.map(e=>e.path)})}return g}function l(e){if(0===e.length)return[];let t=e=>e.cluster?.trim()||"—",n=new Map;for(let a of e){let e=t(a),s=n.get(e);s?s.push(a):n.set(e,[a])}let a=e=>Math.min(...n.get(e).map(e=>e.x??0)),r=[...n.keys()].sort((e,t)=>a(e)-a(t)||e.localeCompare(t)),o=[{id:"tour:overview",kind:"overview",title:"Architecture overview",summary:`${e.length} component${1===e.length?"":"s"} across ${r.length} ${1===r.length?"domain":"domains"}. Walk the architecture domain by domain, upstream first.`,focusIds:[]}];for(let e of r){let t=n.get(e),a=t.slice(0,3).map(e=>e.title?.trim()||e.id);o.push({id:`tour:domain:${e}`,kind:"group",title:e,summary:`${t.length} component${1===t.length?"":"s"}: ${a.join(", ")}${s(3,t.length)}.`,focusIds:t.map(e=>e.id)})}return o}},94014:(e,t,n)=>{n.d(t,{Xi:()=>a});function a(e,t){let n,a,s,r=(a=((n=t.viewportAspect)&&Number.isFinite(n)&&n>0?Math.min(3.2,Math.max(.7,n)):1.8)*(t.aspectSlack??1),s=e.reduce((e,n)=>e+(n.w+t.gapX)*(n.h+t.gapY),0),Math.max(t.minBandW,Math.round(Math.sqrt(s*a)))),o=new Map,l=0,i=0,d=0;for(let n of e)l>0&&l+n.w>r&&(i+=d+t.gapY,l=0,d=0),o.set(n.id,{x:l,y:i}),d=Math.max(d,n.h),l+=n.w+t.gapX;return o}},95635:(e,t,n)=>{n.d(t,{x:()=>o});var a=n(95155),s=n(81750),r=n(6266);function o(){let e="!h-2 !w-2 !border-0 !bg-zinc-400";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.h7,{type:"target",position:r.yX.Top,id:"tt",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Top,id:"st",className:e}),(0,a.jsx)(s.h7,{type:"target",position:r.yX.Right,id:"tr",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Right,id:"sr",className:e}),(0,a.jsx)(s.h7,{type:"target",position:r.yX.Bottom,id:"tb",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Bottom,id:"sb",className:e}),(0,a.jsx)(s.h7,{type:"target",position:r.yX.Left,id:"tl",className:e}),(0,a.jsx)(s.h7,{type:"source",position:r.yX.Left,id:"sl",className:e})]})}},96719:(e,t,n)=>{n.d(t,{F:()=>i});var a=n(95155),s=n(64577),r=n(99314),o=n(1275),l=n(4474);function i({url:e,copied:t,onCopy:n}){return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{readOnly:!0,value:e,onFocus:e=>e.currentTarget.select(),className:"min-w-0 flex-1 rounded-md border border-white/10 bg-background px-2.5 py-1.5 text-[12px] text-foreground outline-none"}),(0,a.jsxs)(l.$,{size:"sm",variant:"outline",onClick:n,children:[t?(0,a.jsx)(s.A,{className:"size-3.5"}):(0,a.jsx)(r.A,{className:"size-3.5"}),t?"Copied":"Copy"]})]}),(0,a.jsxs)("a",{href:e,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[12px] text-muted-foreground transition-colors hover:text-foreground",children:[(0,a.jsx)(o.A,{className:"size-3.5"})," Open the shared view"]})]})}},98238:(e,t,n)=>{n.d(t,{F:()=>o,o:()=>l});var a=n(95155),s=n(28161),r=n(91337);function o(e,t){return!!t&&("fullstack"===e?"fullstack"===t:t===e||"fullstack"===t)}function l({value:e,onChange:t,options:n=s.RR,bare:o=!1}){return(0,a.jsx)("div",{className:(0,r.cn)("flex items-center gap-0.5",!o&&"glass rounded-lg p-0.5"),children:n.map(n=>{let o=e===n;return(0,a.jsxs)("button",{type:"button",onClick:()=>t(o?null:n),title:o?"Show every layer at full strength again":`Highlight ${s.YG[n].label} — other cards dim, nothing is hidden`,className:(0,r.cn)("flex h-7 items-center gap-1.5 rounded-md px-2 text-[10px] font-semibold uppercase tracking-wide transition-colors",o?"bg-white/[0.12] text-foreground":"text-muted-foreground hover:bg-white/[0.06] hover:text-foreground"),children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"h-3 w-[3px] shrink-0 rounded-full",style:{background:(0,s.A6)(n)}}),s.YG[n].short]},n)})})}}}]);
|