syntaur 0.41.2 → 0.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dashboard/dist/assets/{_basePickBy-CMGil-NY.js → _basePickBy-ZMecMDb-.js} +1 -1
  3. package/dashboard/dist/assets/{_baseUniq-DllyUaEJ.js → _baseUniq-tVAi81J9.js} +1 -1
  4. package/dashboard/dist/assets/{arc-C6fNP_LJ.js → arc-BMB5nyvD.js} +1 -1
  5. package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-CxXDnbMY.js → architectureDiagram-2XIMDMQ5-1_ttZgNb.js} +1 -1
  6. package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-B8UDJhxg.js → blockDiagram-WCTKOSBZ-BAuowdCy.js} +1 -1
  7. package/dashboard/dist/assets/{c4Diagram-IC4MRINW-9XDZP3AD.js → c4Diagram-IC4MRINW-DgqpYWNQ.js} +1 -1
  8. package/dashboard/dist/assets/channel-CIhg4t-B.js +1 -0
  9. package/dashboard/dist/assets/{chunk-4BX2VUAB-D1LR7D9Y.js → chunk-4BX2VUAB-Dul2PJq1.js} +1 -1
  10. package/dashboard/dist/assets/{chunk-55IACEB6-sumE5d0X.js → chunk-55IACEB6-BNsItfH6.js} +1 -1
  11. package/dashboard/dist/assets/{chunk-FMBD7UC4-C-Iy8wke.js → chunk-FMBD7UC4-C3btqaF-.js} +1 -1
  12. package/dashboard/dist/assets/{chunk-JSJVCQXG-Clyrcmzt.js → chunk-JSJVCQXG-BjrX5MC8.js} +1 -1
  13. package/dashboard/dist/assets/{chunk-KX2RTZJC-BQqetgrP.js → chunk-KX2RTZJC-xMrVR3MQ.js} +1 -1
  14. package/dashboard/dist/assets/{chunk-NQ4KR5QH-Cw60fnx2.js → chunk-NQ4KR5QH-Dd67ojLx.js} +1 -1
  15. package/dashboard/dist/assets/{chunk-QZHKN3VN-Dv40SU2-.js → chunk-QZHKN3VN-Dqombp1k.js} +1 -1
  16. package/dashboard/dist/assets/{chunk-WL4C6EOR-DFiOufrs.js → chunk-WL4C6EOR-CCYZi5vV.js} +1 -1
  17. package/dashboard/dist/assets/classDiagram-VBA2DB6C-Bmt2MjbS.js +1 -0
  18. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-Bmt2MjbS.js +1 -0
  19. package/dashboard/dist/assets/clone-BfVm3try.js +1 -0
  20. package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-DV306SRn.js → cose-bilkent-S5V4N54A-CYmvV1RQ.js} +1 -1
  21. package/dashboard/dist/assets/{dagre-KLK3FWXG-DaQ1pWLV.js → dagre-KLK3FWXG-DXFT_Iz5.js} +1 -1
  22. package/dashboard/dist/assets/{diagram-E7M64L7V-2fsjMT-T.js → diagram-E7M64L7V-CkCF8e9h.js} +1 -1
  23. package/dashboard/dist/assets/{diagram-IFDJBPK2-CoaSyKLw.js → diagram-IFDJBPK2-CqIk_zgE.js} +1 -1
  24. package/dashboard/dist/assets/{diagram-P4PSJMXO-C_j6Kd6q.js → diagram-P4PSJMXO-BV-579JX.js} +1 -1
  25. package/dashboard/dist/assets/{erDiagram-INFDFZHY-CpOdYJWS.js → erDiagram-INFDFZHY-CeFxcSCp.js} +1 -1
  26. package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-KVRjmhbG.js → flowDiagram-PKNHOUZH-D2IGFjb7.js} +1 -1
  27. package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-CA_n5ynk.js → ganttDiagram-A5KZAMGK-CctYGwR7.js} +1 -1
  28. package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-DKkS_iH8.js → gitGraphDiagram-K3NZZRJ6-zt67Doyo.js} +1 -1
  29. package/dashboard/dist/assets/{graph-C6ehraTW.js → graph-DZiyaEGT.js} +1 -1
  30. package/dashboard/dist/assets/{index-CdHziP5R.css → index-6uihSopA.css} +1 -1
  31. package/dashboard/dist/assets/{index-SW4WrQLg.js → index-GK0h-4Nt.js} +3 -3
  32. package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-H1Eg4YK9.js → infoDiagram-LFFYTUFH-jvCdU_x3.js} +1 -1
  33. package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-DSrc4sub.js → ishikawaDiagram-PHBUUO56-B3LJ4cf3.js} +1 -1
  34. package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-Bl_0LgIo.js → journeyDiagram-4ABVD52K-CtEednnS.js} +1 -1
  35. package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-Cq2WGyif.js → kanban-definition-K7BYSVSG-BhPQqjK5.js} +1 -1
  36. package/dashboard/dist/assets/{layout-DJv9vite.js → layout-DBtJEEbD.js} +1 -1
  37. package/dashboard/dist/assets/{linear-CAef3hQD.js → linear-CSinjjkH.js} +1 -1
  38. package/dashboard/dist/assets/{mermaid.core-B_gAmtAa.js → mermaid.core-Cu6allRd.js} +4 -4
  39. package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-4aIWu_CK.js → mindmap-definition-YRQLILUH-SFkGLxic.js} +1 -1
  40. package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-1ThATMqf.js → pieDiagram-SKSYHLDU-CM63Vi0v.js} +1 -1
  41. package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-BEq2jVyN.js → quadrantDiagram-337W2JSQ-KNLfFOZV.js} +1 -1
  42. package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-DbYJrAQ9.js → requirementDiagram-Z7DCOOCP-CUTnDKwW.js} +1 -1
  43. package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-DMr3kn8l.js → sankeyDiagram-WA2Y5GQK-BJh1laae.js} +1 -1
  44. package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-BR03-l-y.js → sequenceDiagram-2WXFIKYE-DLrWjp9t.js} +1 -1
  45. package/dashboard/dist/assets/{stateDiagram-RAJIS63D-DUj-dVll.js → stateDiagram-RAJIS63D-AYRZyAEg.js} +1 -1
  46. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-BRhe6_kr.js +1 -0
  47. package/dashboard/dist/assets/{timeline-definition-YZTLITO2-DpN8jElm.js → timeline-definition-YZTLITO2-BG2DbYEn.js} +1 -1
  48. package/dashboard/dist/assets/{treemap-KZPCXAKY-CyUTDKiM.js → treemap-KZPCXAKY-D8ZVNAo3.js} +1 -1
  49. package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-DRJFiQmT.js → vennDiagram-LZ73GAT5-BqBHdSLd.js} +1 -1
  50. package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-DcrZVnQ-.js → xychartDiagram-JWTSCODW-DBgm8PRH.js} +1 -1
  51. package/dashboard/dist/index.html +2 -2
  52. package/package.json +1 -1
  53. package/platforms/claude-code/.claude-plugin/plugin.json +1 -1
  54. package/platforms/codex/.codex-plugin/plugin.json +1 -1
  55. package/platforms/hermes/plugins/syntaur/__pycache__/__init__.cpython-312.pyc +0 -0
  56. package/platforms/hermes/plugins/syntaur/__pycache__/boundary.cpython-312.pyc +0 -0
  57. package/dashboard/dist/assets/channel-OsoeK3Lk.js +0 -1
  58. package/dashboard/dist/assets/classDiagram-VBA2DB6C-BKX6nUBp.js +0 -1
  59. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-BKX6nUBp.js +0 -1
  60. package/dashboard/dist/assets/clone-f-TTh9ms.js +0 -1
  61. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-Dzzbhq6b.js +0 -1
@@ -527,7 +527,7 @@ You can add a description to the \`${si}\` by passing a \`${Hk}\` component as a
527
527
 
528
528
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${si}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
529
529
 
530
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return f.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},wD=_k,jD=Fk,Yk=zk,Jk=Bk,Xk=Kk,Qk=Gk,Zk=Vk,e1=Wk;const Ga=wD,kD=jD,t1=f.forwardRef(({className:e,...t},n)=>r.jsx(Yk,{ref:n,className:Se("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));t1.displayName=Yk.displayName;const Bo=f.forwardRef(({className:e,...t},n)=>r.jsxs(kD,{children:[r.jsx(t1,{}),r.jsx(Jk,{ref:n,className:Se("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...t})]}));Bo.displayName=Jk.displayName;function Ya({className:e,...t}){return r.jsx("div",{className:Se("flex flex-col space-y-2 text-left",e),...t})}function Ja({className:e,...t}){return r.jsx("div",{className:Se("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Uo=f.forwardRef(({className:e,...t},n)=>r.jsx(Zk,{ref:n,className:Se("text-lg font-semibold tracking-tight text-foreground",e),...t}));Uo.displayName=Zk.displayName;const Vo=f.forwardRef(({className:e,...t},n)=>r.jsx(e1,{ref:n,className:Se("text-sm leading-6 text-muted-foreground",e),...t}));Vo.displayName=e1.displayName;const oo=f.forwardRef(({className:e,...t},n)=>r.jsx(Xk,{ref:n,className:Se(e),...t}));oo.displayName=Xk.displayName;const Ul=f.forwardRef(({className:e,...t},n)=>r.jsx(Qk,{ref:n,className:Se(e),...t}));Ul.displayName=Qk.displayName;const SD=[{to:"/",label:"Overview",icon:u0},{to:"/playbooks",label:"Playbooks",icon:i0},{to:"/memories",label:"Memories",icon:ZT},{to:"/resources",label:"Resources",icon:mR},{to:"/inventories",label:"Inventories",icon:Ld},{to:"/usage",label:"Usage",icon:Od},{to:"/todos",label:"Todos",icon:Dr},{to:"/views",label:"Saved Views",icon:p0},{to:"/archive",label:"Archive",icon:Dd}],ND=[{suffix:"/projects",label:"Projects",icon:eg},{suffix:"/assignments",label:"Assignments",icon:xR},{suffix:"/servers",label:"Servers",icon:sg},{suffix:"/inventories",label:"Inventories",icon:Ld},{suffix:"/usage",label:"Usage",icon:Od},{suffix:"/agent-sessions",label:"Agent Sessions",icon:Ad},{suffix:"/todos",label:"Todos",icon:Dr}],CD=[{to:"/help",label:"Help",icon:hR},{to:"/settings",label:"Settings",icon:ER}];function ED({title:e,breadcrumbs:t,projectSlug:n,workspace:s,children:a}){const[l,c]=f.useState(!1);return Ht({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:l,handler:()=>c(!1)}),r.jsx("div",{className:"min-h-screen bg-background",children:r.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[r.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar px-4 py-4 lg:flex lg:flex-col",children:r.jsx(zv,{activeWorkspace:s})}),l?r.jsx("div",{className:"fixed inset-0 z-40 bg-overlay/40 lg:hidden",children:r.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx(Ee,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>c(!1),children:"Syntaur"}),r.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80",children:r.jsx(ig,{className:"h-4 w-4"})})]}),r.jsx(zv,{activeWorkspace:s,onNavigate:()=>c(!1)})]})}):null,r.jsxs("div",{className:"min-w-0",children:[r.jsx(eD,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>c(!0)}),r.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:a})]})]})})}function zv({activeWorkspace:e,onNavigate:t}){const{data:n}=oc(),s=(n==null?void 0:n.workspaces)??[],a=(n==null?void 0:n.hasUngrouped)??!1,{hidden:l}=Ik(),c=Wn(),[u,p]=f.useState(new Set),[m,h]=f.useState(!1),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null),[N,T]=f.useState(!1),D=Dt();function R(B){p(O=>{const W=new Set(O);return W.has(B)?W.delete(B):W.add(B),W})}const $=rD([...s,...a?[ld]:[]],l);async function L(B){if(j){T(!0);try{const O=`/api/workspaces/${encodeURIComponent(j)}${B?"?cascade=true":""}`,W=await fetch(O,{method:"DELETE"});if(W.status===409){const se=await W.json().catch(()=>({}));C((se==null?void 0:se.blockedBy)??{projects:[],standalones:[]});return}if(!W.ok){const se=await W.json().catch(()=>({}));throw new Error(se.error||"Failed to delete workspace")}w(null),C(null)}catch(O){console.error(O),alert(O instanceof Error?O.message:"Failed to delete workspace")}finally{T(!1)}}}async function K(B,O){try{if(B.type==="project"){const W=await fetch(`/api/projects/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:O})});if(!W.ok){const se=await W.json().catch(()=>({}));throw new Error(se.error||"Failed to move project")}return}if(B.type==="standalone-assignment"){const W=await fetch(`/api/assignments/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:O})});if(!W.ok){const se=await W.json().catch(()=>({}));throw new Error(se.error||"Failed to move assignment")}return}if(B.type==="project-assignment"){alert("Assignments inherit workspace from their project — drag the project (or move it) to change workspaces.");return}}catch(W){console.error(W),alert(W instanceof Error?W.message:"Failed to move item")}}return r.jsxs("div",{className:"flex h-full flex-col gap-3",children:[r.jsx("div",{className:"space-y-3",children:r.jsxs(Ee,{to:"/",className:"inline-flex items-center gap-3",onClick:t,children:[r.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:r.jsxs("svg",{viewBox:"0 0 43 51","aria-label":"Syntaur",role:"img",className:"h-4 w-auto",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M13 2C13 0.89543 13.8954 0 15 0H41C42.1046 0 43 0.895431 43 2V12C43 13.1046 42.1046 14 41 14H13V2Z"}),r.jsx("path",{d:"M0 15C0 13.8954 0.895431 13 2 13H14V25C14 26.1046 13.1046 27 12 27H2C0.89543 27 0 26.1046 0 25V15Z"}),r.jsx("path",{d:"M30 49C30 50.1046 29.1046 51 28 51L2 51C0.89543 51 0 50.1046 0 49L0 39C0 37.8954 0.895431 37 2 37L30 37L30 49Z"}),r.jsx("path",{d:"M42.9646 36C42.9646 37.1046 42.0692 38 40.9646 38H28.9646V26C28.9646 24.8954 29.86 24 30.9646 24H40.9646C42.0692 24 42.9646 24.8954 42.9646 26V36Z"})]})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),r.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),r.jsx(vv,{items:SD,onNavigate:t}),r.jsx("div",{className:"border-t border-border/40"}),r.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[$.length===0&&!m&&r.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),$.map(B=>{const O=B==="_ungrouped",W=O?"Ungrouped":yn(B),se=O?"/w/_ungrouped":`/w/${B}`,z=u.has(B),H=e===B||e===null&&O&&c.pathname.startsWith("/w/_ungrouped"),ee=b===B;return r.jsxs("div",{className:`rounded-md transition ${ee?"bg-accent/40 ring-1 ring-ring/40":""}`,onDragOver:ne=>{ne.dataTransfer.types.includes("application/json")&&(ne.preventDefault(),ne.dataTransfer.dropEffect="move",E(B))},onDragLeave:ne=>{ne.currentTarget.contains(ne.relatedTarget)||E(M=>M===B?null:M)},onDrop:async ne=>{try{const M=ne.dataTransfer.getData("application/json");if(!M)return;ne.preventDefault();let G;try{G=JSON.parse(M)}catch{return}if(!(G!=null&&G.type)||!(G!=null&&G.id))return;await K(G,O?null:B)}finally{E(null)}},children:[r.jsxs("div",{className:"group flex items-center",children:[r.jsxs("button",{type:"button",onClick:()=>R(B),className:`flex flex-1 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${H?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[r.jsx(br,{className:`h-3 w-3 transition-transform ${z?"-rotate-90":""}`}),W]}),O?null:r.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),w(B),C(null)},title:`Delete workspace "${B}"`,"aria-label":`Delete workspace "${B}"`,className:"mr-1 flex h-6 w-6 items-center justify-center rounded text-muted-foreground/60 opacity-0 transition hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",children:r.jsx(or,{className:"h-3 w-3"})})]}),!z&&r.jsx("nav",{className:"ml-2 space-y-0.5",children:ND.map(ne=>{const M=`${se}${ne.suffix}`,G=E0(c.pathname,ne.suffix)&&c.pathname.startsWith(se),A=ne.icon;return r.jsxs(Ee,{to:M,onClick:t,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${G?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[r.jsx(A,{className:"h-4 w-4"}),r.jsx("span",{children:ne.label})]},M)})})]},B)}),m?r.jsx("form",{className:"px-3 py-1.5",onSubmit:B=>{B.preventDefault();const O=g.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");O&&(h(!1),y(""),fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:O})}).then(()=>{t==null||t(),D(`/w/${O}/projects`)}))},children:r.jsx("input",{autoFocus:!0,type:"text",value:g,onChange:B=>y(B.target.value),onKeyDown:B=>{B.key==="Escape"&&(h(!1),y(""))},onBlur:()=>{g.trim()||(h(!1),y(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[r.jsx(rn,{className:"h-3 w-3"}),"New Workspace"]})]}),r.jsx("div",{className:"border-t border-border/40"}),r.jsx(vv,{items:CD,onNavigate:t}),r.jsx(Ga,{open:j!==null,onOpenChange:B=>{N||B||(w(null),C(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:k?"Workspace has references":"Delete workspace?"}),r.jsx(Vo,{children:k?r.jsxs(r.Fragment,{children:["The workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," is still referenced by:"]}):r.jsxs(r.Fragment,{children:["Remove the workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," from the registry. This does not affect projects or standalones unless you choose to cascade."]})})]}),k?r.jsxs("div",{className:"space-y-2 text-sm",children:[k.projects.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Projects (",k.projects.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.projects.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/projects/${B}`,className:"hover:underline",children:B})},B))})]}):null,k.standalones.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Standalones (",k.standalones.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.standalones.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/assignments/${B}`,className:"hover:underline",children:B})},B))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:['Choose "Clear references and delete" to set ',r.jsx("code",{children:"workspace:"})," / ",r.jsx("code",{children:"workspaceGroup:"})," to ",r.jsx("code",{children:"null"})," on each, then remove the workspace."]})]}):null,r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:N,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),k?r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!0)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Clear references and delete"}):r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!1)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Delete"})]})]})})]})}function TD(){const e=Wn(),{workspace:t}=$t(),{title:n,breadcrumbs:s,projectSlug:a}=T0(e.pathname);return r.jsx(ED,{title:n,breadcrumbs:s,projectSlug:a,workspace:t??null,children:r.jsx(dT,{})})}function mt({label:e="Loading dashboard data…"}){return r.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:r.jsx("div",{className:"chrome-card !px-4 !py-3",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function wt({title:e="Something went wrong",error:t,action:n}){return r.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),n?r.jsx("div",{className:"pt-2",children:n}):null]})})}function qu({command:e,description:t,example:n}){return r.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[r.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?r.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function We({title:e,description:t,children:n,className:s,actions:a}){return r.jsxs("section",{className:Se("surface-panel space-y-3",s),children:[e||a?r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?r.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),a]}):null,n]})}function RD({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return r.jsx(We,{title:t?"Getting Started Refresher":"Getting Started",description:t?"A fast reminder of the real flow for creating and running work in Syntaur.":"A first-run checklist that maps to the current CLI and dashboard flow.",actions:r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:r.jsx("div",{className:"space-y-3",children:n.map((s,a)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:s.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s.detail}),s.command?r.jsx(qu,{command:s.command.command,example:s.command.example}):null]})]})},s.title))})})}const jm={review:"{total} items ready for your review","review.singular":"Review {title}",ready_to_implement:"{total} plans ready to implement — start with {title}","ready_to_implement.singular":"Start implementing {title}",ready_for_planning:"{total} assignments ready to plan — start with {title}","ready_for_planning.singular":"Plan {title}",in_progress:"Resume {title} ({total} in progress)","in_progress.singular":"Resume {title}",draft:"Shape your {total} drafts — start with {title}","draft.singular":"Shape {title}",blocked:"Unblock {title} ({total} blocked)","blocked.singular":"Unblock {title}",stale:"Triage {total} stale items","stale.singular":"Triage {title} — sitting stale",clean:"You’re all clear. Nothing needs you right now."},Ho={emptyStateCleanTitle:"You’re all clear",emptyStateCleanCTA:"Browse projects",recentSessionsEmptyTitle:"No recent sessions",recentSessionsEmptyHint:"Use /grab-assignment or `syntaur track-session` to register one.",recentSessionsCopyPathLabel:"Copy path",recentSessionsCopyPathDisabled:"Session has no path",recentSessionsCopyFallbackHint:"Press ⌘C to copy"};function PD(e,t){return e.replace(/\{(\w+)\}/g,(n,s)=>String(t[s]??`{${s}}`))}function AD({hero:e,itemsById:t}){const n=ln();if(e.kind==="clean")return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:Ho.emptyStateCleanTitle}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:jm.clean}),r.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"When work shows up — a draft, a review, a stale row — it’ll surface here."}),r.jsx("div",{className:"mt-4",children:r.jsx(Ee,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:Ho.emptyStateCleanCTA})})]});const s=e.itemId?t[e.itemId]:void 0,a=(s==null?void 0:s.assignmentTitle)??"",l=jm[e.copyKey]??jm[e.kind],c=PD(l,{total:e.total,title:a}),u=s?DD(s,n):`${n}/assignments`;return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:"What needs you today"}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:c}),s?r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",r.jsx("span",{className:"font-medium text-foreground",children:s.projectTitle??"Standalone"})," ","· status ",r.jsx("span",{className:"font-medium text-foreground",children:s.status})]}):null,r.jsx("div",{className:"mt-4",children:r.jsxs(Ee,{to:u,className:"shell-action shell-action--cta",children:["Open ",a||"assignment"]})})]})}function DD(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const Ag=["kanban","list","table"],n1=["title","status","priority","assignee","dependencies","created","updated"],$D=["asc","desc"],LD=["comfortable","compact"],OD=["none","status","type","priority","assignee","project"],ID=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function tt(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const s of t){if(typeof s!="string")continue;const a=s.trim();!a||a==="all"||n.includes(a)||n.push(a)}return n}function MD(e,t){const n=tt(e),s=tt(t);return n.length===s.length&&n.every(a=>s.includes(a))}const _D={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},Vl={version:1,global:_D,projects:{}};function km(e){return e==="table"?"table":"kanban"}function FD(e,t){return t?{...e,...t}:{...e}}function r1(e,t){const n=e.global;if(t===null)return n;const s=e.projects[t];return s?{defaultView:s.defaultView??n.defaultView,sortField:s.sortField??n.sortField,sortDirection:s.sortDirection??n.sortDirection,density:n.density,grouping:s.grouping??n.grouping,filters:FD(n.filters,s.filters)}:n}const Sm=["title","status","priority","assignee","dependencies","created","updated"],zD=["small","wide","tall","large"],BD={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},Bv="2026-05-21T00:00:00Z";function Nm(e,t,n){return{id:e,name:t,workspace:null,config:{viewMode:"list",filters:{...BD,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:Bv,updatedAt:Bv}}const ao={version:1,views:[Nm("default-recently-updated","Recently updated",{}),Nm("default-high-priority","High priority",{priority:"high"}),Nm("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function s1(e,t){const n=tt(e.filters.project),s=n.length===0||n.length===1&&n[0]===t,a=e.filters.activity,l=typeof e.filters.search=="string"&&e.filters.search.trim().length>0;return s&&(!a||a==="all")&&!l}function o1(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?s1(e.config,t.slug):!1}}const a1=`syntaur.savedViews.cache.v${ao.version}`;let oi=UD(),_o=null,Dg=null;const yh=new Set,cd=new Set;let i1=0;function l1(){return++i1}function bh(e){return e===i1}function UD(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(a1);if(!e)return null;const t=JSON.parse(e);return t.version!==ao.version?null:t}catch{return null}}function VD(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(a1,JSON.stringify(e))}catch{}}function c1(e){oi=e,Dg=null,VD(e);for(const t of yh)t(e);for(const t of cd)t(null)}function HD(e){Dg=e;for(const t of cd)t(e)}function u1(e){if(!e||typeof e!="object")return ao;const t=e;return t.version!==ao.version||!Array.isArray(t.views)||!t.dashboard?ao:t}function Uv(){if(_o)return _o;const e=l1();return _o=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=u1(t);return bh(e)&&c1(n),_o=null,oi??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return bh(e)&&HD(n),_o=null,oi??ao}),_o}function $g(){const[e,t]=f.useState(()=>oi??ao),[n,s]=f.useState(()=>oi===null),[a,l]=f.useState(!1),[c,u]=f.useState(()=>Dg);return f.useEffect(()=>{let m=!1;oi===null&&s(!0),Uv().then(y=>{m||(t(y),s(!1),l(!0))});const h=y=>{m||(t(y),s(!1),l(!0),u(null))},g=y=>{m||(u(y),s(!1),l(!0))};return yh.add(h),cd.add(g),()=>{m=!0,yh.delete(h),cd.delete(g)}},[]),{file:e,loading:n,ready:a,error:c,refetch:()=>{_o=null,s(!0),u(null),l(!1),Uv()}}}function Vd(){const{file:e,loading:t}=$g();return{views:e.views,loading:t}}function WD(){const{file:e,loading:t}=$g();return{layout:e.dashboard,loading:t}}function Go(e){const{file:t,loading:n,ready:s,error:a,refetch:l}=$g();return e?{view:t.views.find(u=>u.id===e)??null,loading:n,ready:s,error:a,refetch:l}:{view:null,loading:!1,ready:!0,error:null,refetch:l}}async function Hd(e,t,n){const s=l1(),a=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!a.ok){const c=await a.json().catch(()=>({error:`HTTP ${a.status}`}));throw new Error(c.error??`HTTP ${a.status}`)}const l=u1(await a.json());return bh(s)&&c1(l),l}function Wd(e){return Hd("POST","/api/saved-views",e)}function Lg(e,t){return Hd("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function KD(e){return Hd("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function qD(e){return Hd("PUT","/api/dashboard",{slots:e})}const GD=["top","right","bottom","left"],co=Math.min,hr=Math.max,ud=Math.round,Ru=Math.floor,fs=e=>({x:e,y:e}),YD={left:"right",right:"left",bottom:"top",top:"bottom"};function vh(e,t,n){return hr(e,co(t,n))}function Ds(e,t){return typeof e=="function"?e(t):e}function $s(e){return e.split("-")[0]}function wi(e){return e.split("-")[1]}function Og(e){return e==="x"?"y":"x"}function Ig(e){return e==="y"?"height":"width"}function cs(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Mg(e){return Og(cs(e))}function JD(e,t,n){n===void 0&&(n=!1);const s=wi(e),a=Mg(e),l=Ig(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=dd(c)),[c,dd(c)]}function XD(e){const t=dd(e);return[wh(e),t,wh(t)]}function wh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Vv=["left","right"],Hv=["right","left"],QD=["top","bottom"],ZD=["bottom","top"];function e4(e,t,n){switch(e){case"top":case"bottom":return n?t?Hv:Vv:t?Vv:Hv;case"left":case"right":return t?QD:ZD;default:return[]}}function t4(e,t,n,s){const a=wi(e);let l=e4($s(e),n==="start",s);return a&&(l=l.map(c=>c+"-"+a),t&&(l=l.concat(l.map(wh)))),l}function dd(e){const t=$s(e);return YD[t]+e.slice(t.length)}function n4(e){return{top:0,right:0,bottom:0,left:0,...e}}function d1(e){return typeof e!="number"?n4(e):{top:e,right:e,bottom:e,left:e}}function fd(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Wv(e,t,n){let{reference:s,floating:a}=e;const l=cs(t),c=Mg(t),u=Ig(c),p=$s(t),m=l==="y",h=s.x+s.width/2-a.width/2,g=s.y+s.height/2-a.height/2,y=s[u]/2-a[u]/2;let b;switch(p){case"top":b={x:h,y:s.y-a.height};break;case"bottom":b={x:h,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-a.width,y:g};break;default:b={x:s.x,y:s.y}}switch(wi(t)){case"start":b[c]-=y*(n&&m?-1:1);break;case"end":b[c]+=y*(n&&m?-1:1);break}return b}async function r4(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:l,rects:c,elements:u,strategy:p}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=Ds(t,e),E=d1(b),w=u[y?g==="floating"?"reference":"floating":g],k=fd(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(w)))==null||n?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:m,rootBoundary:h,strategy:p})),C=g==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),T=await(l.isElement==null?void 0:l.isElement(N))?await(l.getScale==null?void 0:l.getScale(N))||{x:1,y:1}:{x:1,y:1},D=fd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:C,offsetParent:N,strategy:p}):C);return{top:(k.top-D.top+E.top)/T.y,bottom:(D.bottom-k.bottom+E.bottom)/T.y,left:(k.left-D.left+E.left)/T.x,right:(D.right-k.right+E.right)/T.x}}const s4=50,o4=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:l=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:r4},p=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:h,y:g}=Wv(m,s,p),y=s,b=0;const E={};for(let j=0;j<l.length;j++){const w=l[j];if(!w)continue;const{name:k,fn:C}=w,{x:N,y:T,data:D,reset:R}=await C({x:h,y:g,initialPlacement:s,placement:y,strategy:a,middlewareData:E,rects:m,platform:u,elements:{reference:e,floating:t}});h=N??h,g=T??g,E[k]={...E[k],...D},R&&b<s4&&(b++,typeof R=="object"&&(R.placement&&(y=R.placement),R.rects&&(m=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):R.rects),{x:h,y:g}=Wv(m,y,p)),j=-1)}return{x:h,y:g,placement:y,strategy:a,middlewareData:E}},a4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:l,platform:c,elements:u,middlewareData:p}=t,{element:m,padding:h=0}=Ds(e,t)||{};if(m==null)return{};const g=d1(h),y={x:n,y:s},b=Mg(a),E=Ig(b),j=await c.getDimensions(m),w=b==="y",k=w?"top":"left",C=w?"bottom":"right",N=w?"clientHeight":"clientWidth",T=l.reference[E]+l.reference[b]-y[b]-l.floating[E],D=y[b]-l.reference[b],R=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let $=R?R[N]:0;(!$||!await(c.isElement==null?void 0:c.isElement(R)))&&($=u.floating[N]||l.floating[E]);const L=T/2-D/2,K=$/2-j[E]/2-1,B=co(g[k],K),O=co(g[C],K),W=B,se=$-j[E]-O,z=$/2-j[E]/2+L,H=vh(W,z,se),ee=!p.arrow&&wi(a)!=null&&z!==H&&l.reference[E]/2-(z<W?B:O)-j[E]/2<0,ne=ee?z<W?z-W:z-se:0;return{[b]:y[b]+ne,data:{[b]:H,centerOffset:z-H-ne,...ee&&{alignmentOffset:ne}},reset:ee}}}),i4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:l,rects:c,initialPlacement:u,platform:p,elements:m}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:j=!0,...w}=Ds(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const k=$s(a),C=cs(u),N=$s(u)===u,T=await(p.isRTL==null?void 0:p.isRTL(m.floating)),D=y||(N||!j?[dd(u)]:XD(u)),R=E!=="none";!y&&R&&D.push(...t4(u,j,E,T));const $=[u,...D],L=await p.detectOverflow(t,w),K=[];let B=((s=l.flip)==null?void 0:s.overflows)||[];if(h&&K.push(L[k]),g){const z=JD(a,c,T);K.push(L[z[0]],L[z[1]])}if(B=[...B,{placement:a,overflows:K}],!K.every(z=>z<=0)){var O,W;const z=(((O=l.flip)==null?void 0:O.index)||0)+1,H=$[z];if(H&&(!(g==="alignment"?C!==cs(H):!1)||B.every(M=>cs(M.placement)===C?M.overflows[0]>0:!0)))return{data:{index:z,overflows:B},reset:{placement:H}};let ee=(W=B.filter(ne=>ne.overflows[0]<=0).sort((ne,M)=>ne.overflows[1]-M.overflows[1])[0])==null?void 0:W.placement;if(!ee)switch(b){case"bestFit":{var se;const ne=(se=B.filter(M=>{if(R){const G=cs(M.placement);return G===C||G==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(G=>G>0).reduce((G,A)=>G+A,0)]).sort((M,G)=>M[1]-G[1])[0])==null?void 0:se[0];ne&&(ee=ne);break}case"initialPlacement":ee=u;break}if(a!==ee)return{reset:{placement:ee}}}return{}}}};function Kv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qv(e){return GD.some(t=>e[t]>=0)}const l4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...l}=Ds(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...l,elementContext:"reference"}),u=Kv(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:qv(u)}}}case"escaped":{const c=await s.detectOverflow(t,{...l,altBoundary:!0}),u=Kv(c,n.floating);return{data:{escapedOffsets:u,escaped:qv(u)}}}default:return{}}}}},f1=new Set(["left","top"]);async function c4(e,t){const{placement:n,platform:s,elements:a}=e,l=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=$s(n),u=wi(n),p=cs(n)==="y",m=f1.has(c)?-1:1,h=l&&p?-1:1,g=Ds(t,e);let{mainAxis:y,crossAxis:b,alignmentAxis:E}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof E=="number"&&(b=u==="end"?E*-1:E),p?{x:b*h,y:y*m}:{x:y*m,y:b*h}}const u4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:l,placement:c,middlewareData:u}=t,p=await c4(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:a+p.x,y:l+p.y,data:{...p,placement:c}}}}},d4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:p={fn:k=>{let{x:C,y:N}=k;return{x:C,y:N}}},...m}=Ds(e,t),h={x:n,y:s},g=await l.detectOverflow(t,m),y=cs($s(a)),b=Og(y);let E=h[b],j=h[y];if(c){const k=b==="y"?"top":"left",C=b==="y"?"bottom":"right",N=E+g[k],T=E-g[C];E=vh(N,E,T)}if(u){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",N=j+g[k],T=j-g[C];j=vh(N,j,T)}const w=p.fn({...t,[b]:E,[y]:j});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[b]:c,[y]:u}}}}}},f4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:m=!0}=Ds(e,t),h={x:n,y:s},g=cs(a),y=Og(g);let b=h[y],E=h[g];const j=Ds(u,t),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(p){const N=y==="y"?"height":"width",T=l.reference[y]-l.floating[N]+w.mainAxis,D=l.reference[y]+l.reference[N]-w.mainAxis;b<T?b=T:b>D&&(b=D)}if(m){var k,C;const N=y==="y"?"width":"height",T=f1.has($s(a)),D=l.reference[g]-l.floating[N]+(T&&((k=c.offset)==null?void 0:k[g])||0)+(T?0:w.crossAxis),R=l.reference[g]+l.reference[N]+(T?0:((C=c.offset)==null?void 0:C[g])||0)-(T?w.crossAxis:0);E<D?E=D:E>R&&(E=R)}return{[y]:b,[g]:E}}}},p4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:l,platform:c,elements:u}=t,{apply:p=()=>{},...m}=Ds(e,t),h=await c.detectOverflow(t,m),g=$s(a),y=wi(a),b=cs(a)==="y",{width:E,height:j}=l.floating;let w,k;g==="top"||g==="bottom"?(w=g,k=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=g,w=y==="end"?"top":"bottom");const C=j-h.top-h.bottom,N=E-h.left-h.right,T=co(j-h[w],C),D=co(E-h[k],N),R=!t.middlewareData.shift;let $=T,L=D;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&($=C),R&&!y){const B=hr(h.left,0),O=hr(h.right,0),W=hr(h.top,0),se=hr(h.bottom,0);b?L=E-2*(B!==0||O!==0?B+O:hr(h.left,h.right)):$=j-2*(W!==0||se!==0?W+se:hr(h.top,h.bottom))}await p({...t,availableWidth:L,availableHeight:$});const K=await c.getDimensions(u.floating);return E!==K.width||j!==K.height?{reset:{rects:!0}}:{}}}};function Kd(){return typeof window<"u"}function ji(e){return p1(e)?(e.nodeName||"").toLowerCase():"#document"}function yr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function xs(e){var t;return(t=(p1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function p1(e){return Kd()?e instanceof Node||e instanceof yr(e).Node:!1}function qr(e){return Kd()?e instanceof Element||e instanceof yr(e).Element:!1}function Is(e){return Kd()?e instanceof HTMLElement||e instanceof yr(e).HTMLElement:!1}function Gv(e){return!Kd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yr(e).ShadowRoot}function ic(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=Gr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function m4(e){return/^(table|td|th)$/.test(ji(e))}function qd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const h4=/transform|translate|scale|rotate|perspective|filter/,g4=/paint|layout|strict|content/,Io=e=>!!e&&e!=="none";let Cm;function _g(e){const t=qr(e)?Gr(e):e;return Io(t.transform)||Io(t.translate)||Io(t.scale)||Io(t.rotate)||Io(t.perspective)||!Fg()&&(Io(t.backdropFilter)||Io(t.filter))||h4.test(t.willChange||"")||g4.test(t.contain||"")}function x4(e){let t=uo(e);for(;Is(t)&&!fi(t);){if(_g(t))return t;if(qd(t))return null;t=uo(t)}return null}function Fg(){return Cm==null&&(Cm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cm}function fi(e){return/^(html|body|#document)$/.test(ji(e))}function Gr(e){return yr(e).getComputedStyle(e)}function Gd(e){return qr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function uo(e){if(ji(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gv(e)&&e.host||xs(e);return Gv(t)?t.host:t}function m1(e){const t=uo(e);return fi(t)?e.ownerDocument?e.ownerDocument.body:e.body:Is(t)&&ic(t)?t:m1(t)}function Hl(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=m1(e),l=a===((s=e.ownerDocument)==null?void 0:s.body),c=yr(a);if(l){const u=jh(c);return t.concat(c,c.visualViewport||[],ic(a)?a:[],u&&n?Hl(u):[])}else return t.concat(a,Hl(a,[],n))}function jh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function h1(e){const t=Gr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Is(e),l=a?e.offsetWidth:n,c=a?e.offsetHeight:s,u=ud(n)!==l||ud(s)!==c;return u&&(n=l,s=c),{width:n,height:s,$:u}}function zg(e){return qr(e)?e:e.contextElement}function ai(e){const t=zg(e);if(!Is(t))return fs(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:l}=h1(t);let c=(l?ud(n.width):n.width)/s,u=(l?ud(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const y4=fs(0);function g1(e){const t=yr(e);return!Fg()||!t.visualViewport?y4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function b4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yr(e)?!1:t}function Yo(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),l=zg(e);let c=fs(1);t&&(s?qr(s)&&(c=ai(s)):c=ai(e));const u=b4(l,n,s)?g1(l):fs(0);let p=(a.left+u.x)/c.x,m=(a.top+u.y)/c.y,h=a.width/c.x,g=a.height/c.y;if(l){const y=yr(l),b=s&&qr(s)?yr(s):s;let E=y,j=jh(E);for(;j&&s&&b!==E;){const w=ai(j),k=j.getBoundingClientRect(),C=Gr(j),N=k.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,T=k.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;p*=w.x,m*=w.y,h*=w.x,g*=w.y,p+=N,m+=T,E=yr(j),j=jh(E)}}return fd({width:h,height:g,x:p,y:m})}function Yd(e,t){const n=Gd(e).scrollLeft;return t?t.left+n:Yo(xs(e)).left+n}function x1(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Yd(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function v4(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const l=a==="fixed",c=xs(s),u=t?qd(t.floating):!1;if(s===c||u&&l)return n;let p={scrollLeft:0,scrollTop:0},m=fs(1);const h=fs(0),g=Is(s);if((g||!g&&!l)&&((ji(s)!=="body"||ic(c))&&(p=Gd(s)),g)){const b=Yo(s);m=ai(s),h.x=b.x+s.clientLeft,h.y=b.y+s.clientTop}const y=c&&!g&&!l?x1(c,p):fs(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-p.scrollLeft*m.x+h.x+y.x,y:n.y*m.y-p.scrollTop*m.y+h.y+y.y}}function w4(e){return Array.from(e.getClientRects())}function j4(e){const t=xs(e),n=Gd(e),s=e.ownerDocument.body,a=hr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=hr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Yd(e);const u=-n.scrollTop;return Gr(s).direction==="rtl"&&(c+=hr(t.clientWidth,s.clientWidth)-a),{width:a,height:l,x:c,y:u}}const Yv=25;function k4(e,t){const n=yr(e),s=xs(e),a=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,p=0;if(a){l=a.width,c=a.height;const h=Fg();(!h||h&&t==="fixed")&&(u=a.offsetLeft,p=a.offsetTop)}const m=Yd(s);if(m<=0){const h=s.ownerDocument,g=h.body,y=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,E=Math.abs(s.clientWidth-g.clientWidth-b);E<=Yv&&(l-=E)}else m<=Yv&&(l+=m);return{width:l,height:c,x:u,y:p}}function S4(e,t){const n=Yo(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,l=Is(e)?ai(e):fs(1),c=e.clientWidth*l.x,u=e.clientHeight*l.y,p=a*l.x,m=s*l.y;return{width:c,height:u,x:p,y:m}}function Jv(e,t,n){let s;if(t==="viewport")s=k4(e,n);else if(t==="document")s=j4(xs(e));else if(qr(t))s=S4(t,n);else{const a=g1(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return fd(s)}function y1(e,t){const n=uo(e);return n===t||!qr(n)||fi(n)?!1:Gr(n).position==="fixed"||y1(n,t)}function N4(e,t){const n=t.get(e);if(n)return n;let s=Hl(e,[],!1).filter(u=>qr(u)&&ji(u)!=="body"),a=null;const l=Gr(e).position==="fixed";let c=l?uo(e):e;for(;qr(c)&&!fi(c);){const u=Gr(c),p=_g(c);!p&&u.position==="fixed"&&(a=null),(l?!p&&!a:!p&&u.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||ic(c)&&!p&&y1(e,c))?s=s.filter(h=>h!==c):a=u,c=uo(c)}return t.set(e,s),s}function C4(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?qd(t)?[]:N4(t,this._c):[].concat(n),s],u=Jv(t,c[0],a);let p=u.top,m=u.right,h=u.bottom,g=u.left;for(let y=1;y<c.length;y++){const b=Jv(t,c[y],a);p=hr(b.top,p),m=co(b.right,m),h=co(b.bottom,h),g=hr(b.left,g)}return{width:m-g,height:h-p,x:g,y:p}}function E4(e){const{width:t,height:n}=h1(e);return{width:t,height:n}}function T4(e,t,n){const s=Is(t),a=xs(t),l=n==="fixed",c=Yo(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const p=fs(0);function m(){p.x=Yd(a)}if(s||!s&&!l)if((ji(t)!=="body"||ic(a))&&(u=Gd(t)),s){const b=Yo(t,!0,l,t);p.x=b.x+t.clientLeft,p.y=b.y+t.clientTop}else a&&m();l&&!s&&a&&m();const h=a&&!s&&!l?x1(a,u):fs(0),g=c.left+u.scrollLeft-p.x-h.x,y=c.top+u.scrollTop-p.y-h.y;return{x:g,y,width:c.width,height:c.height}}function Em(e){return Gr(e).position==="static"}function Xv(e,t){if(!Is(e)||Gr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return xs(e)===n&&(n=n.ownerDocument.body),n}function b1(e,t){const n=yr(e);if(qd(e))return n;if(!Is(e)){let a=uo(e);for(;a&&!fi(a);){if(qr(a)&&!Em(a))return a;a=uo(a)}return n}let s=Xv(e,t);for(;s&&m4(s)&&Em(s);)s=Xv(s,t);return s&&fi(s)&&Em(s)&&!_g(s)?n:s||x4(e)||n}const R4=async function(e){const t=this.getOffsetParent||b1,n=this.getDimensions,s=await n(e.floating);return{reference:T4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function P4(e){return Gr(e).direction==="rtl"}const A4={convertOffsetParentRelativeRectToViewportRelativeRect:v4,getDocumentElement:xs,getClippingRect:C4,getOffsetParent:b1,getElementRects:R4,getClientRects:w4,getDimensions:E4,getScale:ai,isElement:qr,isRTL:P4};function v1(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function D4(e,t){let n=null,s;const a=xs(e);function l(){var u;clearTimeout(s),(u=n)==null||u.disconnect(),n=null}function c(u,p){u===void 0&&(u=!1),p===void 0&&(p=1),l();const m=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=m;if(u||t(),!y||!b)return;const E=Ru(g),j=Ru(a.clientWidth-(h+y)),w=Ru(a.clientHeight-(g+b)),k=Ru(h),N={rootMargin:-E+"px "+-j+"px "+-w+"px "+-k+"px",threshold:hr(0,co(1,p))||1};let T=!0;function D(R){const $=R[0].intersectionRatio;if($!==p){if(!T)return c();$?c(!1,$):s=setTimeout(()=>{c(!1,1e-7)},1e3)}$===1&&!v1(m,e.getBoundingClientRect())&&c(),T=!1}try{n=new IntersectionObserver(D,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(D,N)}n.observe(e)}return c(!0),l}function $4(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:p=!1}=s,m=zg(e),h=a||l?[...m?Hl(m):[],...t?Hl(t):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),l&&k.addEventListener("resize",n)});const g=m&&u?D4(m,n):null;let y=-1,b=null;c&&(b=new ResizeObserver(k=>{let[C]=k;C&&C.target===m&&b&&t&&(b.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var N;(N=b)==null||N.observe(t)})),n()}),m&&!p&&b.observe(m),t&&b.observe(t));let E,j=p?Yo(e):null;p&&w();function w(){const k=Yo(e);j&&!v1(j,k)&&n(),j=k,E=requestAnimationFrame(w)}return n(),()=>{var k;h.forEach(C=>{a&&C.removeEventListener("scroll",n),l&&C.removeEventListener("resize",n)}),g==null||g(),(k=b)==null||k.disconnect(),b=null,p&&cancelAnimationFrame(E)}}const L4=u4,O4=d4,I4=i4,M4=p4,_4=l4,Qv=a4,F4=f4,z4=(e,t,n)=>{const s=new Map,a={platform:A4,...n},l={...a.platform,_c:s};return o4(e,t,{...a,platform:l})};var B4=typeof document<"u",U4=function(){},Gu=B4?f.useLayoutEffect:U4;function pd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!pd(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const l=a[s];if(!(l==="_owner"&&e.$$typeof)&&!pd(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function w1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Zv(e,t){const n=w1(e);return Math.round(t*n)/n}function Tm(e){const t=f.useRef(e);return Gu(()=>{t.current=e}),t}function V4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:p,open:m}=e,[h,g]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,b]=f.useState(s);pd(y,s)||b(s);const[E,j]=f.useState(null),[w,k]=f.useState(null),C=f.useCallback(M=>{M!==R.current&&(R.current=M,j(M))},[]),N=f.useCallback(M=>{M!==$.current&&($.current=M,k(M))},[]),T=l||E,D=c||w,R=f.useRef(null),$=f.useRef(null),L=f.useRef(h),K=p!=null,B=Tm(p),O=Tm(a),W=Tm(m),se=f.useCallback(()=>{if(!R.current||!$.current)return;const M={placement:t,strategy:n,middleware:y};O.current&&(M.platform=O.current),z4(R.current,$.current,M).then(G=>{const A={...G,isPositioned:W.current!==!1};z.current&&!pd(L.current,A)&&(L.current=A,Rs.flushSync(()=>{g(A)}))})},[y,t,n,O,W]);Gu(()=>{m===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,g(M=>({...M,isPositioned:!1})))},[m]);const z=f.useRef(!1);Gu(()=>(z.current=!0,()=>{z.current=!1}),[]),Gu(()=>{if(T&&(R.current=T),D&&($.current=D),T&&D){if(B.current)return B.current(T,D,se);se()}},[T,D,se,B,K]);const H=f.useMemo(()=>({reference:R,floating:$,setReference:C,setFloating:N}),[C,N]),ee=f.useMemo(()=>({reference:T,floating:D}),[T,D]),ne=f.useMemo(()=>{const M={position:n,left:0,top:0};if(!ee.floating)return M;const G=Zv(ee.floating,h.x),A=Zv(ee.floating,h.y);return u?{...M,transform:"translate("+G+"px, "+A+"px)",...w1(ee.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:A}},[n,u,ee.floating,h.x,h.y]);return f.useMemo(()=>({...h,update:se,refs:H,elements:ee,floatingStyles:ne}),[h,se,H,ee,ne])}const H4=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Qv({element:s.current,padding:a}).fn(n):{}:s?Qv({element:s,padding:a}).fn(n):{}}}},W4=(e,t)=>{const n=L4(e);return{name:n.name,fn:n.fn,options:[e,t]}},K4=(e,t)=>{const n=O4(e);return{name:n.name,fn:n.fn,options:[e,t]}},q4=(e,t)=>({fn:F4(e).fn,options:[e,t]}),G4=(e,t)=>{const n=I4(e);return{name:n.name,fn:n.fn,options:[e,t]}},Y4=(e,t)=>{const n=M4(e);return{name:n.name,fn:n.fn,options:[e,t]}},J4=(e,t)=>{const n=_4(e);return{name:n.name,fn:n.fn,options:[e,t]}},X4=(e,t)=>{const n=H4(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Q4="Arrow",j1=f.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...l}=e;return r.jsx(mn.svg,{...l,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});j1.displayName=Q4;var Z4=j1;function e$(e){const[t,n]=f.useState(void 0);return lo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const l=a[0];let c,u;if("borderBoxSize"in l){const p=l.borderBoxSize,m=Array.isArray(p)?p[0]:p;c=m.inlineSize,u=m.blockSize}else c=e.offsetWidth,u=e.offsetHeight;n({width:c,height:u})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Bg="Popper",[k1,S1]=Xo(Bg),[t$,N1]=k1(Bg),C1=e=>{const{__scopePopper:t,children:n}=e,[s,a]=f.useState(null);return r.jsx(t$,{scope:t,anchor:s,onAnchorChange:a,children:n})};C1.displayName=Bg;var E1="PopperAnchor",T1=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,l=N1(E1,n),c=f.useRef(null),u=Fn(t,c),p=f.useRef(null);return f.useEffect(()=>{const m=p.current;p.current=(s==null?void 0:s.current)||c.current,m!==p.current&&l.onAnchorChange(p.current)}),s?null:r.jsx(mn.div,{...a,ref:u})});T1.displayName=E1;var Ug="PopperContent",[n$,r$]=k1(Ug),R1=f.forwardRef((e,t)=>{var ae,me,ve,ke,he,Je;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:y=!1,updatePositionStrategy:b="optimized",onPlaced:E,...j}=e,w=N1(Ug,n),[k,C]=f.useState(null),N=Fn(t,Ye=>C(Ye)),[T,D]=f.useState(null),R=e$(T),$=(R==null?void 0:R.width)??0,L=(R==null?void 0:R.height)??0,K=s+(l!=="center"?"-"+l:""),B=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},O=Array.isArray(m)?m:[m],W=O.length>0,se={padding:B,boundary:O.filter(o$),altBoundary:W},{refs:z,floatingStyles:H,placement:ee,isPositioned:ne,middlewareData:M}=V4({strategy:"fixed",placement:K,whileElementsMounted:(...Ye)=>$4(...Ye,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[W4({mainAxis:a+L,alignmentAxis:c}),p&&K4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?q4():void 0,...se}),p&&G4({...se}),Y4({...se,apply:({elements:Ye,rects:ot,availableWidth:J,availableHeight:Ie})=>{const{width:Ne,height:Oe}=ot.reference,Xe=Ye.floating.style;Xe.setProperty("--radix-popper-available-width",`${J}px`),Xe.setProperty("--radix-popper-available-height",`${Ie}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ne}px`),Xe.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),T&&X4({element:T,padding:u}),a$({arrowWidth:$,arrowHeight:L}),y&&J4({strategy:"referenceHidden",...se})]}),[G,A]=D1(ee),F=Ko(E);lo(()=>{ne&&(F==null||F())},[ne,F]);const Z=(ae=M.arrow)==null?void 0:ae.x,I=(me=M.arrow)==null?void 0:me.y,de=((ve=M.arrow)==null?void 0:ve.centerOffset)!==0,[ge,V]=f.useState();return lo(()=>{k&&V(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:ne?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(ke=M.transformOrigin)==null?void 0:ke.x,(he=M.transformOrigin)==null?void 0:he.y].join(" "),...((Je=M.hide)==null?void 0:Je.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(n$,{scope:n,placedSide:G,onArrowChange:D,arrowX:Z,arrowY:I,shouldHideArrow:de,children:r.jsx(mn.div,{"data-side":G,"data-align":A,...j,ref:N,style:{...j.style,animation:ne?void 0:"none"}})})})});R1.displayName=Ug;var P1="PopperArrow",s$={top:"bottom",right:"left",bottom:"top",left:"right"},A1=f.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,l=r$(P1,s),c=s$[l.placedSide];return r.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:r.jsx(Z4,{...a,ref:n,style:{...a.style,display:"block"}})})});A1.displayName=P1;function o$(e){return e!==null}var a$=e=>({name:"transformOrigin",options:e,fn(t){var w,k,C;const{placement:n,rects:s,middlewareData:a}=t,c=((w=a.arrow)==null?void 0:w.centerOffset)!==0,u=c?0:e.arrowWidth,p=c?0:e.arrowHeight,[m,h]=D1(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(((k=a.arrow)==null?void 0:k.x)??0)+u/2,b=(((C=a.arrow)==null?void 0:C.y)??0)+p/2;let E="",j="";return m==="bottom"?(E=c?g:`${y}px`,j=`${-p}px`):m==="top"?(E=c?g:`${y}px`,j=`${s.floating.height+p}px`):m==="right"?(E=`${-p}px`,j=c?g:`${b}px`):m==="left"&&(E=`${s.floating.width+p}px`,j=c?g:`${b}px`),{data:{x:E,y:j}}}});function D1(e){const[t,n="center"]=e.split("-");return[t,n]}var i$=C1,l$=T1,c$=R1,u$=A1,d$=Symbol("radix.slottable");function f$(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=d$,t}var p$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),m$="VisuallyHidden",$1=f.forwardRef((e,t)=>r.jsx(mn.span,{...e,ref:t,style:{...p$,...e.style}}));$1.displayName=m$;var h$=$1,[Jd]=Xo("Tooltip",[S1]),Xd=S1(),L1="TooltipProvider",g$=700,kh="tooltip.open",[x$,Vg]=Jd(L1),O1=e=>{const{__scopeTooltip:t,delayDuration:n=g$,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:l}=e,c=f.useRef(!0),u=f.useRef(!1),p=f.useRef(0);return f.useEffect(()=>{const m=p.current;return()=>window.clearTimeout(m)},[]),r.jsx(x$,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(p.current),c.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:u,onPointerInTransitChange:f.useCallback(m=>{u.current=m},[]),disableHoverableContent:a,children:l})};O1.displayName=L1;var Wl="Tooltip",[y$,lc]=Jd(Wl),I1=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:a,onOpenChange:l,disableHoverableContent:c,delayDuration:u}=e,p=Vg(Wl,e.__scopeTooltip),m=Xd(t),[h,g]=f.useState(null),y=ni(),b=f.useRef(0),E=c??p.disableHoverableContent,j=u??p.delayDuration,w=f.useRef(!1),[k,C]=zd({prop:s,defaultProp:a??!1,onChange:$=>{$?(p.onOpen(),document.dispatchEvent(new CustomEvent(kh))):p.onClose(),l==null||l($)},caller:Wl}),N=f.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),T=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,C(!0)},[C]),D=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C(!1)},[C]),R=f.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,C(!0),b.current=0},j)},[j,C]);return f.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),r.jsx(i$,{...m,children:r.jsx(y$,{scope:t,contentId:y,open:k,stateAttribute:N,trigger:h,onTriggerChange:g,onTriggerEnter:f.useCallback(()=>{p.isOpenDelayedRef.current?R():T()},[p.isOpenDelayedRef,R,T]),onTriggerLeave:f.useCallback(()=>{E?D():(window.clearTimeout(b.current),b.current=0)},[D,E]),onOpen:T,onClose:D,disableHoverableContent:E,children:n})})};I1.displayName=Wl;var Sh="TooltipTrigger",M1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=lc(Sh,n),l=Vg(Sh,n),c=Xd(n),u=f.useRef(null),p=Fn(t,u,a.onTriggerChange),m=f.useRef(!1),h=f.useRef(!1),g=f.useCallback(()=>m.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(l$,{asChild:!0,...c,children:r.jsx(mn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:p,onPointerMove:qt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),h.current=!0)}),onPointerLeave:qt(e.onPointerLeave,()=>{a.onTriggerLeave(),h.current=!1}),onPointerDown:qt(e.onPointerDown,()=>{a.open&&a.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:qt(e.onFocus,()=>{m.current||a.onOpen()}),onBlur:qt(e.onBlur,a.onClose),onClick:qt(e.onClick,a.onClose)})})});M1.displayName=Sh;var Hg="TooltipPortal",[b$,v$]=Jd(Hg,{forceMount:void 0}),_1=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:a}=e,l=lc(Hg,t);return r.jsx(b$,{scope:t,forceMount:n,children:r.jsx(Qo,{present:n||l.open,children:r.jsx(xg,{asChild:!0,container:a,children:s})})})};_1.displayName=Hg;var pi="TooltipContent",F1=f.forwardRef((e,t)=>{const n=v$(pi,e.__scopeTooltip),{forceMount:s=n.forceMount,side:a="top",...l}=e,c=lc(pi,e.__scopeTooltip);return r.jsx(Qo,{present:s||c.open,children:c.disableHoverableContent?r.jsx(z1,{side:a,...l,ref:t}):r.jsx(w$,{side:a,...l,ref:t})})}),w$=f.forwardRef((e,t)=>{const n=lc(pi,e.__scopeTooltip),s=Vg(pi,e.__scopeTooltip),a=f.useRef(null),l=Fn(t,a),[c,u]=f.useState(null),{trigger:p,onClose:m}=n,h=a.current,{onPointerInTransitChange:g}=s,y=f.useCallback(()=>{u(null),g(!1)},[g]),b=f.useCallback((E,j)=>{const w=E.currentTarget,k={x:E.clientX,y:E.clientY},C=C$(k,w.getBoundingClientRect()),N=E$(k,C),T=T$(j.getBoundingClientRect()),D=P$([...N,...T]);u(D),g(!0)},[g]);return f.useEffect(()=>()=>y(),[y]),f.useEffect(()=>{if(p&&h){const E=w=>b(w,h),j=w=>b(w,p);return p.addEventListener("pointerleave",E),h.addEventListener("pointerleave",j),()=>{p.removeEventListener("pointerleave",E),h.removeEventListener("pointerleave",j)}}},[p,h,b,y]),f.useEffect(()=>{if(c){const E=j=>{const w=j.target,k={x:j.clientX,y:j.clientY},C=(p==null?void 0:p.contains(w))||(h==null?void 0:h.contains(w)),N=!R$(k,c);C?y():N&&(y(),m())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[p,h,c,m,y]),r.jsx(z1,{...e,ref:l})}),[j$,k$]=Jd(Wl,{isInside:!1}),S$=f$("TooltipContent"),z1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=e,p=lc(pi,n),m=Xd(n),{onClose:h}=p;return f.useEffect(()=>(document.addEventListener(kh,h),()=>document.removeEventListener(kh,h)),[h]),f.useEffect(()=>{if(p.trigger){const g=y=>{const b=y.target;b!=null&&b.contains(p.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[p.trigger,h]),r.jsx(gg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:r.jsxs(c$,{"data-state":p.stateAttribute,...m,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(S$,{children:s}),r.jsx(j$,{scope:n,isInside:!0,children:r.jsx(h$,{id:p.contentId,role:"tooltip",children:a||s})})]})})});F1.displayName=pi;var B1="TooltipArrow",N$=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=Xd(n);return k$(B1,n).isInside?null:r.jsx(u$,{...a,...s,ref:t})});N$.displayName=B1;function C$(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,s,a,l)){case l:return"left";case a:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function E$(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function T$(e){const{top:t,right:n,bottom:s,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:s},{x:a,y:s}]}function R$(e,t){const{x:n,y:s}=e;let a=!1;for(let l=0,c=t.length-1;l<t.length;c=l++){const u=t[l],p=t[c],m=u.x,h=u.y,g=p.x,y=p.y;h>s!=y>s&&n<(g-m)*(s-h)/(y-h)+m&&(a=!a)}return a}function P$(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),A$(t)}function A$(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const a=e[s];for(;t.length>=2;){const l=t[t.length-1],c=t[t.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var D$=O1,$$=I1,L$=M1,O$=_1,U1=F1;const Wo=D$,Pr=$$,Ar=L$,gr=f.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(O$,{children:r.jsx(U1,{ref:s,sideOffset:t,className:Se("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gr.displayName=U1.displayName;function Wg({items:e,align:t="end"}){const[n,s]=f.useState(!1),[a,l]=f.useState(null),c=f.useRef(null);if(f.useEffect(()=>{if(!n){l(null);return}function p(h){c.current&&!c.current.contains(h.target)&&s(!1)}function m(h){h.key==="Escape"&&s(!1)}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[n]),e.length===0)return null;function u(p,m){const h=p.icon,g=Se("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",m&&"pl-8",p.disabled?"opacity-50 cursor-not-allowed":p.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),y=m?p.active?r.jsx(Xr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):r.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):h?r.jsx(h,{className:"h-4 w-4 shrink-0"}):null,b=r.jsxs(r.Fragment,{children:[y,r.jsx("span",{className:"block min-w-0 truncate",children:p.label})]});if(p.disabled){const E=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:g,children:b})});return p.disabledReason?r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:E}),r.jsx(gr,{side:"left",children:p.disabledReason})]},p.key):r.jsx("div",{children:E},p.key)}return p.href?r.jsx(Ee,{to:p.href,className:g,onClick:()=>s(!1),children:b},p.key):r.jsx("button",{type:"button",className:g,onClick:()=>{var E;(E=p.onSelect)==null||E.call(p),s(!1)},children:b},p.key)}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsx("button",{type:"button",onClick:()=>s(p=>!p),className:"shell-action",title:"More actions","aria-haspopup":"true","aria-expanded":n,children:r.jsx(lR,{className:"h-4 w-4"})}),n&&r.jsx("div",{className:Se("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:r.jsx(Wo,{delayDuration:200,children:e.map(p=>{if(p.submenu&&p.submenu.length>0){const m=p.icon,h=a===p.key;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",className:Se("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":h,onClick:()=>l(h?null:p.key),children:[m?r.jsx(m,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 flex-1 truncate",children:p.label}),h?r.jsx(br,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(l0,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),h?p.submenu.map(g=>u(g,!0)):null]},p.key)}return u(p,!1)})})})]})}function ew(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const I$={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function M$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,0,0,0,0).getTime()}function _$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,23,59,59,999).getTime()}function F$(e,t,n=Date.now()){if(!t)return!0;const s=t.field==="created"?e.created??e.updated:e.updated,a=Date.parse(s);if(Number.isNaN(a))return!1;if(t.preset){const u=I$[t.preset];return u===void 0?!0:t.preset.startsWith("older_")?n-a>u:a>=n-u&&a<=n}const l=t.from&&t.from.length>0?t.from:void 0,c=t.to&&t.to.length>0?t.to:void 0;return!l&&!c?!0:!(l&&a<M$(l)||c&&a>_$(c))}function Kg(e,t,n={}){const{workspace:s,search:a,includeArchived:l}=n;if(e.archived===!0&&!l)return!1;const c=tt(t.status),u=tt(t.priority),p=tt(t.type),m=tt(t.assignee),h=tt(t.project),g=tt(t.tags),{activity:y}=t;if(s){if(s==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==s)return!1}if(c.length&&!c.includes(e.status)||u.length&&!u.includes(e.priority)||p.length&&!p.includes(e.type??"")||y==="stale"&&!ew(e.updated)||y==="fresh"&&ew(e.updated))return!1;if(m.length){const b=e.assignee??"__unassigned__";if(!m.includes(b))return!1}if(h.length&&!h.some(E=>E==="__standalone__"?e.projectSlug==null:e.projectSlug===E))return!1;if(g.length){const b=e.tags??[];if(!g.some(E=>b.includes(E)))return!1}if(!F$(e,t.dateRange))return!1;if(a){const b=a.trim().toLowerCase();if(b&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(b))return!1}return!0}function Kl(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const V1={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],custom:!1};let Pl=null,Fo=null;function z$(){return Pl?Promise.resolve(Pl):Fo||(Fo=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Pl=e,Fo=null,e)).catch(()=>(Fo=null,V1)),Fo)}function Zo(){const[e,t]=f.useState(()=>Pl??V1);return f.useEffect(()=>{z$().then(t)},[]),e}function tw(){Pl=null,Fo=null}function cc(e,t){const n=e.statuses.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const nw={critical:0,high:1,medium:2,low:3};function Pu(e){return Date.parse(e??"")||0}function uc(e,t,n){return[...e].sort((a,l)=>{let c=0;switch(t){case"title":c=a.title.localeCompare(l.title);break;case"status":c=a.status.localeCompare(l.status);break;case"priority":c=(nw[a.priority]??99)-(nw[l.priority]??99);break;case"assignee":c=(a.assignee??"").localeCompare(l.assignee??"");break;case"dependencies":c=a.dependsOn.length-l.dependsOn.length;break;case"created":c=Pu(a.created)-Pu(l.created);break;case"updated":c=Pu(a.updated)-Pu(l.updated);break}return n==="asc"?c:-c})}function St({title:e,description:t,actions:n}){return r.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:r.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?r.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const mi='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Qd({columns:e,items:t,getItemId:n,getColumnId:s,renderCard:a,canDrop:l,onMove:c,getExternalDragData:u,onCardContextMenu:p,emptyMessage:m="No cards in this column.",hiddenColumnIds:h,onHideColumn:g,compact:y=!1,dragDisabled:b=!1}){const E=f.useMemo(()=>new Set(h??[]),[h]),j=f.useMemo(()=>e.filter(z=>!E.has(z.id)),[e,E]),w=f.useMemo(()=>e.filter(z=>E.has(z.id)),[e,E]),[k,C]=f.useState(null),[N,T]=f.useState(null),D=f.useRef(null),R=f.useMemo(()=>new Map(t.map(z=>[n(z),z])),[n,t]),$=f.useMemo(()=>j.map(z=>({column:z,items:t.filter(H=>s(H)===z.id)})),[j,s,t]),L=k?R.get(k)??null:null;function K(z){if(!L)return{allowed:!1};const H=s(L);return(l==null?void 0:l({item:L,fromColumnId:H,toColumnId:z}))??{allowed:!0}}function B(){C(null),T(null)}function O(z,H,ee){if(b)return;const ne=(u==null?void 0:u(H))??null;!c&&!ne||(z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",ee),ne&&z.dataTransfer.setData("application/json",JSON.stringify(ne)),c&&C(ee))}function W(z,H,ee){b||!c||!L||!K(H).allowed||(z.preventDefault(),z.dataTransfer.dropEffect="move",T(M=>(M==null?void 0:M.columnId)===H&&M.index===ee?M:{columnId:H,index:ee}))}async function se(z,H,ee){var F;if(z.preventDefault(),b||!c||!L){B();return}const ne=s(L),G=(((F=$.find(Z=>Z.column.id===ne))==null?void 0:F.items)??[]).findIndex(Z=>n(Z)===n(L));if(!K(H).allowed||G<0){B();return}if(ne===H&&(ee===G||ee===G+1)){B();return}try{await c({item:L,fromColumnId:ne,toColumnId:H,fromIndex:G,toIndex:ee})}finally{B()}}return r.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[w.length>0&&g?r.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Hidden:"}),w.map(z=>r.jsxs("button",{type:"button",onClick:()=>g(z.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${z.title}" column`,children:[z.title," ×"]},z.id))]}):null,r.jsx("div",{className:Se("grid min-w-max grid-flow-col gap-4",y?"auto-cols-[minmax(200px,240px)]":"auto-cols-[minmax(260px,320px)]"),children:$.map(({column:z,items:H})=>{const ee=K(z.id),ne=(N==null?void 0:N.columnId)===z.id;return r.jsxs("section",{className:Se("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",y?"min-h-[200px] p-2":"min-h-[320px] p-3",L&&!ee.allowed?"border-dashed opacity-65":"",L&&ee.allowed?"border-primary/30 bg-accent/30":"",ne?"ring-2 ring-ring/30":""),title:L&&!ee.allowed?ee.reason:void 0,children:[r.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:Se("font-semibold uppercase tracking-[0.16em] text-muted-foreground",y?"text-xs":"text-sm"),children:z.title}),z.description&&!y?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:z.description}):null]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:H.length}),g?r.jsx("button",{type:"button",onClick:()=>g(z.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${z.title}" column`,"aria-label":`Hide column ${z.title}`,children:"×"}):null]})]}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:M=>W(M,z.id,H.length),onDrop:M=>se(M,z.id,H.length),children:[H.length===0?b?r.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof m=="function"?m(z):m}):r.jsx(B$,{active:(N==null?void 0:N.columnId)===z.id&&N.index===0,disabled:!!L&&!ee.allowed,children:typeof m=="function"?m(z):m}):null,H.map((M,G)=>{const A=n(M),F=k===A;return r.jsxs(f.Fragment,{children:[r.jsx("div",{className:Se("h-2 rounded-full transition",(N==null?void 0:N.columnId)===z.id&&N.index===G?"bg-primary/70":"bg-transparent"),onDragOver:Z=>W(Z,z.id,G),onDrop:Z=>se(Z,z.id,G)}),r.jsx("div",{draggable:!b&&!!(c||u),onMouseDown:Z=>{D.current=Z.target},onDragStart:Z=>{const I=D.current;if(I!=null&&I.closest(mi)){Z.preventDefault();return}O(Z,M,A)},onDragEnd:B,onContextMenu:Z=>{if(!p)return;const I=Z.target;I!=null&&I.closest(mi)||p(M,Z)},className:Se("transition",!b&&(c||u)?"cursor-grab active:cursor-grabbing":"",F?"scale-[0.98] opacity-50":""),children:a(M,{dragging:F})})]},A)}),H.length>0&&!b?r.jsx("div",{className:Se("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(N==null?void 0:N.columnId)===z.id&&N.index===H.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",L&&!ee.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},z.id)})})]})}function B$({active:e,disabled:t,children:n}){return r.jsx("div",{className:Se("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const El="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Rm="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",U$="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",V$="border-status-review-foreground/30 bg-status-review text-status-review-foreground",H$="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",W$="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",K$="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",md={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:El,icon:bi},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:El,icon:rR},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:El,icon:u0},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Rm,icon:wR},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Rm,icon:rg},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:U$,icon:lh},review:{label:"Review",description:"Ready for inspection or approval.",className:V$,icon:SR},completed:{label:"Completed",description:"Finished successfully.",className:H$,icon:Zh},failed:{label:"Failed",description:"Could not be completed as planned.",className:W$,icon:lh},active:{label:"Active",description:"The project has active or review work in flight.",className:Rm,icon:ch},stopped:{label:"Stopped",description:"Session ended without completing.",className:El,icon:tR},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:K$,icon:ch}};function hd(e){const t=md[e];return t||{className:El,icon:ch,label:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),description:`Status: ${e}`}}function H1(e,t){return Se("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal","shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]",hd(e).className,t)}function pn({status:e,className:t,showIcon:n=!0,progress:s}){const a=hd(e),l=a.icon,c=s&&s.total>0,u=c?Math.min(1,Math.max(0,s.checked/s.total)):0,p=c?`${a.description} (${s.checked}/${s.total} criteria)`:a.description,m=n?c?r.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 items-center justify-center",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-u)})]}),r.jsx(l,{className:"h-2.5 w-2.5"})]}):r.jsx(l,{className:"h-3.5 w-3.5"}):null;return r.jsxs("span",{title:p,className:H1(e,t),children:[m,r.jsx("span",{children:a.label})]})}function Zd(e){var t;return((t=md[e])==null?void 0:t.description)??`Status: ${e}`}const W1={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Yu=null,za=null;function q$(){return Yu?Promise.resolve(Yu):za||(za=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Yu=e,za=null,e)).catch(()=>(za=null,W1)),za)}function ef(){const[e,t]=f.useState(()=>Yu??W1);return f.useEffect(()=>{q$().then(t)},[]),e}function ii(e,t){if(!t)return"—";const n=e.definitions.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function G$(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}function ea({type:e,className:t,compact:n=!1}){const s=ef();if(!e)return null;const a=G$(s,e),l=(a==null?void 0:a.label)??e.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),c=a!=null&&a.color?{backgroundColor:`color-mix(in oklch, ${a.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${a.color} 50%, transparent)`,color:a.color}:void 0;return r.jsx("span",{title:(a==null?void 0:a.description)??`Type: ${l}`,style:c,className:Se("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!c&&"border-border/60 text-muted-foreground",t),children:l})}function $r({value:e,label:t,disabled:n=!1,disabledReason:s,onError:a}){const[l,c]=f.useState(!1);async function u(){if(!n)try{if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500)}catch(p){a==null||a(p instanceof Error?p:new Error(String(p)))}}return n?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:s??"Copy unavailable","aria-label":t??"Copy",children:r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:l?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:l?r.jsx(Xr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})})}function Y$(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function J$({items:e,statusOrder:t,sortField:n,sortDirection:s,listSectionVisibility:a,compact:l=!1}){const c=Zo(),[u,p]=f.useState(()=>new Set(a.collapsed));f.useEffect(()=>{p(new Set(a.collapsed))},[a]);const m=h=>{p(g=>{const y=new Set(g);return y.has(h)?y.delete(h):y.add(h),y})};return r.jsx("div",{className:Se("space-y-2",l?"space-y-1.5":"space-y-3"),children:t.map(h=>{const g=uc(e.filter(E=>E.status===h),n,s);if(g.length===0)return null;const y=!u.has(h),b=cc(c,h);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[r.jsxs("button",{type:"button",onClick:()=>m(h),className:Se("flex w-full items-center gap-2 text-left",l?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[r.jsx(br,{className:Se("text-muted-foreground transition-transform",l?"h-3.5 w-3.5":"h-4 w-4",y?"":"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:b}),r.jsx("span",{className:Se("rounded-full border border-border/60 text-muted-foreground",l?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:g.length})]}),y&&r.jsx("ul",{className:Se("divide-y divide-border/40 border-t border-border/40",l?"text-xs":"text-sm"),children:g.map(E=>{const j=Y$(E);return r.jsx("li",{children:r.jsxs(Ee,{to:j,className:Se("flex items-center gap-3 hover:bg-muted/40",l?"px-3 py-1.5":"px-4 py-2.5"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:E.title}),E.projectTitle?r.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:E.projectTitle}):null,r.jsx("span",{className:"shrink-0 text-muted-foreground",children:Dn(E.updated)})]})},`${E.projectSlug??"standalone"}:${E.id}`)})})]},h)})})}function X$(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function Q$({items:e,sortField:t,sortDirection:n,tableColumnVisibility:s,compact:a=!1}){const l=new Set(s.hidden);l.delete("title");const c=h=>!l.has(h),u=uc(e,t,n),p=a?"py-2 pr-3":"py-3 pr-4",m=a?"text-xs":"text-sm";return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:Se("w-full text-left",m),children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[c("title")?r.jsx("th",{className:Se("font-medium",p),children:"Assignment"}):null,c("status")?r.jsx("th",{className:Se("font-medium",p),children:"Status"}):null,c("priority")?r.jsx("th",{className:Se("font-medium",p),children:"Priority"}):null,c("assignee")?r.jsx("th",{className:Se("font-medium",p),children:"Assignee"}):null,c("dependencies")?r.jsx("th",{className:Se("font-medium",p),children:"Dependencies"}):null,c("created")?r.jsx("th",{className:Se("font-medium",p),children:"Created"}):null,c("updated")?r.jsx("th",{className:Se("font-medium",p),children:"Updated"}):null]})}),r.jsx("tbody",{children:u.map(h=>{const g=X$(h),y=`${h.projectSlug??"standalone"}:${h.id}`;return r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[c("title")?r.jsxs("td",{className:p,children:[r.jsx(Ee,{to:g,className:"font-semibold text-foreground hover:text-primary",children:h.title}),h.projectTitle?r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h.projectTitle}):null]}):null,c("status")?r.jsx("td",{className:p,children:r.jsx(pn,{status:h.status})}):null,c("priority")?r.jsx("td",{className:Se("capitalize text-muted-foreground",p),children:h.priority}):null,c("assignee")?r.jsx("td",{className:Se("text-muted-foreground",p),children:h.assignee??"Unassigned"}):null,c("dependencies")?r.jsx("td",{className:Se("text-muted-foreground",p),children:h.dependsOn.length}):null,c("created")?r.jsx("td",{className:Se("text-muted-foreground",p),children:Dn(h.created)}):null,c("updated")?r.jsx("td",{className:Se("text-muted-foreground",p),children:Dn(h.updated)}):null]},y)})})]})})}function Z$(e,t,n){return e.filter(s=>Kg(s,t,{workspace:n,search:t.search}))}function K1({view:e,compact:t,emptyDescription:n}){const{data:s,loading:a,error:l}=Md(),c=Zo(),u=f.useMemo(()=>c.order.map(m=>({id:m,title:cc(c,m),description:Zd(m)})),[c]),p=f.useMemo(()=>{if(!s)return[];const m=Z$(s.assignments,e.config.filters,e.workspace);return uc(m,e.config.sortField,e.config.sortDirection)},[s,e]);if(a&&!s)return r.jsx(mt,{label:"Loading assignments…"});if(l)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l})]});if(p.length===0)return r.jsx(St,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return r.jsx(Qd,{compact:t,dragDisabled:!0,columns:u,items:p,getItemId:m=>m.slug||m.id,getColumnId:m=>m.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:m=>t?r.jsx(eL,{item:m}):r.jsx(tL,{item:m})});case"list":return r.jsx(J$,{items:p,statusOrder:c.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return r.jsx(Q$,{items:p,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function eL({item:e}){const t=Kl(e);return r.jsxs("div",{className:Se("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(pn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:Dn(e.updated)})]}),e.id?r.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),r.jsx($r,{value:e.id})]}):null]})}function tL({item:e}){const t=Kl(e);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(pn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[r.jsx(ea,{type:e.type,compact:!0}),r.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:Dn(e.updated)})]})]})}function nL({viewId:e,onPickAnother:t}){const{view:n,loading:s,error:a,refetch:l}=Go(e);return s?r.jsx(mt,{label:"Loading view…"}):a?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.message}),r.jsx("button",{type:"button",onClick:()=>l(),className:"shell-action mt-3",children:"Retry"})]}):n?r.jsx(K1,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),r.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function rL({sessions:e}){return r.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:r.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:Ho.recentSessionsEmptyTitle}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:Ho.recentSessionsEmptyHint})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>r.jsx("li",{children:r.jsx(sL,{session:t})},t.sessionId))})]})}function sL({session:e}){const t=ln(),[n,s]=f.useState(!1),a=oL(e,t),l=aL(e),c=!e.path;return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:a,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[l," · ",N0(e.started)]}),n&&e.path?r.jsxs("div",{className:"mt-1 space-y-0.5",children:[r.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),r.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ho.recentSessionsCopyFallbackHint})]}):null]}),r.jsx($r,{value:e.path,label:Ho.recentSessionsCopyPathLabel,disabled:c,disabledReason:Ho.recentSessionsCopyPathDisabled,onError:()=>s(!0)})]})}function oL(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function aL(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}function iL(){const{data:e,loading:t,error:n}=U0();return t&&!e?r.jsx(mt,{label:"Loading sessions…"}):n?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]}):r.jsx(rL,{sessions:(e==null?void 0:e.sessions)??[]})}const lL=5;function cL(){const{data:e,loading:t,error:n}=B0();if(t&&!e)return r.jsx(mt,{label:"Loading inventories…"});if(n)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]});const a=((e==null?void 0:e.inventories)??[]).slice(0,lL);return r.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[r.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),r.jsx(Ee,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),a.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:a.map(l=>{const c=l.inventory,u=l.active_leases.length,p=l.members.length,m=c.display_name??c.slug;return r.jsx("li",{children:r.jsxs(Ee,{to:`/inventories/${encodeURIComponent(c.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[u,"/",p," leased"]})]})},c.slug)})})]})}const q1={"saved-view":{title:"Saved view",icon:p0,render:(e,t)=>e.kind!=="saved-view"?null:f.createElement(nL,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:Ad,render:()=>f.createElement(iL)},inventories:{title:"Inventories",icon:Ld,render:()=>f.createElement(cL)}},uL={small:"min-h-[320px]",wide:"xl:col-span-2 min-h-[320px]",tall:"min-h-[560px]",large:"xl:col-span-2 min-h-[560px]"},dL={small:"Small",wide:"Wide",tall:"Tall",large:"Large"};function fL({slot:e,onReplace:t,onRemove:n,onResize:s}){const a=e.size??"small",l=uL[a];if(e.widget===null)return r.jsx("div",{className:Se("flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-card/40 p-3 shadow-sm",l),children:r.jsxs("button",{type:"button",onClick:t,className:"shell-action inline-flex items-center gap-2",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add widget"]})});const c=q1[e.widget.kind];if(!c)return r.jsx("div",{className:Se("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})});const u=c.icon;return r.jsxs("div",{className:Se("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:[r.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[r.jsx(u,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:r.jsx(pL,{slot:e,fallback:c.title})})]}),r.jsx(Wg,{items:[{key:"replace",label:"Replace…",icon:jR,onSelect:t},{key:"size",label:"Size",icon:yR,submenu:zD.map(p=>({key:`size-${p}`,label:dL[p],active:p===a,onSelect:()=>s(p)}))},{key:"remove",label:"Remove",icon:or,destructive:!0,onSelect:n}]})]}),r.jsx("div",{children:c.render(e.widget,{slotId:e.id,onPickAnother:t})})]})}function pL({slot:e,fallback:t}){var a,l;const n=((a=e.widget)==null?void 0:a.kind)==="saved-view"?e.widget.viewId:null,{view:s}=Go(n);return((l=e.widget)==null?void 0:l.kind)==="saved-view"&&s?r.jsx(r.Fragment,{children:s.name}):r.jsx(r.Fragment,{children:t})}const mL=["agent-sessions","inventories"];function hL({open:e,onOpenChange:t,onSelect:n}){const{views:s,loading:a}=Vd();function l(c){n(c),t(!1)}return r.jsx(ar,{open:e,onOpenChange:t,children:r.jsxs(Kn,{className:"max-w-xl",children:[r.jsxs(Zr,{children:[r.jsx(qn,{children:"Add a widget"}),r.jsx(gs,{children:"Choose a built-in widget or one of your saved views."})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:mL.map(c=>{const u=q1[c],p=u.icon;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:c}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx(p,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("span",{className:"font-medium text-foreground",children:u.title})]})},c)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),a?r.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):s.length===0?r.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",r.jsx(Ee,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):r.jsx("ul",{className:"max-h-72 divide-y divide-border/40 overflow-auto rounded-md border border-border/60",children:s.map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:"saved-view",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null,r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:c.config.viewMode})]})},c.id))}),!a&&s.some(c=>c.workspace!==null)?r.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}function gL(){const{data:e,error:t,refetch:n}=vP(),{data:s}=_0(),{layout:a}=WD(),[l,c]=f.useState(!1),[u,p]=f.useState(null),[m,h]=f.useState(null);mo("list:overview"),Ht({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const g=f.useCallback(k=>{p(k),c(!0)},[]),y=f.useCallback(async k=>{h(null);try{await qD(k)}catch(C){h(C instanceof Error?C.message:String(C))}},[]),b=f.useCallback(k=>{if(u===null)return;const C=a.slots.map((N,T)=>T===u?{...N,widget:k}:N);p(null),y(C)},[a.slots,u,y]),E=f.useCallback(k=>{const C=a.slots.map((N,T)=>T===k?{...N,widget:null}:N);y(C)},[a.slots,y]),j=f.useCallback((k,C)=>{const N=a.slots.map((T,D)=>D===k?{...T,size:C}:T);y(N)},[a.slots,y]),w={};if(e)for(const k of Object.keys(e.segments))for(const C of e.segments[k].items)w[C.id]=C;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("header",{className:"space-y-2",children:[r.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),r.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?r.jsx(AD,{hero:e.hero,itemsById:w}):t?r.jsx(wt,{error:t}):r.jsx(mt,{label:"Loading overview…"}),e!=null&&e.firstRun?r.jsx(RD,{help:s}):null,m?r.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",m]}):null,r.jsx("div",{className:"grid grid-flow-dense grid-cols-1 gap-4 xl:grid-cols-2",children:a.slots.map((k,C)=>r.jsx(fL,{slot:k,index:C,onReplace:()=>g(C),onRemove:()=>E(C),onResize:N=>j(C,N)},k.id))}),e!=null&&e.serverStats?r.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(sg,{className:"h-3 w-3","aria-hidden":"true"}),r.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,r.jsx(hL,{open:l,onOpenChange:k=>{c(k),k||p(null)},onSelect:b})]})}function xL({term:e,description:t}){return r.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function yL(){const{data:e,loading:t,error:n}=_0(),{openCheatsheet:s}=po();return t?r.jsx(mt,{label:"Loading help…"}):n||!e?r.jsx(wt,{error:n||"Help content is unavailable."}):r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",r.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",ds("Mod+k")," opens the command palette."]})]})}),r.jsx(We,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:r.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(a=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:a},a))})}),r.jsx(We,{title:"Getting Started",children:r.jsx("div",{className:"space-y-3",children:e.workflow.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,description:a.command.description,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsxs(We,{title:"Core Concepts",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(a=>r.jsx(xL,{term:a.term,description:a.description},a.term))}),r.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.term}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.term))})]}),r.jsx(We,{title:"Status Guide",children:r.jsx("div",{className:"space-y-3",children:e.statusGuide.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:a.status}),r.jsx("p",{className:"font-semibold text-foreground",children:a.meaning})]}),r.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:a.useWhen})]},a.status))})})]}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"Ownership And File Rules",children:r.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.files.map(l=>r.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:l},l))})]},a.label))})}),r.jsx(We,{title:"How To Navigate The Dashboard",children:r.jsx("div",{className:"space-y-3",children:e.navigation.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open"})]}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.label))})})]}),r.jsx(We,{title:"CLI Quick Reference",children:r.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(a=>r.jsx(qu,{command:a.command,description:a.description,example:a.example},a.command))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"FAQ",children:r.jsx("div",{className:"space-y-3",children:e.faq.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.question}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.answer})]},a.question))})}),r.jsx(We,{title:"First Project Checklist",children:r.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})})]})]})}function qg({children:e}){return r.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const tf=f.forwardRef(({value:e,onChange:t,placeholder:n="Search"},s)=>r.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[r.jsx(fo,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),r.jsx("input",{ref:s,value:e,onChange:a=>t(a.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));tf.displayName="SearchInput";function nf({value:e,options:t,onChange:n}){return r.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(s=>r.jsx("button",{type:"button","aria-pressed":e===s.value,onClick:()=>n(s.value),className:Se("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===s.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:s.label},s.value))})}const bL={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},rw=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function gd({progress:e,className:t,showLegend:n=!1}){const s=Zo(),a=f.useMemo(()=>{let c=0;return(s.order.length>0?s.order:Object.keys(e).filter(p=>p!=="total")).map(p=>({key:p,className:bL[p]??rw[c++%rw.length]}))},[s.order,e]),l=a.filter(c=>(e[c.key]??0)>0);return r.jsxs("div",{className:Se("space-y-2",t),children:[r.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?r.jsx("div",{className:"h-full w-full bg-muted"}):l.map(c=>r.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${yn(c.key)}: ${e[c.key]??0}`},c.key))}),n?r.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:a.map(c=>r.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[r.jsx("span",{className:Se("h-2 w-2 rounded-full",c.className)}),r.jsx("span",{children:yn(c.key)}),r.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const vL=["pending","active","blocked","failed","completed"],Gg=vL,wL=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function G1(e){return e&&e.length>0?e:[...wL]}function jL(e,t,n){if(t<0||t>=e.length)return e;const s=[...e],[a]=s.splice(t,1),l=t<n?n-1:n;return s.splice(Math.max(0,Math.min(l,s.length)),0,a),s}const kL=220,Au=8;function Y1({anchor:e,items:t,onClose:n}){const s=f.useRef(null),[a,l]=f.useState(null);return f.useLayoutEffect(()=>{if(!e){l(null);return}const c=s.current,u=(c==null?void 0:c.offsetWidth)??kL,p=(c==null?void 0:c.offsetHeight)??0,m=Math.max(Au,window.innerWidth-u-Au),h=Math.max(Au,window.innerHeight-p-Au);l({left:Math.min(e.x,m),top:Math.min(e.y,h)})},[e]),f.useEffect(()=>{if(!e)return;function c(m){s.current&&!s.current.contains(m.target)&&n()}function u(m){m.key==="Escape"&&n()}function p(){n()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),document.addEventListener("contextmenu",c),window.addEventListener("scroll",p,!0),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u),document.removeEventListener("contextmenu",c),window.removeEventListener("scroll",p,!0)}},[e,n]),!e||t.length===0?null:r.jsx("div",{ref:s,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(a==null?void 0:a.left)??e.x,top:(a==null?void 0:a.top)??e.y,visibility:a?"visible":"hidden"},children:r.jsx(Wo,{delayDuration:200,children:t.map(c=>{const u=c.icon,p=Se("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",c.disabled?"cursor-not-allowed opacity-50":c.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),m=r.jsxs(r.Fragment,{children:[u?r.jsx(u,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 truncate",children:c.label})]});if(c.disabled){const h=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:p,children:m})});return c.disabledReason?r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:h}),r.jsx(gr,{side:"left",children:c.disabledReason})]},c.key):r.jsx("div",{children:h},c.key)}return c.href?r.jsx(Ee,{to:c.href,className:p,onClick:()=>n(),children:m},c.key):r.jsx("button",{type:"button",className:p,onClick:()=>{var h;(h=c.onSelect)==null||h.call(c),n()},children:m},c.key)})})})}const SL="__ungrouped__";function Yg({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:s,title:a="Move to workspace",description:l="Pick the workspace this item should belong to."}){const{data:c,loading:u}=oc(),[p,m]=f.useState(n),[h,g]=f.useState(!1),[y,b]=f.useState(null);f.useEffect(()=>{e&&(m(n),b(null))},[e,n]);const E=f.useMemo(()=>[...((c==null?void 0:c.workspaces)??[]).map(C=>({key:C,label:C,value:C})),{key:SL,label:"Ungrouped",value:null}],[c]),j=!h&&p!==n;async function w(){if(j){g(!0),b(null);try{await s(p),t(!1)}catch(k){b(k instanceof Error?k.message:"Failed to move item")}finally{g(!1)}}}return r.jsx(ar,{open:e,onOpenChange:k=>h?void 0:t(k),children:r.jsxs(Kn,{children:[r.jsxs(Zr,{children:[r.jsx(qn,{children:a}),r.jsx(gs,{children:l})]}),r.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:u&&E.length===0?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[r.jsx(rg,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):E.map(k=>{const C=k.value===n,N=k.value===p;return r.jsxs("button",{type:"button",disabled:C||h,onClick:()=>m(k.value),className:Se("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",C?"cursor-not-allowed bg-foreground/5 text-muted-foreground":N?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:Se("block min-w-0 truncate",k.value===null?"italic text-muted-foreground":""),children:[k.label,C?r.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),N?r.jsx(Xr,{className:"h-4 w-4 text-foreground"}):null]},k.key)})}),y?r.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}):null,r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),disabled:h,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",onClick:w,disabled:!j,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving…":"Move"})]})]})})}function sw(){const{workspace:e}=$t(),t=ln(),n=Dt(),{data:s,loading:a,error:l,refetch:c}=Jo(),u=f.useRef(null);mo("list:projects");const[p,m]=f.useState(""),[h,g]=f.useState("all"),[y,b]=f.useState("all"),[E,j]=f.useState("updated"),[w,k]=hs(),C=w.get("view"),N=C==="table"||C==="kanban"?C:"cards",T=M=>{k(G=>{const A=new URLSearchParams(G);return M==="cards"?A.delete("view"):A.set("view",M),A})},[D,R]=f.useState({}),[$,L]=f.useState(null),[K,B]=f.useState(null),O=f.useMemo(()=>s?s.filter(M=>{if(e){if(e==="_ungrouped"){if(M.workspace!==null)return!1}else if(M.workspace!==e)return!1}return h!=="all"&&M.status!==h||y!=="all"&&!M.tags.includes(y)?!1:p.trim()?`${M.title} ${M.tags.join(" ")} ${M.slug}`.toLowerCase().includes(p.toLowerCase()):!0}).sort((M,G)=>EL(M,G,E)):[],[s,p,h,y,E,e]),W=O.map(M=>`${M.slug}:${M.status}`).join("|");f.useEffect(()=>{R(TL(O))},[W,E]);const se=f.useMemo(()=>{const M=new Map(O.map(G=>[G.slug,G]));return Gg.flatMap(G=>(D[G]??O.filter(F=>F.status===G).map(F=>F.slug)).map(F=>M.get(F)).filter(F=>!!F))},[O,D]),{visibleItems:z,visibleIndexByKey:H}=f.useMemo(()=>{const M=N==="kanban"?se:O,G=new Map;return M.forEach((A,F)=>G.set(A.slug,F)),{visibleItems:M,visibleIndexByKey:G}},[N,O,se]),{hotkeyRowProps:ee}=ac(z,{scope:"list:projects",onOpen:M=>n(`${t}/projects/${M.slug}`)});if(Ht({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var M;return(M=u.current)==null?void 0:M.focus()}}),Ht({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),a)return r.jsx(mt,{label:"Loading projects…"});if(l||!s)return r.jsx(wt,{error:l||"Project list is unavailable."});const ne=Array.from(new Set(s.flatMap(M=>M.tags))).sort();return r.jsxs("div",{className:"space-y-5",children:[r.jsxs(qg,{children:[r.jsx(tf,{ref:u,value:p,onChange:m,placeholder:"Search by project title or tag"}),r.jsxs("select",{value:h,onChange:M=>g(M.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All statuses"}),r.jsx("option",{value:"pending",children:"Pending"}),r.jsx("option",{value:"active",children:"Active"}),r.jsx("option",{value:"blocked",children:"Blocked"}),r.jsx("option",{value:"failed",children:"Failed"}),r.jsx("option",{value:"completed",children:"Completed"})]}),r.jsxs("select",{value:y,onChange:M=>b(M.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All tags"}),ne.map(M=>r.jsx("option",{value:M,children:M},M))]}),r.jsxs("select",{value:E,onChange:M=>j(M.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"updated",children:"Sort: Updated"}),r.jsx("option",{value:"created",children:"Sort: Created"}),r.jsx("option",{value:"title",children:"Sort: Title"}),r.jsx("option",{value:"attention",children:"Sort: Attention"})]}),r.jsx(nf,{value:N,onChange:M=>T(M),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),O.length===0?s.length===0?r.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[r.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),r.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),r.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),r.jsx(Ee,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):r.jsx(St,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):N==="cards"?r.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:O.map((M,G)=>r.jsxs(Ee,{to:`${t}/projects/${M.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...ee(G),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:M.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Dn(M.updated)]})]}),r.jsx(pn,{status:M.status})]}),r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsx(gd,{progress:M.progress,showLegend:!0}),r.jsx("div",{className:"flex flex-wrap gap-2",children:M.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:A},A))}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:M.needsAttention.blockedCount+M.needsAttention.failedCount})]}),r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:M.progress.total})]})]})]})]},M.slug))}):N==="table"?r.jsx(We,{title:`${O.length} project${O.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[r.jsx("th",{className:"pb-3 font-medium",children:"Project"}),r.jsx("th",{className:"pb-3 font-medium",children:"Status"}),r.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),r.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),r.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),r.jsx("tbody",{children:O.map((M,G)=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",...ee(G),children:[r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(Ee,{to:`${t}/projects/${M.slug}`,className:"font-semibold text-foreground hover:text-primary",children:M.title}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:M.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:A},A))})]}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx(pn,{status:M.status})}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx("div",{className:"min-w-[220px]",children:r.jsx(gd,{progress:M.progress})})}),r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:M.needsAttention.blockedCount+M.needsAttention.failedCount}),r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(M.updated)})]},M.slug))})]})})}):r.jsx(Qd,{columns:CL,items:se,getItemId:M=>M.slug,getColumnId:M=>M.status,canDrop:({fromColumnId:M,toColumnId:G})=>({allowed:!0,reason:M===G?void 0:"This will set a manual status override on the project."}),onMove:({item:M,fromColumnId:G,toColumnId:A,fromIndex:F,toIndex:Z})=>{if(G===A){const I=D[G]??O.filter(de=>de.status===G).map(de=>de.slug);R(de=>({...de,[G]:jL(I,F,Z)}));return}fetch(`/api/projects/${M.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})}).then(()=>{window.location.reload()})},getExternalDragData:M=>({type:"project",id:M.slug}),onCardContextMenu:(M,G)=>{G.preventDefault(),L({project:M,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:M=>`No ${M.title.toLowerCase()} projects.`,renderCard:(M,{dragging:G})=>{const A=H.get(M.slug)??-1;return r.jsx("div",{...A>=0?ee(A):{},children:r.jsx(RL,{project:M,dragging:G})})}}),r.jsx(Y1,{anchor:($==null?void 0:$.anchor)??null,items:$?[{key:"edit",label:"Edit",icon:bi,onSelect:()=>n(`${t}/projects/${$.project.slug}`)},{key:"move",label:"Move to workspace…",icon:$d,onSelect:()=>B($.project)}]:[],onClose:()=>L(null)}),r.jsx(Yg,{open:K!==null,onOpenChange:M=>{M||B(null)},currentWorkspace:(K==null?void 0:K.workspace)??null,title:"Move project to workspace",onSubmit:async M=>{if(!K)return;const G=await fetch(`/api/projects/${encodeURIComponent(K.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:M})});if(!G.ok){const A=await G.json().catch(()=>({}));throw new Error(A.error||"Failed to move project")}c()}}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(ng,{className:"mt-0.5 h-4 w-4"}),r.jsxs("p",{children:["Project status is derived from assignment state by default.",N==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const NL={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},CL=Gg.map(e=>({id:e,title:NL[e],description:Zd(e)}));function EL(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return ow(t)-ow(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function ow(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function TL(e){return Object.fromEntries(Gg.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function RL({project:e,dragging:t}){const n=ln();return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Ee,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Dn(e.updated)]})]}),r.jsx(pn,{status:e.status})]}),r.jsx("div",{className:"mt-4",children:r.jsx(gd,{progress:e.progress})}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(s=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:s},s)),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),r.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function xd({title:e,description:t,actions:n,className:s}){return r.jsxs("div",{className:Se("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",s),children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}const PL=4e3;function ta(){const[e,t]=f.useState(null),n=f.useRef(null),s=f.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),a=f.useCallback((l,c="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:l,kind:c}),n.current=setTimeout(()=>{t(null),n.current=null},PL)},[]);return f.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:a,dismissToast:s}}function na({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return r.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:r.jsx("button",{type:"button",onClick:t,className:Se("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}function AL(){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[r.jsx(Dd,{className:"h-3 w-3"}),"Archived"]})}function aw(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function DL(){const{data:e,loading:t,error:n,refetch:s}=wP(),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState({}),{toast:h,showToast:g,dismissToast:y}=ta();async function b(N,T,D){l(T),u(null);try{const R=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"}});if(!R.ok){const $=await R.json().catch(()=>null);throw new Error(($==null?void 0:$.error)||`HTTP ${R.status}`)}s(),g(D,"success")}catch(R){u(R instanceof Error?R.message:"Restore failed")}finally{l(null)}}function E(N){return b(`/api/projects/${N.slug}/unarchive`,`project:${N.slug}`,"Project restored")}function j(N){const T=N.projectSlug?`/api/projects/${N.projectSlug}/assignments/${N.slug}/unarchive`:`/api/assignments/${N.id}/unarchive`;return b(T,`assignment:${N.id}`,"Assignment restored")}if(t)return r.jsx(mt,{label:"Loading archived content…"});if(n)return r.jsx(wt,{error:n});const w=(e==null?void 0:e.projects)??[],k=(e==null?void 0:e.assignments)??[],C=w.length===0&&k.length===0;return r.jsxs("div",{className:"space-y-6",children:[r.jsx(na,{toast:h,onDismiss:y}),r.jsx(xd,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),c?r.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:c}):null,C?r.jsx(St,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):r.jsxs(r.Fragment,{children:[w.length>0&&r.jsx(We,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:r.jsx("ul",{className:"divide-y divide-border",children:w.map(N=>{const T=p[N.slug]??!1;return r.jsxs("li",{className:"py-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>m(D=>({...D,[N.slug]:!T})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":T,children:[T?r.jsx(br,{className:"h-4 w-4"}):r.jsx(l0,{className:"h-4 w-4"}),r.jsx(eg,{className:"h-4 w-4 text-muted-foreground"}),N.title,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.assignments.length," assignment",N.assignments.length===1?"":"s",")"]})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(Ee,{to:`/projects/${N.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),r.jsxs("button",{type:"button",onClick:()=>E(N),disabled:a===`project:${N.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]})]}),T&&N.assignments.length>0&&r.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:N.assignments.map(D=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[r.jsx(Ee,{to:aw(D),className:"text-foreground hover:text-foreground/80",children:D.title}),r.jsx(pn,{status:D.status,showIcon:!1}),r.jsx("span",{className:"text-xs text-muted-foreground",children:D.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},D.id))})]},N.slug)})})}),k.length>0&&r.jsx(We,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:r.jsx("ul",{className:"divide-y divide-border",children:k.map(N=>r.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[r.jsx(Ee,{to:aw(N),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:N.title}),r.jsx(pn,{status:N.status,showIcon:!1}),r.jsx(AL,{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.projectTitle??"Standalone"," · Archived"," ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("button",{type:"button",onClick:()=>j(N),disabled:a===`assignment:${N.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]},N.id))})})]})]})}const iw="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",lw="block min-w-0 truncate";function Jg({externalIds:e,className:t}){return e.length===0?null:r.jsx("span",{className:Se("flex flex-wrap items-center gap-1.5",t),children:e.map((n,s)=>{const a=`${n.system}:${n.id}`,l=`${n.system}:${n.id}:${s}`;return n.url!=null&&n.url.length>0?r.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:Se(iw,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${a} in ${n.system}`,children:[r.jsx("span",{className:lw,children:a}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]},l):r.jsx("span",{className:iw,title:a,children:r.jsx("span",{className:lw,children:a})},l)})})}const $L={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function An({label:e,value:t,description:n,icon:s,tone:a="default",to:l}){const c=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),r.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),s?r.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:r.jsx(s,{className:"h-5 w-5"})}):null]}),n?r.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),u=Se($L[a],l?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return l?r.jsx(Ee,{to:l,className:u,children:c}):r.jsx("article",{className:u,children:c})}function cw(e){const t=LL(e),n=f.forwardRef((s,a)=>{const{children:l,...c}=s,u=f.Children.toArray(l),p=u.find(IL);if(p){const m=p.props.children,h=u.map(g=>g===p?f.Children.count(m)>1?f.Children.only(null):f.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...c,ref:a,children:f.isValidElement(m)?f.cloneElement(m,void 0,h):null})}return r.jsx(t,{...c,ref:a,children:l})});return n.displayName=`${e}.Slot`,n}function LL(e){const t=f.forwardRef((n,s)=>{const{children:a,...l}=n;if(f.isValidElement(a)){const c=_L(a),u=ML(l,a.props);return a.type!==f.Fragment&&(u.ref=s?Fd(s,c):c),f.cloneElement(a,u)}return f.Children.count(a)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var OL=Symbol("radix.slottable");function IL(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===OL}function ML(e,t){const n={...t};for(const s in t){const a=e[s],l=t[s];/^on[A-Z]/.test(s)?a&&l?n[s]=(...u)=>{const p=l(...u);return a(...u),p}:a&&(n[s]=a):s==="style"?n[s]={...a,...l}:s==="className"&&(n[s]=[a,l].filter(Boolean).join(" "))}return{...e,...n}}function _L(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function FL(e){const t=e+"CollectionProvider",[n,s]=Xo(t),[a,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j=>{const{scope:w,children:k}=j,C=nn.useRef(null),N=nn.useRef(new Map).current;return r.jsx(a,{scope:w,itemMap:N,collectionRef:C,children:k})};c.displayName=t;const u=e+"CollectionSlot",p=cw(u),m=nn.forwardRef((j,w)=>{const{scope:k,children:C}=j,N=l(u,k),T=Fn(w,N.collectionRef);return r.jsx(p,{ref:T,children:C})});m.displayName=u;const h=e+"CollectionItemSlot",g="data-radix-collection-item",y=cw(h),b=nn.forwardRef((j,w)=>{const{scope:k,children:C,...N}=j,T=nn.useRef(null),D=Fn(w,T),R=l(h,k);return nn.useEffect(()=>(R.itemMap.set(T,{ref:T,...N}),()=>void R.itemMap.delete(T))),r.jsx(y,{[g]:"",ref:D,children:C})});b.displayName=h;function E(j){const w=l(e+"CollectionConsumer",j);return nn.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const N=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(w.itemMap.values()).sort((R,$)=>N.indexOf(R.ref.current)-N.indexOf($.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:c,Slot:m,ItemSlot:b},E,s]}var zL=f.createContext(void 0);function J1(e){const t=f.useContext(zL);return e||t||"ltr"}var Pm="rovingFocusGroup.onEntryFocus",BL={bubbles:!1,cancelable:!0},dc="RovingFocusGroup",[Nh,X1,UL]=FL(dc),[VL,Q1]=Xo(dc,[UL]),[HL,WL]=VL(dc),Z1=f.forwardRef((e,t)=>r.jsx(Nh.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Nh.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(KL,{...e,ref:t})})}));Z1.displayName=dc;var KL=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:p,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,y=f.useRef(null),b=Fn(t,y),E=J1(l),[j,w]=zd({prop:c,defaultProp:u??null,onChange:p,caller:dc}),[k,C]=f.useState(!1),N=Ko(m),T=X1(n),D=f.useRef(!1),[R,$]=f.useState(0);return f.useEffect(()=>{const L=y.current;if(L)return L.addEventListener(Pm,N),()=>L.removeEventListener(Pm,N)},[N]),r.jsx(HL,{scope:n,orientation:s,dir:E,loop:a,currentTabStopId:j,onItemFocus:f.useCallback(L=>w(L),[w]),onItemShiftTab:f.useCallback(()=>C(!0),[]),onFocusableItemAdd:f.useCallback(()=>$(L=>L+1),[]),onFocusableItemRemove:f.useCallback(()=>$(L=>L-1),[]),children:r.jsx(mn.div,{tabIndex:k||R===0?-1:0,"data-orientation":s,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:qt(e.onMouseDown,()=>{D.current=!0}),onFocus:qt(e.onFocus,L=>{const K=!D.current;if(L.target===L.currentTarget&&K&&!k){const B=new CustomEvent(Pm,BL);if(L.currentTarget.dispatchEvent(B),!B.defaultPrevented){const O=T().filter(ee=>ee.focusable),W=O.find(ee=>ee.active),se=O.find(ee=>ee.id===j),H=[W,se,...O].filter(Boolean).map(ee=>ee.ref.current);nS(H,h)}}D.current=!1}),onBlur:qt(e.onBlur,()=>C(!1))})})}),eS="RovingFocusGroupItem",tS=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:l,children:c,...u}=e,p=ni(),m=l||p,h=WL(eS,n),g=h.currentTabStopId===m,y=X1(n),{onFocusableItemAdd:b,onFocusableItemRemove:E,currentTabStopId:j}=h;return f.useEffect(()=>{if(s)return b(),()=>E()},[s,b,E]),r.jsx(Nh.ItemSlot,{scope:n,id:m,focusable:s,active:a,children:r.jsx(mn.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:qt(e.onMouseDown,w=>{s?h.onItemFocus(m):w.preventDefault()}),onFocus:qt(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:qt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=YL(w,h.orientation,h.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let N=y().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")N.reverse();else if(k==="prev"||k==="next"){k==="prev"&&N.reverse();const T=N.indexOf(w.currentTarget);N=h.loop?JL(N,T+1):N.slice(T+1)}setTimeout(()=>nS(N))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:j!=null}):c})})});tS.displayName=eS;var qL={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function GL(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function YL(e,t,n){const s=GL(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return qL[s]}function nS(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function JL(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var XL=Z1,QL=tS,rf="Tabs",[ZL]=Xo(rf,[Q1]),rS=Q1(),[eO,Xg]=ZL(rf),sS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:l,orientation:c="horizontal",dir:u,activationMode:p="automatic",...m}=e,h=J1(u),[g,y]=zd({prop:s,onChange:a,defaultProp:l??"",caller:rf});return r.jsx(eO,{scope:n,baseId:ni(),value:g,onValueChange:y,orientation:c,dir:h,activationMode:p,children:r.jsx(mn.div,{dir:h,"data-orientation":c,...m,ref:t})})});sS.displayName=rf;var oS="TabsList",aS=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,l=Xg(oS,n),c=rS(n);return r.jsx(XL,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:r.jsx(mn.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:t})})});aS.displayName=oS;var iS="TabsTrigger",lS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...l}=e,c=Xg(iS,n),u=rS(n),p=dS(c.baseId,s),m=fS(c.baseId,s),h=s===c.value;return r.jsx(QL,{asChild:!0,...u,focusable:!a,active:h,children:r.jsx(mn.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:p,...l,ref:t,onMouseDown:qt(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:qt(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:qt(e.onFocus,()=>{const g=c.activationMode!=="manual";!h&&!a&&g&&c.onValueChange(s)})})})});lS.displayName=iS;var cS="TabsContent",uS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:l,...c}=e,u=Xg(cS,n),p=dS(u.baseId,s),m=fS(u.baseId,s),h=s===u.value,g=f.useRef(h);return f.useEffect(()=>{const y=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(y)},[]),r.jsx(Qo,{present:a||h,children:({present:y})=>r.jsx(mn.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":p,hidden:!y,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:y&&l})})});uS.displayName=cS;function dS(e,t){return`${e}-trigger-${t}`}function fS(e,t){return`${e}-content-${t}`}var pS=sS,mS=aS,Ch=lS,Eh=uS;function Qg({value:e,onValueChange:t,items:n,className:s}){return r.jsxs(pS,{value:e,onValueChange:t,className:s,children:[r.jsx(mS,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(a=>r.jsxs(Ch,{value:a.value,className:Se("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[r.jsx("span",{children:a.label}),typeof a.count=="number"?r.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:a.count}):null]},a.value))}),n.map(a=>r.jsx(Eh,{value:a.value,className:"pt-3",children:a.content},a.value))]})}const tO="modulepreload",nO=function(e){return"/"+e},uw={},rO=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),p=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(m=>{if(m=nO(m),m in uw)return;uw[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":tO,h||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),h)return new Promise((b,E)=>{y.addEventListener("load",b),y.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})};function sO({definition:e,className:t,nodeRoutes:n={}}){const s=f.useRef(null),[a,l]=f.useState(null),[c,u]=f.useState(!0),p=Dt(),m=document.documentElement.classList.contains("dark")?"dark":"default";return f.useEffect(()=>{let h=!1;async function g(){if(s.current)try{const y=(await rO(async()=>{const{default:j}=await import("./mermaid.core-B_gAmtAa.js").then(w=>w.bF);return{default:j}},[])).default;if(y.initialize({startOnLoad:!1,theme:"base",themeVariables:oO(m==="dark")}),h)return;const b=`mermaid-${Date.now()}`,{svg:E}=await y.render(b,e);if(h||!s.current)return;s.current.innerHTML=E,aO(s.current,n,p),u(!1)}catch(y){h||(l(y instanceof Error?y.message:"Failed to render graph"),u(!1))}}return u(!0),l(null),g(),()=>{h=!0}},[e,p,n,m]),a?r.jsxs("div",{className:Se("rounded-lg border border-border bg-card p-4",t),children:[r.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",a]}),r.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):r.jsxs("div",{className:Se("rounded-lg border border-border bg-card p-4",t),children:[c&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),r.jsx("div",{ref:s,className:"overflow-auto"})]})}function oO(e){const t=document.documentElement,n=g=>{const y=getComputedStyle(t).getPropertyValue(g).trim();return y?`oklch(${y})`:""},s=n("--card"),a=n("--card-foreground"),l=n("--border"),c=n("--primary"),u=n("--primary-foreground"),p=n("--muted"),m=n("--muted-foreground"),h=n("--secondary");return{background:s,primaryColor:s,primaryTextColor:a,primaryBorderColor:l,secondaryColor:p,secondaryTextColor:a,secondaryBorderColor:l,tertiaryColor:p,tertiaryTextColor:m,tertiaryBorderColor:l,lineColor:e?m:l,textColor:a,mainBkg:s,nodeBkg:s,nodeTextColor:a,nodeBorder:l,clusterBkg:p,clusterBorder:l,edgeLabelBackground:s,titleColor:a,activeTaskBkgColor:c,activeTaskBorderColor:c,altBackground:p,labelColor:a,errorBkgColor:h,errorTextColor:u}}function aO(e,t,n){var s;for(const a of e.querySelectorAll(".node")){const l=((s=a.textContent)==null?void 0:s.replace(/\s+/g," ").trim())??"",c=t[l];if(!c)continue;a.style.cursor="pointer",a.setAttribute("role","link"),a.setAttribute("tabindex","0"),a.setAttribute("aria-label",`Open ${l}`);const u=()=>n(c);a.addEventListener("click",u),a.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),u())})}}function iO(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uO={};function dw(e,t){return(uO.jsx?cO:lO).test(e)}const dO=/[ \t\n\f\r]/g;function fO(e){return typeof e=="object"?e.type==="text"?fw(e.value):!1:fw(e)}function fw(e){return e.replace(dO,"")===""}class fc{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}fc.prototype.normal={};fc.prototype.property={};fc.prototype.space=void 0;function hS(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new fc(n,s,t)}function Th(e){return e.toLowerCase()}class ir{constructor(t,n){this.attribute=n,this.property=t}}ir.prototype.attribute="";ir.prototype.booleanish=!1;ir.prototype.boolean=!1;ir.prototype.commaOrSpaceSeparated=!1;ir.prototype.commaSeparated=!1;ir.prototype.defined=!1;ir.prototype.mustUseProperty=!1;ir.prototype.number=!1;ir.prototype.overloadedBoolean=!1;ir.prototype.property="";ir.prototype.spaceSeparated=!1;ir.prototype.space=void 0;let pO=0;const dt=ra(),dn=ra(),Rh=ra(),Te=ra(),It=ra(),li=ra(),pr=ra();function ra(){return 2**++pO}const Ph=Object.freeze(Object.defineProperty({__proto__:null,boolean:dt,booleanish:dn,commaOrSpaceSeparated:pr,commaSeparated:li,number:Te,overloadedBoolean:Rh,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),Am=Object.keys(Ph);class Zg extends ir{constructor(t,n,s,a){let l=-1;if(super(t,n),pw(this,"space",a),typeof s=="number")for(;++l<Am.length;){const c=Am[l];pw(this,Am[l],(s&Ph[c])===Ph[c])}}}Zg.prototype.defined=!0;function pw(e,t,n){n&&(e[t]=n)}function ki(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new Zg(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Th(s)]=s,n[Th(l.attribute)]=s}return new fc(t,n,e.space)}const gS=ki({properties:{ariaActiveDescendant:null,ariaAtomic:dn,ariaAutoComplete:null,ariaBusy:dn,ariaChecked:dn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:It,ariaCurrent:null,ariaDescribedBy:It,ariaDetails:null,ariaDisabled:dn,ariaDropEffect:It,ariaErrorMessage:null,ariaExpanded:dn,ariaFlowTo:It,ariaGrabbed:dn,ariaHasPopup:null,ariaHidden:dn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:It,ariaLevel:Te,ariaLive:null,ariaModal:dn,ariaMultiLine:dn,ariaMultiSelectable:dn,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:dn,ariaReadOnly:dn,ariaRelevant:null,ariaRequired:dn,ariaRoleDescription:It,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:dn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function xS(e,t){return t in e?e[t]:t}function yS(e,t){return xS(e,t.toLowerCase())}const mO=ki({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:li,acceptCharset:It,accessKey:It,action:null,allow:null,allowFullScreen:dt,allowPaymentRequest:dt,allowUserMedia:dt,alt:null,as:null,async:dt,autoCapitalize:null,autoComplete:It,autoFocus:dt,autoPlay:dt,blocking:It,capture:null,charSet:null,checked:dt,cite:null,className:It,cols:Te,colSpan:null,content:null,contentEditable:dn,controls:dt,controlsList:It,coords:Te|li,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dt,defer:dt,dir:null,dirName:null,disabled:dt,download:Rh,draggable:dn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dt,formTarget:null,headers:It,height:Te,hidden:Rh,high:Te,href:null,hrefLang:null,htmlFor:It,httpEquiv:It,id:null,imageSizes:null,imageSrcSet:null,inert:dt,inputMode:null,integrity:null,is:null,isMap:dt,itemId:null,itemProp:It,itemRef:It,itemScope:dt,itemType:It,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dt,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:dt,muted:dt,name:null,nonce:null,noModule:dt,noValidate:dt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:dt,optimum:Te,pattern:null,ping:It,placeholder:null,playsInline:dt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dt,referrerPolicy:null,rel:It,required:dt,reversed:dt,rows:Te,rowSpan:Te,sandbox:It,scope:null,scoped:dt,seamless:dt,selected:dt,shadowRootClonable:dt,shadowRootDelegatesFocus:dt,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:dn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:dt,useMap:null,value:dn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:It,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dt,declare:dt,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:dt,noHref:dt,noShade:dt,noWrap:dt,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:dn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dt,disableRemotePlayback:dt,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:yS}),hO=ki({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pr,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:It,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:dt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:li,g2:li,glyphName:li,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:pr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Te,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:It,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pr,rev:pr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pr,requiredFeatures:pr,requiredFonts:pr,requiredFormats:pr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:pr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pr,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xS}),bS=ki({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),vS=ki({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yS}),wS=ki({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),gO={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},xO=/[A-Z]/g,mw=/-[a-z]/g,yO=/^data[-\w.:]+$/i;function bO(e,t){const n=Th(t);let s=t,a=ir;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&yO.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(mw,wO);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!mw.test(l)){let c=l.replace(xO,vO);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Zg}return new a(s,t)}function vO(e){return"-"+e.toLowerCase()}function wO(e){return e.charAt(1).toUpperCase()}const jO=hS([gS,mO,bS,vS,wS],"html"),ex=hS([gS,hO,bS,vS,wS],"svg");function kO(e){return e.join(" ").trim()}var Ba={},Dm,hw;function SO(){if(hw)return Dm;hw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,p=`
530
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return f.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},wD=_k,jD=Fk,Yk=zk,Jk=Bk,Xk=Kk,Qk=Gk,Zk=Vk,e1=Wk;const Ga=wD,kD=jD,t1=f.forwardRef(({className:e,...t},n)=>r.jsx(Yk,{ref:n,className:Se("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));t1.displayName=Yk.displayName;const Bo=f.forwardRef(({className:e,...t},n)=>r.jsxs(kD,{children:[r.jsx(t1,{}),r.jsx(Jk,{ref:n,className:Se("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...t})]}));Bo.displayName=Jk.displayName;function Ya({className:e,...t}){return r.jsx("div",{className:Se("flex flex-col space-y-2 text-left",e),...t})}function Ja({className:e,...t}){return r.jsx("div",{className:Se("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Uo=f.forwardRef(({className:e,...t},n)=>r.jsx(Zk,{ref:n,className:Se("text-lg font-semibold tracking-tight text-foreground",e),...t}));Uo.displayName=Zk.displayName;const Vo=f.forwardRef(({className:e,...t},n)=>r.jsx(e1,{ref:n,className:Se("text-sm leading-6 text-muted-foreground",e),...t}));Vo.displayName=e1.displayName;const oo=f.forwardRef(({className:e,...t},n)=>r.jsx(Xk,{ref:n,className:Se(e),...t}));oo.displayName=Xk.displayName;const Ul=f.forwardRef(({className:e,...t},n)=>r.jsx(Qk,{ref:n,className:Se(e),...t}));Ul.displayName=Qk.displayName;const SD=[{to:"/",label:"Overview",icon:u0},{to:"/playbooks",label:"Playbooks",icon:i0},{to:"/memories",label:"Memories",icon:ZT},{to:"/resources",label:"Resources",icon:mR},{to:"/inventories",label:"Inventories",icon:Ld},{to:"/usage",label:"Usage",icon:Od},{to:"/todos",label:"Todos",icon:Dr},{to:"/views",label:"Saved Views",icon:p0},{to:"/archive",label:"Archive",icon:Dd}],ND=[{suffix:"/projects",label:"Projects",icon:eg},{suffix:"/assignments",label:"Assignments",icon:xR},{suffix:"/servers",label:"Servers",icon:sg},{suffix:"/inventories",label:"Inventories",icon:Ld},{suffix:"/usage",label:"Usage",icon:Od},{suffix:"/agent-sessions",label:"Agent Sessions",icon:Ad},{suffix:"/todos",label:"Todos",icon:Dr}],CD=[{to:"/help",label:"Help",icon:hR},{to:"/settings",label:"Settings",icon:ER}];function ED({title:e,breadcrumbs:t,projectSlug:n,workspace:s,children:a}){const[l,c]=f.useState(!1);return Ht({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:l,handler:()=>c(!1)}),r.jsx("div",{className:"min-h-screen bg-background",children:r.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[r.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar px-4 py-4 lg:flex lg:flex-col",children:r.jsx(zv,{activeWorkspace:s})}),l?r.jsx("div",{className:"fixed inset-0 z-40 bg-overlay/40 lg:hidden",children:r.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx(Ee,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>c(!1),children:"Syntaur"}),r.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80",children:r.jsx(ig,{className:"h-4 w-4"})})]}),r.jsx(zv,{activeWorkspace:s,onNavigate:()=>c(!1)})]})}):null,r.jsxs("div",{className:"min-w-0",children:[r.jsx(eD,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>c(!0)}),r.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:a})]})]})})}function zv({activeWorkspace:e,onNavigate:t}){const{data:n}=oc(),s=(n==null?void 0:n.workspaces)??[],a=(n==null?void 0:n.hasUngrouped)??!1,{hidden:l}=Ik(),c=Wn(),[u,p]=f.useState(new Set),[m,h]=f.useState(!1),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null),[N,T]=f.useState(!1),D=Dt();function R(B){p(O=>{const W=new Set(O);return W.has(B)?W.delete(B):W.add(B),W})}const $=rD([...s,...a?[ld]:[]],l);async function L(B){if(j){T(!0);try{const O=`/api/workspaces/${encodeURIComponent(j)}${B?"?cascade=true":""}`,W=await fetch(O,{method:"DELETE"});if(W.status===409){const se=await W.json().catch(()=>({}));C((se==null?void 0:se.blockedBy)??{projects:[],standalones:[]});return}if(!W.ok){const se=await W.json().catch(()=>({}));throw new Error(se.error||"Failed to delete workspace")}w(null),C(null)}catch(O){console.error(O),alert(O instanceof Error?O.message:"Failed to delete workspace")}finally{T(!1)}}}async function K(B,O){try{if(B.type==="project"){const W=await fetch(`/api/projects/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:O})});if(!W.ok){const se=await W.json().catch(()=>({}));throw new Error(se.error||"Failed to move project")}return}if(B.type==="standalone-assignment"){const W=await fetch(`/api/assignments/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:O})});if(!W.ok){const se=await W.json().catch(()=>({}));throw new Error(se.error||"Failed to move assignment")}return}if(B.type==="project-assignment"){alert("Assignments inherit workspace from their project — drag the project (or move it) to change workspaces.");return}}catch(W){console.error(W),alert(W instanceof Error?W.message:"Failed to move item")}}return r.jsxs("div",{className:"flex h-full flex-col gap-3",children:[r.jsx("div",{className:"space-y-3",children:r.jsxs(Ee,{to:"/",className:"inline-flex items-center gap-3",onClick:t,children:[r.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:r.jsxs("svg",{viewBox:"0 0 43 51","aria-label":"Syntaur",role:"img",className:"h-4 w-auto",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M13 2C13 0.89543 13.8954 0 15 0H41C42.1046 0 43 0.895431 43 2V12C43 13.1046 42.1046 14 41 14H13V2Z"}),r.jsx("path",{d:"M0 15C0 13.8954 0.895431 13 2 13H14V25C14 26.1046 13.1046 27 12 27H2C0.89543 27 0 26.1046 0 25V15Z"}),r.jsx("path",{d:"M30 49C30 50.1046 29.1046 51 28 51L2 51C0.89543 51 0 50.1046 0 49L0 39C0 37.8954 0.895431 37 2 37L30 37L30 49Z"}),r.jsx("path",{d:"M42.9646 36C42.9646 37.1046 42.0692 38 40.9646 38H28.9646V26C28.9646 24.8954 29.86 24 30.9646 24H40.9646C42.0692 24 42.9646 24.8954 42.9646 26V36Z"})]})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),r.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),r.jsx(vv,{items:SD,onNavigate:t}),r.jsx("div",{className:"border-t border-border/40"}),r.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[$.length===0&&!m&&r.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),$.map(B=>{const O=B==="_ungrouped",W=O?"Ungrouped":yn(B),se=O?"/w/_ungrouped":`/w/${B}`,z=u.has(B),H=e===B||e===null&&O&&c.pathname.startsWith("/w/_ungrouped"),ee=b===B;return r.jsxs("div",{className:`rounded-md transition ${ee?"bg-accent/40 ring-1 ring-ring/40":""}`,onDragOver:ne=>{ne.dataTransfer.types.includes("application/json")&&(ne.preventDefault(),ne.dataTransfer.dropEffect="move",E(B))},onDragLeave:ne=>{ne.currentTarget.contains(ne.relatedTarget)||E(M=>M===B?null:M)},onDrop:async ne=>{try{const M=ne.dataTransfer.getData("application/json");if(!M)return;ne.preventDefault();let G;try{G=JSON.parse(M)}catch{return}if(!(G!=null&&G.type)||!(G!=null&&G.id))return;await K(G,O?null:B)}finally{E(null)}},children:[r.jsxs("div",{className:"group flex items-center",children:[r.jsxs("button",{type:"button",onClick:()=>R(B),className:`flex flex-1 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${H?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[r.jsx(br,{className:`h-3 w-3 transition-transform ${z?"-rotate-90":""}`}),W]}),O?null:r.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),w(B),C(null)},title:`Delete workspace "${B}"`,"aria-label":`Delete workspace "${B}"`,className:"mr-1 flex h-6 w-6 items-center justify-center rounded text-muted-foreground/60 opacity-0 transition hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",children:r.jsx(or,{className:"h-3 w-3"})})]}),!z&&r.jsx("nav",{className:"ml-2 space-y-0.5",children:ND.map(ne=>{const M=`${se}${ne.suffix}`,G=E0(c.pathname,ne.suffix)&&c.pathname.startsWith(se),A=ne.icon;return r.jsxs(Ee,{to:M,onClick:t,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${G?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[r.jsx(A,{className:"h-4 w-4"}),r.jsx("span",{children:ne.label})]},M)})})]},B)}),m?r.jsx("form",{className:"px-3 py-1.5",onSubmit:B=>{B.preventDefault();const O=g.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");O&&(h(!1),y(""),fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:O})}).then(()=>{t==null||t(),D(`/w/${O}/projects`)}))},children:r.jsx("input",{autoFocus:!0,type:"text",value:g,onChange:B=>y(B.target.value),onKeyDown:B=>{B.key==="Escape"&&(h(!1),y(""))},onBlur:()=>{g.trim()||(h(!1),y(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[r.jsx(rn,{className:"h-3 w-3"}),"New Workspace"]})]}),r.jsx("div",{className:"border-t border-border/40"}),r.jsx(vv,{items:CD,onNavigate:t}),r.jsx(Ga,{open:j!==null,onOpenChange:B=>{N||B||(w(null),C(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:k?"Workspace has references":"Delete workspace?"}),r.jsx(Vo,{children:k?r.jsxs(r.Fragment,{children:["The workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," is still referenced by:"]}):r.jsxs(r.Fragment,{children:["Remove the workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," from the registry. This does not affect projects or standalones unless you choose to cascade."]})})]}),k?r.jsxs("div",{className:"space-y-2 text-sm",children:[k.projects.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Projects (",k.projects.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.projects.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/projects/${B}`,className:"hover:underline",children:B})},B))})]}):null,k.standalones.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Standalones (",k.standalones.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.standalones.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/assignments/${B}`,className:"hover:underline",children:B})},B))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:['Choose "Clear references and delete" to set ',r.jsx("code",{children:"workspace:"})," / ",r.jsx("code",{children:"workspaceGroup:"})," to ",r.jsx("code",{children:"null"})," on each, then remove the workspace."]})]}):null,r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:N,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),k?r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!0)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Clear references and delete"}):r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!1)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Delete"})]})]})})]})}function TD(){const e=Wn(),{workspace:t}=$t(),{title:n,breadcrumbs:s,projectSlug:a}=T0(e.pathname);return r.jsx(ED,{title:n,breadcrumbs:s,projectSlug:a,workspace:t??null,children:r.jsx(dT,{})})}function mt({label:e="Loading dashboard data…"}){return r.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:r.jsx("div",{className:"chrome-card !px-4 !py-3",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function wt({title:e="Something went wrong",error:t,action:n}){return r.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),n?r.jsx("div",{className:"pt-2",children:n}):null]})})}function qu({command:e,description:t,example:n}){return r.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[r.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?r.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function We({title:e,description:t,children:n,className:s,actions:a}){return r.jsxs("section",{className:Se("surface-panel space-y-3",s),children:[e||a?r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?r.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),a]}):null,n]})}function RD({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return r.jsx(We,{title:t?"Getting Started Refresher":"Getting Started",description:t?"A fast reminder of the real flow for creating and running work in Syntaur.":"A first-run checklist that maps to the current CLI and dashboard flow.",actions:r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:r.jsx("div",{className:"space-y-3",children:n.map((s,a)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:s.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s.detail}),s.command?r.jsx(qu,{command:s.command.command,example:s.command.example}):null]})]})},s.title))})})}const jm={review:"{total} items ready for your review","review.singular":"Review {title}",ready_to_implement:"{total} plans ready to implement — start with {title}","ready_to_implement.singular":"Start implementing {title}",ready_for_planning:"{total} assignments ready to plan — start with {title}","ready_for_planning.singular":"Plan {title}",in_progress:"Resume {title} ({total} in progress)","in_progress.singular":"Resume {title}",draft:"Shape your {total} drafts — start with {title}","draft.singular":"Shape {title}",blocked:"Unblock {title} ({total} blocked)","blocked.singular":"Unblock {title}",stale:"Triage {total} stale items","stale.singular":"Triage {title} — sitting stale",clean:"You’re all clear. Nothing needs you right now."},Ho={emptyStateCleanTitle:"You’re all clear",emptyStateCleanCTA:"Browse projects",recentSessionsEmptyTitle:"No recent sessions",recentSessionsEmptyHint:"Use /grab-assignment or `syntaur track-session` to register one.",recentSessionsCopyPathLabel:"Copy path",recentSessionsCopyPathDisabled:"Session has no path",recentSessionsCopyFallbackHint:"Press ⌘C to copy"};function PD(e,t){return e.replace(/\{(\w+)\}/g,(n,s)=>String(t[s]??`{${s}}`))}function AD({hero:e,itemsById:t}){const n=ln();if(e.kind==="clean")return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:Ho.emptyStateCleanTitle}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:jm.clean}),r.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"When work shows up — a draft, a review, a stale row — it’ll surface here."}),r.jsx("div",{className:"mt-4",children:r.jsx(Ee,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:Ho.emptyStateCleanCTA})})]});const s=e.itemId?t[e.itemId]:void 0,a=(s==null?void 0:s.assignmentTitle)??"",l=jm[e.copyKey]??jm[e.kind],c=PD(l,{total:e.total,title:a}),u=s?DD(s,n):`${n}/assignments`;return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:"What needs you today"}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:c}),s?r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",r.jsx("span",{className:"font-medium text-foreground",children:s.projectTitle??"Standalone"})," ","· status ",r.jsx("span",{className:"font-medium text-foreground",children:s.status})]}):null,r.jsx("div",{className:"mt-4",children:r.jsxs(Ee,{to:u,className:"shell-action shell-action--cta",children:["Open ",a||"assignment"]})})]})}function DD(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const Ag=["kanban","list","table"],n1=["title","status","priority","assignee","dependencies","created","updated"],$D=["asc","desc"],LD=["comfortable","compact"],OD=["none","status","type","priority","assignee","project"],ID=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function tt(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const s of t){if(typeof s!="string")continue;const a=s.trim();!a||a==="all"||n.includes(a)||n.push(a)}return n}function MD(e,t){const n=tt(e),s=tt(t);return n.length===s.length&&n.every(a=>s.includes(a))}const _D={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},Vl={version:1,global:_D,projects:{}};function km(e){return e==="table"?"table":"kanban"}function FD(e,t){return t?{...e,...t}:{...e}}function r1(e,t){const n=e.global;if(t===null)return n;const s=e.projects[t];return s?{defaultView:s.defaultView??n.defaultView,sortField:s.sortField??n.sortField,sortDirection:s.sortDirection??n.sortDirection,density:n.density,grouping:s.grouping??n.grouping,filters:FD(n.filters,s.filters)}:n}const Sm=["title","status","priority","assignee","dependencies","created","updated"],zD=["small","wide","tall","large"],BD={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},Bv="2026-05-21T00:00:00Z";function Nm(e,t,n){return{id:e,name:t,workspace:null,config:{viewMode:"list",filters:{...BD,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:Bv,updatedAt:Bv}}const ao={version:1,views:[Nm("default-recently-updated","Recently updated",{}),Nm("default-high-priority","High priority",{priority:"high"}),Nm("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function s1(e,t){const n=tt(e.filters.project),s=n.length===0||n.length===1&&n[0]===t,a=e.filters.activity,l=typeof e.filters.search=="string"&&e.filters.search.trim().length>0;return s&&(!a||a==="all")&&!l}function o1(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?s1(e.config,t.slug):!1}}const a1=`syntaur.savedViews.cache.v${ao.version}`;let oi=UD(),_o=null,Dg=null;const yh=new Set,cd=new Set;let i1=0;function l1(){return++i1}function bh(e){return e===i1}function UD(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(a1);if(!e)return null;const t=JSON.parse(e);return t.version!==ao.version?null:t}catch{return null}}function VD(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(a1,JSON.stringify(e))}catch{}}function c1(e){oi=e,Dg=null,VD(e);for(const t of yh)t(e);for(const t of cd)t(null)}function HD(e){Dg=e;for(const t of cd)t(e)}function u1(e){if(!e||typeof e!="object")return ao;const t=e;return t.version!==ao.version||!Array.isArray(t.views)||!t.dashboard?ao:t}function Uv(){if(_o)return _o;const e=l1();return _o=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=u1(t);return bh(e)&&c1(n),_o=null,oi??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return bh(e)&&HD(n),_o=null,oi??ao}),_o}function $g(){const[e,t]=f.useState(()=>oi??ao),[n,s]=f.useState(()=>oi===null),[a,l]=f.useState(!1),[c,u]=f.useState(()=>Dg);return f.useEffect(()=>{let m=!1;oi===null&&s(!0),Uv().then(y=>{m||(t(y),s(!1),l(!0))});const h=y=>{m||(t(y),s(!1),l(!0),u(null))},g=y=>{m||(u(y),s(!1),l(!0))};return yh.add(h),cd.add(g),()=>{m=!0,yh.delete(h),cd.delete(g)}},[]),{file:e,loading:n,ready:a,error:c,refetch:()=>{_o=null,s(!0),u(null),l(!1),Uv()}}}function Vd(){const{file:e,loading:t}=$g();return{views:e.views,loading:t}}function WD(){const{file:e,loading:t}=$g();return{layout:e.dashboard,loading:t}}function Go(e){const{file:t,loading:n,ready:s,error:a,refetch:l}=$g();return e?{view:t.views.find(u=>u.id===e)??null,loading:n,ready:s,error:a,refetch:l}:{view:null,loading:!1,ready:!0,error:null,refetch:l}}async function Hd(e,t,n){const s=l1(),a=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!a.ok){const c=await a.json().catch(()=>({error:`HTTP ${a.status}`}));throw new Error(c.error??`HTTP ${a.status}`)}const l=u1(await a.json());return bh(s)&&c1(l),l}function Wd(e){return Hd("POST","/api/saved-views",e)}function Lg(e,t){return Hd("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function KD(e){return Hd("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function qD(e){return Hd("PUT","/api/dashboard",{slots:e})}const GD=["top","right","bottom","left"],co=Math.min,hr=Math.max,ud=Math.round,Ru=Math.floor,fs=e=>({x:e,y:e}),YD={left:"right",right:"left",bottom:"top",top:"bottom"};function vh(e,t,n){return hr(e,co(t,n))}function Ds(e,t){return typeof e=="function"?e(t):e}function $s(e){return e.split("-")[0]}function wi(e){return e.split("-")[1]}function Og(e){return e==="x"?"y":"x"}function Ig(e){return e==="y"?"height":"width"}function cs(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Mg(e){return Og(cs(e))}function JD(e,t,n){n===void 0&&(n=!1);const s=wi(e),a=Mg(e),l=Ig(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=dd(c)),[c,dd(c)]}function XD(e){const t=dd(e);return[wh(e),t,wh(t)]}function wh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Vv=["left","right"],Hv=["right","left"],QD=["top","bottom"],ZD=["bottom","top"];function e4(e,t,n){switch(e){case"top":case"bottom":return n?t?Hv:Vv:t?Vv:Hv;case"left":case"right":return t?QD:ZD;default:return[]}}function t4(e,t,n,s){const a=wi(e);let l=e4($s(e),n==="start",s);return a&&(l=l.map(c=>c+"-"+a),t&&(l=l.concat(l.map(wh)))),l}function dd(e){const t=$s(e);return YD[t]+e.slice(t.length)}function n4(e){return{top:0,right:0,bottom:0,left:0,...e}}function d1(e){return typeof e!="number"?n4(e):{top:e,right:e,bottom:e,left:e}}function fd(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Wv(e,t,n){let{reference:s,floating:a}=e;const l=cs(t),c=Mg(t),u=Ig(c),p=$s(t),m=l==="y",h=s.x+s.width/2-a.width/2,g=s.y+s.height/2-a.height/2,y=s[u]/2-a[u]/2;let b;switch(p){case"top":b={x:h,y:s.y-a.height};break;case"bottom":b={x:h,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-a.width,y:g};break;default:b={x:s.x,y:s.y}}switch(wi(t)){case"start":b[c]-=y*(n&&m?-1:1);break;case"end":b[c]+=y*(n&&m?-1:1);break}return b}async function r4(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:l,rects:c,elements:u,strategy:p}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=Ds(t,e),E=d1(b),w=u[y?g==="floating"?"reference":"floating":g],k=fd(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(w)))==null||n?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:m,rootBoundary:h,strategy:p})),C=g==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),T=await(l.isElement==null?void 0:l.isElement(N))?await(l.getScale==null?void 0:l.getScale(N))||{x:1,y:1}:{x:1,y:1},D=fd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:C,offsetParent:N,strategy:p}):C);return{top:(k.top-D.top+E.top)/T.y,bottom:(D.bottom-k.bottom+E.bottom)/T.y,left:(k.left-D.left+E.left)/T.x,right:(D.right-k.right+E.right)/T.x}}const s4=50,o4=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:l=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:r4},p=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:h,y:g}=Wv(m,s,p),y=s,b=0;const E={};for(let j=0;j<l.length;j++){const w=l[j];if(!w)continue;const{name:k,fn:C}=w,{x:N,y:T,data:D,reset:R}=await C({x:h,y:g,initialPlacement:s,placement:y,strategy:a,middlewareData:E,rects:m,platform:u,elements:{reference:e,floating:t}});h=N??h,g=T??g,E[k]={...E[k],...D},R&&b<s4&&(b++,typeof R=="object"&&(R.placement&&(y=R.placement),R.rects&&(m=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):R.rects),{x:h,y:g}=Wv(m,y,p)),j=-1)}return{x:h,y:g,placement:y,strategy:a,middlewareData:E}},a4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:l,platform:c,elements:u,middlewareData:p}=t,{element:m,padding:h=0}=Ds(e,t)||{};if(m==null)return{};const g=d1(h),y={x:n,y:s},b=Mg(a),E=Ig(b),j=await c.getDimensions(m),w=b==="y",k=w?"top":"left",C=w?"bottom":"right",N=w?"clientHeight":"clientWidth",T=l.reference[E]+l.reference[b]-y[b]-l.floating[E],D=y[b]-l.reference[b],R=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let $=R?R[N]:0;(!$||!await(c.isElement==null?void 0:c.isElement(R)))&&($=u.floating[N]||l.floating[E]);const L=T/2-D/2,K=$/2-j[E]/2-1,B=co(g[k],K),O=co(g[C],K),W=B,se=$-j[E]-O,z=$/2-j[E]/2+L,H=vh(W,z,se),ee=!p.arrow&&wi(a)!=null&&z!==H&&l.reference[E]/2-(z<W?B:O)-j[E]/2<0,ne=ee?z<W?z-W:z-se:0;return{[b]:y[b]+ne,data:{[b]:H,centerOffset:z-H-ne,...ee&&{alignmentOffset:ne}},reset:ee}}}),i4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:l,rects:c,initialPlacement:u,platform:p,elements:m}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:j=!0,...w}=Ds(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const k=$s(a),C=cs(u),N=$s(u)===u,T=await(p.isRTL==null?void 0:p.isRTL(m.floating)),D=y||(N||!j?[dd(u)]:XD(u)),R=E!=="none";!y&&R&&D.push(...t4(u,j,E,T));const $=[u,...D],L=await p.detectOverflow(t,w),K=[];let B=((s=l.flip)==null?void 0:s.overflows)||[];if(h&&K.push(L[k]),g){const z=JD(a,c,T);K.push(L[z[0]],L[z[1]])}if(B=[...B,{placement:a,overflows:K}],!K.every(z=>z<=0)){var O,W;const z=(((O=l.flip)==null?void 0:O.index)||0)+1,H=$[z];if(H&&(!(g==="alignment"?C!==cs(H):!1)||B.every(M=>cs(M.placement)===C?M.overflows[0]>0:!0)))return{data:{index:z,overflows:B},reset:{placement:H}};let ee=(W=B.filter(ne=>ne.overflows[0]<=0).sort((ne,M)=>ne.overflows[1]-M.overflows[1])[0])==null?void 0:W.placement;if(!ee)switch(b){case"bestFit":{var se;const ne=(se=B.filter(M=>{if(R){const G=cs(M.placement);return G===C||G==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(G=>G>0).reduce((G,A)=>G+A,0)]).sort((M,G)=>M[1]-G[1])[0])==null?void 0:se[0];ne&&(ee=ne);break}case"initialPlacement":ee=u;break}if(a!==ee)return{reset:{placement:ee}}}return{}}}};function Kv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qv(e){return GD.some(t=>e[t]>=0)}const l4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...l}=Ds(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...l,elementContext:"reference"}),u=Kv(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:qv(u)}}}case"escaped":{const c=await s.detectOverflow(t,{...l,altBoundary:!0}),u=Kv(c,n.floating);return{data:{escapedOffsets:u,escaped:qv(u)}}}default:return{}}}}},f1=new Set(["left","top"]);async function c4(e,t){const{placement:n,platform:s,elements:a}=e,l=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=$s(n),u=wi(n),p=cs(n)==="y",m=f1.has(c)?-1:1,h=l&&p?-1:1,g=Ds(t,e);let{mainAxis:y,crossAxis:b,alignmentAxis:E}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof E=="number"&&(b=u==="end"?E*-1:E),p?{x:b*h,y:y*m}:{x:y*m,y:b*h}}const u4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:l,placement:c,middlewareData:u}=t,p=await c4(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:a+p.x,y:l+p.y,data:{...p,placement:c}}}}},d4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:p={fn:k=>{let{x:C,y:N}=k;return{x:C,y:N}}},...m}=Ds(e,t),h={x:n,y:s},g=await l.detectOverflow(t,m),y=cs($s(a)),b=Og(y);let E=h[b],j=h[y];if(c){const k=b==="y"?"top":"left",C=b==="y"?"bottom":"right",N=E+g[k],T=E-g[C];E=vh(N,E,T)}if(u){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",N=j+g[k],T=j-g[C];j=vh(N,j,T)}const w=p.fn({...t,[b]:E,[y]:j});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[b]:c,[y]:u}}}}}},f4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:m=!0}=Ds(e,t),h={x:n,y:s},g=cs(a),y=Og(g);let b=h[y],E=h[g];const j=Ds(u,t),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(p){const N=y==="y"?"height":"width",T=l.reference[y]-l.floating[N]+w.mainAxis,D=l.reference[y]+l.reference[N]-w.mainAxis;b<T?b=T:b>D&&(b=D)}if(m){var k,C;const N=y==="y"?"width":"height",T=f1.has($s(a)),D=l.reference[g]-l.floating[N]+(T&&((k=c.offset)==null?void 0:k[g])||0)+(T?0:w.crossAxis),R=l.reference[g]+l.reference[N]+(T?0:((C=c.offset)==null?void 0:C[g])||0)-(T?w.crossAxis:0);E<D?E=D:E>R&&(E=R)}return{[y]:b,[g]:E}}}},p4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:l,platform:c,elements:u}=t,{apply:p=()=>{},...m}=Ds(e,t),h=await c.detectOverflow(t,m),g=$s(a),y=wi(a),b=cs(a)==="y",{width:E,height:j}=l.floating;let w,k;g==="top"||g==="bottom"?(w=g,k=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=g,w=y==="end"?"top":"bottom");const C=j-h.top-h.bottom,N=E-h.left-h.right,T=co(j-h[w],C),D=co(E-h[k],N),R=!t.middlewareData.shift;let $=T,L=D;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&($=C),R&&!y){const B=hr(h.left,0),O=hr(h.right,0),W=hr(h.top,0),se=hr(h.bottom,0);b?L=E-2*(B!==0||O!==0?B+O:hr(h.left,h.right)):$=j-2*(W!==0||se!==0?W+se:hr(h.top,h.bottom))}await p({...t,availableWidth:L,availableHeight:$});const K=await c.getDimensions(u.floating);return E!==K.width||j!==K.height?{reset:{rects:!0}}:{}}}};function Kd(){return typeof window<"u"}function ji(e){return p1(e)?(e.nodeName||"").toLowerCase():"#document"}function yr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function xs(e){var t;return(t=(p1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function p1(e){return Kd()?e instanceof Node||e instanceof yr(e).Node:!1}function qr(e){return Kd()?e instanceof Element||e instanceof yr(e).Element:!1}function Is(e){return Kd()?e instanceof HTMLElement||e instanceof yr(e).HTMLElement:!1}function Gv(e){return!Kd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yr(e).ShadowRoot}function ic(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=Gr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function m4(e){return/^(table|td|th)$/.test(ji(e))}function qd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const h4=/transform|translate|scale|rotate|perspective|filter/,g4=/paint|layout|strict|content/,Io=e=>!!e&&e!=="none";let Cm;function _g(e){const t=qr(e)?Gr(e):e;return Io(t.transform)||Io(t.translate)||Io(t.scale)||Io(t.rotate)||Io(t.perspective)||!Fg()&&(Io(t.backdropFilter)||Io(t.filter))||h4.test(t.willChange||"")||g4.test(t.contain||"")}function x4(e){let t=uo(e);for(;Is(t)&&!fi(t);){if(_g(t))return t;if(qd(t))return null;t=uo(t)}return null}function Fg(){return Cm==null&&(Cm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cm}function fi(e){return/^(html|body|#document)$/.test(ji(e))}function Gr(e){return yr(e).getComputedStyle(e)}function Gd(e){return qr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function uo(e){if(ji(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gv(e)&&e.host||xs(e);return Gv(t)?t.host:t}function m1(e){const t=uo(e);return fi(t)?e.ownerDocument?e.ownerDocument.body:e.body:Is(t)&&ic(t)?t:m1(t)}function Hl(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=m1(e),l=a===((s=e.ownerDocument)==null?void 0:s.body),c=yr(a);if(l){const u=jh(c);return t.concat(c,c.visualViewport||[],ic(a)?a:[],u&&n?Hl(u):[])}else return t.concat(a,Hl(a,[],n))}function jh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function h1(e){const t=Gr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Is(e),l=a?e.offsetWidth:n,c=a?e.offsetHeight:s,u=ud(n)!==l||ud(s)!==c;return u&&(n=l,s=c),{width:n,height:s,$:u}}function zg(e){return qr(e)?e:e.contextElement}function ai(e){const t=zg(e);if(!Is(t))return fs(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:l}=h1(t);let c=(l?ud(n.width):n.width)/s,u=(l?ud(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const y4=fs(0);function g1(e){const t=yr(e);return!Fg()||!t.visualViewport?y4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function b4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yr(e)?!1:t}function Yo(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),l=zg(e);let c=fs(1);t&&(s?qr(s)&&(c=ai(s)):c=ai(e));const u=b4(l,n,s)?g1(l):fs(0);let p=(a.left+u.x)/c.x,m=(a.top+u.y)/c.y,h=a.width/c.x,g=a.height/c.y;if(l){const y=yr(l),b=s&&qr(s)?yr(s):s;let E=y,j=jh(E);for(;j&&s&&b!==E;){const w=ai(j),k=j.getBoundingClientRect(),C=Gr(j),N=k.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,T=k.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;p*=w.x,m*=w.y,h*=w.x,g*=w.y,p+=N,m+=T,E=yr(j),j=jh(E)}}return fd({width:h,height:g,x:p,y:m})}function Yd(e,t){const n=Gd(e).scrollLeft;return t?t.left+n:Yo(xs(e)).left+n}function x1(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Yd(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function v4(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const l=a==="fixed",c=xs(s),u=t?qd(t.floating):!1;if(s===c||u&&l)return n;let p={scrollLeft:0,scrollTop:0},m=fs(1);const h=fs(0),g=Is(s);if((g||!g&&!l)&&((ji(s)!=="body"||ic(c))&&(p=Gd(s)),g)){const b=Yo(s);m=ai(s),h.x=b.x+s.clientLeft,h.y=b.y+s.clientTop}const y=c&&!g&&!l?x1(c,p):fs(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-p.scrollLeft*m.x+h.x+y.x,y:n.y*m.y-p.scrollTop*m.y+h.y+y.y}}function w4(e){return Array.from(e.getClientRects())}function j4(e){const t=xs(e),n=Gd(e),s=e.ownerDocument.body,a=hr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=hr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Yd(e);const u=-n.scrollTop;return Gr(s).direction==="rtl"&&(c+=hr(t.clientWidth,s.clientWidth)-a),{width:a,height:l,x:c,y:u}}const Yv=25;function k4(e,t){const n=yr(e),s=xs(e),a=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,p=0;if(a){l=a.width,c=a.height;const h=Fg();(!h||h&&t==="fixed")&&(u=a.offsetLeft,p=a.offsetTop)}const m=Yd(s);if(m<=0){const h=s.ownerDocument,g=h.body,y=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,E=Math.abs(s.clientWidth-g.clientWidth-b);E<=Yv&&(l-=E)}else m<=Yv&&(l+=m);return{width:l,height:c,x:u,y:p}}function S4(e,t){const n=Yo(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,l=Is(e)?ai(e):fs(1),c=e.clientWidth*l.x,u=e.clientHeight*l.y,p=a*l.x,m=s*l.y;return{width:c,height:u,x:p,y:m}}function Jv(e,t,n){let s;if(t==="viewport")s=k4(e,n);else if(t==="document")s=j4(xs(e));else if(qr(t))s=S4(t,n);else{const a=g1(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return fd(s)}function y1(e,t){const n=uo(e);return n===t||!qr(n)||fi(n)?!1:Gr(n).position==="fixed"||y1(n,t)}function N4(e,t){const n=t.get(e);if(n)return n;let s=Hl(e,[],!1).filter(u=>qr(u)&&ji(u)!=="body"),a=null;const l=Gr(e).position==="fixed";let c=l?uo(e):e;for(;qr(c)&&!fi(c);){const u=Gr(c),p=_g(c);!p&&u.position==="fixed"&&(a=null),(l?!p&&!a:!p&&u.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||ic(c)&&!p&&y1(e,c))?s=s.filter(h=>h!==c):a=u,c=uo(c)}return t.set(e,s),s}function C4(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?qd(t)?[]:N4(t,this._c):[].concat(n),s],u=Jv(t,c[0],a);let p=u.top,m=u.right,h=u.bottom,g=u.left;for(let y=1;y<c.length;y++){const b=Jv(t,c[y],a);p=hr(b.top,p),m=co(b.right,m),h=co(b.bottom,h),g=hr(b.left,g)}return{width:m-g,height:h-p,x:g,y:p}}function E4(e){const{width:t,height:n}=h1(e);return{width:t,height:n}}function T4(e,t,n){const s=Is(t),a=xs(t),l=n==="fixed",c=Yo(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const p=fs(0);function m(){p.x=Yd(a)}if(s||!s&&!l)if((ji(t)!=="body"||ic(a))&&(u=Gd(t)),s){const b=Yo(t,!0,l,t);p.x=b.x+t.clientLeft,p.y=b.y+t.clientTop}else a&&m();l&&!s&&a&&m();const h=a&&!s&&!l?x1(a,u):fs(0),g=c.left+u.scrollLeft-p.x-h.x,y=c.top+u.scrollTop-p.y-h.y;return{x:g,y,width:c.width,height:c.height}}function Em(e){return Gr(e).position==="static"}function Xv(e,t){if(!Is(e)||Gr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return xs(e)===n&&(n=n.ownerDocument.body),n}function b1(e,t){const n=yr(e);if(qd(e))return n;if(!Is(e)){let a=uo(e);for(;a&&!fi(a);){if(qr(a)&&!Em(a))return a;a=uo(a)}return n}let s=Xv(e,t);for(;s&&m4(s)&&Em(s);)s=Xv(s,t);return s&&fi(s)&&Em(s)&&!_g(s)?n:s||x4(e)||n}const R4=async function(e){const t=this.getOffsetParent||b1,n=this.getDimensions,s=await n(e.floating);return{reference:T4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function P4(e){return Gr(e).direction==="rtl"}const A4={convertOffsetParentRelativeRectToViewportRelativeRect:v4,getDocumentElement:xs,getClippingRect:C4,getOffsetParent:b1,getElementRects:R4,getClientRects:w4,getDimensions:E4,getScale:ai,isElement:qr,isRTL:P4};function v1(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function D4(e,t){let n=null,s;const a=xs(e);function l(){var u;clearTimeout(s),(u=n)==null||u.disconnect(),n=null}function c(u,p){u===void 0&&(u=!1),p===void 0&&(p=1),l();const m=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=m;if(u||t(),!y||!b)return;const E=Ru(g),j=Ru(a.clientWidth-(h+y)),w=Ru(a.clientHeight-(g+b)),k=Ru(h),N={rootMargin:-E+"px "+-j+"px "+-w+"px "+-k+"px",threshold:hr(0,co(1,p))||1};let T=!0;function D(R){const $=R[0].intersectionRatio;if($!==p){if(!T)return c();$?c(!1,$):s=setTimeout(()=>{c(!1,1e-7)},1e3)}$===1&&!v1(m,e.getBoundingClientRect())&&c(),T=!1}try{n=new IntersectionObserver(D,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(D,N)}n.observe(e)}return c(!0),l}function $4(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:p=!1}=s,m=zg(e),h=a||l?[...m?Hl(m):[],...t?Hl(t):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),l&&k.addEventListener("resize",n)});const g=m&&u?D4(m,n):null;let y=-1,b=null;c&&(b=new ResizeObserver(k=>{let[C]=k;C&&C.target===m&&b&&t&&(b.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var N;(N=b)==null||N.observe(t)})),n()}),m&&!p&&b.observe(m),t&&b.observe(t));let E,j=p?Yo(e):null;p&&w();function w(){const k=Yo(e);j&&!v1(j,k)&&n(),j=k,E=requestAnimationFrame(w)}return n(),()=>{var k;h.forEach(C=>{a&&C.removeEventListener("scroll",n),l&&C.removeEventListener("resize",n)}),g==null||g(),(k=b)==null||k.disconnect(),b=null,p&&cancelAnimationFrame(E)}}const L4=u4,O4=d4,I4=i4,M4=p4,_4=l4,Qv=a4,F4=f4,z4=(e,t,n)=>{const s=new Map,a={platform:A4,...n},l={...a.platform,_c:s};return o4(e,t,{...a,platform:l})};var B4=typeof document<"u",U4=function(){},Gu=B4?f.useLayoutEffect:U4;function pd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!pd(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const l=a[s];if(!(l==="_owner"&&e.$$typeof)&&!pd(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function w1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Zv(e,t){const n=w1(e);return Math.round(t*n)/n}function Tm(e){const t=f.useRef(e);return Gu(()=>{t.current=e}),t}function V4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:p,open:m}=e,[h,g]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,b]=f.useState(s);pd(y,s)||b(s);const[E,j]=f.useState(null),[w,k]=f.useState(null),C=f.useCallback(M=>{M!==R.current&&(R.current=M,j(M))},[]),N=f.useCallback(M=>{M!==$.current&&($.current=M,k(M))},[]),T=l||E,D=c||w,R=f.useRef(null),$=f.useRef(null),L=f.useRef(h),K=p!=null,B=Tm(p),O=Tm(a),W=Tm(m),se=f.useCallback(()=>{if(!R.current||!$.current)return;const M={placement:t,strategy:n,middleware:y};O.current&&(M.platform=O.current),z4(R.current,$.current,M).then(G=>{const A={...G,isPositioned:W.current!==!1};z.current&&!pd(L.current,A)&&(L.current=A,Rs.flushSync(()=>{g(A)}))})},[y,t,n,O,W]);Gu(()=>{m===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,g(M=>({...M,isPositioned:!1})))},[m]);const z=f.useRef(!1);Gu(()=>(z.current=!0,()=>{z.current=!1}),[]),Gu(()=>{if(T&&(R.current=T),D&&($.current=D),T&&D){if(B.current)return B.current(T,D,se);se()}},[T,D,se,B,K]);const H=f.useMemo(()=>({reference:R,floating:$,setReference:C,setFloating:N}),[C,N]),ee=f.useMemo(()=>({reference:T,floating:D}),[T,D]),ne=f.useMemo(()=>{const M={position:n,left:0,top:0};if(!ee.floating)return M;const G=Zv(ee.floating,h.x),A=Zv(ee.floating,h.y);return u?{...M,transform:"translate("+G+"px, "+A+"px)",...w1(ee.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:A}},[n,u,ee.floating,h.x,h.y]);return f.useMemo(()=>({...h,update:se,refs:H,elements:ee,floatingStyles:ne}),[h,se,H,ee,ne])}const H4=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Qv({element:s.current,padding:a}).fn(n):{}:s?Qv({element:s,padding:a}).fn(n):{}}}},W4=(e,t)=>{const n=L4(e);return{name:n.name,fn:n.fn,options:[e,t]}},K4=(e,t)=>{const n=O4(e);return{name:n.name,fn:n.fn,options:[e,t]}},q4=(e,t)=>({fn:F4(e).fn,options:[e,t]}),G4=(e,t)=>{const n=I4(e);return{name:n.name,fn:n.fn,options:[e,t]}},Y4=(e,t)=>{const n=M4(e);return{name:n.name,fn:n.fn,options:[e,t]}},J4=(e,t)=>{const n=_4(e);return{name:n.name,fn:n.fn,options:[e,t]}},X4=(e,t)=>{const n=H4(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Q4="Arrow",j1=f.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...l}=e;return r.jsx(mn.svg,{...l,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});j1.displayName=Q4;var Z4=j1;function e$(e){const[t,n]=f.useState(void 0);return lo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const l=a[0];let c,u;if("borderBoxSize"in l){const p=l.borderBoxSize,m=Array.isArray(p)?p[0]:p;c=m.inlineSize,u=m.blockSize}else c=e.offsetWidth,u=e.offsetHeight;n({width:c,height:u})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Bg="Popper",[k1,S1]=Xo(Bg),[t$,N1]=k1(Bg),C1=e=>{const{__scopePopper:t,children:n}=e,[s,a]=f.useState(null);return r.jsx(t$,{scope:t,anchor:s,onAnchorChange:a,children:n})};C1.displayName=Bg;var E1="PopperAnchor",T1=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,l=N1(E1,n),c=f.useRef(null),u=Fn(t,c),p=f.useRef(null);return f.useEffect(()=>{const m=p.current;p.current=(s==null?void 0:s.current)||c.current,m!==p.current&&l.onAnchorChange(p.current)}),s?null:r.jsx(mn.div,{...a,ref:u})});T1.displayName=E1;var Ug="PopperContent",[n$,r$]=k1(Ug),R1=f.forwardRef((e,t)=>{var ae,me,ve,ke,he,Je;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:y=!1,updatePositionStrategy:b="optimized",onPlaced:E,...j}=e,w=N1(Ug,n),[k,C]=f.useState(null),N=Fn(t,Ye=>C(Ye)),[T,D]=f.useState(null),R=e$(T),$=(R==null?void 0:R.width)??0,L=(R==null?void 0:R.height)??0,K=s+(l!=="center"?"-"+l:""),B=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},O=Array.isArray(m)?m:[m],W=O.length>0,se={padding:B,boundary:O.filter(o$),altBoundary:W},{refs:z,floatingStyles:H,placement:ee,isPositioned:ne,middlewareData:M}=V4({strategy:"fixed",placement:K,whileElementsMounted:(...Ye)=>$4(...Ye,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[W4({mainAxis:a+L,alignmentAxis:c}),p&&K4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?q4():void 0,...se}),p&&G4({...se}),Y4({...se,apply:({elements:Ye,rects:ot,availableWidth:J,availableHeight:Ie})=>{const{width:Ne,height:Oe}=ot.reference,Xe=Ye.floating.style;Xe.setProperty("--radix-popper-available-width",`${J}px`),Xe.setProperty("--radix-popper-available-height",`${Ie}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ne}px`),Xe.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),T&&X4({element:T,padding:u}),a$({arrowWidth:$,arrowHeight:L}),y&&J4({strategy:"referenceHidden",...se})]}),[G,A]=D1(ee),F=Ko(E);lo(()=>{ne&&(F==null||F())},[ne,F]);const Z=(ae=M.arrow)==null?void 0:ae.x,I=(me=M.arrow)==null?void 0:me.y,de=((ve=M.arrow)==null?void 0:ve.centerOffset)!==0,[ge,V]=f.useState();return lo(()=>{k&&V(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:ne?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(ke=M.transformOrigin)==null?void 0:ke.x,(he=M.transformOrigin)==null?void 0:he.y].join(" "),...((Je=M.hide)==null?void 0:Je.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(n$,{scope:n,placedSide:G,onArrowChange:D,arrowX:Z,arrowY:I,shouldHideArrow:de,children:r.jsx(mn.div,{"data-side":G,"data-align":A,...j,ref:N,style:{...j.style,animation:ne?void 0:"none"}})})})});R1.displayName=Ug;var P1="PopperArrow",s$={top:"bottom",right:"left",bottom:"top",left:"right"},A1=f.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,l=r$(P1,s),c=s$[l.placedSide];return r.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:r.jsx(Z4,{...a,ref:n,style:{...a.style,display:"block"}})})});A1.displayName=P1;function o$(e){return e!==null}var a$=e=>({name:"transformOrigin",options:e,fn(t){var w,k,C;const{placement:n,rects:s,middlewareData:a}=t,c=((w=a.arrow)==null?void 0:w.centerOffset)!==0,u=c?0:e.arrowWidth,p=c?0:e.arrowHeight,[m,h]=D1(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(((k=a.arrow)==null?void 0:k.x)??0)+u/2,b=(((C=a.arrow)==null?void 0:C.y)??0)+p/2;let E="",j="";return m==="bottom"?(E=c?g:`${y}px`,j=`${-p}px`):m==="top"?(E=c?g:`${y}px`,j=`${s.floating.height+p}px`):m==="right"?(E=`${-p}px`,j=c?g:`${b}px`):m==="left"&&(E=`${s.floating.width+p}px`,j=c?g:`${b}px`),{data:{x:E,y:j}}}});function D1(e){const[t,n="center"]=e.split("-");return[t,n]}var i$=C1,l$=T1,c$=R1,u$=A1,d$=Symbol("radix.slottable");function f$(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=d$,t}var p$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),m$="VisuallyHidden",$1=f.forwardRef((e,t)=>r.jsx(mn.span,{...e,ref:t,style:{...p$,...e.style}}));$1.displayName=m$;var h$=$1,[Jd]=Xo("Tooltip",[S1]),Xd=S1(),L1="TooltipProvider",g$=700,kh="tooltip.open",[x$,Vg]=Jd(L1),O1=e=>{const{__scopeTooltip:t,delayDuration:n=g$,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:l}=e,c=f.useRef(!0),u=f.useRef(!1),p=f.useRef(0);return f.useEffect(()=>{const m=p.current;return()=>window.clearTimeout(m)},[]),r.jsx(x$,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(p.current),c.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:u,onPointerInTransitChange:f.useCallback(m=>{u.current=m},[]),disableHoverableContent:a,children:l})};O1.displayName=L1;var Wl="Tooltip",[y$,lc]=Jd(Wl),I1=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:a,onOpenChange:l,disableHoverableContent:c,delayDuration:u}=e,p=Vg(Wl,e.__scopeTooltip),m=Xd(t),[h,g]=f.useState(null),y=ni(),b=f.useRef(0),E=c??p.disableHoverableContent,j=u??p.delayDuration,w=f.useRef(!1),[k,C]=zd({prop:s,defaultProp:a??!1,onChange:$=>{$?(p.onOpen(),document.dispatchEvent(new CustomEvent(kh))):p.onClose(),l==null||l($)},caller:Wl}),N=f.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),T=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,C(!0)},[C]),D=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C(!1)},[C]),R=f.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,C(!0),b.current=0},j)},[j,C]);return f.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),r.jsx(i$,{...m,children:r.jsx(y$,{scope:t,contentId:y,open:k,stateAttribute:N,trigger:h,onTriggerChange:g,onTriggerEnter:f.useCallback(()=>{p.isOpenDelayedRef.current?R():T()},[p.isOpenDelayedRef,R,T]),onTriggerLeave:f.useCallback(()=>{E?D():(window.clearTimeout(b.current),b.current=0)},[D,E]),onOpen:T,onClose:D,disableHoverableContent:E,children:n})})};I1.displayName=Wl;var Sh="TooltipTrigger",M1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=lc(Sh,n),l=Vg(Sh,n),c=Xd(n),u=f.useRef(null),p=Fn(t,u,a.onTriggerChange),m=f.useRef(!1),h=f.useRef(!1),g=f.useCallback(()=>m.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(l$,{asChild:!0,...c,children:r.jsx(mn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:p,onPointerMove:qt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),h.current=!0)}),onPointerLeave:qt(e.onPointerLeave,()=>{a.onTriggerLeave(),h.current=!1}),onPointerDown:qt(e.onPointerDown,()=>{a.open&&a.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:qt(e.onFocus,()=>{m.current||a.onOpen()}),onBlur:qt(e.onBlur,a.onClose),onClick:qt(e.onClick,a.onClose)})})});M1.displayName=Sh;var Hg="TooltipPortal",[b$,v$]=Jd(Hg,{forceMount:void 0}),_1=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:a}=e,l=lc(Hg,t);return r.jsx(b$,{scope:t,forceMount:n,children:r.jsx(Qo,{present:n||l.open,children:r.jsx(xg,{asChild:!0,container:a,children:s})})})};_1.displayName=Hg;var pi="TooltipContent",F1=f.forwardRef((e,t)=>{const n=v$(pi,e.__scopeTooltip),{forceMount:s=n.forceMount,side:a="top",...l}=e,c=lc(pi,e.__scopeTooltip);return r.jsx(Qo,{present:s||c.open,children:c.disableHoverableContent?r.jsx(z1,{side:a,...l,ref:t}):r.jsx(w$,{side:a,...l,ref:t})})}),w$=f.forwardRef((e,t)=>{const n=lc(pi,e.__scopeTooltip),s=Vg(pi,e.__scopeTooltip),a=f.useRef(null),l=Fn(t,a),[c,u]=f.useState(null),{trigger:p,onClose:m}=n,h=a.current,{onPointerInTransitChange:g}=s,y=f.useCallback(()=>{u(null),g(!1)},[g]),b=f.useCallback((E,j)=>{const w=E.currentTarget,k={x:E.clientX,y:E.clientY},C=C$(k,w.getBoundingClientRect()),N=E$(k,C),T=T$(j.getBoundingClientRect()),D=P$([...N,...T]);u(D),g(!0)},[g]);return f.useEffect(()=>()=>y(),[y]),f.useEffect(()=>{if(p&&h){const E=w=>b(w,h),j=w=>b(w,p);return p.addEventListener("pointerleave",E),h.addEventListener("pointerleave",j),()=>{p.removeEventListener("pointerleave",E),h.removeEventListener("pointerleave",j)}}},[p,h,b,y]),f.useEffect(()=>{if(c){const E=j=>{const w=j.target,k={x:j.clientX,y:j.clientY},C=(p==null?void 0:p.contains(w))||(h==null?void 0:h.contains(w)),N=!R$(k,c);C?y():N&&(y(),m())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[p,h,c,m,y]),r.jsx(z1,{...e,ref:l})}),[j$,k$]=Jd(Wl,{isInside:!1}),S$=f$("TooltipContent"),z1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=e,p=lc(pi,n),m=Xd(n),{onClose:h}=p;return f.useEffect(()=>(document.addEventListener(kh,h),()=>document.removeEventListener(kh,h)),[h]),f.useEffect(()=>{if(p.trigger){const g=y=>{const b=y.target;b!=null&&b.contains(p.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[p.trigger,h]),r.jsx(gg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:r.jsxs(c$,{"data-state":p.stateAttribute,...m,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(S$,{children:s}),r.jsx(j$,{scope:n,isInside:!0,children:r.jsx(h$,{id:p.contentId,role:"tooltip",children:a||s})})]})})});F1.displayName=pi;var B1="TooltipArrow",N$=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=Xd(n);return k$(B1,n).isInside?null:r.jsx(u$,{...a,...s,ref:t})});N$.displayName=B1;function C$(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,s,a,l)){case l:return"left";case a:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function E$(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function T$(e){const{top:t,right:n,bottom:s,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:s},{x:a,y:s}]}function R$(e,t){const{x:n,y:s}=e;let a=!1;for(let l=0,c=t.length-1;l<t.length;c=l++){const u=t[l],p=t[c],m=u.x,h=u.y,g=p.x,y=p.y;h>s!=y>s&&n<(g-m)*(s-h)/(y-h)+m&&(a=!a)}return a}function P$(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),A$(t)}function A$(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const a=e[s];for(;t.length>=2;){const l=t[t.length-1],c=t[t.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var D$=O1,$$=I1,L$=M1,O$=_1,U1=F1;const Wo=D$,Pr=$$,Ar=L$,gr=f.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(O$,{children:r.jsx(U1,{ref:s,sideOffset:t,className:Se("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gr.displayName=U1.displayName;function Wg({items:e,align:t="end"}){const[n,s]=f.useState(!1),[a,l]=f.useState(null),c=f.useRef(null);if(f.useEffect(()=>{if(!n){l(null);return}function p(h){c.current&&!c.current.contains(h.target)&&s(!1)}function m(h){h.key==="Escape"&&s(!1)}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[n]),e.length===0)return null;function u(p,m){const h=p.icon,g=Se("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",m&&"pl-8",p.disabled?"opacity-50 cursor-not-allowed":p.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),y=m?p.active?r.jsx(Xr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):r.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):h?r.jsx(h,{className:"h-4 w-4 shrink-0"}):null,b=r.jsxs(r.Fragment,{children:[y,r.jsx("span",{className:"block min-w-0 truncate",children:p.label})]});if(p.disabled){const E=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:g,children:b})});return p.disabledReason?r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:E}),r.jsx(gr,{side:"left",children:p.disabledReason})]},p.key):r.jsx("div",{children:E},p.key)}return p.href?r.jsx(Ee,{to:p.href,className:g,onClick:()=>s(!1),children:b},p.key):r.jsx("button",{type:"button",className:g,onClick:()=>{var E;(E=p.onSelect)==null||E.call(p),s(!1)},children:b},p.key)}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsx("button",{type:"button",onClick:()=>s(p=>!p),className:"shell-action",title:"More actions","aria-haspopup":"true","aria-expanded":n,children:r.jsx(lR,{className:"h-4 w-4"})}),n&&r.jsx("div",{className:Se("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:r.jsx(Wo,{delayDuration:200,children:e.map(p=>{if(p.submenu&&p.submenu.length>0){const m=p.icon,h=a===p.key;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",className:Se("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":h,onClick:()=>l(h?null:p.key),children:[m?r.jsx(m,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 flex-1 truncate",children:p.label}),h?r.jsx(br,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(l0,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),h?p.submenu.map(g=>u(g,!0)):null]},p.key)}return u(p,!1)})})})]})}function ew(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const I$={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function M$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,0,0,0,0).getTime()}function _$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,23,59,59,999).getTime()}function F$(e,t,n=Date.now()){if(!t)return!0;const s=t.field==="created"?e.created??e.updated:e.updated,a=Date.parse(s);if(Number.isNaN(a))return!1;if(t.preset){const u=I$[t.preset];return u===void 0?!0:t.preset.startsWith("older_")?n-a>u:a>=n-u&&a<=n}const l=t.from&&t.from.length>0?t.from:void 0,c=t.to&&t.to.length>0?t.to:void 0;return!l&&!c?!0:!(l&&a<M$(l)||c&&a>_$(c))}function Kg(e,t,n={}){const{workspace:s,search:a,includeArchived:l}=n;if(e.archived===!0&&!l)return!1;const c=tt(t.status),u=tt(t.priority),p=tt(t.type),m=tt(t.assignee),h=tt(t.project),g=tt(t.tags),{activity:y}=t;if(s){if(s==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==s)return!1}if(c.length&&!c.includes(e.status)||u.length&&!u.includes(e.priority)||p.length&&!p.includes(e.type??"")||y==="stale"&&!ew(e.updated)||y==="fresh"&&ew(e.updated))return!1;if(m.length){const b=e.assignee??"__unassigned__";if(!m.includes(b))return!1}if(h.length&&!h.some(E=>E==="__standalone__"?e.projectSlug==null:e.projectSlug===E))return!1;if(g.length){const b=e.tags??[];if(!g.some(E=>b.includes(E)))return!1}if(!F$(e,t.dateRange))return!1;if(a){const b=a.trim().toLowerCase();if(b&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(b))return!1}return!0}function Kl(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const V1={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],custom:!1};let Pl=null,Fo=null;function z$(){return Pl?Promise.resolve(Pl):Fo||(Fo=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Pl=e,Fo=null,e)).catch(()=>(Fo=null,V1)),Fo)}function Zo(){const[e,t]=f.useState(()=>Pl??V1);return f.useEffect(()=>{z$().then(t)},[]),e}function tw(){Pl=null,Fo=null}function cc(e,t){const n=e.statuses.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const nw={critical:0,high:1,medium:2,low:3};function Pu(e){return Date.parse(e??"")||0}function uc(e,t,n){return[...e].sort((a,l)=>{let c=0;switch(t){case"title":c=a.title.localeCompare(l.title);break;case"status":c=a.status.localeCompare(l.status);break;case"priority":c=(nw[a.priority]??99)-(nw[l.priority]??99);break;case"assignee":c=(a.assignee??"").localeCompare(l.assignee??"");break;case"dependencies":c=a.dependsOn.length-l.dependsOn.length;break;case"created":c=Pu(a.created)-Pu(l.created);break;case"updated":c=Pu(a.updated)-Pu(l.updated);break}return n==="asc"?c:-c})}function St({title:e,description:t,actions:n}){return r.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:r.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?r.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const mi='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Qd({columns:e,items:t,getItemId:n,getColumnId:s,renderCard:a,canDrop:l,onMove:c,getExternalDragData:u,onCardContextMenu:p,emptyMessage:m="No cards in this column.",hiddenColumnIds:h,onHideColumn:g,compact:y=!1,dragDisabled:b=!1}){const E=f.useMemo(()=>new Set(h??[]),[h]),j=f.useMemo(()=>e.filter(z=>!E.has(z.id)),[e,E]),w=f.useMemo(()=>e.filter(z=>E.has(z.id)),[e,E]),[k,C]=f.useState(null),[N,T]=f.useState(null),D=f.useRef(null),R=f.useMemo(()=>new Map(t.map(z=>[n(z),z])),[n,t]),$=f.useMemo(()=>j.map(z=>({column:z,items:t.filter(H=>s(H)===z.id)})),[j,s,t]),L=k?R.get(k)??null:null;function K(z){if(!L)return{allowed:!1};const H=s(L);return(l==null?void 0:l({item:L,fromColumnId:H,toColumnId:z}))??{allowed:!0}}function B(){C(null),T(null)}function O(z,H,ee){if(b)return;const ne=(u==null?void 0:u(H))??null;!c&&!ne||(z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",ee),ne&&z.dataTransfer.setData("application/json",JSON.stringify(ne)),c&&C(ee))}function W(z,H,ee){b||!c||!L||!K(H).allowed||(z.preventDefault(),z.dataTransfer.dropEffect="move",T(M=>(M==null?void 0:M.columnId)===H&&M.index===ee?M:{columnId:H,index:ee}))}async function se(z,H,ee){var F;if(z.preventDefault(),b||!c||!L){B();return}const ne=s(L),G=(((F=$.find(Z=>Z.column.id===ne))==null?void 0:F.items)??[]).findIndex(Z=>n(Z)===n(L));if(!K(H).allowed||G<0){B();return}if(ne===H&&(ee===G||ee===G+1)){B();return}try{await c({item:L,fromColumnId:ne,toColumnId:H,fromIndex:G,toIndex:ee})}finally{B()}}return r.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[w.length>0&&g?r.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Hidden:"}),w.map(z=>r.jsxs("button",{type:"button",onClick:()=>g(z.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${z.title}" column`,children:[z.title," ×"]},z.id))]}):null,r.jsx("div",{className:Se("grid min-w-max grid-flow-col gap-4",y?"auto-cols-[minmax(200px,240px)]":"auto-cols-[minmax(260px,320px)]"),children:$.map(({column:z,items:H})=>{const ee=K(z.id),ne=(N==null?void 0:N.columnId)===z.id;return r.jsxs("section",{className:Se("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",y?"min-h-[200px] p-2":"min-h-[320px] p-3",L&&!ee.allowed?"border-dashed opacity-65":"",L&&ee.allowed?"border-primary/30 bg-accent/30":"",ne?"ring-2 ring-ring/30":""),title:L&&!ee.allowed?ee.reason:void 0,children:[r.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:Se("font-semibold uppercase tracking-[0.16em] text-muted-foreground",y?"text-xs":"text-sm"),children:z.title}),z.description&&!y?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:z.description}):null]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:H.length}),g?r.jsx("button",{type:"button",onClick:()=>g(z.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${z.title}" column`,"aria-label":`Hide column ${z.title}`,children:"×"}):null]})]}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:M=>W(M,z.id,H.length),onDrop:M=>se(M,z.id,H.length),children:[H.length===0?b?r.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof m=="function"?m(z):m}):r.jsx(B$,{active:(N==null?void 0:N.columnId)===z.id&&N.index===0,disabled:!!L&&!ee.allowed,children:typeof m=="function"?m(z):m}):null,H.map((M,G)=>{const A=n(M),F=k===A;return r.jsxs(f.Fragment,{children:[r.jsx("div",{className:Se("h-2 rounded-full transition",(N==null?void 0:N.columnId)===z.id&&N.index===G?"bg-primary/70":"bg-transparent"),onDragOver:Z=>W(Z,z.id,G),onDrop:Z=>se(Z,z.id,G)}),r.jsx("div",{draggable:!b&&!!(c||u),onMouseDown:Z=>{D.current=Z.target},onDragStart:Z=>{const I=D.current;if(I!=null&&I.closest(mi)){Z.preventDefault();return}O(Z,M,A)},onDragEnd:B,onContextMenu:Z=>{if(!p)return;const I=Z.target;I!=null&&I.closest(mi)||p(M,Z)},className:Se("transition",!b&&(c||u)?"cursor-grab active:cursor-grabbing":"",F?"scale-[0.98] opacity-50":""),children:a(M,{dragging:F})})]},A)}),H.length>0&&!b?r.jsx("div",{className:Se("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(N==null?void 0:N.columnId)===z.id&&N.index===H.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",L&&!ee.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},z.id)})})]})}function B$({active:e,disabled:t,children:n}){return r.jsx("div",{className:Se("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const El="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Rm="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",U$="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",V$="border-status-review-foreground/30 bg-status-review text-status-review-foreground",H$="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",W$="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",K$="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",md={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:El,icon:bi},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:El,icon:rR},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:El,icon:u0},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Rm,icon:wR},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Rm,icon:rg},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:U$,icon:lh},review:{label:"Review",description:"Ready for inspection or approval.",className:V$,icon:SR},completed:{label:"Completed",description:"Finished successfully.",className:H$,icon:Zh},failed:{label:"Failed",description:"Could not be completed as planned.",className:W$,icon:lh},active:{label:"Active",description:"The project has active or review work in flight.",className:Rm,icon:ch},stopped:{label:"Stopped",description:"Session ended without completing.",className:El,icon:tR},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:K$,icon:ch}};function hd(e){const t=md[e];return t||{className:El,icon:ch,label:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),description:`Status: ${e}`}}function H1(e,t){return Se("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal","shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]",hd(e).className,t)}function pn({status:e,className:t,showIcon:n=!0,progress:s}){const a=hd(e),l=a.icon,c=s&&s.total>0,u=c?Math.min(1,Math.max(0,s.checked/s.total)):0,p=c?`${a.description} (${s.checked}/${s.total} criteria)`:a.description,m=n?c?r.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 items-center justify-center",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-u)})]}),r.jsx(l,{className:"h-2.5 w-2.5"})]}):r.jsx(l,{className:"h-3.5 w-3.5"}):null;return r.jsxs("span",{title:p,className:H1(e,t),children:[m,r.jsx("span",{children:a.label})]})}function Zd(e){var t;return((t=md[e])==null?void 0:t.description)??`Status: ${e}`}const W1={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Yu=null,za=null;function q$(){return Yu?Promise.resolve(Yu):za||(za=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Yu=e,za=null,e)).catch(()=>(za=null,W1)),za)}function ef(){const[e,t]=f.useState(()=>Yu??W1);return f.useEffect(()=>{q$().then(t)},[]),e}function ii(e,t){if(!t)return"—";const n=e.definitions.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function G$(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}function ea({type:e,className:t,compact:n=!1}){const s=ef();if(!e)return null;const a=G$(s,e),l=(a==null?void 0:a.label)??e.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),c=a!=null&&a.color?{backgroundColor:`color-mix(in oklch, ${a.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${a.color} 50%, transparent)`,color:a.color}:void 0;return r.jsx("span",{title:(a==null?void 0:a.description)??`Type: ${l}`,style:c,className:Se("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!c&&"border-border/60 text-muted-foreground",t),children:l})}function $r({value:e,label:t,disabled:n=!1,disabledReason:s,onError:a}){const[l,c]=f.useState(!1);async function u(){if(!n)try{if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500)}catch(p){a==null||a(p instanceof Error?p:new Error(String(p)))}}return n?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:s??"Copy unavailable","aria-label":t??"Copy",children:r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:l?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:l?r.jsx(Xr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})})}function Y$(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function J$({items:e,statusOrder:t,sortField:n,sortDirection:s,listSectionVisibility:a,compact:l=!1}){const c=Zo(),[u,p]=f.useState(()=>new Set(a.collapsed));f.useEffect(()=>{p(new Set(a.collapsed))},[a]);const m=h=>{p(g=>{const y=new Set(g);return y.has(h)?y.delete(h):y.add(h),y})};return r.jsx("div",{className:Se("space-y-2",l?"space-y-1.5":"space-y-3"),children:t.map(h=>{const g=uc(e.filter(E=>E.status===h),n,s);if(g.length===0)return null;const y=!u.has(h),b=cc(c,h);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[r.jsxs("button",{type:"button",onClick:()=>m(h),className:Se("flex w-full items-center gap-2 text-left",l?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[r.jsx(br,{className:Se("text-muted-foreground transition-transform",l?"h-3.5 w-3.5":"h-4 w-4",y?"":"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:b}),r.jsx("span",{className:Se("rounded-full border border-border/60 text-muted-foreground",l?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:g.length})]}),y&&r.jsx("ul",{className:Se("divide-y divide-border/40 border-t border-border/40",l?"text-xs":"text-sm"),children:g.map(E=>{const j=Y$(E);return r.jsx("li",{children:r.jsxs(Ee,{to:j,className:Se("flex items-center gap-3 hover:bg-muted/40",l?"px-3 py-1.5":"px-4 py-2.5"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:E.title}),E.projectTitle?r.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:E.projectTitle}):null,r.jsx("span",{className:"shrink-0 text-muted-foreground",children:Dn(E.updated)})]})},`${E.projectSlug??"standalone"}:${E.id}`)})})]},h)})})}function X$(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function Q$({items:e,sortField:t,sortDirection:n,tableColumnVisibility:s,compact:a=!1}){const l=new Set(s.hidden);l.delete("title");const c=h=>!l.has(h),u=uc(e,t,n),p=a?"py-2 pr-3":"py-3 pr-4",m=a?"text-xs":"text-sm";return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:Se("w-full text-left",m),children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[c("title")?r.jsx("th",{className:Se("font-medium",p),children:"Assignment"}):null,c("status")?r.jsx("th",{className:Se("font-medium",p),children:"Status"}):null,c("priority")?r.jsx("th",{className:Se("font-medium",p),children:"Priority"}):null,c("assignee")?r.jsx("th",{className:Se("font-medium",p),children:"Assignee"}):null,c("dependencies")?r.jsx("th",{className:Se("font-medium",p),children:"Dependencies"}):null,c("created")?r.jsx("th",{className:Se("font-medium",p),children:"Created"}):null,c("updated")?r.jsx("th",{className:Se("font-medium",p),children:"Updated"}):null]})}),r.jsx("tbody",{children:u.map(h=>{const g=X$(h),y=`${h.projectSlug??"standalone"}:${h.id}`;return r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[c("title")?r.jsxs("td",{className:p,children:[r.jsx(Ee,{to:g,className:"font-semibold text-foreground hover:text-primary",children:h.title}),h.projectTitle?r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h.projectTitle}):null]}):null,c("status")?r.jsx("td",{className:p,children:r.jsx(pn,{status:h.status})}):null,c("priority")?r.jsx("td",{className:Se("capitalize text-muted-foreground",p),children:h.priority}):null,c("assignee")?r.jsx("td",{className:Se("text-muted-foreground",p),children:h.assignee??"Unassigned"}):null,c("dependencies")?r.jsx("td",{className:Se("text-muted-foreground",p),children:h.dependsOn.length}):null,c("created")?r.jsx("td",{className:Se("text-muted-foreground",p),children:Dn(h.created)}):null,c("updated")?r.jsx("td",{className:Se("text-muted-foreground",p),children:Dn(h.updated)}):null]},y)})})]})})}function Z$(e,t,n){return e.filter(s=>Kg(s,t,{workspace:n,search:t.search}))}function K1({view:e,compact:t,emptyDescription:n}){const{data:s,loading:a,error:l}=Md(),c=Zo(),u=f.useMemo(()=>c.order.map(m=>({id:m,title:cc(c,m),description:Zd(m)})),[c]),p=f.useMemo(()=>{if(!s)return[];const m=Z$(s.assignments,e.config.filters,e.workspace);return uc(m,e.config.sortField,e.config.sortDirection)},[s,e]);if(a&&!s)return r.jsx(mt,{label:"Loading assignments…"});if(l)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l})]});if(p.length===0)return r.jsx(St,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return r.jsx(Qd,{compact:t,dragDisabled:!0,columns:u,items:p,getItemId:m=>m.slug||m.id,getColumnId:m=>m.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:m=>t?r.jsx(eL,{item:m}):r.jsx(tL,{item:m})});case"list":return r.jsx(J$,{items:p,statusOrder:c.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return r.jsx(Q$,{items:p,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function eL({item:e}){const t=Kl(e);return r.jsxs("div",{className:Se("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(pn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:Dn(e.updated)})]}),e.id?r.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),r.jsx($r,{value:e.id})]}):null]})}function tL({item:e}){const t=Kl(e);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(pn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[r.jsx(ea,{type:e.type,compact:!0}),r.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:Dn(e.updated)})]})]})}function nL({viewId:e,onPickAnother:t}){const{view:n,loading:s,error:a,refetch:l}=Go(e);return s?r.jsx(mt,{label:"Loading view…"}):a?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.message}),r.jsx("button",{type:"button",onClick:()=>l(),className:"shell-action mt-3",children:"Retry"})]}):n?r.jsx(K1,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),r.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function rL({sessions:e}){return r.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:r.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:Ho.recentSessionsEmptyTitle}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:Ho.recentSessionsEmptyHint})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>r.jsx("li",{children:r.jsx(sL,{session:t})},t.sessionId))})]})}function sL({session:e}){const t=ln(),[n,s]=f.useState(!1),a=oL(e,t),l=aL(e),c=!e.path;return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:a,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[l," · ",N0(e.started)]}),n&&e.path?r.jsxs("div",{className:"mt-1 space-y-0.5",children:[r.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),r.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ho.recentSessionsCopyFallbackHint})]}):null]}),r.jsx($r,{value:e.path,label:Ho.recentSessionsCopyPathLabel,disabled:c,disabledReason:Ho.recentSessionsCopyPathDisabled,onError:()=>s(!0)})]})}function oL(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function aL(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}function iL(){const{data:e,loading:t,error:n}=U0();return t&&!e?r.jsx(mt,{label:"Loading sessions…"}):n?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]}):r.jsx(rL,{sessions:(e==null?void 0:e.sessions)??[]})}const lL=5;function cL(){const{data:e,loading:t,error:n}=B0();if(t&&!e)return r.jsx(mt,{label:"Loading inventories…"});if(n)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]});const a=((e==null?void 0:e.inventories)??[]).slice(0,lL);return r.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[r.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),r.jsx(Ee,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),a.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:a.map(l=>{const c=l.inventory,u=l.active_leases.length,p=l.members.length,m=c.display_name??c.slug;return r.jsx("li",{children:r.jsxs(Ee,{to:`/inventories/${encodeURIComponent(c.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[u,"/",p," leased"]})]})},c.slug)})})]})}const q1={"saved-view":{title:"Saved view",icon:p0,render:(e,t)=>e.kind!=="saved-view"?null:f.createElement(nL,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:Ad,render:()=>f.createElement(iL)},inventories:{title:"Inventories",icon:Ld,render:()=>f.createElement(cL)}},uL={small:"min-h-[320px]",wide:"xl:col-span-2 min-h-[320px]",tall:"min-h-[560px]",large:"xl:col-span-2 min-h-[560px]"},dL={small:"Small",wide:"Wide",tall:"Tall",large:"Large"};function fL({slot:e,onReplace:t,onRemove:n,onResize:s}){const a=e.size??"small",l=uL[a];if(e.widget===null)return r.jsx("div",{className:Se("flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-card/40 p-3 shadow-sm",l),children:r.jsxs("button",{type:"button",onClick:t,className:"shell-action inline-flex items-center gap-2",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add widget"]})});const c=q1[e.widget.kind];if(!c)return r.jsx("div",{className:Se("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})});const u=c.icon;return r.jsxs("div",{className:Se("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:[r.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[r.jsx(u,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:r.jsx(pL,{slot:e,fallback:c.title})})]}),r.jsx(Wg,{items:[{key:"replace",label:"Replace…",icon:jR,onSelect:t},{key:"size",label:"Size",icon:yR,submenu:zD.map(p=>({key:`size-${p}`,label:dL[p],active:p===a,onSelect:()=>s(p)}))},{key:"remove",label:"Remove",icon:or,destructive:!0,onSelect:n}]})]}),r.jsx("div",{children:c.render(e.widget,{slotId:e.id,onPickAnother:t})})]})}function pL({slot:e,fallback:t}){var a,l;const n=((a=e.widget)==null?void 0:a.kind)==="saved-view"?e.widget.viewId:null,{view:s}=Go(n);return((l=e.widget)==null?void 0:l.kind)==="saved-view"&&s?r.jsx(r.Fragment,{children:s.name}):r.jsx(r.Fragment,{children:t})}const mL=["agent-sessions","inventories"];function hL({open:e,onOpenChange:t,onSelect:n}){const{views:s,loading:a}=Vd();function l(c){n(c),t(!1)}return r.jsx(ar,{open:e,onOpenChange:t,children:r.jsxs(Kn,{className:"max-w-xl",children:[r.jsxs(Zr,{children:[r.jsx(qn,{children:"Add a widget"}),r.jsx(gs,{children:"Choose a built-in widget or one of your saved views."})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:mL.map(c=>{const u=q1[c],p=u.icon;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:c}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx(p,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("span",{className:"font-medium text-foreground",children:u.title})]})},c)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),a?r.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):s.length===0?r.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",r.jsx(Ee,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):r.jsx("ul",{className:"max-h-72 divide-y divide-border/40 overflow-auto rounded-md border border-border/60",children:s.map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:"saved-view",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null,r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:c.config.viewMode})]})},c.id))}),!a&&s.some(c=>c.workspace!==null)?r.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}function gL(){const{data:e,error:t,refetch:n}=vP(),{data:s}=_0(),{layout:a}=WD(),[l,c]=f.useState(!1),[u,p]=f.useState(null),[m,h]=f.useState(null);mo("list:overview"),Ht({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const g=f.useCallback(k=>{p(k),c(!0)},[]),y=f.useCallback(async k=>{h(null);try{await qD(k)}catch(C){h(C instanceof Error?C.message:String(C))}},[]),b=f.useCallback(k=>{if(u===null)return;const C=a.slots.map((N,T)=>T===u?{...N,widget:k}:N);p(null),y(C)},[a.slots,u,y]),E=f.useCallback(k=>{const C=a.slots.map((N,T)=>T===k?{...N,widget:null}:N);y(C)},[a.slots,y]),j=f.useCallback((k,C)=>{const N=a.slots.map((T,D)=>D===k?{...T,size:C}:T);y(N)},[a.slots,y]),w={};if(e)for(const k of Object.keys(e.segments))for(const C of e.segments[k].items)w[C.id]=C;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("header",{className:"space-y-2",children:[r.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),r.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?r.jsx(AD,{hero:e.hero,itemsById:w}):t?r.jsx(wt,{error:t}):r.jsx(mt,{label:"Loading overview…"}),e!=null&&e.firstRun?r.jsx(RD,{help:s}):null,m?r.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",m]}):null,r.jsx("div",{className:"grid grid-flow-dense grid-cols-1 gap-4 xl:grid-cols-2",children:a.slots.map((k,C)=>r.jsx(fL,{slot:k,index:C,onReplace:()=>g(C),onRemove:()=>E(C),onResize:N=>j(C,N)},k.id))}),e!=null&&e.serverStats?r.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(sg,{className:"h-3 w-3","aria-hidden":"true"}),r.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,r.jsx(hL,{open:l,onOpenChange:k=>{c(k),k||p(null)},onSelect:b})]})}function xL({term:e,description:t}){return r.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function yL(){const{data:e,loading:t,error:n}=_0(),{openCheatsheet:s}=po();return t?r.jsx(mt,{label:"Loading help…"}):n||!e?r.jsx(wt,{error:n||"Help content is unavailable."}):r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",r.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",ds("Mod+k")," opens the command palette."]})]})}),r.jsx(We,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:r.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(a=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:a},a))})}),r.jsx(We,{title:"Getting Started",children:r.jsx("div",{className:"space-y-3",children:e.workflow.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,description:a.command.description,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsxs(We,{title:"Core Concepts",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(a=>r.jsx(xL,{term:a.term,description:a.description},a.term))}),r.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.term}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.term))})]}),r.jsx(We,{title:"Status Guide",children:r.jsx("div",{className:"space-y-3",children:e.statusGuide.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:a.status}),r.jsx("p",{className:"font-semibold text-foreground",children:a.meaning})]}),r.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:a.useWhen})]},a.status))})})]}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"Ownership And File Rules",children:r.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.files.map(l=>r.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:l},l))})]},a.label))})}),r.jsx(We,{title:"How To Navigate The Dashboard",children:r.jsx("div",{className:"space-y-3",children:e.navigation.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open"})]}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.label))})})]}),r.jsx(We,{title:"CLI Quick Reference",children:r.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(a=>r.jsx(qu,{command:a.command,description:a.description,example:a.example},a.command))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"FAQ",children:r.jsx("div",{className:"space-y-3",children:e.faq.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.question}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.answer})]},a.question))})}),r.jsx(We,{title:"First Project Checklist",children:r.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})})]})]})}function qg({children:e}){return r.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const tf=f.forwardRef(({value:e,onChange:t,placeholder:n="Search"},s)=>r.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[r.jsx(fo,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),r.jsx("input",{ref:s,value:e,onChange:a=>t(a.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));tf.displayName="SearchInput";function nf({value:e,options:t,onChange:n}){return r.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(s=>r.jsx("button",{type:"button","aria-pressed":e===s.value,onClick:()=>n(s.value),className:Se("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===s.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:s.label},s.value))})}const bL={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},rw=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function gd({progress:e,className:t,showLegend:n=!1}){const s=Zo(),a=f.useMemo(()=>{let c=0;return(s.order.length>0?s.order:Object.keys(e).filter(p=>p!=="total")).map(p=>({key:p,className:bL[p]??rw[c++%rw.length]}))},[s.order,e]),l=a.filter(c=>(e[c.key]??0)>0);return r.jsxs("div",{className:Se("space-y-2",t),children:[r.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?r.jsx("div",{className:"h-full w-full bg-muted"}):l.map(c=>r.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${yn(c.key)}: ${e[c.key]??0}`},c.key))}),n?r.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:a.map(c=>r.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[r.jsx("span",{className:Se("h-2 w-2 rounded-full",c.className)}),r.jsx("span",{children:yn(c.key)}),r.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const vL=["pending","active","blocked","failed","completed"],Gg=vL,wL=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function G1(e){return e&&e.length>0?e:[...wL]}function jL(e,t,n){if(t<0||t>=e.length)return e;const s=[...e],[a]=s.splice(t,1),l=t<n?n-1:n;return s.splice(Math.max(0,Math.min(l,s.length)),0,a),s}const kL=220,Au=8;function Y1({anchor:e,items:t,onClose:n}){const s=f.useRef(null),[a,l]=f.useState(null);return f.useLayoutEffect(()=>{if(!e){l(null);return}const c=s.current,u=(c==null?void 0:c.offsetWidth)??kL,p=(c==null?void 0:c.offsetHeight)??0,m=Math.max(Au,window.innerWidth-u-Au),h=Math.max(Au,window.innerHeight-p-Au);l({left:Math.min(e.x,m),top:Math.min(e.y,h)})},[e]),f.useEffect(()=>{if(!e)return;function c(m){s.current&&!s.current.contains(m.target)&&n()}function u(m){m.key==="Escape"&&n()}function p(){n()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),document.addEventListener("contextmenu",c),window.addEventListener("scroll",p,!0),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u),document.removeEventListener("contextmenu",c),window.removeEventListener("scroll",p,!0)}},[e,n]),!e||t.length===0?null:r.jsx("div",{ref:s,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(a==null?void 0:a.left)??e.x,top:(a==null?void 0:a.top)??e.y,visibility:a?"visible":"hidden"},children:r.jsx(Wo,{delayDuration:200,children:t.map(c=>{const u=c.icon,p=Se("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",c.disabled?"cursor-not-allowed opacity-50":c.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),m=r.jsxs(r.Fragment,{children:[u?r.jsx(u,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 truncate",children:c.label})]});if(c.disabled){const h=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:p,children:m})});return c.disabledReason?r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:h}),r.jsx(gr,{side:"left",children:c.disabledReason})]},c.key):r.jsx("div",{children:h},c.key)}return c.href?r.jsx(Ee,{to:c.href,className:p,onClick:()=>n(),children:m},c.key):r.jsx("button",{type:"button",className:p,onClick:()=>{var h;(h=c.onSelect)==null||h.call(c),n()},children:m},c.key)})})})}const SL="__ungrouped__";function Yg({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:s,title:a="Move to workspace",description:l="Pick the workspace this item should belong to."}){const{data:c,loading:u}=oc(),[p,m]=f.useState(n),[h,g]=f.useState(!1),[y,b]=f.useState(null);f.useEffect(()=>{e&&(m(n),b(null))},[e,n]);const E=f.useMemo(()=>[...((c==null?void 0:c.workspaces)??[]).map(C=>({key:C,label:C,value:C})),{key:SL,label:"Ungrouped",value:null}],[c]),j=!h&&p!==n;async function w(){if(j){g(!0),b(null);try{await s(p),t(!1)}catch(k){b(k instanceof Error?k.message:"Failed to move item")}finally{g(!1)}}}return r.jsx(ar,{open:e,onOpenChange:k=>h?void 0:t(k),children:r.jsxs(Kn,{children:[r.jsxs(Zr,{children:[r.jsx(qn,{children:a}),r.jsx(gs,{children:l})]}),r.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:u&&E.length===0?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[r.jsx(rg,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):E.map(k=>{const C=k.value===n,N=k.value===p;return r.jsxs("button",{type:"button",disabled:C||h,onClick:()=>m(k.value),className:Se("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",C?"cursor-not-allowed bg-foreground/5 text-muted-foreground":N?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:Se("block min-w-0 truncate",k.value===null?"italic text-muted-foreground":""),children:[k.label,C?r.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),N?r.jsx(Xr,{className:"h-4 w-4 text-foreground"}):null]},k.key)})}),y?r.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}):null,r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),disabled:h,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",onClick:w,disabled:!j,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving…":"Move"})]})]})})}function sw(){const{workspace:e}=$t(),t=ln(),n=Dt(),{data:s,loading:a,error:l,refetch:c}=Jo(),u=f.useRef(null);mo("list:projects");const[p,m]=f.useState(""),[h,g]=f.useState("all"),[y,b]=f.useState("all"),[E,j]=f.useState("updated"),[w,k]=hs(),C=w.get("view"),N=C==="table"||C==="kanban"?C:"cards",T=M=>{k(G=>{const A=new URLSearchParams(G);return M==="cards"?A.delete("view"):A.set("view",M),A})},[D,R]=f.useState({}),[$,L]=f.useState(null),[K,B]=f.useState(null),O=f.useMemo(()=>s?s.filter(M=>{if(e){if(e==="_ungrouped"){if(M.workspace!==null)return!1}else if(M.workspace!==e)return!1}return h!=="all"&&M.status!==h||y!=="all"&&!M.tags.includes(y)?!1:p.trim()?`${M.title} ${M.tags.join(" ")} ${M.slug}`.toLowerCase().includes(p.toLowerCase()):!0}).sort((M,G)=>EL(M,G,E)):[],[s,p,h,y,E,e]),W=O.map(M=>`${M.slug}:${M.status}`).join("|");f.useEffect(()=>{R(TL(O))},[W,E]);const se=f.useMemo(()=>{const M=new Map(O.map(G=>[G.slug,G]));return Gg.flatMap(G=>(D[G]??O.filter(F=>F.status===G).map(F=>F.slug)).map(F=>M.get(F)).filter(F=>!!F))},[O,D]),{visibleItems:z,visibleIndexByKey:H}=f.useMemo(()=>{const M=N==="kanban"?se:O,G=new Map;return M.forEach((A,F)=>G.set(A.slug,F)),{visibleItems:M,visibleIndexByKey:G}},[N,O,se]),{hotkeyRowProps:ee}=ac(z,{scope:"list:projects",onOpen:M=>n(`${t}/projects/${M.slug}`)});if(Ht({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var M;return(M=u.current)==null?void 0:M.focus()}}),Ht({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),a)return r.jsx(mt,{label:"Loading projects…"});if(l||!s)return r.jsx(wt,{error:l||"Project list is unavailable."});const ne=Array.from(new Set(s.flatMap(M=>M.tags))).sort();return r.jsxs("div",{className:"space-y-5",children:[r.jsxs(qg,{children:[r.jsx(tf,{ref:u,value:p,onChange:m,placeholder:"Search by project title or tag"}),r.jsxs("select",{value:h,onChange:M=>g(M.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All statuses"}),r.jsx("option",{value:"pending",children:"Pending"}),r.jsx("option",{value:"active",children:"Active"}),r.jsx("option",{value:"blocked",children:"Blocked"}),r.jsx("option",{value:"failed",children:"Failed"}),r.jsx("option",{value:"completed",children:"Completed"})]}),r.jsxs("select",{value:y,onChange:M=>b(M.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All tags"}),ne.map(M=>r.jsx("option",{value:M,children:M},M))]}),r.jsxs("select",{value:E,onChange:M=>j(M.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"updated",children:"Sort: Updated"}),r.jsx("option",{value:"created",children:"Sort: Created"}),r.jsx("option",{value:"title",children:"Sort: Title"}),r.jsx("option",{value:"attention",children:"Sort: Attention"})]}),r.jsx(nf,{value:N,onChange:M=>T(M),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),O.length===0?s.length===0?r.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[r.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),r.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),r.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),r.jsx(Ee,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):r.jsx(St,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):N==="cards"?r.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:O.map((M,G)=>r.jsxs(Ee,{to:`${t}/projects/${M.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...ee(G),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:M.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Dn(M.updated)]})]}),r.jsx(pn,{status:M.status})]}),r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsx(gd,{progress:M.progress,showLegend:!0}),r.jsx("div",{className:"flex flex-wrap gap-2",children:M.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:A},A))}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:M.needsAttention.blockedCount+M.needsAttention.failedCount})]}),r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:M.progress.total})]})]})]})]},M.slug))}):N==="table"?r.jsx(We,{title:`${O.length} project${O.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[r.jsx("th",{className:"pb-3 font-medium",children:"Project"}),r.jsx("th",{className:"pb-3 font-medium",children:"Status"}),r.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),r.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),r.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),r.jsx("tbody",{children:O.map((M,G)=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",...ee(G),children:[r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(Ee,{to:`${t}/projects/${M.slug}`,className:"font-semibold text-foreground hover:text-primary",children:M.title}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:M.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:A},A))})]}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx(pn,{status:M.status})}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx("div",{className:"min-w-[220px]",children:r.jsx(gd,{progress:M.progress})})}),r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:M.needsAttention.blockedCount+M.needsAttention.failedCount}),r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(M.updated)})]},M.slug))})]})})}):r.jsx(Qd,{columns:CL,items:se,getItemId:M=>M.slug,getColumnId:M=>M.status,canDrop:({fromColumnId:M,toColumnId:G})=>({allowed:!0,reason:M===G?void 0:"This will set a manual status override on the project."}),onMove:({item:M,fromColumnId:G,toColumnId:A,fromIndex:F,toIndex:Z})=>{if(G===A){const I=D[G]??O.filter(de=>de.status===G).map(de=>de.slug);R(de=>({...de,[G]:jL(I,F,Z)}));return}fetch(`/api/projects/${M.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})}).then(()=>{window.location.reload()})},getExternalDragData:M=>({type:"project",id:M.slug}),onCardContextMenu:(M,G)=>{G.preventDefault(),L({project:M,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:M=>`No ${M.title.toLowerCase()} projects.`,renderCard:(M,{dragging:G})=>{const A=H.get(M.slug)??-1;return r.jsx("div",{...A>=0?ee(A):{},children:r.jsx(RL,{project:M,dragging:G})})}}),r.jsx(Y1,{anchor:($==null?void 0:$.anchor)??null,items:$?[{key:"edit",label:"Edit",icon:bi,onSelect:()=>n(`${t}/projects/${$.project.slug}`)},{key:"move",label:"Move to workspace…",icon:$d,onSelect:()=>B($.project)}]:[],onClose:()=>L(null)}),r.jsx(Yg,{open:K!==null,onOpenChange:M=>{M||B(null)},currentWorkspace:(K==null?void 0:K.workspace)??null,title:"Move project to workspace",onSubmit:async M=>{if(!K)return;const G=await fetch(`/api/projects/${encodeURIComponent(K.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:M})});if(!G.ok){const A=await G.json().catch(()=>({}));throw new Error(A.error||"Failed to move project")}c()}}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(ng,{className:"mt-0.5 h-4 w-4"}),r.jsxs("p",{children:["Project status is derived from assignment state by default.",N==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const NL={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},CL=Gg.map(e=>({id:e,title:NL[e],description:Zd(e)}));function EL(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return ow(t)-ow(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function ow(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function TL(e){return Object.fromEntries(Gg.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function RL({project:e,dragging:t}){const n=ln();return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Ee,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Dn(e.updated)]})]}),r.jsx(pn,{status:e.status})]}),r.jsx("div",{className:"mt-4",children:r.jsx(gd,{progress:e.progress})}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(s=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:s},s)),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),r.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function xd({title:e,description:t,actions:n,className:s}){return r.jsxs("div",{className:Se("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",s),children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}const PL=4e3;function ta(){const[e,t]=f.useState(null),n=f.useRef(null),s=f.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),a=f.useCallback((l,c="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:l,kind:c}),n.current=setTimeout(()=>{t(null),n.current=null},PL)},[]);return f.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:a,dismissToast:s}}function na({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return r.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:r.jsx("button",{type:"button",onClick:t,className:Se("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}function AL(){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[r.jsx(Dd,{className:"h-3 w-3"}),"Archived"]})}function aw(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function DL(){const{data:e,loading:t,error:n,refetch:s}=wP(),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState({}),{toast:h,showToast:g,dismissToast:y}=ta();async function b(N,T,D){l(T),u(null);try{const R=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"}});if(!R.ok){const $=await R.json().catch(()=>null);throw new Error(($==null?void 0:$.error)||`HTTP ${R.status}`)}s(),g(D,"success")}catch(R){u(R instanceof Error?R.message:"Restore failed")}finally{l(null)}}function E(N){return b(`/api/projects/${N.slug}/unarchive`,`project:${N.slug}`,"Project restored")}function j(N){const T=N.projectSlug?`/api/projects/${N.projectSlug}/assignments/${N.slug}/unarchive`:`/api/assignments/${N.id}/unarchive`;return b(T,`assignment:${N.id}`,"Assignment restored")}if(t)return r.jsx(mt,{label:"Loading archived content…"});if(n)return r.jsx(wt,{error:n});const w=(e==null?void 0:e.projects)??[],k=(e==null?void 0:e.assignments)??[],C=w.length===0&&k.length===0;return r.jsxs("div",{className:"space-y-6",children:[r.jsx(na,{toast:h,onDismiss:y}),r.jsx(xd,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),c?r.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:c}):null,C?r.jsx(St,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):r.jsxs(r.Fragment,{children:[w.length>0&&r.jsx(We,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:r.jsx("ul",{className:"divide-y divide-border",children:w.map(N=>{const T=p[N.slug]??!1;return r.jsxs("li",{className:"py-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>m(D=>({...D,[N.slug]:!T})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":T,children:[T?r.jsx(br,{className:"h-4 w-4"}):r.jsx(l0,{className:"h-4 w-4"}),r.jsx(eg,{className:"h-4 w-4 text-muted-foreground"}),N.title,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.assignments.length," assignment",N.assignments.length===1?"":"s",")"]})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(Ee,{to:`/projects/${N.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),r.jsxs("button",{type:"button",onClick:()=>E(N),disabled:a===`project:${N.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]})]}),T&&N.assignments.length>0&&r.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:N.assignments.map(D=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[r.jsx(Ee,{to:aw(D),className:"text-foreground hover:text-foreground/80",children:D.title}),r.jsx(pn,{status:D.status,showIcon:!1}),r.jsx("span",{className:"text-xs text-muted-foreground",children:D.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},D.id))})]},N.slug)})})}),k.length>0&&r.jsx(We,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:r.jsx("ul",{className:"divide-y divide-border",children:k.map(N=>r.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[r.jsx(Ee,{to:aw(N),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:N.title}),r.jsx(pn,{status:N.status,showIcon:!1}),r.jsx(AL,{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.projectTitle??"Standalone"," · Archived"," ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("button",{type:"button",onClick:()=>j(N),disabled:a===`assignment:${N.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]},N.id))})})]})]})}const iw="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",lw="block min-w-0 truncate";function Jg({externalIds:e,className:t}){return e.length===0?null:r.jsx("span",{className:Se("flex flex-wrap items-center gap-1.5",t),children:e.map((n,s)=>{const a=`${n.system}:${n.id}`,l=`${n.system}:${n.id}:${s}`;return n.url!=null&&n.url.length>0?r.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:Se(iw,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${a} in ${n.system}`,children:[r.jsx("span",{className:lw,children:a}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]},l):r.jsx("span",{className:iw,title:a,children:r.jsx("span",{className:lw,children:a})},l)})})}const $L={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function An({label:e,value:t,description:n,icon:s,tone:a="default",to:l}){const c=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),r.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),s?r.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:r.jsx(s,{className:"h-5 w-5"})}):null]}),n?r.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),u=Se($L[a],l?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return l?r.jsx(Ee,{to:l,className:u,children:c}):r.jsx("article",{className:u,children:c})}function cw(e){const t=LL(e),n=f.forwardRef((s,a)=>{const{children:l,...c}=s,u=f.Children.toArray(l),p=u.find(IL);if(p){const m=p.props.children,h=u.map(g=>g===p?f.Children.count(m)>1?f.Children.only(null):f.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...c,ref:a,children:f.isValidElement(m)?f.cloneElement(m,void 0,h):null})}return r.jsx(t,{...c,ref:a,children:l})});return n.displayName=`${e}.Slot`,n}function LL(e){const t=f.forwardRef((n,s)=>{const{children:a,...l}=n;if(f.isValidElement(a)){const c=_L(a),u=ML(l,a.props);return a.type!==f.Fragment&&(u.ref=s?Fd(s,c):c),f.cloneElement(a,u)}return f.Children.count(a)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var OL=Symbol("radix.slottable");function IL(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===OL}function ML(e,t){const n={...t};for(const s in t){const a=e[s],l=t[s];/^on[A-Z]/.test(s)?a&&l?n[s]=(...u)=>{const p=l(...u);return a(...u),p}:a&&(n[s]=a):s==="style"?n[s]={...a,...l}:s==="className"&&(n[s]=[a,l].filter(Boolean).join(" "))}return{...e,...n}}function _L(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function FL(e){const t=e+"CollectionProvider",[n,s]=Xo(t),[a,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j=>{const{scope:w,children:k}=j,C=nn.useRef(null),N=nn.useRef(new Map).current;return r.jsx(a,{scope:w,itemMap:N,collectionRef:C,children:k})};c.displayName=t;const u=e+"CollectionSlot",p=cw(u),m=nn.forwardRef((j,w)=>{const{scope:k,children:C}=j,N=l(u,k),T=Fn(w,N.collectionRef);return r.jsx(p,{ref:T,children:C})});m.displayName=u;const h=e+"CollectionItemSlot",g="data-radix-collection-item",y=cw(h),b=nn.forwardRef((j,w)=>{const{scope:k,children:C,...N}=j,T=nn.useRef(null),D=Fn(w,T),R=l(h,k);return nn.useEffect(()=>(R.itemMap.set(T,{ref:T,...N}),()=>void R.itemMap.delete(T))),r.jsx(y,{[g]:"",ref:D,children:C})});b.displayName=h;function E(j){const w=l(e+"CollectionConsumer",j);return nn.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const N=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(w.itemMap.values()).sort((R,$)=>N.indexOf(R.ref.current)-N.indexOf($.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:c,Slot:m,ItemSlot:b},E,s]}var zL=f.createContext(void 0);function J1(e){const t=f.useContext(zL);return e||t||"ltr"}var Pm="rovingFocusGroup.onEntryFocus",BL={bubbles:!1,cancelable:!0},dc="RovingFocusGroup",[Nh,X1,UL]=FL(dc),[VL,Q1]=Xo(dc,[UL]),[HL,WL]=VL(dc),Z1=f.forwardRef((e,t)=>r.jsx(Nh.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Nh.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(KL,{...e,ref:t})})}));Z1.displayName=dc;var KL=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:p,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,y=f.useRef(null),b=Fn(t,y),E=J1(l),[j,w]=zd({prop:c,defaultProp:u??null,onChange:p,caller:dc}),[k,C]=f.useState(!1),N=Ko(m),T=X1(n),D=f.useRef(!1),[R,$]=f.useState(0);return f.useEffect(()=>{const L=y.current;if(L)return L.addEventListener(Pm,N),()=>L.removeEventListener(Pm,N)},[N]),r.jsx(HL,{scope:n,orientation:s,dir:E,loop:a,currentTabStopId:j,onItemFocus:f.useCallback(L=>w(L),[w]),onItemShiftTab:f.useCallback(()=>C(!0),[]),onFocusableItemAdd:f.useCallback(()=>$(L=>L+1),[]),onFocusableItemRemove:f.useCallback(()=>$(L=>L-1),[]),children:r.jsx(mn.div,{tabIndex:k||R===0?-1:0,"data-orientation":s,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:qt(e.onMouseDown,()=>{D.current=!0}),onFocus:qt(e.onFocus,L=>{const K=!D.current;if(L.target===L.currentTarget&&K&&!k){const B=new CustomEvent(Pm,BL);if(L.currentTarget.dispatchEvent(B),!B.defaultPrevented){const O=T().filter(ee=>ee.focusable),W=O.find(ee=>ee.active),se=O.find(ee=>ee.id===j),H=[W,se,...O].filter(Boolean).map(ee=>ee.ref.current);nS(H,h)}}D.current=!1}),onBlur:qt(e.onBlur,()=>C(!1))})})}),eS="RovingFocusGroupItem",tS=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:l,children:c,...u}=e,p=ni(),m=l||p,h=WL(eS,n),g=h.currentTabStopId===m,y=X1(n),{onFocusableItemAdd:b,onFocusableItemRemove:E,currentTabStopId:j}=h;return f.useEffect(()=>{if(s)return b(),()=>E()},[s,b,E]),r.jsx(Nh.ItemSlot,{scope:n,id:m,focusable:s,active:a,children:r.jsx(mn.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:qt(e.onMouseDown,w=>{s?h.onItemFocus(m):w.preventDefault()}),onFocus:qt(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:qt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=YL(w,h.orientation,h.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let N=y().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")N.reverse();else if(k==="prev"||k==="next"){k==="prev"&&N.reverse();const T=N.indexOf(w.currentTarget);N=h.loop?JL(N,T+1):N.slice(T+1)}setTimeout(()=>nS(N))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:j!=null}):c})})});tS.displayName=eS;var qL={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function GL(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function YL(e,t,n){const s=GL(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return qL[s]}function nS(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function JL(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var XL=Z1,QL=tS,rf="Tabs",[ZL]=Xo(rf,[Q1]),rS=Q1(),[eO,Xg]=ZL(rf),sS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:l,orientation:c="horizontal",dir:u,activationMode:p="automatic",...m}=e,h=J1(u),[g,y]=zd({prop:s,onChange:a,defaultProp:l??"",caller:rf});return r.jsx(eO,{scope:n,baseId:ni(),value:g,onValueChange:y,orientation:c,dir:h,activationMode:p,children:r.jsx(mn.div,{dir:h,"data-orientation":c,...m,ref:t})})});sS.displayName=rf;var oS="TabsList",aS=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,l=Xg(oS,n),c=rS(n);return r.jsx(XL,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:r.jsx(mn.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:t})})});aS.displayName=oS;var iS="TabsTrigger",lS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...l}=e,c=Xg(iS,n),u=rS(n),p=dS(c.baseId,s),m=fS(c.baseId,s),h=s===c.value;return r.jsx(QL,{asChild:!0,...u,focusable:!a,active:h,children:r.jsx(mn.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:p,...l,ref:t,onMouseDown:qt(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:qt(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:qt(e.onFocus,()=>{const g=c.activationMode!=="manual";!h&&!a&&g&&c.onValueChange(s)})})})});lS.displayName=iS;var cS="TabsContent",uS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:l,...c}=e,u=Xg(cS,n),p=dS(u.baseId,s),m=fS(u.baseId,s),h=s===u.value,g=f.useRef(h);return f.useEffect(()=>{const y=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(y)},[]),r.jsx(Qo,{present:a||h,children:({present:y})=>r.jsx(mn.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":p,hidden:!y,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:y&&l})})});uS.displayName=cS;function dS(e,t){return`${e}-trigger-${t}`}function fS(e,t){return`${e}-content-${t}`}var pS=sS,mS=aS,Ch=lS,Eh=uS;function Qg({value:e,onValueChange:t,items:n,className:s}){return r.jsxs(pS,{value:e,onValueChange:t,className:s,children:[r.jsx(mS,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(a=>r.jsxs(Ch,{value:a.value,className:Se("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[r.jsx("span",{children:a.label}),typeof a.count=="number"?r.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:a.count}):null]},a.value))}),n.map(a=>r.jsx(Eh,{value:a.value,className:"pt-3",children:a.content},a.value))]})}const tO="modulepreload",nO=function(e){return"/"+e},uw={},rO=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),p=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(m=>{if(m=nO(m),m in uw)return;uw[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":tO,h||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),h)return new Promise((b,E)=>{y.addEventListener("load",b),y.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})};function sO({definition:e,className:t,nodeRoutes:n={}}){const s=f.useRef(null),[a,l]=f.useState(null),[c,u]=f.useState(!0),p=Dt(),m=document.documentElement.classList.contains("dark")?"dark":"default";return f.useEffect(()=>{let h=!1;async function g(){if(s.current)try{const y=(await rO(async()=>{const{default:j}=await import("./mermaid.core-Cu6allRd.js").then(w=>w.bF);return{default:j}},[])).default;if(y.initialize({startOnLoad:!1,theme:"base",themeVariables:oO(m==="dark")}),h)return;const b=`mermaid-${Date.now()}`,{svg:E}=await y.render(b,e);if(h||!s.current)return;s.current.innerHTML=E,aO(s.current,n,p),u(!1)}catch(y){h||(l(y instanceof Error?y.message:"Failed to render graph"),u(!1))}}return u(!0),l(null),g(),()=>{h=!0}},[e,p,n,m]),a?r.jsxs("div",{className:Se("rounded-lg border border-border bg-card p-4",t),children:[r.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",a]}),r.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):r.jsxs("div",{className:Se("rounded-lg border border-border bg-card p-4",t),children:[c&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),r.jsx("div",{ref:s,className:"overflow-auto"})]})}function oO(e){const t=document.documentElement,n=g=>{const y=getComputedStyle(t).getPropertyValue(g).trim();return y?`oklch(${y})`:""},s=n("--card"),a=n("--card-foreground"),l=n("--border"),c=n("--primary"),u=n("--primary-foreground"),p=n("--muted"),m=n("--muted-foreground"),h=n("--secondary");return{background:s,primaryColor:s,primaryTextColor:a,primaryBorderColor:l,secondaryColor:p,secondaryTextColor:a,secondaryBorderColor:l,tertiaryColor:p,tertiaryTextColor:m,tertiaryBorderColor:l,lineColor:e?m:l,textColor:a,mainBkg:s,nodeBkg:s,nodeTextColor:a,nodeBorder:l,clusterBkg:p,clusterBorder:l,edgeLabelBackground:s,titleColor:a,activeTaskBkgColor:c,activeTaskBorderColor:c,altBackground:p,labelColor:a,errorBkgColor:h,errorTextColor:u}}function aO(e,t,n){var s;for(const a of e.querySelectorAll(".node")){const l=((s=a.textContent)==null?void 0:s.replace(/\s+/g," ").trim())??"",c=t[l];if(!c)continue;a.style.cursor="pointer",a.setAttribute("role","link"),a.setAttribute("tabindex","0"),a.setAttribute("aria-label",`Open ${l}`);const u=()=>n(c);a.addEventListener("click",u),a.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),u())})}}function iO(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uO={};function dw(e,t){return(uO.jsx?cO:lO).test(e)}const dO=/[ \t\n\f\r]/g;function fO(e){return typeof e=="object"?e.type==="text"?fw(e.value):!1:fw(e)}function fw(e){return e.replace(dO,"")===""}class fc{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}fc.prototype.normal={};fc.prototype.property={};fc.prototype.space=void 0;function hS(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new fc(n,s,t)}function Th(e){return e.toLowerCase()}class ir{constructor(t,n){this.attribute=n,this.property=t}}ir.prototype.attribute="";ir.prototype.booleanish=!1;ir.prototype.boolean=!1;ir.prototype.commaOrSpaceSeparated=!1;ir.prototype.commaSeparated=!1;ir.prototype.defined=!1;ir.prototype.mustUseProperty=!1;ir.prototype.number=!1;ir.prototype.overloadedBoolean=!1;ir.prototype.property="";ir.prototype.spaceSeparated=!1;ir.prototype.space=void 0;let pO=0;const dt=ra(),dn=ra(),Rh=ra(),Te=ra(),It=ra(),li=ra(),pr=ra();function ra(){return 2**++pO}const Ph=Object.freeze(Object.defineProperty({__proto__:null,boolean:dt,booleanish:dn,commaOrSpaceSeparated:pr,commaSeparated:li,number:Te,overloadedBoolean:Rh,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),Am=Object.keys(Ph);class Zg extends ir{constructor(t,n,s,a){let l=-1;if(super(t,n),pw(this,"space",a),typeof s=="number")for(;++l<Am.length;){const c=Am[l];pw(this,Am[l],(s&Ph[c])===Ph[c])}}}Zg.prototype.defined=!0;function pw(e,t,n){n&&(e[t]=n)}function ki(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new Zg(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Th(s)]=s,n[Th(l.attribute)]=s}return new fc(t,n,e.space)}const gS=ki({properties:{ariaActiveDescendant:null,ariaAtomic:dn,ariaAutoComplete:null,ariaBusy:dn,ariaChecked:dn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:It,ariaCurrent:null,ariaDescribedBy:It,ariaDetails:null,ariaDisabled:dn,ariaDropEffect:It,ariaErrorMessage:null,ariaExpanded:dn,ariaFlowTo:It,ariaGrabbed:dn,ariaHasPopup:null,ariaHidden:dn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:It,ariaLevel:Te,ariaLive:null,ariaModal:dn,ariaMultiLine:dn,ariaMultiSelectable:dn,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:dn,ariaReadOnly:dn,ariaRelevant:null,ariaRequired:dn,ariaRoleDescription:It,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:dn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function xS(e,t){return t in e?e[t]:t}function yS(e,t){return xS(e,t.toLowerCase())}const mO=ki({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:li,acceptCharset:It,accessKey:It,action:null,allow:null,allowFullScreen:dt,allowPaymentRequest:dt,allowUserMedia:dt,alt:null,as:null,async:dt,autoCapitalize:null,autoComplete:It,autoFocus:dt,autoPlay:dt,blocking:It,capture:null,charSet:null,checked:dt,cite:null,className:It,cols:Te,colSpan:null,content:null,contentEditable:dn,controls:dt,controlsList:It,coords:Te|li,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dt,defer:dt,dir:null,dirName:null,disabled:dt,download:Rh,draggable:dn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dt,formTarget:null,headers:It,height:Te,hidden:Rh,high:Te,href:null,hrefLang:null,htmlFor:It,httpEquiv:It,id:null,imageSizes:null,imageSrcSet:null,inert:dt,inputMode:null,integrity:null,is:null,isMap:dt,itemId:null,itemProp:It,itemRef:It,itemScope:dt,itemType:It,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dt,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:dt,muted:dt,name:null,nonce:null,noModule:dt,noValidate:dt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:dt,optimum:Te,pattern:null,ping:It,placeholder:null,playsInline:dt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dt,referrerPolicy:null,rel:It,required:dt,reversed:dt,rows:Te,rowSpan:Te,sandbox:It,scope:null,scoped:dt,seamless:dt,selected:dt,shadowRootClonable:dt,shadowRootDelegatesFocus:dt,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:dn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:dt,useMap:null,value:dn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:It,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dt,declare:dt,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:dt,noHref:dt,noShade:dt,noWrap:dt,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:dn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dt,disableRemotePlayback:dt,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:yS}),hO=ki({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pr,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:It,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:dt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:li,g2:li,glyphName:li,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:pr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Te,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:It,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pr,rev:pr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pr,requiredFeatures:pr,requiredFonts:pr,requiredFormats:pr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:pr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pr,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xS}),bS=ki({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),vS=ki({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yS}),wS=ki({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),gO={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},xO=/[A-Z]/g,mw=/-[a-z]/g,yO=/^data[-\w.:]+$/i;function bO(e,t){const n=Th(t);let s=t,a=ir;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&yO.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(mw,wO);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!mw.test(l)){let c=l.replace(xO,vO);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Zg}return new a(s,t)}function vO(e){return"-"+e.toLowerCase()}function wO(e){return e.charAt(1).toUpperCase()}const jO=hS([gS,mO,bS,vS,wS],"html"),ex=hS([gS,hO,bS,vS,wS],"svg");function kO(e){return e.join(" ").trim()}var Ba={},Dm,hw;function SO(){if(hw)return Dm;hw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,p=`
531
531
  `,m="/",h="*",g="",y="comment",b="declaration";function E(w,k){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];k=k||{};var C=1,N=1;function T(z){var H=z.match(t);H&&(C+=H.length);var ee=z.lastIndexOf(p);N=~ee?z.length-ee:N+z.length}function D(){var z={line:C,column:N};return function(H){return H.position=new R(z),K(),H}}function R(z){this.start=z,this.end={line:C,column:N},this.source=k.source}R.prototype.content=w;function $(z){var H=new Error(k.source+":"+C+":"+N+": "+z);if(H.reason=z,H.filename=k.source,H.line=C,H.column=N,H.source=w,!k.silent)throw H}function L(z){var H=z.exec(w);if(H){var ee=H[0];return T(ee),w=w.slice(ee.length),H}}function K(){L(n)}function B(z){var H;for(z=z||[];H=O();)H!==!1&&z.push(H);return z}function O(){var z=D();if(!(m!=w.charAt(0)||h!=w.charAt(1))){for(var H=2;g!=w.charAt(H)&&(h!=w.charAt(H)||m!=w.charAt(H+1));)++H;if(H+=2,g===w.charAt(H-1))return $("End of comment missing");var ee=w.slice(2,H-2);return N+=2,T(ee),w=w.slice(H),N+=2,z({type:y,comment:ee})}}function W(){var z=D(),H=L(s);if(H){if(O(),!L(a))return $("property missing ':'");var ee=L(l),ne=z({type:b,property:j(H[0].replace(e,g)),value:ee?j(ee[0].replace(e,g)):g});return L(c),ne}}function se(){var z=[];B(z);for(var H;H=W();)H!==!1&&(z.push(H),B(z));return z}return K(),se()}function j(w){return w?w.replace(u,g):g}return Dm=E,Dm}var gw;function NO(){if(gw)return Ba;gw=1;var e=Ba&&Ba.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.default=n;const t=e(SO());function n(s,a){let l=null;if(!s||typeof s!="string")return l;const c=(0,t.default)(s),u=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:m,value:h}=p;u?a(m,h,p):h&&(l=l||{},l[m]=h)}),l}return Ba}var yl={},xw;function CO(){if(xw)return yl;xw=1,Object.defineProperty(yl,"__esModule",{value:!0}),yl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(m){return!m||n.test(m)||e.test(m)},c=function(m,h){return h.toUpperCase()},u=function(m,h){return"".concat(h,"-")},p=function(m,h){return h===void 0&&(h={}),l(m)?m:(m=m.toLowerCase(),h.reactCompat?m=m.replace(a,u):m=m.replace(s,u),m.replace(t,c))};return yl.camelCase=p,yl}var bl,yw;function EO(){if(yw)return bl;yw=1;var e=bl&&bl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(NO()),n=CO();function s(a,l){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(u,p){u&&p&&(c[(0,n.camelCase)(u,l)]=p)}),c}return s.default=s,bl=s,bl}var TO=EO();const RO=Td(TO),jS=kS("end"),tx=kS("start");function kS(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function PO(e){const t=tx(e),n=jS(e);if(t&&n)return{start:t,end:n}}function Al(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?bw(e.position):"start"in e||"end"in e?bw(e):"line"in e||"column"in e?Ah(e):""}function Ah(e){return vw(e&&e.line)+":"+vw(e&&e.column)}function bw(e){return Ah(e&&e.start)+"-"+Ah(e&&e.end)}function vw(e){return e&&typeof e=="number"?e:1}class zn extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",l={},c=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(c=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?l.ruleId=s:(l.source=s.slice(0,p),l.ruleId=s.slice(p+1))}if(!l.place&&l.ancestors&&l.ancestors){const p=l.ancestors[l.ancestors.length-1];p&&(l.place=p.position)}const u=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=u?u.line:void 0,this.name=Al(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}zn.prototype.file="";zn.prototype.name="";zn.prototype.reason="";zn.prototype.message="";zn.prototype.stack="";zn.prototype.column=void 0;zn.prototype.line=void 0;zn.prototype.ancestors=void 0;zn.prototype.cause=void 0;zn.prototype.fatal=void 0;zn.prototype.place=void 0;zn.prototype.ruleId=void 0;zn.prototype.source=void 0;const nx={}.hasOwnProperty,AO=new Map,DO=/[A-Z]/g,$O=new Set(["table","tbody","thead","tfoot","tr"]),LO=new Set(["td","th"]),SS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function OO(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=VO(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=UO(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ex:jO,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=NS(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function NS(e,t,n){if(t.type==="element")return IO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return MO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return FO(e,t,n);if(t.type==="mdxjsEsm")return _O(e,t);if(t.type==="root")return zO(e,t,n);if(t.type==="text")return BO(e,t)}function IO(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=ex,e.schema=a),e.ancestors.push(t);const l=ES(e,t.tagName,!1),c=HO(e,t);let u=sx(e,t);return $O.has(t.tagName)&&(u=u.filter(function(p){return typeof p=="string"?!fO(p):!0})),CS(e,c,l,t),rx(c,u),e.ancestors.pop(),e.schema=s,e.create(t,l,c,n)}function MO(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}ql(e,t.position)}function _O(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ql(e,t.position)}function FO(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=ex,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:ES(e,t.name,!0),c=WO(e,t),u=sx(e,t);return CS(e,c,l,t),rx(c,u),e.ancestors.pop(),e.schema=s,e.create(t,l,c,n)}function zO(e,t,n){const s={};return rx(s,sx(e,t)),e.create(t,e.Fragment,s,n)}function BO(e,t){return t.value}function CS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function rx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function UO(e,t,n){return s;function s(a,l,c,u){const m=Array.isArray(c.children)?n:t;return u?m(l,c,u):m(l,c)}}function VO(e,t){return n;function n(s,a,l,c){const u=Array.isArray(l.children),p=tx(s);return t(a,l,c,u,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function HO(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&nx.call(t.properties,a)){const l=KO(e,a,t.properties[a]);if(l){const[c,u]=l;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&LO.has(t.tagName)?s=u:n[c]=u}}if(s){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function WO(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const l=s.data.estree.body[0];l.type;const c=l.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else ql(e,t.position);else{const a=s.name;let l;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const u=s.value.data.estree.body[0];u.type,l=e.evaluater.evaluateExpression(u.expression)}else ql(e,t.position);else l=s.value===null?!0:s.value;n[a]=l}return n}function sx(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:AO;for(;++s<t.children.length;){const l=t.children[s];let c;if(e.passKeys){const p=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(p){const m=a.get(p)||0;c=p+"-"+m,a.set(p,m+1)}}const u=NS(e,l,c);u!==void 0&&n.push(u)}return n}function KO(e,t,n){const s=bO(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?iO(n):kO(n)),s.property==="style"){let a=typeof n=="object"?n:qO(e,String(n));return e.stylePropertyNameCase==="css"&&(a=GO(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?gO[s.property]||s.property:s.attribute,n]}}function qO(e,t){try{return RO(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,a=new zn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=SS+"#cannot-parse-style-attribute",a}}function ES(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,c;for(;++l<a.length;){const u=dw(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(l&&u.type==="Literal"),optional:!1}:u}s=c}else s=dw(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return nx.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);ql(e)}function ql(e,t){const n=new zn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=SS+"#cannot-handle-mdx-estrees-without-createevaluater",n}function GO(e){const t={};let n;for(n in e)nx.call(e,n)&&(t[YO(n)]=e[n]);return t}function YO(e){let t=e.replace(DO,JO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function JO(e){return"-"+e.toLowerCase()}const $m={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},XO={};function QO(e,t){const n=XO,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return TS(e,s,a)}function TS(e,t,n){if(ZO(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return ww(e.children,t,n)}return Array.isArray(e)?ww(e,t,n):""}function ww(e,t,n){const s=[];let a=-1;for(;++a<e.length;)s[a]=TS(e[a],t,n);return s.join("")}function ZO(e){return!!(e&&typeof e=="object")}const jw=document.createElement("i");function ox(e){const t="&"+e+";";jw.innerHTML=t;const n=jw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ps(e,t,n,s){const a=e.length;let l=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<s.length;)c=s.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function Rr(e,t){return e.length>0?(ps(e,e.length,0,t),e):t}const kw={}.hasOwnProperty;function eI(e){const t={};let n=-1;for(;++n<e.length;)tI(t,e[n]);return t}function tI(e,t){let n;for(n in t){const a=(kw.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){kw.call(a,c)||(a[c]=[]);const u=l[c];nI(a[c],Array.isArray(u)?u:u?[u]:[])}}}function nI(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);ps(e,0,0,s)}function RS(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function ci(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ls=ho(/[A-Za-z]/),xr=ho(/[\dA-Za-z]/),rI=ho(/[#-'*+\--9=?A-Z^-~]/);function Dh(e){return e!==null&&(e<32||e===127)}const $h=ho(/\d/),sI=ho(/[\dA-Fa-f]/),oI=ho(/[!-/:-@[-`{-~]/);function st(e){return e!==null&&e<-2}function sr(e){return e!==null&&(e<0||e===32)}function Tt(e){return e===-2||e===-1||e===32}const aI=ho(new RegExp("\\p{P}|\\p{S}","u")),iI=ho(/\s/);function ho(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Si(e){const t=[];let n=-1,s=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&xr(e.charCodeAt(n+1))&&xr(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const u=e.charCodeAt(n+1);l<56320&&u>56319&&u<57344?(c=String.fromCharCode(l,u),a=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Mt(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(p){return Tt(p)?(e.enter(n),u(p)):t(p)}function u(p){return Tt(p)&&l++<a?(e.consume(p),u):(e.exit(n),t(p))}}const lI={tokenize:cI};function cI(e){const t=e.attempt(this.parser.constructs.contentInitial,s,a);let n;return t;function s(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Mt(e,t,"linePrefix")}function a(u){return e.enter("paragraph"),l(u)}function l(u){const p=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=p),n=p,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return st(u)?(e.consume(u),e.exit("chunkText"),l):(e.consume(u),c)}}const uI={tokenize:dI},Sw={tokenize:fI};function dI(e){const t=this,n=[];let s=0,a,l,c;return u;function u(N){if(s<n.length){const T=n[s];return t.containerState=T[1],e.attempt(T[0].continuation,p,m)(N)}return m(N)}function p(N){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&C();const T=t.events.length;let D=T,R;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){R=t.events[D][1].end;break}k(s);let $=T;for(;$<t.events.length;)t.events[$][1].end={...R},$++;return ps(t.events,D+1,0,t.events.slice(T)),t.events.length=$,m(N)}return u(N)}function m(N){if(s===n.length){if(!a)return y(N);if(a.currentConstruct&&a.currentConstruct.concrete)return E(N);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sw,h,g)(N)}function h(N){return a&&C(),k(s),y(N)}function g(N){return t.parser.lazy[t.now().line]=s!==n.length,c=t.now().offset,E(N)}function y(N){return t.containerState={},e.attempt(Sw,b,E)(N)}function b(N){return s++,n.push([t.currentConstruct,t.containerState]),y(N)}function E(N){if(N===null){a&&C(),k(0),e.consume(N);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),j(N)}function j(N){if(N===null){w(e.exit("chunkFlow"),!0),k(0),e.consume(N);return}return st(N)?(e.consume(N),w(e.exit("chunkFlow")),s=0,t.interrupt=void 0,u):(e.consume(N),j)}function w(N,T){const D=t.sliceStream(N);if(T&&D.push(null),N.previous=l,l&&(l.next=N),l=N,a.defineSkip(N.start),a.write(D),t.parser.lazy[N.start.line]){let R=a.events.length;for(;R--;)if(a.events[R][1].start.offset<c&&(!a.events[R][1].end||a.events[R][1].end.offset>c))return;const $=t.events.length;let L=$,K,B;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(K){B=t.events[L][1].end;break}K=!0}for(k(s),R=$;R<t.events.length;)t.events[R][1].end={...B},R++;ps(t.events,L+1,0,t.events.slice($)),t.events.length=R}}function k(N){let T=n.length;for(;T-- >N;){const D=n[T];t.containerState=D[1],D[0].exit.call(t,e)}n.length=N}function C(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function fI(e,t,n){return Mt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Nw(e){if(e===null||sr(e)||iI(e))return 1;if(aI(e))return 2}function ax(e,t,n){const s=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!s.includes(l)&&(t=l(t,n),s.push(l))}return t}const Lh={name:"attention",resolveAll:pI,tokenize:mI};function pI(e,t){let n=-1,s,a,l,c,u,p,m,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;p=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[s][1].end},y={...e[n][1].start};Cw(g,-p),Cw(y,p),c={type:p>1?"strongSequence":"emphasisSequence",start:g,end:{...e[s][1].end}},u={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},l={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[s][1].end={...c.start},e[n][1].start={...u.end},m=[],e[s][1].end.offset-e[s][1].start.offset&&(m=Rr(m,[["enter",e[s][1],t],["exit",e[s][1],t]])),m=Rr(m,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",l,t]]),m=Rr(m,ax(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),m=Rr(m,[["exit",l,t],["enter",u,t],["exit",u,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,m=Rr(m,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,ps(e,s-1,n-s+3,m),n=s+m.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function mI(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Nw(s);let l;return c;function c(p){return l=p,e.enter("attentionSequence"),u(p)}function u(p){if(p===l)return e.consume(p),u;const m=e.exit("attentionSequence"),h=Nw(p),g=!h||h===2&&a||n.includes(p),y=!a||a===2&&h||n.includes(s);return m._open=!!(l===42?g:g&&(a||!y)),m._close=!!(l===42?y:y&&(h||!g)),t(p)}}function Cw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const hI={name:"autolink",tokenize:gI};function gI(e,t,n){let s=0;return a;function a(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(b){return ls(b)?(e.consume(b),c):b===64?n(b):m(b)}function c(b){return b===43||b===45||b===46||xr(b)?(s=1,u(b)):m(b)}function u(b){return b===58?(e.consume(b),s=0,p):(b===43||b===45||b===46||xr(b))&&s++<32?(e.consume(b),u):(s=0,m(b))}function p(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||Dh(b)?n(b):(e.consume(b),p)}function m(b){return b===64?(e.consume(b),h):rI(b)?(e.consume(b),m):n(b)}function h(b){return xr(b)?g(b):n(b)}function g(b){return b===46?(e.consume(b),s=0,h):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):y(b)}function y(b){if((b===45||xr(b))&&s++<63){const E=b===45?y:g;return e.consume(b),E}return n(b)}}const sf={partial:!0,tokenize:xI};function xI(e,t,n){return s;function s(l){return Tt(l)?Mt(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||st(l)?t(l):n(l)}}const PS={continuation:{tokenize:bI},exit:vI,name:"blockQuote",tokenize:yI};function yI(e,t,n){const s=this;return a;function a(c){if(c===62){const u=s.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return Tt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function bI(e,t,n){const s=this;return a;function a(c){return Tt(c)?Mt(e,l,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(PS,t,n)(c)}}function vI(e){e.exit("blockQuote")}const AS={name:"characterEscape",tokenize:wI};function wI(e,t,n){return s;function s(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return oI(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const DS={name:"characterReference",tokenize:jI};function jI(e,t,n){const s=this;let a=0,l,c;return u;function u(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),p}function p(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),m):(e.enter("characterReferenceValue"),l=31,c=xr,h(g))}function m(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=sI,h):(e.enter("characterReferenceValue"),l=7,c=$h,h(g))}function h(g){if(g===59&&a){const y=e.exit("characterReferenceValue");return c===xr&&!ox(s.sliceSerialize(y))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&a++<l?(e.consume(g),h):n(g)}}const Ew={partial:!0,tokenize:SI},Tw={concrete:!0,name:"codeFenced",tokenize:kI};function kI(e,t,n){const s=this,a={partial:!0,tokenize:D};let l=0,c=0,u;return p;function p(R){return m(R)}function m(R){const $=s.events[s.events.length-1];return l=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,u=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(R)}function h(R){return R===u?(c++,e.consume(R),h):c<3?n(R):(e.exit("codeFencedFenceSequence"),Tt(R)?Mt(e,g,"whitespace")(R):g(R))}function g(R){return R===null||st(R)?(e.exit("codeFencedFence"),s.interrupt?t(R):e.check(Ew,j,T)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(R))}function y(R){return R===null||st(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):Tt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Mt(e,b,"whitespace")(R)):R===96&&R===u?n(R):(e.consume(R),y)}function b(R){return R===null||st(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),E(R))}function E(R){return R===null||st(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===u?n(R):(e.consume(R),E)}function j(R){return e.attempt(a,T,w)(R)}function w(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),k}function k(R){return l>0&&Tt(R)?Mt(e,C,"linePrefix",l+1)(R):C(R)}function C(R){return R===null||st(R)?e.check(Ew,j,T)(R):(e.enter("codeFlowValue"),N(R))}function N(R){return R===null||st(R)?(e.exit("codeFlowValue"),C(R)):(e.consume(R),N)}function T(R){return e.exit("codeFenced"),t(R)}function D(R,$,L){let K=0;return B;function B(H){return R.enter("lineEnding"),R.consume(H),R.exit("lineEnding"),O}function O(H){return R.enter("codeFencedFence"),Tt(H)?Mt(R,W,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):W(H)}function W(H){return H===u?(R.enter("codeFencedFenceSequence"),se(H)):L(H)}function se(H){return H===u?(K++,R.consume(H),se):K>=c?(R.exit("codeFencedFenceSequence"),Tt(H)?Mt(R,z,"whitespace")(H):z(H)):L(H)}function z(H){return H===null||st(H)?(R.exit("codeFencedFence"),$(H)):L(H)}}}function SI(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const Lm={name:"codeIndented",tokenize:CI},NI={partial:!0,tokenize:EI};function CI(e,t,n){const s=this;return a;function a(m){return e.enter("codeIndented"),Mt(e,l,"linePrefix",5)(m)}function l(m){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?c(m):n(m)}function c(m){return m===null?p(m):st(m)?e.attempt(NI,c,p)(m):(e.enter("codeFlowValue"),u(m))}function u(m){return m===null||st(m)?(e.exit("codeFlowValue"),c(m)):(e.consume(m),u)}function p(m){return e.exit("codeIndented"),t(m)}}function EI(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):st(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Mt(e,l,"linePrefix",5)(c)}function l(c){const u=s.events[s.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):st(c)?a(c):n(c)}}const TI={name:"codeText",previous:PI,resolve:RI,tokenize:AI};function RI(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)a===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(a=s):(s===t||e[s][1].type==="lineEnding")&&(e[a][1].type="codeTextData",s!==a+2&&(e[a][1].end=e[s-1][1].end,e.splice(a+2,s-a-2),t-=s-a-2,s=a+2),a=void 0);return e}function PI(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function AI(e,t,n){let s=0,a,l;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),s++,u):(e.exit("codeTextSequence"),p(g))}function p(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),p):g===96?(l=e.enter("codeTextSequence"),a=0,h(g)):st(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),p):(e.enter("codeTextData"),m(g))}function m(g){return g===null||g===32||g===96||st(g)?(e.exit("codeTextData"),p(g)):(e.consume(g),m)}function h(g){return g===96?(e.consume(g),a++,h):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(l.type="codeTextData",m(g))}}class DI{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&vl(this.left,s),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),vl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),vl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);vl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);vl(this.left,n.reverse())}}}function vl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function $S(e){const t={};let n=-1,s,a,l,c,u,p,m;const h=new DI(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(s=h.get(n),n&&s[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(p=s[1]._tokenizer.events,l=0,l<p.length&&p[l][1].type==="lineEndingBlank"&&(l+=2),l<p.length&&p[l][1].type==="content"))for(;++l<p.length&&p[l][1].type!=="content";)p[l][1].type==="chunkText"&&(p[l][1]._isInFirstContentOfListItem=!0,l++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,$I(h,n)),n=t[n],m=!0);else if(s[1]._container){for(l=n,a=void 0;l--;)if(c=h.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(h.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(s[1].end={...h.get(a)[1].start},u=h.slice(a,n),u.unshift(s),h.splice(a,n-a+1,u))}}return ps(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!m}function $I(e,t){const n=e.get(t)[1],s=e.get(t)[2];let a=t-1;const l=[];let c=n._tokenizer;c||(c=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,p=[],m={};let h,g,y=-1,b=n,E=0,j=0;const w=[j];for(;b;){for(;e.get(++a)[1]!==b;);l.push(a),b._tokenizer||(h=s.sliceStream(b),b.next||h.push(null),g&&c.defineSkip(b.start),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(h),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=n;++y<u.length;)u[y][0]==="exit"&&u[y-1][0]==="enter"&&u[y][1].type===u[y-1][1].type&&u[y][1].start.line!==u[y][1].end.line&&(j=y+1,w.push(j),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(c.events=[],b?(b._tokenizer=void 0,b.previous=void 0):w.pop(),y=w.length;y--;){const k=u.slice(w[y],w[y+1]),C=l.pop();p.push([C,C+k.length-1]),e.splice(C,2,k)}for(p.reverse(),y=-1;++y<p.length;)m[E+p[y][0]]=E+p[y][1],E+=p[y][1]-p[y][0]-1;return m}const LI={resolve:II,tokenize:MI},OI={partial:!0,tokenize:_I};function II(e){return $S(e),e}function MI(e,t){let n;return s;function s(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(u)}function a(u){return u===null?l(u):st(u)?e.check(OI,c,l)(u):(e.consume(u),a)}function l(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function _I(e,t,n){const s=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Mt(e,l,"linePrefix")}function l(c){if(c===null||st(c))return n(c);const u=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function LS(e,t,n,s,a,l,c,u,p){const m=p||Number.POSITIVE_INFINITY;let h=0;return g;function g(k){return k===60?(e.enter(s),e.enter(a),e.enter(l),e.consume(k),e.exit(l),y):k===null||k===32||k===41||Dh(k)?n(k):(e.enter(s),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),j(k))}function y(k){return k===62?(e.enter(l),e.consume(k),e.exit(l),e.exit(a),e.exit(s),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),b(k))}function b(k){return k===62?(e.exit("chunkString"),e.exit(u),y(k)):k===null||k===60||st(k)?n(k):(e.consume(k),k===92?E:b)}function E(k){return k===60||k===62||k===92?(e.consume(k),b):b(k)}function j(k){return!h&&(k===null||k===41||sr(k))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(s),t(k)):h<m&&k===40?(e.consume(k),h++,j):k===41?(e.consume(k),h--,j):k===null||k===32||k===40||Dh(k)?n(k):(e.consume(k),k===92?w:j)}function w(k){return k===40||k===41||k===92?(e.consume(k),j):j(k)}}function OS(e,t,n,s,a,l){const c=this;let u=0,p;return m;function m(b){return e.enter(s),e.enter(a),e.consume(b),e.exit(a),e.enter(l),h}function h(b){return u>999||b===null||b===91||b===93&&!p||b===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(b):b===93?(e.exit(l),e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):st(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||b===91||b===93||st(b)||u++>999?(e.exit("chunkString"),h(b)):(e.consume(b),p||(p=!Tt(b)),b===92?y:g)}function y(b){return b===91||b===92||b===93?(e.consume(b),u++,g):g(b)}}function IS(e,t,n,s,a,l){let c;return u;function u(y){return y===34||y===39||y===40?(e.enter(s),e.enter(a),e.consume(y),e.exit(a),c=y===40?41:y,p):n(y)}function p(y){return y===c?(e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):(e.enter(l),m(y))}function m(y){return y===c?(e.exit(l),p(c)):y===null?n(y):st(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Mt(e,m,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===c||y===null||st(y)?(e.exit("chunkString"),m(y)):(e.consume(y),y===92?g:h)}function g(y){return y===c||y===92?(e.consume(y),h):h(y)}}function Dl(e,t){let n;return s;function s(a){return st(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Tt(a)?Mt(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const FI={name:"definition",tokenize:BI},zI={partial:!0,tokenize:UI};function BI(e,t,n){const s=this;let a;return l;function l(b){return e.enter("definition"),c(b)}function c(b){return OS.call(s,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function u(b){return a=ci(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),p):n(b)}function p(b){return sr(b)?Dl(e,m)(b):m(b)}function m(b){return LS(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function h(b){return e.attempt(zI,g,g)(b)}function g(b){return Tt(b)?Mt(e,y,"whitespace")(b):y(b)}function y(b){return b===null||st(b)?(e.exit("definition"),s.parser.defined.push(a),t(b)):n(b)}}function UI(e,t,n){return s;function s(u){return sr(u)?Dl(e,a)(u):n(u)}function a(u){return IS(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function l(u){return Tt(u)?Mt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||st(u)?t(u):n(u)}}const VI={name:"hardBreakEscape",tokenize:HI};function HI(e,t,n){return s;function s(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return st(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const WI={name:"headingAtx",resolve:KI,tokenize:qI};function KI(e,t){let n=e.length-2,s=3,a,l;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},l={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},ps(e,s,n-s+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function qI(e,t,n){let s=0;return a;function a(h){return e.enter("atxHeading"),l(h)}function l(h){return e.enter("atxHeadingSequence"),c(h)}function c(h){return h===35&&s++<6?(e.consume(h),c):h===null||sr(h)?(e.exit("atxHeadingSequence"),u(h)):n(h)}function u(h){return h===35?(e.enter("atxHeadingSequence"),p(h)):h===null||st(h)?(e.exit("atxHeading"),t(h)):Tt(h)?Mt(e,u,"whitespace")(h):(e.enter("atxHeadingText"),m(h))}function p(h){return h===35?(e.consume(h),p):(e.exit("atxHeadingSequence"),u(h))}function m(h){return h===null||h===35||sr(h)?(e.exit("atxHeadingText"),u(h)):(e.consume(h),m)}}const GI=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Rw=["pre","script","style","textarea"],YI={concrete:!0,name:"htmlFlow",resolveTo:QI,tokenize:ZI},JI={partial:!0,tokenize:t5},XI={partial:!0,tokenize:e5};function QI(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ZI(e,t,n){const s=this;let a,l,c,u,p;return m;function m(I){return h(I)}function h(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),g}function g(I){return I===33?(e.consume(I),y):I===47?(e.consume(I),l=!0,j):I===63?(e.consume(I),a=3,s.interrupt?t:A):ls(I)?(e.consume(I),c=String.fromCharCode(I),w):n(I)}function y(I){return I===45?(e.consume(I),a=2,b):I===91?(e.consume(I),a=5,u=0,E):ls(I)?(e.consume(I),a=4,s.interrupt?t:A):n(I)}function b(I){return I===45?(e.consume(I),s.interrupt?t:A):n(I)}function E(I){const de="CDATA[";return I===de.charCodeAt(u++)?(e.consume(I),u===de.length?s.interrupt?t:W:E):n(I)}function j(I){return ls(I)?(e.consume(I),c=String.fromCharCode(I),w):n(I)}function w(I){if(I===null||I===47||I===62||sr(I)){const de=I===47,ge=c.toLowerCase();return!de&&!l&&Rw.includes(ge)?(a=1,s.interrupt?t(I):W(I)):GI.includes(c.toLowerCase())?(a=6,de?(e.consume(I),k):s.interrupt?t(I):W(I)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(I):l?C(I):N(I))}return I===45||xr(I)?(e.consume(I),c+=String.fromCharCode(I),w):n(I)}function k(I){return I===62?(e.consume(I),s.interrupt?t:W):n(I)}function C(I){return Tt(I)?(e.consume(I),C):B(I)}function N(I){return I===47?(e.consume(I),B):I===58||I===95||ls(I)?(e.consume(I),T):Tt(I)?(e.consume(I),N):B(I)}function T(I){return I===45||I===46||I===58||I===95||xr(I)?(e.consume(I),T):D(I)}function D(I){return I===61?(e.consume(I),R):Tt(I)?(e.consume(I),D):N(I)}function R(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),p=I,$):Tt(I)?(e.consume(I),R):L(I)}function $(I){return I===p?(e.consume(I),p=null,K):I===null||st(I)?n(I):(e.consume(I),$)}function L(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||sr(I)?D(I):(e.consume(I),L)}function K(I){return I===47||I===62||Tt(I)?N(I):n(I)}function B(I){return I===62?(e.consume(I),O):n(I)}function O(I){return I===null||st(I)?W(I):Tt(I)?(e.consume(I),O):n(I)}function W(I){return I===45&&a===2?(e.consume(I),ee):I===60&&a===1?(e.consume(I),ne):I===62&&a===4?(e.consume(I),F):I===63&&a===3?(e.consume(I),A):I===93&&a===5?(e.consume(I),G):st(I)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(JI,Z,se)(I)):I===null||st(I)?(e.exit("htmlFlowData"),se(I)):(e.consume(I),W)}function se(I){return e.check(XI,z,Z)(I)}function z(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),H}function H(I){return I===null||st(I)?se(I):(e.enter("htmlFlowData"),W(I))}function ee(I){return I===45?(e.consume(I),A):W(I)}function ne(I){return I===47?(e.consume(I),c="",M):W(I)}function M(I){if(I===62){const de=c.toLowerCase();return Rw.includes(de)?(e.consume(I),F):W(I)}return ls(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),M):W(I)}function G(I){return I===93?(e.consume(I),A):W(I)}function A(I){return I===62?(e.consume(I),F):I===45&&a===2?(e.consume(I),A):W(I)}function F(I){return I===null||st(I)?(e.exit("htmlFlowData"),Z(I)):(e.consume(I),F)}function Z(I){return e.exit("htmlFlow"),t(I)}}function e5(e,t,n){const s=this;return a;function a(c){return st(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function t5(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(sf,t,n)}}const n5={name:"htmlText",tokenize:r5};function r5(e,t,n){const s=this;let a,l,c;return u;function u(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),p}function p(A){return A===33?(e.consume(A),m):A===47?(e.consume(A),D):A===63?(e.consume(A),N):ls(A)?(e.consume(A),L):n(A)}function m(A){return A===45?(e.consume(A),h):A===91?(e.consume(A),l=0,E):ls(A)?(e.consume(A),C):n(A)}function h(A){return A===45?(e.consume(A),b):n(A)}function g(A){return A===null?n(A):A===45?(e.consume(A),y):st(A)?(c=g,ne(A)):(e.consume(A),g)}function y(A){return A===45?(e.consume(A),b):g(A)}function b(A){return A===62?ee(A):A===45?y(A):g(A)}function E(A){const F="CDATA[";return A===F.charCodeAt(l++)?(e.consume(A),l===F.length?j:E):n(A)}function j(A){return A===null?n(A):A===93?(e.consume(A),w):st(A)?(c=j,ne(A)):(e.consume(A),j)}function w(A){return A===93?(e.consume(A),k):j(A)}function k(A){return A===62?ee(A):A===93?(e.consume(A),k):j(A)}function C(A){return A===null||A===62?ee(A):st(A)?(c=C,ne(A)):(e.consume(A),C)}function N(A){return A===null?n(A):A===63?(e.consume(A),T):st(A)?(c=N,ne(A)):(e.consume(A),N)}function T(A){return A===62?ee(A):N(A)}function D(A){return ls(A)?(e.consume(A),R):n(A)}function R(A){return A===45||xr(A)?(e.consume(A),R):$(A)}function $(A){return st(A)?(c=$,ne(A)):Tt(A)?(e.consume(A),$):ee(A)}function L(A){return A===45||xr(A)?(e.consume(A),L):A===47||A===62||sr(A)?K(A):n(A)}function K(A){return A===47?(e.consume(A),ee):A===58||A===95||ls(A)?(e.consume(A),B):st(A)?(c=K,ne(A)):Tt(A)?(e.consume(A),K):ee(A)}function B(A){return A===45||A===46||A===58||A===95||xr(A)?(e.consume(A),B):O(A)}function O(A){return A===61?(e.consume(A),W):st(A)?(c=O,ne(A)):Tt(A)?(e.consume(A),O):K(A)}function W(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),a=A,se):st(A)?(c=W,ne(A)):Tt(A)?(e.consume(A),W):(e.consume(A),z)}function se(A){return A===a?(e.consume(A),a=void 0,H):A===null?n(A):st(A)?(c=se,ne(A)):(e.consume(A),se)}function z(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||sr(A)?K(A):(e.consume(A),z)}function H(A){return A===47||A===62||sr(A)?K(A):n(A)}function ee(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function ne(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),M}function M(A){return Tt(A)?Mt(e,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):G(A)}function G(A){return e.enter("htmlTextData"),c(A)}}const ix={name:"labelEnd",resolveAll:i5,resolveTo:l5,tokenize:c5},s5={tokenize:u5},o5={tokenize:d5},a5={tokenize:f5};function i5(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",t+=a}}return e.length!==n.length&&ps(e,0,e.length,n),e}function l5(e,t){let n=e.length,s=0,a,l,c,u;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(c=n);const p={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},m={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},h={type:"labelText",start:{...e[l+s+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",p,t],["enter",m,t]],u=Rr(u,e.slice(l+1,l+s+3)),u=Rr(u,[["enter",h,t]]),u=Rr(u,ax(t.parser.constructs.insideSpan.null,e.slice(l+s+4,c-3),t)),u=Rr(u,[["exit",h,t],e[c-2],e[c-1],["exit",m,t]]),u=Rr(u,e.slice(c+1)),u=Rr(u,[["exit",p,t]]),ps(e,l,e.length,u),e}function c5(e,t,n){const s=this;let a=s.events.length,l,c;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){l=s.events[a][1];break}return u;function u(y){return l?l._inactive?g(y):(c=s.parser.defined.includes(ci(s.sliceSerialize({start:l.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),p):n(y)}function p(y){return y===40?e.attempt(s5,h,c?h:g)(y):y===91?e.attempt(o5,h,c?m:g)(y):c?h(y):g(y)}function m(y){return e.attempt(a5,h,g)(y)}function h(y){return t(y)}function g(y){return l._balanced=!0,n(y)}}function u5(e,t,n){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),a}function a(g){return sr(g)?Dl(e,l)(g):l(g)}function l(g){return g===41?h(g):LS(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return sr(g)?Dl(e,p)(g):h(g)}function u(g){return n(g)}function p(g){return g===34||g===39||g===40?IS(e,m,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):h(g)}function m(g){return sr(g)?Dl(e,h)(g):h(g)}function h(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function d5(e,t,n){const s=this;return a;function a(u){return OS.call(s,e,l,c,"reference","referenceMarker","referenceString")(u)}function l(u){return s.parser.defined.includes(ci(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function f5(e,t,n){return s;function s(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const p5={name:"labelStartImage",resolveAll:ix.resolveAll,tokenize:m5};function m5(e,t,n){const s=this;return a;function a(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),l}function l(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(u):t(u)}}const h5={name:"labelStartLink",resolveAll:ix.resolveAll,tokenize:g5};function g5(e,t,n){const s=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(c):t(c)}}const Om={name:"lineEnding",tokenize:x5};function x5(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Mt(e,t,"linePrefix")}}const Ju={name:"thematicBreak",tokenize:y5};function y5(e,t,n){let s=0,a;return l;function l(m){return e.enter("thematicBreak"),c(m)}function c(m){return a=m,u(m)}function u(m){return m===a?(e.enter("thematicBreakSequence"),p(m)):s>=3&&(m===null||st(m))?(e.exit("thematicBreak"),t(m)):n(m)}function p(m){return m===a?(e.consume(m),s++,p):(e.exit("thematicBreakSequence"),Tt(m)?Mt(e,u,"whitespace")(m):u(m))}}const tr={continuation:{tokenize:j5},exit:S5,name:"list",tokenize:w5},b5={partial:!0,tokenize:N5},v5={partial:!0,tokenize:k5};function w5(e,t,n){const s=this,a=s.events[s.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return u;function u(b){const E=s.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(E==="listUnordered"?!s.containerState.marker||b===s.containerState.marker:$h(b)){if(s.containerState.type||(s.containerState.type=E,e.enter(E,{_container:!0})),E==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Ju,n,m)(b):m(b);if(!s.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(b)}return n(b)}function p(b){return $h(b)&&++c<10?(e.consume(b),p):(!s.interrupt||c<2)&&(s.containerState.marker?b===s.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),m(b)):n(b)}function m(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||b,e.check(sf,s.interrupt?n:h,e.attempt(b5,y,g))}function h(b){return s.containerState.initialBlankLine=!0,l++,y(b)}function g(b){return Tt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),y):n(b)}function y(b){return s.containerState.size=l+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function j5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(sf,a,l);function a(u){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Mt(e,t,"listItemIndent",s.containerState.size+1)(u)}function l(u){return s.containerState.furtherBlankLines||!Tt(u)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(u)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(v5,t,c)(u))}function c(u){return s.containerState._closeFlow=!0,s.interrupt=void 0,Mt(e,e.attempt(tr,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function k5(e,t,n){const s=this;return Mt(e,a,"listItemIndent",s.containerState.size+1);function a(l){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(l):n(l)}}function S5(e){e.exit(this.containerState.type)}function N5(e,t,n){const s=this;return Mt(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const c=s.events[s.events.length-1];return!Tt(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Pw={name:"setextUnderline",resolveTo:C5,tokenize:E5};function C5(e,t){let n=e.length,s,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",c,t]),e.splice(l+1,0,["exit",e[s][1],t]),e[s][1].end={...e[l][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function E5(e,t,n){const s=this;let a;return l;function l(m){let h=s.events.length,g;for(;h--;)if(s.events[h][1].type!=="lineEnding"&&s.events[h][1].type!=="linePrefix"&&s.events[h][1].type!=="content"){g=s.events[h][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),a=m,c(m)):n(m)}function c(m){return e.enter("setextHeadingLineSequence"),u(m)}function u(m){return m===a?(e.consume(m),u):(e.exit("setextHeadingLineSequence"),Tt(m)?Mt(e,p,"lineSuffix")(m):p(m))}function p(m){return m===null||st(m)?(e.exit("setextHeadingLine"),t(m)):n(m)}}const T5={tokenize:R5};function R5(e){const t=this,n=e.attempt(sf,s,e.attempt(this.parser.constructs.flowInitial,a,Mt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(LI,a)),"linePrefix")));return n;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const P5={resolveAll:_S()},A5=MS("string"),D5=MS("text");function MS(e){return{resolveAll:_S(e==="text"?$5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],l=n.attempt(a,c,u);return c;function c(h){return m(h)?l(h):u(h)}function u(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),p}function p(h){return m(h)?(n.exit("data"),l(h)):(n.consume(h),p)}function m(h){if(h===null)return!0;const g=a[h];let y=-1;if(g)for(;++y<g.length;){const b=g[y];if(!b.previous||b.previous.call(s,s.previous))return!0}return!1}}}function _S(e){return t;function t(n,s){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,s):n}}function $5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let l=a.length,c=-1,u=0,p;for(;l--;){const m=a[l];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(m===-2)p=!0,u++;else if(m!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const m={type:n===e.length||p||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:s.start._bufferIndex+c,_index:s.start._index+l,line:s.end.line,column:s.end.column-u,offset:s.end.offset-u},end:{...s.end}};s.end={...m.start},s.start.offset===s.end.offset?Object.assign(s,m):(e.splice(n,0,["enter",m,t],["exit",m,t]),n+=2)}n++}return e}const L5={42:tr,43:tr,45:tr,48:tr,49:tr,50:tr,51:tr,52:tr,53:tr,54:tr,55:tr,56:tr,57:tr,62:PS},O5={91:FI},I5={[-2]:Lm,[-1]:Lm,32:Lm},M5={35:WI,42:Ju,45:[Pw,Ju],60:YI,61:Pw,95:Ju,96:Tw,126:Tw},_5={38:DS,92:AS},F5={[-5]:Om,[-4]:Om,[-3]:Om,33:p5,38:DS,42:Lh,60:[hI,n5],91:h5,92:[VI,AS],93:ix,95:Lh,96:TI},z5={null:[Lh,P5]},B5={null:[42,95]},U5={null:[]},V5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:B5,contentInitial:O5,disable:U5,document:L5,flow:M5,flowInitial:I5,insideSpan:z5,string:_5,text:F5},Symbol.toStringTag,{value:"Module"}));function H5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let c=[],u=[];const p={attempt:$(D),check:$(R),consume:C,enter:N,exit:T,interrupt:$(R,{interrupt:!0})},m={code:null,containerState:{},defineSkip:j,events:[],now:E,parser:e,previous:null,sliceSerialize:y,sliceStream:b,write:g};let h=t.tokenize.call(m,p);return t.resolveAll&&l.push(t),m;function g(O){return c=Rr(c,O),w(),c[c.length-1]!==null?[]:(L(t,0),m.events=ax(l,m.events,m),m.events)}function y(O,W){return K5(b(O),W)}function b(O){return W5(c,O)}function E(){const{_bufferIndex:O,_index:W,line:se,column:z,offset:H}=s;return{_bufferIndex:O,_index:W,line:se,column:z,offset:H}}function j(O){a[O.line]=O.column,B()}function w(){let O;for(;s._index<c.length;){const W=c[s._index];if(typeof W=="string")for(O=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===O&&s._bufferIndex<W.length;)k(W.charCodeAt(s._bufferIndex));else k(W)}}function k(O){h=h(O)}function C(O){st(O)?(s.line++,s.column=1,s.offset+=O===-3?2:1,B()):O!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),m.previous=O}function N(O,W){const se=W||{};return se.type=O,se.start=E(),m.events.push(["enter",se,m]),u.push(se),se}function T(O){const W=u.pop();return W.end=E(),m.events.push(["exit",W,m]),W}function D(O,W){L(O,W.from)}function R(O,W){W.restore()}function $(O,W){return se;function se(z,H,ee){let ne,M,G,A;return Array.isArray(z)?Z(z):"tokenize"in z?Z([z]):F(z);function F(V){return ae;function ae(me){const ve=me!==null&&V[me],ke=me!==null&&V.null,he=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(ke)?ke:ke?[ke]:[]];return Z(he)(me)}}function Z(V){return ne=V,M=0,V.length===0?ee:I(V[M])}function I(V){return ae;function ae(me){return A=K(),G=V,V.partial||(m.currentConstruct=V),V.name&&m.parser.constructs.disable.null.includes(V.name)?ge():V.tokenize.call(W?Object.assign(Object.create(m),W):m,p,de,ge)(me)}}function de(V){return O(G,A),H}function ge(V){return A.restore(),++M<ne.length?I(ne[M]):ee}}}function L(O,W){O.resolveAll&&!l.includes(O)&&l.push(O),O.resolve&&ps(m.events,W,m.events.length-W,O.resolve(m.events.slice(W),m)),O.resolveTo&&(m.events=O.resolveTo(m.events,m))}function K(){const O=E(),W=m.previous,se=m.currentConstruct,z=m.events.length,H=Array.from(u);return{from:z,restore:ee};function ee(){s=O,m.previous=W,m.currentConstruct=se,m.events.length=z,u=H,B()}}function B(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function W5(e,t){const n=t.start._index,s=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let c;if(n===a)c=[e[n].slice(s,l)];else{if(c=e.slice(n,a),s>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(s):c.shift()}l>0&&c.push(e[a].slice(0,l))}return c}function K5(e,t){let n=-1;const s=[];let a;for(;++n<e.length;){const l=e[n];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
532
532
  `;break}case-3:{c=`\r
533
533
  `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(l)}a=l===-2,s.push(c)}return s.join("")}function q5(e){const s={constructs:eI([V5,...(e||{}).extensions||[]]),content:a(lI),defined:[],document:a(uI),flow:a(T5),lazy:{},string:a(A5),text:a(D5)};return s;function a(l){return c;function c(u){return H5(s,l,u)}}}function G5(e){for(;!$S(e););return e}const Aw=/[\0\t\n\r]/g;function Y5(){let e=1,t="",n=!0,s;return a;function a(l,c,u){const p=[];let m,h,g,y,b;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),g=0,t="",n&&(l.charCodeAt(0)===65279&&g++,n=void 0);g<l.length;){if(Aw.lastIndex=g,m=Aw.exec(l),y=m&&m.index!==void 0?m.index:l.length,b=l.charCodeAt(y),!m){t=l.slice(g);break}if(b===10&&g===y&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),g<y&&(p.push(l.slice(g,y)),e+=y-g),b){case 0:{p.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,p.push(-2);e++<h;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}g=y+1}return u&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const J5=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function X5(e){return e.replace(J5,Q5)}function Q5(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return RS(n.slice(l?2:1),l?16:10)}return ox(n)||e}const FS={}.hasOwnProperty;function Z5(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),eM(n)(G5(q5(n).document().write(Y5()(e,t,!0))))}function eM(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Xe),autolinkProtocol:K,autolinkEmail:K,atxHeading:l(J),blockQuote:l(ke),characterEscape:K,characterReference:K,codeFenced:l(he),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(he,c),codeText:l(Je,c),codeTextData:K,data:K,codeFlowValue:K,definition:l(Ye),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(ot),hardBreakEscape:l(Ie),hardBreakTrailing:l(Ie),htmlFlow:l(Ne,c),htmlFlowData:K,htmlText:l(Ne,c),htmlTextData:K,image:l(Oe),label:c,link:l(Xe),listItem:l(nt),listItemValue:y,listOrdered:l(Me,g),listUnordered:l(Me),paragraph:l(Ke),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(J),strong:l(gt),thematicBreak:l(at)},exit:{atxHeading:p(),atxHeadingSequence:D,autolink:p(),autolinkEmail:ve,autolinkProtocol:me,blockQuote:p(),characterEscapeValue:B,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:V,characterReference:ae,codeFenced:p(w),codeFencedFence:j,codeFencedFenceInfo:b,codeFencedFenceMeta:E,codeFlowValue:B,codeIndented:p(k),codeText:p(H),codeTextData:B,data:B,definition:p(),definitionDestinationString:T,definitionLabelString:C,definitionTitleString:N,emphasis:p(),hardBreakEscape:p(W),hardBreakTrailing:p(W),htmlFlow:p(se),htmlFlowData:B,htmlText:p(z),htmlTextData:B,image:p(ne),label:G,labelText:M,lineEnding:O,link:p(ee),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:de,resourceDestinationString:A,resourceTitleString:F,resource:Z,setextHeading:p(L),setextHeadingLineSequence:$,setextHeadingText:R,strong:p(),thematicBreak:p()}};zS(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(ie){let Y={type:"root",children:[]};const pe={stack:[Y],tokenStack:[],config:t,enter:u,exit:m,buffer:c,resume:h,data:n},Q=[];let ye=-1;for(;++ye<ie.length;)if(ie[ye][1].type==="listOrdered"||ie[ye][1].type==="listUnordered")if(ie[ye][0]==="enter")Q.push(ye);else{const Pe=Q.pop();ye=a(ie,Pe,ye)}for(ye=-1;++ye<ie.length;){const Pe=t[ie[ye][0]];FS.call(Pe,ie[ye][1].type)&&Pe[ie[ye][1].type].call(Object.assign({sliceSerialize:ie[ye][2].sliceSerialize},pe),ie[ye][1])}if(pe.tokenStack.length>0){const Pe=pe.tokenStack[pe.tokenStack.length-1];(Pe[1]||Dw).call(pe,void 0,Pe[0])}for(Y.position={start:eo(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:eo(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},ye=-1;++ye<t.transforms.length;)Y=t.transforms[ye](Y)||Y;return Y}function a(ie,Y,pe){let Q=Y-1,ye=-1,Pe=!1,lt,te,be,Le;for(;++Q<=pe;){const it=ie[Q];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?ye++:ye--,Le=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(lt&&!Le&&!ye&&!be&&(be=Q),Le=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Le=void 0}if(!ye&&it[0]==="enter"&&it[1].type==="listItemPrefix"||ye===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(lt){let _e=Q;for(te=void 0;_e--;){const bt=ie[_e];if(bt[1].type==="lineEnding"||bt[1].type==="lineEndingBlank"){if(bt[0]==="exit")continue;te&&(ie[te][1].type="lineEndingBlank",Pe=!0),bt[1].type="lineEnding",te=_e}else if(!(bt[1].type==="linePrefix"||bt[1].type==="blockQuotePrefix"||bt[1].type==="blockQuotePrefixWhitespace"||bt[1].type==="blockQuoteMarker"||bt[1].type==="listItemIndent"))break}be&&(!te||be<te)&&(lt._spread=!0),lt.end=Object.assign({},te?ie[te][1].start:it[1].end),ie.splice(te||Q,0,["exit",lt,it[2]]),Q++,pe++}if(it[1].type==="listItemPrefix"){const _e={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};lt=_e,ie.splice(Q,0,["enter",_e,it[2]]),Q++,pe++,be=void 0,Le=!0}}}return ie[Y][1]._spread=Pe,pe}function l(ie,Y){return pe;function pe(Q){u.call(this,ie(Q),Q),Y&&Y.call(this,Q)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(ie,Y,pe){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([Y,pe||void 0]),ie.position={start:eo(Y.start),end:void 0}}function p(ie){return Y;function Y(pe){ie&&ie.call(this,pe),m.call(this,pe)}}function m(ie,Y){const pe=this.stack.pop(),Q=this.tokenStack.pop();if(Q)Q[0].type!==ie.type&&(Y?Y.call(this,ie,Q[0]):(Q[1]||Dw).call(this,ie,Q[0]));else throw new Error("Cannot close `"+ie.type+"` ("+Al({start:ie.start,end:ie.end})+"): it’s not open");pe.position.end=eo(ie.end)}function h(){return QO(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function y(ie){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function b(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=ie}function E(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=ie}function j(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie.replace(/(\r?\n|\r)$/g,"")}function C(ie){const Y=this.resume(),pe=this.stack[this.stack.length-1];pe.label=Y,pe.identifier=ci(this.sliceSerialize(ie)).toLowerCase()}function N(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.title=ie}function T(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.url=ie}function D(ie){const Y=this.stack[this.stack.length-1];if(!Y.depth){const pe=this.sliceSerialize(ie).length;Y.depth=pe}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function $(ie){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function K(ie){const pe=this.stack[this.stack.length-1].children;let Q=pe[pe.length-1];(!Q||Q.type!=="text")&&(Q=Rt(),Q.position={start:eo(ie.start),end:void 0},pe.push(Q)),this.stack.push(Q)}function B(ie){const Y=this.stack.pop();Y.value+=this.sliceSerialize(ie),Y.position.end=eo(ie.end)}function O(ie){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const pe=Y.children[Y.children.length-1];pe.position.end=eo(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(K.call(this,ie),B.call(this,ie))}function W(){this.data.atHardBreak=!0}function se(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie}function z(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie}function H(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie}function ee(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=Y,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function ne(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=Y,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function M(ie){const Y=this.sliceSerialize(ie),pe=this.stack[this.stack.length-2];pe.label=X5(Y),pe.identifier=ci(Y).toLowerCase()}function G(){const ie=this.stack[this.stack.length-1],Y=this.resume(),pe=this.stack[this.stack.length-1];if(this.data.inReference=!0,pe.type==="link"){const Q=ie.children;pe.children=Q}else pe.alt=Y}function A(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.url=ie}function F(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.title=ie}function Z(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function de(ie){const Y=this.resume(),pe=this.stack[this.stack.length-1];pe.label=Y,pe.identifier=ci(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function ge(ie){this.data.characterReferenceType=ie.type}function V(ie){const Y=this.sliceSerialize(ie),pe=this.data.characterReferenceType;let Q;pe?(Q=RS(Y,pe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Q=ox(Y);const ye=this.stack[this.stack.length-1];ye.value+=Q}function ae(ie){const Y=this.stack.pop();Y.position.end=eo(ie.end)}function me(ie){B.call(this,ie);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(ie)}function ve(ie){B.call(this,ie);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(ie)}function ke(){return{type:"blockquote",children:[]}}function he(){return{type:"code",lang:null,meta:null,value:""}}function Je(){return{type:"inlineCode",value:""}}function Ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ot(){return{type:"emphasis",children:[]}}function J(){return{type:"heading",depth:0,children:[]}}function Ie(){return{type:"break"}}function Ne(){return{type:"html",value:""}}function Oe(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function Me(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function nt(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function Ke(){return{type:"paragraph",children:[]}}function gt(){return{type:"strong",children:[]}}function Rt(){return{type:"text",value:""}}function at(){return{type:"thematicBreak"}}}function eo(e){return{line:e.line,column:e.column,offset:e.offset}}function zS(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?zS(e,s):tM(e,s)}}function tM(e,t){let n;for(n in t)if(FS.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function Dw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Al({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Al({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Al({start:t.start,end:t.end})+") is still open")}function nM(e){const t=this;t.parser=n;function n(s){return Z5(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function rM(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function sM(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -540,7 +540,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
540
540
  `});++s<e.length;)s&&n.push({type:"text",value:`
541
541
  `}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
542
542
  `}),n}function zw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Bw(e,t){const n=KM(e,t),s=n.one(e,void 0),a=OM(n),l=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
543
- `},a),l}function XM(e,t){return e&&"run"in e?async function(n,s){const a=Bw(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Bw(n,{file:s,...e||t})}}function Uw(e){if(e)throw e}var Im,Vw;function QM(){if(Vw)return Im;Vw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},l=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var h=e.call(m,"constructor"),g=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!h&&!g)return!1;var y;for(y in m);return typeof y>"u"||e.call(m,y)},c=function(m,h){n&&h.name==="__proto__"?n(m,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):m[h.name]=h.newValue},u=function(m,h){if(h==="__proto__")if(e.call(m,h)){if(s)return s(m,h).value}else return;return m[h]};return Im=function p(){var m,h,g,y,b,E,j=arguments[0],w=1,k=arguments.length,C=!1;for(typeof j=="boolean"&&(C=j,j=arguments[1]||{},w=2),(j==null||typeof j!="object"&&typeof j!="function")&&(j={});w<k;++w)if(m=arguments[w],m!=null)for(h in m)g=u(j,h),y=u(m,h),j!==y&&(C&&y&&(l(y)||(b=a(y)))?(b?(b=!1,E=g&&a(g)?g:[]):E=g&&l(g)?g:{},c(j,{name:h,newValue:p(C,E,y)})):typeof y<"u"&&c(j,{name:h,newValue:y}));return j},Im}var ZM=QM();const Mm=Td(ZM);function Ih(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function e_(){const e=[],t={run:n,use:s};return t;function n(...a){let l=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);u(null,...a);function u(p,...m){const h=e[++l];let g=-1;if(p){c(p);return}for(;++g<a.length;)(m[g]===null||m[g]===void 0)&&(m[g]=a[g]);a=m,h?t_(h,u)(...m):c(null,...m)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function t_(e,t){let n;return s;function s(...c){const u=e.length>c.length;let p;u&&c.push(a);try{p=e.apply(this,c)}catch(m){const h=m;if(u&&n)throw h;return a(h)}u||(p&&p.then&&typeof p.then=="function"?p.then(l,a):p instanceof Error?a(p):l(p))}function a(c,...u){n||(n=!0,t(c,...u))}function l(c){a(null,c)}}const as={basename:n_,dirname:r_,extname:s_,join:o_,sep:"/"};function n_(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');pc(e);let n=0,s=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else s<0&&(l=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else c<0&&(l=!0,c=a+1),u>-1&&(e.codePointAt(a)===t.codePointAt(u--)?u<0&&(s=a):(u=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function r_(e){if(pc(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function s_(e){pc(e);let t=e.length,n=-1,s=0,a=-1,l=0,c;for(;t--;){const u=e.codePointAt(t);if(u===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),u===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function o_(...e){let t=-1,n;for(;++t<e.length;)pc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":a_(n)}function a_(e){pc(e);const t=e.codePointAt(0)===47;let n=i_(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function i_(e,t){let n="",s=0,a=-1,l=0,c=-1,u,p;for(;++c<=e.length;){if(c<e.length)u=e.codePointAt(c);else{if(u===47)break;u=47}if(u===47){if(!(a===c-1||l===1))if(a!==c-1&&l===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,l=0;continue}}else if(n.length>0){n="",s=0,a=c,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,l=0}else u===46&&l>-1?l++:l=-1}return n}function pc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const l_={cwd:c_};function c_(){return"/"}function Mh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function u_(e){if(typeof e=="string")e=new URL(e);else if(!Mh(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return d_(e)}function d_(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const _m=["history","path","basename","stem","extname","dirname"];class YS{constructor(t){let n;t?Mh(t)?n={path:t}:typeof t=="string"||f_(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":l_.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<_m.length;){const l=_m[s];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)_m.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?as.basename(this.path):void 0}set basename(t){zm(t,"basename"),Fm(t,"basename"),this.path=as.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?as.dirname(this.path):void 0}set dirname(t){Hw(this.basename,"dirname"),this.path=as.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?as.extname(this.path):void 0}set extname(t){if(Fm(t,"extname"),Hw(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=as.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Mh(t)&&(t=u_(t)),zm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?as.basename(this.path,this.extname):void 0}set stem(t){zm(t,"stem"),Fm(t,"stem"),this.path=as.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const a=this.message(t,n,s);throw a.fatal=!0,a}info(t,n,s){const a=this.message(t,n,s);return a.fatal=void 0,a}message(t,n,s){const a=new zn(t,n,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Fm(e,t){if(e&&e.includes(as.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+as.sep+"`")}function zm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Hw(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function f_(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const p_=(function(e){const s=this.constructor.prototype,a=s[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),m_={}.hasOwnProperty;class fx extends p_{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=e_()}copy(){const t=new fx;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Mm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Vm("data",this.frozen),this.namespace[t]=n,this):m_.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Vm("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=n.call(t,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Lu(t),s=this.parser||this.Parser;return Bm("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Bm("process",this.parser||this.Parser),Um("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,c){const u=Lu(t),p=s.parse(u);s.run(p,u,function(h,g,y){if(h||!g||!y)return m(h);const b=g,E=s.stringify(b,y);x_(E)?y.value=E:y.result=E,m(h,y)});function m(h,g){h||!g?c(h):l?l(g):n(void 0,g)}}}processSync(t){let n=!1,s;return this.freeze(),Bm("processSync",this.parser||this.Parser),Um("processSync",this.compiler||this.Compiler),this.process(t,a),Kw("processSync","process",n),s;function a(l,c){n=!0,Uw(l),s=c}}run(t,n,s){Ww(t),this.freeze();const a=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?l(void 0,s):new Promise(l);function l(c,u){const p=Lu(n);a.run(t,p,m);function m(h,g,y){const b=g||t;h?u(h):c?c(b):s(void 0,b,y)}}}runSync(t,n){let s=!1,a;return this.run(t,n,l),Kw("runSync","run",s),a;function l(c,u){Uw(c),a=u,s=!0}}stringify(t,n){this.freeze();const s=Lu(n),a=this.compiler||this.Compiler;return Um("stringify",a),Ww(t),a(t,s)}use(t,...n){const s=this.attachers,a=this.namespace;if(Vm("use",this.frozen),t!=null)if(typeof t=="function")p(t,n);else if(typeof t=="object")Array.isArray(t)?u(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(m){if(typeof m=="function")p(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[h,...g]=m;p(h,g)}else c(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function c(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");u(m.plugins),m.settings&&(a.settings=Mm(!0,a.settings,m.settings))}function u(m){let h=-1;if(m!=null)if(Array.isArray(m))for(;++h<m.length;){const g=m[h];l(g)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function p(m,h){let g=-1,y=-1;for(;++g<s.length;)if(s[g][0]===m){y=g;break}if(y===-1)s.push([m,...h]);else if(h.length>0){let[b,...E]=h;const j=s[y][1];Ih(j)&&Ih(b)&&(b=Mm(!0,j,b)),s[y]=[m,b,...E]}}}}const h_=new fx().freeze();function Bm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Um(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Vm(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ww(e){if(!Ih(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Kw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Lu(e){return g_(e)?e:new YS(e)}function g_(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function x_(e){return typeof e=="string"||y_(e)}function y_(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const b_="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",qw=[],Gw={allowDangerousHtml:!0},v_=/^(https?|ircs?|mailto|xmpp)$/i,w_=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function j_(e){const t=k_(e),n=S_(e);return N_(t.runSync(t.parse(n),n),e)}function k_(e){const t=e.rehypePlugins||qw,n=e.remarkPlugins||qw,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Gw}:Gw;return h_().use(nM).use(n).use(XM,s).use(t)}function S_(e){const t=e.children||"",n=new YS;return typeof t=="string"&&(n.value=t),n}function N_(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,l=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,p=t.urlTransform||C_;for(const h of w_)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+b_+h.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),GS(e,m),OO(e,{Fragment:r.Fragment,components:a,ignoreInvalidStyle:!0,jsx:r.jsx,jsxs:r.jsxs,passKeys:!0,passNode:!0});function m(h,g,y){if(h.type==="raw"&&y&&typeof g=="number")return c?y.children.splice(g,1):y.children[g]={type:"text",value:h.value},g;if(h.type==="element"){let b;for(b in $m)if(Object.hasOwn($m,b)&&Object.hasOwn(h.properties,b)){const E=h.properties[b],j=$m[b];(j===null||j.includes(h.tagName))&&(h.properties[b]=p(String(E||""),b,h))}}if(h.type==="element"){let b=n?!n.includes(h.tagName):l?l.includes(h.tagName):!1;if(!b&&s&&typeof g=="number"&&(b=!s(h,g,y)),b&&y&&typeof g=="number")return u&&h.children?y.children.splice(g,1,...h.children):y.children.splice(g,1),g}}}function C_(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||v_.test(e.slice(0,t))?e:""}function fn({content:e,className:t,emptyState:n="No markdown content yet."}){const s=e.replace(/<!--[\s\S]*?-->/g,"");return s.trim()?r.jsx("div",{className:Se("prose-syntaur max-w-none",t),children:r.jsx(j_,{children:s})}):r.jsx("div",{className:"rounded-md border border-dashed border-border/80 bg-muted/30 px-3 py-4 text-sm text-muted-foreground",children:n})}function Ir(e){return`/api/projects/${encodeURIComponent(e)}/todos`}function E_(e){const[t,n]=f.useState(null),[s,a]=f.useState(!0),[l,c]=f.useState(null),u=f.useCallback(async()=>{if(e)try{const p=await fetch(Ir(e));if(!p.ok)throw new Error(`HTTP ${p.status}`);n(await p.json()),c(null)}catch(p){c(p instanceof Error?p.message:"Failed to fetch todos")}finally{a(!1)}},[e]);return f.useEffect(()=>{u()},[u]),sc(p=>{p.type==="todos-updated"&&p.projectSlug===e&&u()}),{data:t,loading:s,error:l,refetch:u}}async function T_(e,t,n){await fetch(Ir(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:t,tags:n})})}async function R_(e,t,n){await fetch(`${Ir(e)}/${t}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({summary:"Completed."})})}async function P_(e,t,n){await fetch(`${Ir(e)}/${t}/block`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:n})})}async function A_(e,t,n){await fetch(`${Ir(e)}/${t}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:n})})}async function D_(e,t){await fetch(`${Ir(e)}/${t}/reopen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})})}async function $_(e,t){await fetch(`${Ir(e)}/${t}`,{method:"DELETE"})}async function L_(e,t,n){const s=await fetch(`${Ir(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!s.ok)throw new Error(await s.text().catch(()=>"")||`HTTP ${s.status}`)}function JS(e,t,n){return`${Ir(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function O_(e,t,n){for(const s of n){const a=await fetch(`${Ir(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(s.name||"file"),"x-attachment-mime":s.type||"application/octet-stream"},body:s});if(!a.ok)throw new Error(await a.text().catch(()=>"")||`HTTP ${a.status}`)}}async function I_(e,t,n){const s=await fetch(JS(e,t,n),{method:"DELETE"});if(!s.ok)throw new Error(await s.text().catch(()=>"")||`HTTP ${s.status}`)}async function XS(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const s=await n.text().catch(()=>"");let a=null;try{a=s?JSON.parse(s):null}catch{}const l=(a==null?void 0:a.error)||s||`HTTP ${n.status}`,c=new Error(l);throw c.status=n.status,c}return n.json().catch(()=>({}))}async function M_(e,t){return await XS(`${Ir(e)}/promote`,t)}async function __(e,t,n){await XS(`${Ir(e)}/${t}/move`,{to:n})}const Yw=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-status-in-progress-foreground"},{value:"completed",icon:"✓",label:"Completed",color:"text-status-completed-foreground"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-status-blocked-foreground"}];function QS({status:e,onChange:t}){const[n,s]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(!n)return;function c(u){a.current&&!a.current.contains(u.target)&&s(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);const l=Yw.find(c=>c.value===e);return r.jsxs("div",{className:"relative",ref:a,onClick:c=>c.stopPropagation(),children:[r.jsx("button",{onClick:()=>s(!n),className:`text-lg leading-none ${l.color} hover:opacity-70 transition`,title:l.label,children:l.icon}),n&&r.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:Yw.filter(c=>c.value!==e).map(c=>r.jsxs("button",{onClick:()=>{t(c.value),s(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${c.color}`,children:[r.jsx("span",{className:"text-base leading-none",children:c.icon}),r.jsx("span",{children:c.label})]},c.value))})]})}function ZS({item:e,copiedId:t,selected:n,editing:s,onBeginEdit:a,onEndEdit:l,onPatchDescription:c,onAddAttachments:u,onDeleteAttachment:p,attachmentUrl:m,onToggleSelected:h,onMoveOne:g,onStatusChange:y,onCopyId:b,onDelete:E,hotkeyRowProps:j,onDragOrigin:w,onDragStart:k,onDragEnd:C,isDragging:N}){return r.jsxs("div",{draggable:!0,"data-todo-id":e.id,...j??{},onMouseDown:w,onDragStart:T=>k(T,e.id),onDragEnd:C,className:`surface-panel flex items-start gap-3 px-3 py-2 cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${N?"opacity-50 shadow-lg":""}`,children:[r.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${e.id}`,title:"Select",checked:n,onChange:T=>h(e.id,T),onClick:T=>T.stopPropagation(),className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),r.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx(QS,{status:e.status,onChange:T=>y(e.id,T)})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[r.jsx(eN,{description:e.description,status:e.status,editing:s,onBeginEdit:()=>a(e.id),onEndEdit:l,onSave:T=>c(e.id,T)}),e.tags.length>0&&r.jsx("span",{className:"text-xs text-muted-foreground",children:e.tags.map(T=>`#${T}`).join(" ")}),e.session&&r.jsxs("span",{className:"text-xs text-info-foreground/70 font-mono",children:["session:",e.session.slice(0,8)]}),r.jsx(V_,{item:e})]}),r.jsx(tN,{item:e,attachmentUrl:m,onAdd:T=>u(e.id,T),onDelete:T=>p(e.id,T)})]}),t===e.id?r.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[r.jsx(Xr,{className:"h-3 w-3"})," Copied to clipboard"]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{"data-no-drag":!0,className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:T=>b(T,e.id),children:["t:",e.id]}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:T=>b(T,e.id),children:r.jsx(rd,{className:"h-3 w-3"})}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Move to...",onClick:T=>g(e.id,T),children:r.jsx($d,{className:"h-3 w-3"})}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-destructive transition",title:"Delete todo",onClick:T=>E(T,e.id,e.description),children:r.jsx(or,{className:"h-3 w-3"})})]})]})}function eN({description:e,status:t,editing:n,onBeginEdit:s,onEndEdit:a,onSave:l}){return n?r.jsx(F_,{initialValue:e,onSave:l,onExit:a}):r.jsx("button",{type:"button","data-no-drag":!0,onClick:c=>{c.stopPropagation(),s()},title:"Click to edit",className:Se("text-left text-sm rounded-sm transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",t==="completed"?"line-through text-muted-foreground":"text-foreground"),children:e})}function F_({initialValue:e,onSave:t,onExit:n}){const s=f.useRef(e),[a,l]=f.useState(e),[c,u]=f.useState(!1),[p,m]=f.useState(!1),h=f.useRef(null),g=f.useRef(!1);f.useEffect(()=>{const j=h.current;j&&(j.focus(),j.select())},[]);const y=f.useCallback(()=>{var j;m(!0),window.setTimeout(()=>m(!1),260),(j=h.current)==null||j.focus()},[]),b=f.useCallback(async()=>{if(g.current)return;const j=a.trim();if(j.length===0){y();return}if(j===s.current){n();return}g.current=!0,u(!0);try{await t(j)}catch{}finally{u(!1),n()}},[a,n,t,y]);function E(j){j.key==="Enter"?(j.preventDefault(),b()):j.key==="Escape"&&(j.preventDefault(),g.current=!0,n())}return r.jsx("input",{ref:h,type:"text","data-no-drag":!0,disabled:c,value:a,onClick:j=>j.stopPropagation(),onChange:j=>l(j.target.value),onKeyDown:E,onBlur:()=>void b(),className:Se("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-sm text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",p&&"syntaur-input-shake",c&&"opacity-70")})}function z_(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function B_(e){const t=e.clipboardData,n=[];if(t.files&&t.files.length&&n.push(...Array.from(t.files)),!n.length&&t.items){for(const s of Array.from(t.items))if(s.kind==="file"){const a=s.getAsFile();a&&n.push(a)}}return n}function tN({item:e,attachmentUrl:t,onAdd:n,onDelete:s}){const a=e.attachments??[],[l,c]=f.useState(!1),[u,p]=f.useState(!1),m=f.useRef(null),h=f.useRef(null);f.useEffect(()=>{var y;l&&((y=h.current)==null||y.focus())},[l]);const g=f.useCallback(async y=>{if(y.length){p(!0);try{await n(y),c(!1)}finally{p(!1)}}},[n]);return r.jsxs("div",{className:"mt-1","data-no-drag":!0,onClick:y=>y.stopPropagation(),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.map(y=>r.jsx(U_,{att:y,url:t(e.id,y.id),onDelete:()=>void s(y.id)},y.id)),r.jsxs("button",{type:"button","data-no-drag":!0,title:"Attach files",onClick:()=>c(y=>!y),className:"inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground hover:border-border transition",children:[r.jsx(m0,{className:"h-3 w-3"}),a.length===0?"Attach":""]})]}),l&&r.jsxs("div",{ref:h,"data-no-drag":!0,tabIndex:0,role:"button","aria-label":"Add attachments: drop, paste, or click",onPaste:y=>{const b=B_(y);b.length&&(y.preventDefault(),g(b))},onDragOver:y=>{Array.from(y.dataTransfer.types).includes("Files")&&y.preventDefault()},onDrop:y=>{const b=Array.from(y.dataTransfer.files);b.length&&(y.preventDefault(),g(b))},onClick:()=>{var y;return(y=m.current)==null?void 0:y.click()},className:"mt-1 cursor-pointer rounded-md border border-dashed border-border/70 px-3 py-2 text-xs text-muted-foreground hover:border-border focus:outline-none focus:ring-2 focus:ring-ring/40",children:[u?"Uploading…":"Drop, paste (⌘V / Ctrl+V), or click to add files",r.jsx("input",{ref:m,type:"file",multiple:!0,className:"hidden",onChange:y=>{const b=Array.from(y.target.files??[]);y.target.value="",g(b)}})]})]})}function U_({att:e,url:t,onDelete:n}){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border/60 bg-background px-1.5 py-0.5 text-xs",children:[z_(e.mime)?r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:e.filename,children:r.jsx("img",{src:t,alt:e.filename,className:"h-6 w-6 rounded object-cover"})}):r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-foreground hover:text-primary",children:[r.jsx(m0,{className:"h-3 w-3"}),r.jsx("span",{className:"block max-w-[160px] truncate",children:e.filename})]}),r.jsx("button",{type:"button",title:"Remove attachment",onClick:n,className:"text-muted-foreground/60 hover:text-destructive transition",children:r.jsx(ig,{className:"h-3 w-3"})})]})}function V_({item:e}){return!(e.branch||e.planDir||e.worktreePath||e.createdAt||e.updatedAt)?null:r.jsxs("span",{className:"inline-flex items-center gap-1 align-middle",children:[e.branch?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-info-foreground/30 bg-info/30 px-1.5 py-0.5 text-[10px] font-mono text-info-foreground",children:[r.jsx(tg,{className:"h-2.5 w-2.5"}),r.jsx("span",{className:"block min-w-0 max-w-[120px] truncate",children:e.branch})]})}),r.jsx(gr,{children:e.branch})]})}):null,e.planDir?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("button",{type:"button","data-no-drag":!0,onClick:n=>{n.stopPropagation(),navigator.clipboard.writeText(e.planDir)},className:"inline-flex items-center rounded-full border border-status-completed-foreground/40 bg-status-completed/30 p-1 text-status-completed-foreground hover:bg-status-completed/50","aria-label":"Copy plan directory path",children:r.jsx(d0,{className:"h-2.5 w-2.5"})})}),r.jsxs(gr,{children:["Plan: ",e.planDir]})]})}):null,e.worktreePath||e.createdAt||e.updatedAt?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{className:"text-[10px] text-muted-foreground/60 cursor-default",children:"·"})}),r.jsx(gr,{children:r.jsxs("div",{className:"space-y-0.5 text-xs font-mono",children:[e.worktreePath?r.jsxs("div",{children:["worktree: ",e.worktreePath]}):null,e.createdAt?r.jsxs("div",{children:["created: ",e.createdAt]}):null,e.updatedAt?r.jsxs("div",{children:["updated: ",e.updatedAt]}):null]})})]})}):null]})}const nN="__one_off__";function px({open:e,selectedIds:t,scope:n,onOpenChange:s,onDone:a,defaultProject:l,defaultTitle:c,allowOneOff:u=!0}){const[p,m]=f.useState("new"),[h,g]=f.useState(!1),[y,b]=f.useState(null),[E,j]=f.useState(null),[w,k]=f.useState(null),[C,N]=f.useState(""),[T,D]=f.useState(""),[R,$]=f.useState(""),[L,K]=f.useState(""),[B,O]=f.useState(""),[W,se]=f.useState(""),[z,H]=f.useState(null),[ee,ne]=f.useState(!1),M=t.length>1;f.useEffect(()=>{if(!e){m("new"),b(null),N(""),D(""),$(""),K(""),O(""),se(""),H(null);return}N(l??""),D(c??"");let de=!1;return(async()=>{try{const ge=await fetch("/api/projects");if(!ge.ok)throw new Error(`HTTP ${ge.status}`);const V=await ge.json();de||j(V.filter(ae=>!ae.archived))}catch(ge){de||k(ge instanceof Error?ge.message:String(ge))}})(),()=>{de=!0}},[e,l,c]),f.useEffect(()=>{if(!B){H(null);return}let de=!1;return ne(!0),(async()=>{try{const ge=await fetch(`/api/projects/${encodeURIComponent(B)}/assignments`);if(!ge.ok)throw new Error(`HTTP ${ge.status}`);const V=await ge.json();de||H(V)}catch{de||H([])}finally{de||ne(!1)}})(),()=>{de=!0}},[B]);const G=f.useMemo(()=>E??[],[E]);async function A(de){if(de.preventDefault(),!C){b('Pick a target project (or "One-off").');return}if(M&&!T.trim()){b("Title is required when promoting multiple todos.");return}const ge=C===nN?{oneOff:!0}:{project:C};if(n.kind==="aggregate"){const ae={groups:n.groups,mode:"new-assignment",target:ge,title:T.trim()||void 0,type:R.trim()||void 0,priority:L||void 0};await I(ae);return}const V={todoIds:t,mode:"new-assignment",target:ge,title:T.trim()||void 0,type:R.trim()||void 0,priority:L||void 0};await Z(V)}async function F(de){if(de.preventDefault(),n.kind==="aggregate"){b("Existing-assignment mode does not support cross-workspace selections yet.");return}if(!B||!W){b("Pick both project and assignment.");return}const ge={todoIds:t,mode:"to-assignment",target:{assignment:`${B}/${W}`}};await Z(ge)}async function Z(de){g(!0),b(null);try{let ge;if(n.kind==="workspace")ge=await BP(n.workspace,de);else if(n.kind==="project")ge=await M_(n.projectId,de);else throw new Error("Aggregate scope requires runBulkMutation.");a(ge),s(!1)}catch(ge){b(ge instanceof Error?ge.message:String(ge))}finally{g(!1)}}async function I(de){g(!0),b(null);try{const ge=await UP(de);a(ge),s(!1)}catch(ge){b(ge instanceof Error?ge.message:String(ge))}finally{g(!1)}}return r.jsx(ar,{open:e,onOpenChange:de=>h?void 0:s(de),children:r.jsxs(Kn,{className:"max-w-xl",children:[r.jsxs(Zr,{children:[r.jsxs(qn,{children:["Promote ",t.length," todo",t.length===1?"":"s"]}),r.jsxs(gs,{children:["Convert the selected todo",t.length===1?"":"s"," to a new or existing assignment. Source todo",t.length===1?"":"s"," will be marked ",r.jsx("strong",{children:"in progress"})," and linked to the new assignment (auto-completed when the assignment closes)."]})]}),r.jsxs(pS,{value:p,onValueChange:de=>m(de),children:[r.jsxs(mS,{className:"flex gap-2 rounded-md border border-border/70 bg-card/80 p-1 mb-4",children:[r.jsx(Ch,{value:"new",className:Se("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"New assignment"}),r.jsx(Ch,{value:"existing",className:Se("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"Existing assignment"})]}),r.jsx(Eh,{value:"new",children:r.jsxs("form",{onSubmit:A,className:"space-y-4",children:[r.jsx(Va,{label:"Target project",children:r.jsx(Jw,{value:C,onChange:N,projects:G,error:w,disabled:h,allowOneOff:u})}),r.jsx(Va,{label:M?"Title (required)":"Title (defaults to first todo)",children:r.jsx("input",{type:"text",value:T,onChange:de=>D(de.target.value),disabled:h,className:"editor-input bg-background/95 font-sans"})}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Va,{label:"Type",children:r.jsx("input",{type:"text",value:R,onChange:de=>$(de.target.value),placeholder:"feature",disabled:h,className:"editor-input bg-background/95 font-sans"})}),r.jsx(Va,{label:"Priority",children:r.jsxs("select",{value:L,onChange:de=>K(de.target.value),disabled:h,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"—"}),r.jsx("option",{value:"low",children:"low"}),r.jsx("option",{value:"medium",children:"medium"}),r.jsx("option",{value:"high",children:"high"}),r.jsx("option",{value:"critical",children:"critical"})]})})]}),y?r.jsx(Xw,{message:y}):null,r.jsx(Qw,{onCancel:()=>s(!1),submitting:h,submitLabel:"Promote"})]})}),r.jsx(Eh,{value:"existing",children:r.jsxs("form",{onSubmit:F,className:"space-y-4",children:[r.jsx(Va,{label:"Project",children:r.jsx(Jw,{value:B,onChange:de=>{O(de),se("")},projects:G,error:w,disabled:h})}),r.jsx(Va,{label:ee?"Assignment (loading...)":"Assignment",children:r.jsxs("select",{value:W,onChange:de=>se(de.target.value),disabled:h||!B||ee,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:B?"Select assignment...":"Pick a project first"}),(z??[]).map(de=>r.jsxs("option",{value:de.slug,children:[de.title," (",de.status,")"]},de.slug))]})}),y?r.jsx(Xw,{message:y}):null,r.jsx(Qw,{onCancel:()=>s(!1),submitting:h,submitLabel:"Promote"})]})})]})]})})}function Va({label:e,children:t}){return r.jsxs("label",{className:"block space-y-1.5",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Jw({value:e,onChange:t,projects:n,error:s,disabled:a,allowOneOff:l}){return s?r.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load projects: ",s]}):r.jsxs("select",{value:e,onChange:c=>t(c.target.value),disabled:a,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"Select project..."}),l?r.jsx("option",{value:nN,children:"One-off (no project)"}):null,n.map(c=>r.jsxs("option",{value:c.slug,children:[c.title," (",c.slug,")"]},c.slug))]})}function Xw({message:e}){return r.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function Qw({onCancel:e,submitting:t,submitLabel:n}){return r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:e,disabled:t,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:t,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:t?"Submitting...":n})]})}function rN({open:e,selectedIds:t,scope:n,onOpenChange:s,onDone:a}){const[l,c]=f.useState("project"),[u,p]=f.useState(""),[m,h]=f.useState(""),[g,y]=f.useState(!1),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null);f.useEffect(()=>{if(!e){c("project"),p(""),h(""),E(null),w(null);return}let $=!1;return(async()=>{try{const L=await fetch("/api/projects");if(!L.ok)throw new Error(`HTTP ${L.status}`);const K=await L.json();$||C(K.filter(B=>!B.archived))}catch(L){$||w(L instanceof Error?L.message:String(L))}})(),()=>{$=!0}},[e]);const N=f.useMemo(()=>k?n.kind==="project"?k.filter($=>$.slug!==n.projectId):k:[],[k,n]);function T(){if(l==="global")return{global:!0};if(l==="workspace"){const $=u.trim();return $?{workspace:$}:"Workspace name is required."}return m?{project:m}:"Pick a target project."}async function D($,L){try{return n.kind==="workspace"?await VP(n.workspace,$,L):await __(n.projectId,$,L),{ok:!0}}catch(K){return{ok:!1,error:K instanceof Error?K.message:String(K)}}}async function R($){$.preventDefault(),w(null);const L=T();if(typeof L=="string"){w(L);return}y(!0),E(null);const K=[],B=[];for(const O of t){const W=await D(O,L);W.ok?K.push(O):B.push({id:O,error:W.error})}y(!1),a(),B.length===0?s(!1):E({succeeded:K,failed:B})}return r.jsx(ar,{open:e,onOpenChange:$=>g?void 0:s($),children:r.jsx(Kn,{className:"max-w-xl",children:r.jsxs("form",{onSubmit:R,className:"space-y-4",children:[r.jsxs(Zr,{children:[r.jsxs(qn,{children:["Move ",t.length," todo",t.length===1?"":"s"]}),r.jsxs(gs,{children:["Move the selected todo",t.length===1?"":"s"," to a different scope. id, tags, branch, timestamps, and plan dir are preserved."]})]}),r.jsxs("fieldset",{className:"space-y-2",disabled:g,children:[r.jsx("legend",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground mb-1",children:"Target scope"}),r.jsx(Hm,{kind:"project",checked:l==="project",onChange:()=>c("project"),label:"Project"}),r.jsx(Hm,{kind:"workspace",checked:l==="workspace",onChange:()=>c("workspace"),label:"Workspace"}),r.jsx(Hm,{kind:"global",checked:l==="global",onChange:()=>c("global"),label:"Global"})]}),l==="project"?r.jsx(Zw,{label:"Target project",children:r.jsxs("select",{value:m,onChange:$=>h($.target.value),disabled:g,className:"editor-textarea w-full bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"Select project..."}),N.map($=>r.jsxs("option",{value:$.slug,children:[$.title," (",$.slug,")"]},$.slug))]})}):null,l==="workspace"?r.jsx(Zw,{label:"Target workspace name",children:r.jsx("input",{type:"text",value:u,onChange:$=>p($.target.value),disabled:g,placeholder:"e.g. syntaur",className:"editor-textarea w-full bg-background/95 font-sans"})}):null,j?r.jsx(H_,{message:j}):null,b?r.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground space-y-1",children:[r.jsxs("div",{className:"font-medium",children:["Moved ",b.succeeded.length," of ",t.length,"; ",b.failed.length," failed."]}),r.jsx("ul",{className:"text-xs space-y-0.5",children:b.failed.map($=>r.jsxs("li",{children:["[t:",$.id,"] ",$.error]},$.id))})]}):null,r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>s(!1),disabled:g,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:b?"Close":"Cancel"}),b===null?r.jsx("button",{type:"submit",disabled:g,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:g?"Moving...":"Move"}):null]})]})})})}function Zw({label:e,children:t}){return r.jsxs("label",{className:"block space-y-1.5",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Hm({kind:e,checked:t,onChange:n,label:s}){return r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[r.jsx("input",{type:"radio",name:"move-target-kind",value:e,checked:t,onChange:n}),r.jsx("span",{children:s})]})}function H_({message:e}){return r.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function mx({label:e,count:t,expanded:n,onToggle:s,isDropTarget:a=!1,onDragOver:l,onDragLeave:c,onDrop:u,children:p}){return r.jsxs("div",{className:Se("rounded-lg border border-border/60 bg-card/40 transition",a&&"ring-2 ring-ring/30"),onDragOver:l,onDragLeave:c,onDrop:u,children:[r.jsxs("button",{type:"button",onClick:s,"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2.5 text-left",children:[r.jsx(br,{className:Se("h-4 w-4 text-muted-foreground transition-transform",!n&&"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:e}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:t})]}),n&&r.jsx("div",{className:"space-y-1 px-2 pb-2",children:p})]})}const sN=[{id:"open-blocked",label:"Open / Blocked",statuses:["open","blocked"],dropStatus:"open",defaultCollapsed:!1},{id:"in-progress",label:"In Progress",statuses:["in_progress"],dropStatus:"in_progress",defaultCollapsed:!1},{id:"done",label:"Done",statuses:["completed"],dropStatus:"completed",defaultCollapsed:!0}];function lf(e){switch(e){case"in_progress":return"in-progress";case"completed":return"done";case"open":case"blocked":default:return"open-blocked"}}function hx(e){const t={"open-blocked":[],"in-progress":[],done:[]};for(const n of e)t[lf(n.status)].push(n);return sN.map(n=>({config:n,items:t[n.id]}))}const oN="syntaur.todos.sections.collapsed.v1",ej=Object.fromEntries(sN.map(e=>[e.id,e.defaultCollapsed]));function Wm(){if(typeof window>"u"||!window.localStorage)return{};try{const e=window.localStorage.getItem(oN);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function W_(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(oN,JSON.stringify(e))}catch{}}function gx(e){const[t,n]=f.useState(()=>Wm()[e]??{});f.useEffect(()=>{n(Wm()[e]??{})},[e]);const s=f.useCallback(l=>t[l]??ej[l],[t]),a=f.useCallback(l=>{const c=Wm(),u=c[e]??{},p=u[l]??ej[l],m={...u,[l]:!p};c[e]=m,W_(c),n(m)},[e]);return{isCollapsed:s,toggle:a}}function K_({projectId:e}){const{data:t,loading:n,error:s,refetch:a}=E_(e),[l,c]=f.useState(""),[u,p]=f.useState(""),[m,h]=f.useState(""),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(new Set),[N,T]=f.useState(!1),[D,R]=f.useState(!1),[$,L]=f.useState(null),K=f.useRef(null);mo("list:todos");const B=gx("project:"+e),[O,W]=f.useState(null),[se,z]=f.useState(null),H=f.useRef(null);function ee(Y,pe){Y.stopPropagation(),navigator.clipboard.writeText(pe),E(pe),setTimeout(()=>E(Q=>Q===pe?null:Q),1500)}const ne=f.useMemo(()=>{if(!(t!=null&&t.items))return[];const Y=new Set;for(const pe of t.items)for(const Q of pe.tags)Y.add(Q);return Array.from(Y).sort()},[t]),M=f.useMemo(()=>{if(!(t!=null&&t.items))return[];let Y=t.items;if(l.trim()){const pe=l.toLowerCase();Y=Y.filter(Q=>Q.description.toLowerCase().includes(pe)||Q.tags.some(ye=>ye.toLowerCase().includes(pe))||Q.id.includes(pe))}return u&&(Y=Y.filter(pe=>pe.status===u)),m&&(Y=Y.filter(pe=>pe.tags.includes(m))),Y},[t,l,u,m]);f.useEffect(()=>{C(new Set)},[l,u,m,e]);const G=f.useMemo(()=>M.filter(Y=>k.has(Y.id)).length,[M,k]),A=M.length>0&&G===M.length,F=G>0&&!A;function Z(Y){C(pe=>{const Q=new Set(pe);return Q.has(Y)?Q.delete(Y):Q.add(Y),Q})}function I(){C(Y=>{const pe=new Set(Y);if(A)for(const Q of M)pe.delete(Q.id);else for(const Q of M)pe.add(Q.id);return pe})}function de(){C(new Set)}const ge=$?[$]:Array.from(k);function V(){C(new Set),L(null),a()}function ae(){C(new Set),a()}async function me(){g.trim()&&(await T_(e,g.trim()),y(""),a())}async function ve(Y,pe,Q){Y.stopPropagation(),window.confirm(`Delete "${Q}"? This can't be undone.`)&&(await $_(e,pe),a())}async function ke(Y,pe){switch(pe){case"open":await D_(e,Y);break;case"in_progress":await A_(e,Y);break;case"completed":await R_(e,Y);break;case"blocked":await P_(e,Y);break}a()}async function he(Y,pe){await L_(e,Y,pe),a()}async function Je(Y,pe){await O_(e,Y,pe),a()}async function Ye(Y,pe){await I_(e,Y,pe),a()}const ot=hx(M),J=ot.filter(Y=>!B.isCollapsed(Y.config.id)).flatMap(Y=>Y.items),{hotkeyRowProps:Ie}=ac(J,{scope:"list:todos",bindO:!1,onOpen:Y=>w(Y.id)});Ht({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var Y;return(Y=K.current)==null?void 0:Y.focus()}}),Ht({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>a()});const[Ne,Oe]=hs(),Xe=Ne.get("focus");f.useEffect(()=>{if(!Xe||!(t!=null&&t.items))return;const Y=t.items.find(Q=>Q.id===Xe);if(!Y)return;const pe=lf(Y.status);B.isCollapsed(pe)&&B.toggle(pe)},[Xe,t==null?void 0:t.items]),f.useEffect(()=>{if(!Xe)return;const Y=document.querySelector(`[data-todo-id="${window.CSS.escape(Xe)}"]`);if(!Y)return;Y.scrollIntoView({block:"nearest"}),Y.classList.add("ring-2","ring-primary/60");const pe=window.setTimeout(()=>{Y.classList.remove("ring-2","ring-primary/60"),Oe(Q=>{const ye=new URLSearchParams(Q);return ye.delete("focus"),ye},{replace:!0})},1500);return()=>window.clearTimeout(pe)},[Xe,J.length,Oe]);const Me=O?(t==null?void 0:t.items.find(Y=>Y.id===O))??null:null;function nt(Y,pe){const Q=H.current;if(Q!=null&&Q.closest(mi)){Y.preventDefault();return}Y.dataTransfer.effectAllowed="move",Y.dataTransfer.setData("text/plain",pe),W(pe)}function Ke(){W(null),z(null)}function gt(Y,pe){!Me||pe.statuses.includes(Me.status)||(Y.preventDefault(),Y.dataTransfer.dropEffect="move",z(pe.id))}function Rt(Y,pe){se===pe.id&&!Y.currentTarget.contains(Y.relatedTarget)&&z(null)}function at(Y,pe){Y.preventDefault();const Q=Me;Ke(),!(!Q||pe.statuses.includes(Q.status))&&ke(Q.id,pe.dropStatus)}if(n)return r.jsx(mt,{label:"Loading todos..."});if(s)return r.jsx(wt,{error:s});const ie=(t==null?void 0:t.counts)||{open:0,in_progress:0,blocked:0,total:0};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[r.jsx(An,{label:"Open",value:ie.open,icon:Dr}),r.jsx(An,{label:"In Progress",value:ie.in_progress,icon:Dr,tone:"info"}),r.jsx(An,{label:"Blocked",value:ie.blocked,icon:ag,tone:"warn"}),r.jsx(An,{label:"Total",value:ie.total,icon:Dr})]}),r.jsx("div",{className:"surface-panel p-3",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",placeholder:"Add a todo...",value:g,onChange:Y=>y(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&me(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),r.jsxs("button",{onClick:me,disabled:!g.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add"]})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(fo,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx("input",{ref:K,type:"text",placeholder:"Search...",value:l,onChange:Y=>c(Y.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),r.jsxs("select",{value:u,onChange:Y=>p(Y.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[r.jsx("option",{value:"",children:"All statuses"}),r.jsx("option",{value:"open",children:"Open"}),r.jsx("option",{value:"in_progress",children:"In Progress"}),r.jsx("option",{value:"completed",children:"Completed"}),r.jsx("option",{value:"blocked",children:"Blocked"})]}),ne.length>0&&r.jsxs("select",{value:m,onChange:Y=>h(Y.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[r.jsx("option",{value:"",children:"All tags"}),ne.map(Y=>r.jsxs("option",{value:Y,children:["#",Y]},Y))]})]}),k.size>0?r.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[r.jsxs("span",{className:"text-sm font-medium",children:[k.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>T(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),r.jsx("button",{type:"button",onClick:()=>{L(null),R(!0)},className:"shell-action",children:"Move to…"}),r.jsx("button",{type:"button",onClick:de,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,M.length>0&&r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[r.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:A,ref:Y=>{Y&&(Y.indeterminate=F)},onChange:I,className:"h-4 w-4 cursor-pointer accent-foreground"}),r.jsxs("span",{children:["Select all in current filter (",M.length,")"]})]}),r.jsx("div",{className:"space-y-3",children:(()=>{let Y=-1;return ot.map(({config:pe,items:Q})=>{const ye=!B.isCollapsed(pe.id);return r.jsx(mx,{label:pe.label,count:Q.length,expanded:ye,onToggle:()=>B.toggle(pe.id),isDropTarget:se===pe.id,onDragOver:Pe=>gt(Pe,pe),onDragLeave:Pe=>Rt(Pe,pe),onDrop:Pe=>at(Pe,pe),children:ye&&Q.map(Pe=>(Y+=1,r.jsx(ZS,{item:Pe,copiedId:b,selected:k.has(Pe.id),editing:j===Pe.id,onBeginEdit:lt=>w(lt),onEndEdit:()=>w(null),onPatchDescription:he,onAddAttachments:Je,onDeleteAttachment:Ye,attachmentUrl:(lt,te)=>JS(e,lt,te),onToggleSelected:lt=>Z(lt),onMoveOne:(lt,te)=>{te.stopPropagation(),L(lt),R(!0)},onStatusChange:ke,onCopyId:ee,onDelete:ve,hotkeyRowProps:Ie(Y),onDragOrigin:lt=>{H.current=lt.target},onDragStart:nt,onDragEnd:Ke,isDragging:O===Pe.id},Pe.id)))},pe.id)})})()}),r.jsx(px,{open:N,selectedIds:Array.from(k),scope:{kind:"project",projectId:e},onOpenChange:T,onDone:ae}),r.jsx(rN,{open:D,selectedIds:ge,scope:{kind:"project",projectId:e},onOpenChange:Y=>{R(Y),Y||L(null)},onDone:V})]})}const q_={title:"Assignment",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},tj=new Set(["title"]);function aN({visibility:e,onChange:t}){const[n,s]=f.useState(!1);function a(c){if(tj.has(c))return;const p=e.hidden.includes(c)?e.hidden.filter(m=>m!==c):[...e.hidden,c];t({hidden:p})}const l=e.hidden.length;return r.jsxs(ar,{open:n,onOpenChange:s,children:[r.jsx($3,{asChild:!0,children:r.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Show or hide table columns",children:[r.jsx(aR,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsxs("span",{children:["Columns",l>0?` (${Sm.length-l}/${Sm.length})`:""]})]})}),r.jsxs(Kn,{className:"max-w-sm",children:[r.jsx(Zr,{children:r.jsx(qn,{children:"Columns"})}),r.jsx("div",{className:"space-y-2",children:Sm.map(c=>{const u=e.hidden.includes(c),p=tj.has(c);return r.jsxs("label",{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm ${p?"opacity-60":"cursor-pointer hover:bg-background/80"}`,children:[r.jsx("input",{type:"checkbox",checked:!u,onChange:()=>a(c),disabled:p,className:"h-4 w-4 rounded border-border accent-foreground"}),r.jsx("span",{children:q_[c]}),p?r.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"always shown"}):null]},c)})})]})]})}const ui={...Vl,custom:!1},iN=`view-prefs.cache.v${Vl.version}`;let Gl=G_(),Ha=null;const Yl=new Set;let lN=0;function xx(){return++lN}function yx(e){return e===lN}function G_(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(iN);if(!e)return null;const t=JSON.parse(e);return t.version!==Vl.version?null:t}catch{return null}}function Y_(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(iN,JSON.stringify(e))}catch{}}function bx(e){Gl=e,Y_(e);for(const t of Yl)t(e)}function vx(e){if(!e||typeof e!="object")return ui;const t=e;return t.version!==Vl.version||!t.global||!t.projects?ui:{version:Vl.version,global:t.global,projects:t.projects,custom:t.custom===!0}}function wx(){if(Ha)return Ha;const e=xx();return Ha=fetch("/api/view-prefs").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=vx(t);return yx(e)&&bx(n),Ha=null,Gl??n}).catch(()=>(Ha=null,Gl??ui)),Ha}function cN(e){const[t,n]=f.useState(()=>Gl??ui);return f.useEffect(()=>{let s=!1;return wx().then(a=>{s||n(a)}),Yl.add(n),()=>{s=!0,Yl.delete(n)}},[]),r1(t,e??null)}function J_(){const[e,t]=f.useState(()=>Gl??ui);return f.useEffect(()=>{let n=!1;return wx().then(s=>{n||t(s)}),Yl.add(t),()=>{n=!0,Yl.delete(t)}},[]),e}async function uN(e){const t=xx(),n=await fetch("/api/view-prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const a=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(a.error??"Failed to save view-prefs")}const s=vx(await n.json());return yx(t)&&bx(s),s}function dN(e){return uN({global:e})}function fN(e,t){return uN({projects:{[e]:t}})}async function X_(){const e=xx(),t=await fetch("/api/view-prefs",{method:"DELETE"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=vx(await t.json());return yx(e)&&bx(n),n}const nj=80;function pN({open:e,onOpenChange:t,initialName:n="",onSubmit:s,title:a="Save view"}){const[l,c]=f.useState(n),[u,p]=f.useState(!1),[m,h]=f.useState(null);f.useEffect(()=>{e&&(c(n),h(null),p(!1))},[e,n]);const g=l.trim(),y=g.length>0&&g.length<=nj;return r.jsx(ar,{open:e,onOpenChange:t,children:r.jsx(Kn,{className:"max-w-md",children:r.jsxs("form",{className:"space-y-4",onSubmit:async b=>{if(b.preventDefault(),!(!y||u)){p(!0),h(null);try{await s(g)}catch(E){h(E instanceof Error?E.message:String(E)),p(!1)}}},children:[r.jsx(Zr,{children:r.jsx(qn,{children:a})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("input",{type:"text",value:l,autoFocus:!0,required:!0,maxLength:nj,onChange:b=>c(b.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),m?r.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:m}):null]}),r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:u,children:"Cancel"}),r.jsx("button",{type:"submit",disabled:!y||u,className:"shell-action shell-action--cta disabled:opacity-50",children:u?"Saving…":"Save"})]})]})})})}function mN({scope:e,loadedViewId:t,onApply:n,onOpenSaveDialog:s}){const{views:a,loading:l}=Vd(),[c,u]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{if(!c)return;function y(E){p.current&&!p.current.contains(E.target)&&u(!1)}function b(E){E.key==="Escape"&&u(!1)}return document.addEventListener("mousedown",y),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",b)}},[c]);const m=f.useMemo(()=>a.filter(y=>o1(y,e)),[a,e]),h=t?a.find(y=>y.id===t)??null:null,g=l?"Saved views…":h?h.name:"Saved views";return r.jsxs("div",{className:"relative",ref:p,children:[r.jsxs("button",{type:"button",disabled:l,onClick:()=>u(y=>!y),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":c,title:"Saved views",children:[r.jsx("span",{className:"max-w-[160px] truncate",children:g}),r.jsx(br,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),c&&r.jsx("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:m.length===0?r.jsxs("div",{className:"px-3 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"mb-2",children:"No saved views yet — Save the current view to start."}),r.jsx("button",{type:"button",onClick:()=>{u(!1),s()},className:"shell-action w-full justify-center",children:"Save current view"})]}):m.map(y=>{const b=y.id===t;return r.jsxs("button",{type:"button",onClick:()=>{u(!1),n(y)},className:Se("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",b&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:b?r.jsx(Xr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),r.jsx("span",{className:"truncate",children:y.name})]},y.id)})})]})}const Q_={__unassigned__:"Unassigned",__standalone__:"No project"};function Pn({options:e,value:t,onChange:n,allLabel:s="Any",className:a,disabled:l,ariaLabel:c}){const[u,p]=f.useState(!1),m=f.useRef(null),h=f.useRef(null),g=f.useRef([]),y=f.useMemo(()=>{const C=new Set(e.map(T=>T.value)),N=t.filter(T=>!C.has(T)).map(T=>({value:T,label:Q_[T]??T}));return[...e,...N]},[e,t]),b=f.useMemo(()=>new Set(t),[t]);f.useEffect(()=>{if(!u)return;function C(N){m.current&&!m.current.contains(N.target)&&p(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u]),f.useEffect(()=>{var C;u&&((C=g.current[0])==null||C.focus())},[u]);const E=f.useMemo(()=>{if(t.length===0)return s;if(t.length===1){const C=y.find(N=>N.value===t[0]);return C?C.label:t[0]}return`${t.length} selected`},[t,y,s]);function j(C){n(b.has(C)?t.filter(N=>N!==C):[...t,C])}function w(C){var T;const N=Math.max(0,Math.min(C,y.length-1));(T=g.current[N])==null||T.focus()}function k(C){var R;const N=g.current,T=document.activeElement,D=N.findIndex($=>$===T);C.key==="ArrowDown"?(C.preventDefault(),w(D<0?0:D+1)):C.key==="ArrowUp"?(C.preventDefault(),w(D<0?y.length-1:D-1)):C.key==="Home"?(C.preventDefault(),w(0)):C.key==="End"?(C.preventDefault(),w(y.length-1)):C.key==="Escape"&&(C.preventDefault(),p(!1),(R=h.current)==null||R.focus())}return r.jsxs("div",{className:"relative",ref:m,children:[r.jsxs("button",{type:"button",ref:h,disabled:l,"aria-haspopup":"menu","aria-expanded":u,"aria-label":c,onClick:()=>p(C=>!C),onKeyDown:C=>{!u&&(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),p(!0))},className:Se("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",a),children:[r.jsx("span",{className:"truncate",children:E}),r.jsx(br,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),u?r.jsxs("div",{role:"menu","aria-label":c,onKeyDown:k,className:"absolute left-0 top-full z-30 mt-1 max-h-72 min-w-[200px] overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===y.length,onClick:()=>n(y.map(C=>C.value)),children:"Select all"}),r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===0,onClick:()=>n([]),children:"Clear"})]}),y.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):y.map((C,N)=>{const T=b.has(C.value);return r.jsxs("button",{ref:D=>{g.current[N]=D},type:"button",role:"menuitemcheckbox","aria-checked":T,tabIndex:-1,onClick:()=>j(C.value),className:Se("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",T?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:Se("flex h-4 w-4 shrink-0 items-center justify-center rounded border",T?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:T?r.jsx(Xr,{className:"h-3 w-3"}):null}),r.jsx("span",{className:"truncate",children:C.label})]},C.value)})]}):null]})}const rj={last_24h:"Last 24 hours",last_7d:"Last 7 days",last_30d:"Last 30 days",last_90d:"Last 90 days",older_7d:"Older than 7 days",older_30d:"Older than 30 days"},Z_=["updated","created"];function jx({value:e,onChange:t,className:n,ariaLabel:s="Date range filter"}){const[a,l]=f.useState(!1),c=f.useRef(null),u=(e==null?void 0:e.field)??"updated",p=!!(e&&!e.preset&&(e.from||e.to)),[m,h]=f.useState(p);f.useEffect(()=>h(p),[p]),f.useEffect(()=>{if(!a)return;function k(N){c.current&&!c.current.contains(N.target)&&l(!1)}function C(N){N.key==="Escape"&&l(!1)}return document.addEventListener("mousedown",k),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",C)}},[a]);const g=!!(e&&(e.preset||e.from||e.to)),y=f.useMemo(()=>!g||!e?"Any date":e.preset?`${u}: ${rj[e.preset]??e.preset}`:`${u}: ${e.from||"…"} → ${e.to||"…"}`,[g,e,u]);function b(k){t(e?{...e,field:k}:{field:k,preset:"",from:"",to:""})}function E(k){h(!1),t({field:u,preset:k,from:"",to:""})}function j(){h(!1),t(null)}function w(k,C){const N={field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...N,[k]:C})}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":a,"aria-label":s,onClick:()=>l(k=>!k),className:Se("editor-input inline-flex items-center justify-between gap-1.5 text-left",g&&"border-foreground/40 text-foreground",n),children:[r.jsx("span",{className:"truncate",children:y}),r.jsx(br,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),a?r.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border border-border/70 bg-background p-2 shadow-lg",children:[r.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:Z_.map(k=>r.jsx("button",{type:"button","aria-pressed":u===k,onClick:()=>b(k),className:Se("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",u===k?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:k},k))}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Km,{label:"Any date",selected:!g,onClick:j}),ID.map(k=>r.jsx(Km,{label:rj[k],selected:(e==null?void 0:e.preset)===k,onClick:()=>E(k)},k)),r.jsx(Km,{label:"Custom range…",selected:m,onClick:()=>{h(!0),t({field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),m?r.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",r.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:k=>w("from",k.target.value),className:"editor-input w-40"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",r.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:k=>w("to",k.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Km({label:e,selected:t,onClick:n}){return r.jsxs("button",{type:"button",onClick:n,className:Se("flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm transition hover:bg-foreground/5",t?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{children:e}),t?r.jsx(Xr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const eF=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search"]);function tF(e,t){const n={};for(const[s,a]of Object.entries(e))eF.has(s)||(n[s]=a);return{...n,...t}}function kx(e,t,n){return{...e,viewMode:t.viewMode,filters:tF(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function nF(e,t){var m;const n={},s=tt(e.status);s.length&&(n.status=s);const a=tt(e.type);a.length&&(n.type=a);const l=tt(e.priority);l.length&&(n.priority=l);const c=tt(e.assignee);c.length&&(n.assignee=c);const u=tt(e.tags);if(u.length&&(n.tags=u),t&&t!=="all")n.project=[t];else{const h=tt(e.project);h.length&&(n.project=h)}e.activity&&e.activity!=="all"&&(n.activity=e.activity),e.dateRange&&(n.dateRange=e.dateRange);const p=(m=e.search)==null?void 0:m.trim();return p&&(n.search=p),n}function Jl(e){const t={viewMode:e.state.viewMode,filters:nF(e.state.filters,e.context.projectSlug),sortField:e.state.sortField,sortDirection:e.state.sortDirection,listSectionVisibility:{collapsed:[...e.state.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...e.state.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...e.state.tableColumnVisibility.hidden]}};return{name:e.name.trim(),workspace:e.context.workspace,config:t}}const Wa={viewMode:"kanban",sortField:"updated",sortDirection:"desc"};function hN(e,t){const{config:n}=Jl({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:e.viewMode,filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}});return{workspace:t,config:n}}function Xl(e){if(!e)return;if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function gN(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function xN(e,t){var s,a,l,c,u,p,m,h,g,y,b,E,j,w;const{config:n}=e;if((s=t.setViewMode)==null||s.call(t,n.viewMode),(a=t.setStatusFilter)==null||a.call(t,tt(n.filters.status)),(l=t.setTypeFilter)==null||l.call(t,tt(n.filters.type)),(c=t.setPriorityFilter)==null||c.call(t,tt(n.filters.priority)),(u=t.setAssigneeFilter)==null||u.call(t,tt(n.filters.assignee)),(p=t.setProjectFilter)==null||p.call(t,tt(n.filters.project)),(m=t.setTagsFilter)==null||m.call(t,tt(n.filters.tags)),(h=t.setDateRange)==null||h.call(t,gN(n.filters.dateRange)),(g=t.setSearch)==null||g.call(t,n.filters.search??""),t.setActivityFilter){const k=n.filters.activity??"all";t.setActivityFilter(k==="fresh"||k==="stale"?k:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(b=t.setSortDirection)==null||b.call(t,n.sortDirection),(E=t.setListSectionVisibility)==null||E.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(j=t.setKanbanColumnVisibility)==null||j.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(w=t.setTableColumnVisibility)==null||w.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Xu(e){return e?`/w/${e}/views`:"/views"}function yN(e){return`${Xu(e.workspace)}/${encodeURIComponent(e.id)}`}function bN(e){const t=e.workspace?`/w/${e.workspace}`:"",n=tt(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&s1(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const rF=["critical","high","medium","low"],sF={last_24h:"last 24 hours",last_7d:"last 7 days",last_30d:"last 30 days",last_90d:"last 90 days",older_7d:"older than 7 days",older_30d:"older than 30 days"};function oF(e){if(e.preset)return`${e.field} ${sF[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function vN(e){var s;const t=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=tt(e[a]);l.length&&t.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&t.push(`activity=${e.activity}`),e.dateRange&&t.push(oF(e.dateRange));const n=(s=e.search)==null?void 0:s.trim();return n&&t.push(`search="${n}"`),t.join(" · ")||"no filters"}const aF=new Set(["overview","assignments","todos","dependencies","knowledge"]),sj="__unknown_type__";function oj(){const{slug:e,workspace:t}=$t(),n=ln(),s=Dt();mo("project"),Ht({keys:"a",scope:"project",description:"Create assignment",handler:()=>s(`${n}/projects/${e}/create/assignment`)}),Ht({keys:"e",scope:"project",description:"Edit project",handler:()=>s(`${n}/projects/${e}/edit`)});const{data:a,loading:l,error:c,refetch:u}=F0(e),p=Zo(),m=ef(),{data:h}=oc(),[g,y]=hs(),b=g.get("tab"),E=b&&aF.has(b)?b:"overview";function j(re){y(Ae=>{const Qe=new URLSearchParams(Ae);return re==="overview"?Qe.delete("tab"):Qe.set("tab",re),Qe},{replace:!0})}const w=e?`p:${e}`:null,k=cN(w),[C,N]=f.useState(()=>km(k.defaultView)),[T,D]=f.useState(()=>tt(k.filters.status)),[R,$]=f.useState(()=>tt(k.filters.assignee)),[L,K]=f.useState(()=>tt(k.filters.priority)),[B,O]=f.useState(()=>tt(k.filters.type)),[W,se]=f.useState(()=>tt(k.filters.tags)),[z,H]=f.useState(null),[ee,ne]=f.useState(()=>k.grouping),[M,G]=f.useState(()=>k.sortField),[A,F]=f.useState(()=>k.sortDirection),[Z,I]=f.useState(()=>({collapsed:[]})),[de,ge]=f.useState(()=>({hidden:[]})),[V,ae]=f.useState(()=>({hidden:[]})),[me,ve]=f.useState(null),[ke,he]=f.useState(!1),[Je,Ye]=f.useState(!1),{toast:ot,showToast:J,dismissToast:Ie}=ta(),Ne={kind:"project",slug:e??"",workspace:t??null},Oe=g.get("loadView"),{view:Xe,loading:Me,error:nt}=Go(Oe),{view:Ke,loading:gt,error:Rt}=Go(me),at=f.useRef(null);f.useEffect(()=>{me&&!gt&&!Rt&&!Ke&&ve(null)},[Ke,Rt,me,gt]),f.useEffect(()=>{ve(null),at.current=null,H(null)},[e,t]),f.useEffect(()=>{N(km(k.defaultView)),D(tt(k.filters.status)),$(tt(k.filters.assignee)),K(tt(k.filters.priority)),O(tt(k.filters.type)),se(tt(k.filters.tags)),ne(k.grouping),G(k.sortField),F(k.sortDirection)},[e,k.defaultView,k.filters.status,k.filters.assignee,k.filters.priority,k.filters.type,k.filters.tags,k.grouping,k.sortField,k.sortDirection]);const ie=f.useCallback(re=>{w&&fN(w,re).catch(Ae=>{console.warn("Failed to persist project view prefs:",Ae)})},[w]),Y=f.useCallback(re=>{N(re),ie({defaultView:re})},[ie]),pe=f.useCallback(re=>{D(re),ie({filters:{status:re}})},[ie]),Q=f.useCallback(re=>{$(re),ie({filters:{assignee:re}})},[ie]),ye=f.useCallback(re=>{K(re),ie({filters:{priority:re}})},[ie]),Pe=f.useCallback(re=>{O(re),ie({filters:{type:re}})},[ie]),lt=f.useCallback(re=>{se(re),ie({filters:{tags:re}})},[ie]),te=f.useCallback(re=>{ne(re),ie({grouping:re})},[ie]),be=f.useCallback(re=>{G(re),ie({sortField:re})},[ie]),Le=f.useCallback(re=>{F(re),ie({sortDirection:re})},[ie]),it=f.useCallback(()=>({viewMode:C,filters:{status:T,priority:L,type:B,assignee:R,tags:W,project:"all",activity:"all",dateRange:Xl(z)},sortField:M,sortDirection:A,listSectionVisibility:Z,kanbanColumnVisibility:de,tableColumnVisibility:V}),[C,T,L,B,R,W,z,M,A,Z,de,V]),_e=f.useCallback(re=>{xN(re,{setViewMode:Ae=>N(km(Ae)),setStatusFilter:pe,setPriorityFilter:ye,setTypeFilter:Pe,setAssigneeFilter:Q,setTagsFilter:lt,setDateRange:H,setSortField:be,setSortDirection:Le,setListSectionVisibility:I,setKanbanColumnVisibility:ge,setTableColumnVisibility:ae}),ve(re.id)},[pe,ye,Pe,Q,lt,be,Le]),bt=f.useCallback(re=>{_e(re),at.current=re.id,y(Ae=>{const Qe=new URLSearchParams(Ae);return Qe.set("loadView",re.id),Qe},{replace:!0})},[_e,y]),_t=f.useCallback(async re=>{try{const Ae=Jl({name:re,context:{workspace:t??null,projectSlug:e??null},state:it()}),Qe=await Wd(Ae),Ft=Qe.views[Qe.views.length-1];ve((Ft==null?void 0:Ft.id)??null),Ft&&(at.current=Ft.id,y(hn=>{const Ct=new URLSearchParams(hn);return Ct.set("loadView",Ft.id),Ct},{replace:!0})),he(!1),Ye(!1),J(`Saved view "${re}"`,"success")}catch(Ae){throw J(Ae instanceof Error?Ae.message:"Failed to save view","error"),Ae}},[it,y,J,e,t]),Gt=f.useCallback(async()=>{if(!(!me||!Ke))try{const re=tt(Ke.config.filters.project)[0]??null,Ae=Jl({name:Ke.name,context:{workspace:t??null,projectSlug:re},state:it()}),Qe=kx(Ke.config,Ae.config,Ae.config);await Lg(me,{config:Qe}),J("View updated","success")}catch(re){J(re instanceof Error?re.message:"Failed to update view","error")}},[it,Ke,me,J,t]);f.useEffect(()=>{if(!Oe){at.current=null;return}if(at.current!==Oe&&(me&&me!==Oe&&ve(null),!Me)){if(nt){J("Couldn't load saved view — try again","error");return}if(Xe){if(at.current=Oe,!o1(Xe,{kind:"project",slug:e??"",workspace:t??null})){s(bN(Xe),{replace:!0});return}_e(Xe),y(re=>{const Ae=new URLSearchParams(re);return Ae.delete("loadView"),Ae},{replace:!0});return}at.current=Oe,J("Saved view no longer exists","error"),y(re=>{const Ae=new URLSearchParams(re);return Ae.delete("loadView"),Ae},{replace:!0})}},[Oe,Xe,Me,nt,me,_e,y,J,s,e,t]);function ue(re){M===re?Le(A==="asc"?"desc":"asc"):(be(re),Le("asc"))}const Be=f.useMemo(()=>a?Object.fromEntries(a.assignments.flatMap(re=>{const Ae=`${n}/projects/${a.slug}/assignments/${re.slug}`;return[[re.slug,Ae],[re.title,Ae]]})):{},[a]);async function Fe(re){await fetch(`/api/projects/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:re})}),u()}async function Nt(re){try{const Ae=await fetch(`/api/projects/${e}/${re?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Ae.ok){const Qe=await Ae.json().catch(()=>null);J((Qe==null?void 0:Qe.error)||`HTTP ${Ae.status}`,"error");return}u(),J(re?"Project archived":"Project restored","success")}catch(Ae){J(Ae instanceof Error?Ae.message:"Failed to update archive state","error")}}async function $n(re){await fetch(`/api/projects/${e}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:re})}),u()}if(l)return r.jsx(mt,{label:"Loading project workspace…"});if(c||!a)return r.jsx(wt,{error:c||"Project not found."});const Yt=(()=>{const re=new Set;for(const Qe of a.assignments)Qe.assignee&&re.add(Qe.assignee);const Ae=[{value:"__unassigned__",label:"Unassigned"}];for(const Qe of Array.from(re).sort())Ae.push({value:Qe,label:Qe});return Ae})(),sn=Array.from(new Set(a.assignments.flatMap(re=>re.tags??[]))).sort().map(re=>({value:re,label:re})),Wt=a.assignments.filter(re=>Kg(re,{status:T,priority:L,type:B,assignee:R,tags:W,dateRange:Xl(z)})),Gn=uc(Wt,M,A),xt=new Set(m.definitions.map(re=>re.id)),jn=ee==="type"?[...m.definitions.map(re=>({id:re.id,title:ii(m,re.id),description:re.description})),...Wt.some(re=>!re.type||!xt.has(re.type))?[{id:sj,title:"Other",description:"Assignments with no recognized type."}]:[]]:G1(p.order).map(re=>({id:re,title:cc(p,re),description:Zd(re)}));function Pt({field:re,children:Ae}){const Qe=M===re;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>ue(re),className:"inline-flex items-center gap-1 hover:text-foreground",children:[Ae,Qe?A==="asc"?r.jsx(c0,{className:"h-3 w-3"}):r.jsx(br,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":k.density,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:a.status}),a.statusOverride&&r.jsx("button",{type:"button",className:"shell-action border-warning-foreground/40 text-warning-foreground",onClick:()=>Fe(null),title:"Clear manual status override and return to derived status",children:"Clear Override"}),r.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm",value:"",onChange:re=>{re.target.value&&Fe(re.target.value)},title:"Override project status",children:[r.jsx("option",{value:"",children:"Set Status…"}),p.statuses.map(re=>r.jsx("option",{value:re.id,children:re.label},re.id)),r.jsx("option",{value:"active",children:"Active"})]}),r.jsx("button",{type:"button",className:"shell-action",onClick:()=>Nt(!a.archived),title:a.archived?"Restore this project and its cascade-hidden assignments":"Archive this project (hides it and its assignments from normal views)",children:a.archived?"Restore":"Archive"}),h&&h.workspaces.length>0&&r.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm",value:"",onChange:re=>{re.target.value==="_ungrouped"?$n(null):re.target.value&&$n(re.target.value)},title:"Move project to a different workspace",children:[r.jsx("option",{value:"",children:"Move to Workspace…"}),h.workspaces.filter(re=>re!==a.workspace).map(re=>r.jsx("option",{value:re,children:re},re)),a.workspace&&r.jsx("option",{value:"_ungrouped",children:"Ungrouped"})]}),r.jsxs(Ee,{className:"shell-action",to:`${n}/projects/${a.slug}/edit`,children:[r.jsx(gv,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Project"})]}),r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${n}/projects/${a.slug}/create/assignment`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Assignment"})]}),r.jsx(Jg,{externalIds:a.externalIds}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Created ",Dn(a.created),". Last source update ",Lr(a.updated),"."]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-5",children:[r.jsx(An,{label:"Assignments",value:a.progress.total}),r.jsx(An,{label:"In Progress",value:a.progress.in_progress??0,tone:"info"}),r.jsx(An,{label:"Review",value:a.progress.review??0,tone:"info"}),r.jsx(An,{label:"Blocked",value:a.progress.blocked??0,tone:"warn"}),r.jsx(An,{label:"Completed",value:a.progress.completed??0,tone:"success"})]}),r.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(Qg,{value:E,onValueChange:j,items:[{value:"overview",label:"Overview",content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Project Overview",children:r.jsx(fn,{content:a.body,emptyState:"This project does not have overview content yet."})})})},{value:"assignments",label:"Assignments",count:a.assignments.filter(re=>!re.archived).length,content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Assignment Queue",description:"Board and table views over the source assignment files.",actions:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(Pn,{ariaLabel:"Status filter",className:"max-w-[170px]",allLabel:"All statuses",options:p.statuses.map(re=>({value:re.id,label:re.label})),value:T,onChange:pe}),r.jsx(Pn,{ariaLabel:"Assignee filter",className:"max-w-[170px]",allLabel:"All assignees",options:Yt,value:R,onChange:Q}),r.jsx(Pn,{ariaLabel:"Priority filter",className:"max-w-[170px]",allLabel:"All priorities",options:[{value:"critical",label:"Critical"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],value:L,onChange:ye}),r.jsx(Pn,{ariaLabel:"Type filter",className:"max-w-[170px]",allLabel:"All types",options:m.definitions.map(re=>({value:re.id,label:ii(m,re.id)})),value:B,onChange:Pe}),r.jsx(Pn,{ariaLabel:"Tags filter",className:"max-w-[170px]",allLabel:"Any tags",options:sn,value:W,onChange:lt}),r.jsx(jx,{className:"max-w-[190px]",value:z,onChange:H}),C==="kanban"&&r.jsxs("select",{value:ee==="type"?"type":"status",onChange:re=>te(re.target.value),className:"editor-input max-w-[170px]",title:"Group kanban by",children:[r.jsx("option",{value:"status",children:"Group: Status"}),r.jsx("option",{value:"type",children:"Group: Type"})]}),r.jsx(nf,{value:C,onChange:re=>Y(re),options:[{value:"kanban",label:"Kanban"},{value:"table",label:"Table"}]}),r.jsx(mN,{scope:Ne,loadedViewId:me,onApply:bt,onOpenSaveDialog:()=>{Ye(!1),he(!0)}}),r.jsx("button",{type:"button",onClick:()=>{Ke?Gt():(Ye(!1),he(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:Ke?`Update ${Ke.name}`:"Save current view",children:Ke?`Update '${Ke.name}'`:"Save view"}),Ke?r.jsx("button",{type:"button",onClick:()=>{Ye(!0),he(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),children:Wt.length===0?r.jsx(St,{title:"No assignments match these filters",description:"Clear the current filters or create a new assignment for this project.",actions:r.jsx(Ee,{className:"shell-action shell-action--cta",to:`${n}/projects/${a.slug}/create/assignment`,children:"Create Assignment"})}):C==="kanban"?r.jsx(Qd,{columns:jn,items:Gn,getItemId:re=>re.slug,getColumnId:re=>ee==="type"?re.type&&xt.has(re.type)?re.type:sj:re.status,dragDisabled:!0,renderCard:re=>r.jsx(iF,{projectSlug:a.slug,assignment:re}),emptyMessage:re=>`No ${re.title.toLowerCase()} assignments.`,hiddenColumnIds:de.hidden,onHideColumn:re=>ge(Ae=>({hidden:Ae.hidden.includes(re)?Ae.hidden.filter(Ft=>Ft!==re):[...Ae.hidden,re]}))}):(()=>{const re=new Set(V.hidden),Ae=Qe=>Qe==="title"||!re.has(Qe);return r.jsxs("div",{className:"overflow-x-auto",children:[r.jsx("div",{className:"mb-3 flex items-center justify-end",children:r.jsx(aN,{visibility:V,onChange:ae})}),r.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[Ae("title")?r.jsx(Pt,{field:"title",children:"Assignment"}):null,Ae("status")?r.jsx(Pt,{field:"status",children:"Status"}):null,r.jsx("th",{className:"pb-3 font-medium",children:"Type"}),Ae("priority")?r.jsx(Pt,{field:"priority",children:"Priority"}):null,Ae("assignee")?r.jsx(Pt,{field:"assignee",children:"Assignee"}):null,Ae("dependencies")?r.jsx(Pt,{field:"dependencies",children:"Dependencies"}):null,Ae("created")?r.jsx(Pt,{field:"created",children:"Created"}):null,Ae("updated")?r.jsx(Pt,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:Gn.map(Qe=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[Ae("title")?r.jsx("td",{className:"py-4",children:r.jsx(Ee,{to:`${n}/projects/${a.slug}/assignments/${Qe.slug}`,className:"font-semibold text-foreground hover:text-primary",children:Qe.title})}):null,Ae("status")?r.jsx("td",{className:"py-4",children:r.jsx(pn,{status:Qe.status})}):null,r.jsx("td",{className:"py-4",children:r.jsx(ea,{type:Qe.type,compact:!0})}),Ae("priority")?r.jsx("td",{className:"py-4 capitalize text-muted-foreground",children:Qe.priority}):null,Ae("assignee")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Qe.assignee??"—"}):null,Ae("dependencies")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Qe.dependsOn.length}):null,Ae("created")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(Qe.created)}):null,Ae("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(Qe.updated)}):null]},Qe.slug))})]})]})})()})})},{value:"todos",label:"Todos",content:r.jsx(K_,{projectId:a.slug})},{value:"dependencies",label:"Dependencies",content:a.dependencyGraph?r.jsx(We,{title:"Dependency Graph",description:"Rendered from the derived graph when available, with a source-based fallback.",children:r.jsx(sO,{definition:a.dependencyGraph,nodeRoutes:Be})}):r.jsx(St,{title:"No dependency graph yet",description:"Dependencies appear here once assignments declare dependsOn relationships."})},{value:"knowledge",label:"Knowledge",content:r.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[r.jsx(We,{title:"Resources",description:"Shared project references.",actions:r.jsxs(Ee,{className:"shell-action",to:`/resources/new?project=${a.slug}`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Resource"})]}),children:a.resources.length===0?r.jsx(St,{title:"No resources yet",description:"Resources live at the project level and stay available to every assignment."}):r.jsx("div",{className:"space-y-3",children:a.resources.map(re=>r.jsxs(Ee,{to:`/projects/${a.slug}/resources/${re.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:re.name}),r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[re.category," · ",re.source]})]},re.slug))})}),r.jsx(We,{title:"Memories",description:"Learnings and patterns captured during the project.",actions:r.jsxs(Ee,{className:"shell-action",to:`/memories/new?project=${a.slug}`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Memory"})]}),children:a.memories.length===0?r.jsx(St,{title:"No memories yet",description:"Memories capture patterns discovered during execution so later assignments can reuse them."}):r.jsx("div",{className:"space-y-3",children:a.memories.map(re=>r.jsxs(Ee,{to:`/projects/${a.slug}/memories/${re.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:re.name}),r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[re.scope," · ",re.source]})]},re.slug))})})]})}]})}),r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Progress Summary",children:r.jsx(gd,{progress:a.progress,showLegend:!0})}),r.jsx(We,{title:"Attention",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Blocked"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.blockedCount})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Failed"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.failedCount})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Unanswered questions"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.openQuestions})]})]})}),r.jsx(We,{title:"Quick Links",children:r.jsxs("div",{className:"space-y-2 text-sm",children:[r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${a.slug}/edit`,children:[r.jsx(gv,{className:"h-4 w-4"}),"Edit project source"]}),r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${a.slug}/create/assignment`,children:[r.jsx(rn,{className:"h-4 w-4"}),"Create assignment"]}),r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:"/help",children:[r.jsx(QT,{className:"h-4 w-4"}),"Review project rules"]}),r.jsxs("button",{type:"button",onClick:()=>j("dependencies"),className:"flex items-center gap-2 text-primary hover:underline",children:[r.jsx(tg,{className:"h-4 w-4"}),"Jump to dependencies"]})]})}),a.archived?r.jsxs(We,{title:"Archive Metadata",children:[r.jsxs("p",{className:"text-sm leading-6 text-muted-foreground",children:["Archived ",a.archivedAt?Lr(a.archivedAt):"with no timestamp recorded","."]}),a.archivedReason?r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.archivedReason}):null]}):null]})]}),r.jsx(na,{toast:ot,onDismiss:Ie}),r.jsx(pN,{open:ke,onOpenChange:re=>{he(re),re||Ye(!1)},initialName:Je&&Ke?`${Ke.name} (copy)`:"",title:Je?"Save as new view":"Save view",onSubmit:_t})]})}function iF({projectSlug:e,assignment:t}){const n=ln();return r.jsxs(Ee,{to:`${n}/projects/${e}/assignments/${t.slug}`,className:"vp-card block rounded-lg border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:t.title}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:t.id,children:[t.id.slice(0,8),r.jsx("span",{onClick:s=>{s.preventDefault(),s.stopPropagation()},children:r.jsx($r,{value:t.id})})]}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Dn(t.updated)]})]}),r.jsx(pn,{status:t.status})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ea,{type:t.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:t.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:t.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[t.dependsOn.length," dependencies"]})]})]})}function wN({sessionId:e,disabled:t=!1,disabledReason:n,onError:s,onNotice:a}){const[l,c]=f.useState(!1),[u,p]=f.useState(!1);async function m(){if(!(t||u)){p(!0);try{const h=await fetch(`/api/launch/command?session=${encodeURIComponent(e)}&mode=resume`);if(!h.ok){const y=await h.json().catch(()=>null);throw new Error((y==null?void 0:y.error)??`HTTP ${h.status}`)}const g=await h.json().catch(()=>null);if(!g||typeof g.command!="string")throw new Error("Malformed response from launch command endpoint");if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(g.command),c(!0),setTimeout(()=>c(!1),1500),typeof g.fallbackWarning=="string"&&g.fallbackWarning&&(a==null||a(g.fallbackWarning))}catch(h){s==null||s(h instanceof Error?h:new Error(String(h)))}finally{p(!1)}}}return t?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:n??"Copy launch command unavailable","aria-label":"Copy launch command",children:r.jsx(xv,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:m,disabled:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded disabled:cursor-wait",title:l?"Copied!":"Copy launch command (cd + resume)","aria-label":"Copy launch command",children:l?r.jsx(Xr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(xv,{className:"h-3 w-3","aria-hidden":"true"})})}function jl(e,t,n,s){let a=`syntaur://open?${e.kind}=${encodeURIComponent(e.id)}`;return e.kind==="session"&&t&&(a+=`&mode=${encodeURIComponent(t)}`),n&&(a+=`&terminal=${encodeURIComponent(n)}`),s&&e.kind==="assignment"&&(a+=`&agent=${encodeURIComponent(s)}`),a}function lF(e){return e.kind==="session"?{method:"POST",url:`/api/agent-sessions/${encodeURIComponent(e.id)}/worktree/recreate`}:e.projectSlug&&e.assignmentSlug?{method:"POST",url:`/api/projects/${encodeURIComponent(e.projectSlug)}/assignments/${encodeURIComponent(e.assignmentSlug)}/worktree/recreate`}:{method:"POST",url:`/api/assignments/${encodeURIComponent(e.id)}/worktree/recreate`}}function cF(e){if(!e.trim())return"Branch name is required.";if(/\s/.test(e))return"Branch name cannot contain whitespace.";if(/[\x00-\x1F\x7F~^:?*[\\]/.test(e))return"Branch name cannot contain any of: ~ ^ : ? * [ \\ or control characters.";if(e.startsWith("-"))return'Branch name cannot start with "-".';if(e.startsWith("/")||e.endsWith("/"))return'Branch name cannot start or end with "/".';if(e.endsWith("."))return'Branch name cannot end with ".".';if(e.includes(".."))return'Branch name cannot contain "..".';if(e.includes("@{"))return'Branch name cannot contain "@{".';if(e==="@")return'Branch name cannot be "@".';for(const t of e.split("/")){if(!t)return'Branch name cannot contain empty path segments (e.g. "a//b").';if(t.startsWith("."))return'Branch name segments cannot start with ".".';if(t.endsWith(".lock"))return'Branch name segments cannot end with ".lock".'}return null}async function jN(e,t,n,s){const a=await fetch(`/api/projects/${e}/assignments/${t}/transitions/${n.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{reason:s}:{})}),l=await a.json().catch(()=>null);if(!a.ok)throw new Error((l==null?void 0:l.error)||`HTTP ${a.status}`);return l.assignment}async function kN(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})}),a=await s.json().catch(()=>null);if(!s.ok)throw new Error((a==null?void 0:a.error)||`HTTP ${s.status}`);return a.assignment}async function uF(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}`,{method:"DELETE"}),s=await n.json().catch(()=>null);if(!n.ok)throw new Error((s==null?void 0:s.error)||`HTTP ${n.status}`)}function SN(e){return e.requiresReason||e.command==="block"}async function dF(e){const t=await fetch(`/api/projects/${e.projectSlug}/assignments/${e.assignmentSlug}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}async function fF(e){const t=await fetch(`/api/assignments/${e.id}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}class Sx extends Error{constructor(t,n){super(t),this.stderr=n,this.name="CreateWorktreeError"}}async function Nx(e){const t=await e.json().catch(()=>null);return new Sx((t==null?void 0:t.error)||`HTTP ${e.status}`,t==null?void 0:t.stderr)}async function pF(e){const t=await fetch(`/api/projects/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function mF(e){const t=await fetch(`/api/assignments/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function hF(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw await Nx(s);return(await s.json()).assignment}async function gF(e,t){const n=await fetch(`/api/assignments/${e}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await Nx(n);return(await n.json()).assignment}async function xF(e){const{url:t}=lF(e),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!n.ok)throw await Nx(n);return await n.json()}async function cf(e){const t=await e.json().catch(()=>null);if(!e.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${e.status}`);return t}async function yF(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/repository-branches?repo=${encodeURIComponent(n)}`);return cf(s)}async function bF(e,t){const n=await fetch(`/api/assignments/${e}/repository-branches?repo=${encodeURIComponent(t)}`);return cf(n)}async function vF(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}/source-assignments`);return(await cf(n)).sourceAssignments}async function wF(e){const t=await fetch(`/api/assignments/${e}/source-assignments`);return(await cf(t)).sourceAssignments}function NN(){const[e,t]=f.useState(!1),[n,s]=f.useState(null),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState(null),[h,g]=f.useState(null),[y,b]=f.useState(!1),[E,j]=f.useState(null),[w,k]=f.useState(null);async function C(R,$,L){if(!e){t(!0);try{const K=await fetch("/api/launch/preflight",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:{kind:R.kind,id:R.id}})});if(!K.ok){window.location.href=jl(R,$,void 0,L);return}const B=await K.json();if(B.ok){window.location.href=jl(R,$,void 0,L);return}if(B.reason==="workspace-path-invalid"){B.recreate?(m(B.recreate),g({target:R,mode:$,agentId:L})):u(B.message);return}s(B),l({target:R,mode:$,agentId:L})}catch(K){console.warn("preflight failed, firing without override:",K),window.location.href=jl(R,$,void 0,L)}finally{t(!1)}}}function N(){!n||!a||(window.location.href=jl(a.target,a.mode,n.suggestedFallback,a.agentId),s(null),l(null))}async function T(){if(!(!p||!h||y)){b(!0),j(null);try{const R=await xF({kind:p.kind,id:p.id,projectSlug:p.projectSlug,assignmentSlug:p.assignmentSlug}),{target:$,mode:L,agentId:K}=h;m(null),g(null),window.location.href=jl($,L,void 0,K),!R.exact&&!R.alreadyExisted&&k(`Recreated from ${R.baseUsed} — the original branch couldn't be restored exactly, but the directory is back and your agent is opening.`)}catch(R){j(R instanceof Sx&&R.stderr?`${R.message}
543
+ `},a),l}function XM(e,t){return e&&"run"in e?async function(n,s){const a=Bw(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Bw(n,{file:s,...e||t})}}function Uw(e){if(e)throw e}var Im,Vw;function QM(){if(Vw)return Im;Vw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},l=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var h=e.call(m,"constructor"),g=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!h&&!g)return!1;var y;for(y in m);return typeof y>"u"||e.call(m,y)},c=function(m,h){n&&h.name==="__proto__"?n(m,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):m[h.name]=h.newValue},u=function(m,h){if(h==="__proto__")if(e.call(m,h)){if(s)return s(m,h).value}else return;return m[h]};return Im=function p(){var m,h,g,y,b,E,j=arguments[0],w=1,k=arguments.length,C=!1;for(typeof j=="boolean"&&(C=j,j=arguments[1]||{},w=2),(j==null||typeof j!="object"&&typeof j!="function")&&(j={});w<k;++w)if(m=arguments[w],m!=null)for(h in m)g=u(j,h),y=u(m,h),j!==y&&(C&&y&&(l(y)||(b=a(y)))?(b?(b=!1,E=g&&a(g)?g:[]):E=g&&l(g)?g:{},c(j,{name:h,newValue:p(C,E,y)})):typeof y<"u"&&c(j,{name:h,newValue:y}));return j},Im}var ZM=QM();const Mm=Td(ZM);function Ih(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function e_(){const e=[],t={run:n,use:s};return t;function n(...a){let l=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);u(null,...a);function u(p,...m){const h=e[++l];let g=-1;if(p){c(p);return}for(;++g<a.length;)(m[g]===null||m[g]===void 0)&&(m[g]=a[g]);a=m,h?t_(h,u)(...m):c(null,...m)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function t_(e,t){let n;return s;function s(...c){const u=e.length>c.length;let p;u&&c.push(a);try{p=e.apply(this,c)}catch(m){const h=m;if(u&&n)throw h;return a(h)}u||(p&&p.then&&typeof p.then=="function"?p.then(l,a):p instanceof Error?a(p):l(p))}function a(c,...u){n||(n=!0,t(c,...u))}function l(c){a(null,c)}}const as={basename:n_,dirname:r_,extname:s_,join:o_,sep:"/"};function n_(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');pc(e);let n=0,s=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else s<0&&(l=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else c<0&&(l=!0,c=a+1),u>-1&&(e.codePointAt(a)===t.codePointAt(u--)?u<0&&(s=a):(u=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function r_(e){if(pc(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function s_(e){pc(e);let t=e.length,n=-1,s=0,a=-1,l=0,c;for(;t--;){const u=e.codePointAt(t);if(u===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),u===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function o_(...e){let t=-1,n;for(;++t<e.length;)pc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":a_(n)}function a_(e){pc(e);const t=e.codePointAt(0)===47;let n=i_(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function i_(e,t){let n="",s=0,a=-1,l=0,c=-1,u,p;for(;++c<=e.length;){if(c<e.length)u=e.codePointAt(c);else{if(u===47)break;u=47}if(u===47){if(!(a===c-1||l===1))if(a!==c-1&&l===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,l=0;continue}}else if(n.length>0){n="",s=0,a=c,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,l=0}else u===46&&l>-1?l++:l=-1}return n}function pc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const l_={cwd:c_};function c_(){return"/"}function Mh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function u_(e){if(typeof e=="string")e=new URL(e);else if(!Mh(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return d_(e)}function d_(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const _m=["history","path","basename","stem","extname","dirname"];class YS{constructor(t){let n;t?Mh(t)?n={path:t}:typeof t=="string"||f_(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":l_.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<_m.length;){const l=_m[s];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)_m.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?as.basename(this.path):void 0}set basename(t){zm(t,"basename"),Fm(t,"basename"),this.path=as.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?as.dirname(this.path):void 0}set dirname(t){Hw(this.basename,"dirname"),this.path=as.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?as.extname(this.path):void 0}set extname(t){if(Fm(t,"extname"),Hw(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=as.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Mh(t)&&(t=u_(t)),zm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?as.basename(this.path,this.extname):void 0}set stem(t){zm(t,"stem"),Fm(t,"stem"),this.path=as.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const a=this.message(t,n,s);throw a.fatal=!0,a}info(t,n,s){const a=this.message(t,n,s);return a.fatal=void 0,a}message(t,n,s){const a=new zn(t,n,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Fm(e,t){if(e&&e.includes(as.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+as.sep+"`")}function zm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Hw(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function f_(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const p_=(function(e){const s=this.constructor.prototype,a=s[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),m_={}.hasOwnProperty;class fx extends p_{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=e_()}copy(){const t=new fx;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Mm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Vm("data",this.frozen),this.namespace[t]=n,this):m_.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Vm("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=n.call(t,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Lu(t),s=this.parser||this.Parser;return Bm("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Bm("process",this.parser||this.Parser),Um("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,c){const u=Lu(t),p=s.parse(u);s.run(p,u,function(h,g,y){if(h||!g||!y)return m(h);const b=g,E=s.stringify(b,y);x_(E)?y.value=E:y.result=E,m(h,y)});function m(h,g){h||!g?c(h):l?l(g):n(void 0,g)}}}processSync(t){let n=!1,s;return this.freeze(),Bm("processSync",this.parser||this.Parser),Um("processSync",this.compiler||this.Compiler),this.process(t,a),Kw("processSync","process",n),s;function a(l,c){n=!0,Uw(l),s=c}}run(t,n,s){Ww(t),this.freeze();const a=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?l(void 0,s):new Promise(l);function l(c,u){const p=Lu(n);a.run(t,p,m);function m(h,g,y){const b=g||t;h?u(h):c?c(b):s(void 0,b,y)}}}runSync(t,n){let s=!1,a;return this.run(t,n,l),Kw("runSync","run",s),a;function l(c,u){Uw(c),a=u,s=!0}}stringify(t,n){this.freeze();const s=Lu(n),a=this.compiler||this.Compiler;return Um("stringify",a),Ww(t),a(t,s)}use(t,...n){const s=this.attachers,a=this.namespace;if(Vm("use",this.frozen),t!=null)if(typeof t=="function")p(t,n);else if(typeof t=="object")Array.isArray(t)?u(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(m){if(typeof m=="function")p(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[h,...g]=m;p(h,g)}else c(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function c(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");u(m.plugins),m.settings&&(a.settings=Mm(!0,a.settings,m.settings))}function u(m){let h=-1;if(m!=null)if(Array.isArray(m))for(;++h<m.length;){const g=m[h];l(g)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function p(m,h){let g=-1,y=-1;for(;++g<s.length;)if(s[g][0]===m){y=g;break}if(y===-1)s.push([m,...h]);else if(h.length>0){let[b,...E]=h;const j=s[y][1];Ih(j)&&Ih(b)&&(b=Mm(!0,j,b)),s[y]=[m,b,...E]}}}}const h_=new fx().freeze();function Bm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Um(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Vm(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ww(e){if(!Ih(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Kw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Lu(e){return g_(e)?e:new YS(e)}function g_(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function x_(e){return typeof e=="string"||y_(e)}function y_(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const b_="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",qw=[],Gw={allowDangerousHtml:!0},v_=/^(https?|ircs?|mailto|xmpp)$/i,w_=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function j_(e){const t=k_(e),n=S_(e);return N_(t.runSync(t.parse(n),n),e)}function k_(e){const t=e.rehypePlugins||qw,n=e.remarkPlugins||qw,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Gw}:Gw;return h_().use(nM).use(n).use(XM,s).use(t)}function S_(e){const t=e.children||"",n=new YS;return typeof t=="string"&&(n.value=t),n}function N_(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,l=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,p=t.urlTransform||C_;for(const h of w_)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+b_+h.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),GS(e,m),OO(e,{Fragment:r.Fragment,components:a,ignoreInvalidStyle:!0,jsx:r.jsx,jsxs:r.jsxs,passKeys:!0,passNode:!0});function m(h,g,y){if(h.type==="raw"&&y&&typeof g=="number")return c?y.children.splice(g,1):y.children[g]={type:"text",value:h.value},g;if(h.type==="element"){let b;for(b in $m)if(Object.hasOwn($m,b)&&Object.hasOwn(h.properties,b)){const E=h.properties[b],j=$m[b];(j===null||j.includes(h.tagName))&&(h.properties[b]=p(String(E||""),b,h))}}if(h.type==="element"){let b=n?!n.includes(h.tagName):l?l.includes(h.tagName):!1;if(!b&&s&&typeof g=="number"&&(b=!s(h,g,y)),b&&y&&typeof g=="number")return u&&h.children?y.children.splice(g,1,...h.children):y.children.splice(g,1),g}}}function C_(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||v_.test(e.slice(0,t))?e:""}function fn({content:e,className:t,emptyState:n="No markdown content yet."}){const s=e.replace(/<!--[\s\S]*?-->/g,"");return s.trim()?r.jsx("div",{className:Se("prose-syntaur max-w-none",t),children:r.jsx(j_,{children:s})}):r.jsx("div",{className:"rounded-md border border-dashed border-border/80 bg-muted/30 px-3 py-4 text-sm text-muted-foreground",children:n})}function Ir(e){return`/api/projects/${encodeURIComponent(e)}/todos`}function E_(e){const[t,n]=f.useState(null),[s,a]=f.useState(!0),[l,c]=f.useState(null),u=f.useCallback(async()=>{if(e)try{const p=await fetch(Ir(e));if(!p.ok)throw new Error(`HTTP ${p.status}`);n(await p.json()),c(null)}catch(p){c(p instanceof Error?p.message:"Failed to fetch todos")}finally{a(!1)}},[e]);return f.useEffect(()=>{u()},[u]),sc(p=>{p.type==="todos-updated"&&p.projectSlug===e&&u()}),{data:t,loading:s,error:l,refetch:u}}async function T_(e,t,n){await fetch(Ir(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:t,tags:n})})}async function R_(e,t,n){await fetch(`${Ir(e)}/${t}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({summary:"Completed."})})}async function P_(e,t,n){await fetch(`${Ir(e)}/${t}/block`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:n})})}async function A_(e,t,n){await fetch(`${Ir(e)}/${t}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:n})})}async function D_(e,t){await fetch(`${Ir(e)}/${t}/reopen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})})}async function $_(e,t){await fetch(`${Ir(e)}/${t}`,{method:"DELETE"})}async function L_(e,t,n){const s=await fetch(`${Ir(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!s.ok)throw new Error(await s.text().catch(()=>"")||`HTTP ${s.status}`)}function JS(e,t,n){return`${Ir(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function O_(e,t,n){for(const s of n){const a=await fetch(`${Ir(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(s.name||"file"),"x-attachment-mime":s.type||"application/octet-stream"},body:s});if(!a.ok)throw new Error(await a.text().catch(()=>"")||`HTTP ${a.status}`)}}async function I_(e,t,n){const s=await fetch(JS(e,t,n),{method:"DELETE"});if(!s.ok)throw new Error(await s.text().catch(()=>"")||`HTTP ${s.status}`)}async function XS(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const s=await n.text().catch(()=>"");let a=null;try{a=s?JSON.parse(s):null}catch{}const l=(a==null?void 0:a.error)||s||`HTTP ${n.status}`,c=new Error(l);throw c.status=n.status,c}return n.json().catch(()=>({}))}async function M_(e,t){return await XS(`${Ir(e)}/promote`,t)}async function __(e,t,n){await XS(`${Ir(e)}/${t}/move`,{to:n})}const Yw=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-status-in-progress-foreground"},{value:"completed",icon:"✓",label:"Completed",color:"text-status-completed-foreground"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-status-blocked-foreground"}];function QS({status:e,onChange:t}){const[n,s]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(!n)return;function c(u){a.current&&!a.current.contains(u.target)&&s(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);const l=Yw.find(c=>c.value===e);return r.jsxs("div",{className:"relative",ref:a,onClick:c=>c.stopPropagation(),children:[r.jsx("button",{onClick:()=>s(!n),className:`text-lg leading-none ${l.color} hover:opacity-70 transition`,title:l.label,children:l.icon}),n&&r.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:Yw.filter(c=>c.value!==e).map(c=>r.jsxs("button",{onClick:()=>{t(c.value),s(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${c.color}`,children:[r.jsx("span",{className:"text-base leading-none",children:c.icon}),r.jsx("span",{children:c.label})]},c.value))})]})}function ZS({item:e,copiedId:t,selected:n,editing:s,onBeginEdit:a,onEndEdit:l,onPatchDescription:c,onAddAttachments:u,onDeleteAttachment:p,attachmentUrl:m,onToggleSelected:h,onMoveOne:g,onStatusChange:y,onCopyId:b,onDelete:E,hotkeyRowProps:j,onDragOrigin:w,onDragStart:k,onDragEnd:C,isDragging:N}){return r.jsxs("div",{draggable:!0,"data-todo-id":e.id,...j??{},onMouseDown:w,onDragStart:T=>k(T,e.id),onDragEnd:C,className:`surface-panel flex items-start gap-3 px-3 py-2 cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${N?"opacity-50 shadow-lg":""}`,children:[r.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${e.id}`,title:"Select",checked:n,onChange:T=>h(e.id,T),onClick:T=>T.stopPropagation(),className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),r.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx(QS,{status:e.status,onChange:T=>y(e.id,T)})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[r.jsx(eN,{description:e.description,status:e.status,editing:s,onBeginEdit:()=>a(e.id),onEndEdit:l,onSave:T=>c(e.id,T)}),e.tags.length>0&&r.jsx("span",{className:"text-xs text-muted-foreground",children:e.tags.map(T=>`#${T}`).join(" ")}),e.session&&r.jsxs("span",{className:"text-xs text-info-foreground/70 font-mono",children:["session:",e.session.slice(0,8)]}),r.jsx(V_,{item:e})]}),r.jsx(tN,{item:e,attachmentUrl:m,onAdd:T=>u(e.id,T),onDelete:T=>p(e.id,T)})]}),t===e.id?r.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[r.jsx(Xr,{className:"h-3 w-3"})," Copied to clipboard"]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{"data-no-drag":!0,className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:T=>b(T,e.id),children:["t:",e.id]}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:T=>b(T,e.id),children:r.jsx(rd,{className:"h-3 w-3"})}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Move to...",onClick:T=>g(e.id,T),children:r.jsx($d,{className:"h-3 w-3"})}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-destructive transition",title:"Delete todo",onClick:T=>E(T,e.id,e.description),children:r.jsx(or,{className:"h-3 w-3"})})]})]})}function eN({description:e,status:t,editing:n,onBeginEdit:s,onEndEdit:a,onSave:l}){return n?r.jsx(F_,{initialValue:e,onSave:l,onExit:a}):r.jsx("button",{type:"button","data-no-drag":!0,onClick:c=>{c.stopPropagation(),s()},title:"Click to edit",className:Se("text-left text-sm rounded-sm transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",t==="completed"?"line-through text-muted-foreground":"text-foreground"),children:e})}function F_({initialValue:e,onSave:t,onExit:n}){const s=f.useRef(e),[a,l]=f.useState(e),[c,u]=f.useState(!1),[p,m]=f.useState(!1),h=f.useRef(null),g=f.useRef(!1);f.useEffect(()=>{const j=h.current;j&&(j.focus(),j.select())},[]);const y=f.useCallback(()=>{var j;m(!0),window.setTimeout(()=>m(!1),260),(j=h.current)==null||j.focus()},[]),b=f.useCallback(async()=>{if(g.current)return;const j=a.trim();if(j.length===0){y();return}if(j===s.current){n();return}g.current=!0,u(!0);try{await t(j)}catch{}finally{u(!1),n()}},[a,n,t,y]);function E(j){j.key==="Enter"?(j.preventDefault(),b()):j.key==="Escape"&&(j.preventDefault(),g.current=!0,n())}return r.jsx("input",{ref:h,type:"text","data-no-drag":!0,disabled:c,value:a,onClick:j=>j.stopPropagation(),onChange:j=>l(j.target.value),onKeyDown:E,onBlur:()=>void b(),className:Se("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-sm text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",p&&"syntaur-input-shake",c&&"opacity-70")})}function z_(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function B_(e){const t=e.clipboardData,n=[];if(t.files&&t.files.length&&n.push(...Array.from(t.files)),!n.length&&t.items){for(const s of Array.from(t.items))if(s.kind==="file"){const a=s.getAsFile();a&&n.push(a)}}return n}function tN({item:e,attachmentUrl:t,onAdd:n,onDelete:s}){const a=e.attachments??[],[l,c]=f.useState(!1),[u,p]=f.useState(!1),m=f.useRef(null),h=f.useRef(null);f.useEffect(()=>{var y;l&&((y=h.current)==null||y.focus())},[l]);const g=f.useCallback(async y=>{if(y.length){p(!0);try{await n(y),c(!1)}finally{p(!1)}}},[n]);return r.jsxs("div",{className:"mt-1","data-no-drag":!0,onClick:y=>y.stopPropagation(),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.map(y=>r.jsx(U_,{att:y,url:t(e.id,y.id),onDelete:()=>void s(y.id)},y.id)),r.jsxs("button",{type:"button","data-no-drag":!0,title:"Attach files",onClick:()=>c(y=>!y),className:"inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground hover:border-border transition",children:[r.jsx(m0,{className:"h-3 w-3"}),a.length===0?"Attach":""]})]}),l&&r.jsxs("div",{ref:h,"data-no-drag":!0,tabIndex:0,role:"button","aria-label":"Add attachments: drop, paste, or click",onPaste:y=>{const b=B_(y);b.length&&(y.preventDefault(),g(b))},onDragOver:y=>{Array.from(y.dataTransfer.types).includes("Files")&&y.preventDefault()},onDrop:y=>{const b=Array.from(y.dataTransfer.files);b.length&&(y.preventDefault(),g(b))},onClick:()=>{var y;return(y=m.current)==null?void 0:y.click()},className:"mt-1 cursor-pointer rounded-md border border-dashed border-border/70 px-3 py-2 text-xs text-muted-foreground hover:border-border focus:outline-none focus:ring-2 focus:ring-ring/40",children:[u?"Uploading…":"Drop, paste (⌘V / Ctrl+V), or click to add files",r.jsx("input",{ref:m,type:"file",multiple:!0,className:"hidden",onChange:y=>{const b=Array.from(y.target.files??[]);y.target.value="",g(b)}})]})]})}function U_({att:e,url:t,onDelete:n}){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border/60 bg-background px-1.5 py-0.5 text-xs",children:[z_(e.mime)?r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:e.filename,children:r.jsx("img",{src:t,alt:e.filename,className:"h-6 w-6 rounded object-cover"})}):r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-foreground hover:text-primary",children:[r.jsx(m0,{className:"h-3 w-3"}),r.jsx("span",{className:"block max-w-[160px] truncate",children:e.filename})]}),r.jsx("button",{type:"button",title:"Remove attachment",onClick:n,className:"text-muted-foreground/60 hover:text-destructive transition",children:r.jsx(ig,{className:"h-3 w-3"})})]})}function V_({item:e}){return!(e.branch||e.planDir||e.worktreePath||e.createdAt||e.updatedAt)?null:r.jsxs("span",{className:"inline-flex items-center gap-1 align-middle",children:[e.branch?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-info-foreground/30 bg-info/30 px-1.5 py-0.5 text-[10px] font-mono text-info-foreground",children:[r.jsx(tg,{className:"h-2.5 w-2.5"}),r.jsx("span",{className:"block min-w-0 max-w-[120px] truncate",children:e.branch})]})}),r.jsx(gr,{children:e.branch})]})}):null,e.planDir?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("button",{type:"button","data-no-drag":!0,onClick:n=>{n.stopPropagation(),navigator.clipboard.writeText(e.planDir)},className:"inline-flex items-center rounded-full border border-status-completed-foreground/40 bg-status-completed/30 p-1 text-status-completed-foreground hover:bg-status-completed/50","aria-label":"Copy plan directory path",children:r.jsx(d0,{className:"h-2.5 w-2.5"})})}),r.jsxs(gr,{children:["Plan: ",e.planDir]})]})}):null,e.worktreePath||e.createdAt||e.updatedAt?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{className:"text-[10px] text-muted-foreground/60 cursor-default",children:"·"})}),r.jsx(gr,{children:r.jsxs("div",{className:"space-y-0.5 text-xs font-mono",children:[e.worktreePath?r.jsxs("div",{children:["worktree: ",e.worktreePath]}):null,e.createdAt?r.jsxs("div",{children:["created: ",e.createdAt]}):null,e.updatedAt?r.jsxs("div",{children:["updated: ",e.updatedAt]}):null]})})]})}):null]})}const nN="__one_off__";function px({open:e,selectedIds:t,scope:n,onOpenChange:s,onDone:a,defaultProject:l,defaultTitle:c,allowOneOff:u=!0}){const[p,m]=f.useState("new"),[h,g]=f.useState(!1),[y,b]=f.useState(null),[E,j]=f.useState(null),[w,k]=f.useState(null),[C,N]=f.useState(""),[T,D]=f.useState(""),[R,$]=f.useState(""),[L,K]=f.useState(""),[B,O]=f.useState(""),[W,se]=f.useState(""),[z,H]=f.useState(null),[ee,ne]=f.useState(!1),M=t.length>1;f.useEffect(()=>{if(!e){m("new"),b(null),N(""),D(""),$(""),K(""),O(""),se(""),H(null);return}N(l??""),D(c??"");let de=!1;return(async()=>{try{const ge=await fetch("/api/projects");if(!ge.ok)throw new Error(`HTTP ${ge.status}`);const V=await ge.json();de||j(V.filter(ae=>!ae.archived))}catch(ge){de||k(ge instanceof Error?ge.message:String(ge))}})(),()=>{de=!0}},[e,l,c]),f.useEffect(()=>{if(!B){H(null);return}let de=!1;return ne(!0),(async()=>{try{const ge=await fetch(`/api/projects/${encodeURIComponent(B)}/assignments`);if(!ge.ok)throw new Error(`HTTP ${ge.status}`);const V=await ge.json();de||H(V)}catch{de||H([])}finally{de||ne(!1)}})(),()=>{de=!0}},[B]);const G=f.useMemo(()=>E??[],[E]);async function A(de){if(de.preventDefault(),!C){b('Pick a target project (or "One-off").');return}if(M&&!T.trim()){b("Title is required when promoting multiple todos.");return}const ge=C===nN?{oneOff:!0}:{project:C};if(n.kind==="aggregate"){const ae={groups:n.groups,mode:"new-assignment",target:ge,title:T.trim()||void 0,type:R.trim()||void 0,priority:L||void 0};await I(ae);return}const V={todoIds:t,mode:"new-assignment",target:ge,title:T.trim()||void 0,type:R.trim()||void 0,priority:L||void 0};await Z(V)}async function F(de){if(de.preventDefault(),n.kind==="aggregate"){b("Existing-assignment mode does not support cross-workspace selections yet.");return}if(!B||!W){b("Pick both project and assignment.");return}const ge={todoIds:t,mode:"to-assignment",target:{assignment:`${B}/${W}`}};await Z(ge)}async function Z(de){g(!0),b(null);try{let ge;if(n.kind==="workspace")ge=await BP(n.workspace,de);else if(n.kind==="project")ge=await M_(n.projectId,de);else throw new Error("Aggregate scope requires runBulkMutation.");a(ge),s(!1)}catch(ge){b(ge instanceof Error?ge.message:String(ge))}finally{g(!1)}}async function I(de){g(!0),b(null);try{const ge=await UP(de);a(ge),s(!1)}catch(ge){b(ge instanceof Error?ge.message:String(ge))}finally{g(!1)}}return r.jsx(ar,{open:e,onOpenChange:de=>h?void 0:s(de),children:r.jsxs(Kn,{className:"max-w-xl",children:[r.jsxs(Zr,{children:[r.jsxs(qn,{children:["Promote ",t.length," todo",t.length===1?"":"s"]}),r.jsxs(gs,{children:["Convert the selected todo",t.length===1?"":"s"," to a new or existing assignment. Source todo",t.length===1?"":"s"," will be marked ",r.jsx("strong",{children:"in progress"})," and linked to the new assignment (auto-completed when the assignment closes)."]})]}),r.jsxs(pS,{value:p,onValueChange:de=>m(de),children:[r.jsxs(mS,{className:"flex gap-2 rounded-md border border-border/70 bg-card/80 p-1 mb-4",children:[r.jsx(Ch,{value:"new",className:Se("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"New assignment"}),r.jsx(Ch,{value:"existing",className:Se("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"Existing assignment"})]}),r.jsx(Eh,{value:"new",children:r.jsxs("form",{onSubmit:A,className:"space-y-4",children:[r.jsx(Va,{label:"Target project",children:r.jsx(Jw,{value:C,onChange:N,projects:G,error:w,disabled:h,allowOneOff:u})}),r.jsx(Va,{label:M?"Title (required)":"Title (defaults to first todo)",children:r.jsx("input",{type:"text",value:T,onChange:de=>D(de.target.value),disabled:h,className:"editor-input bg-background/95 font-sans"})}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Va,{label:"Type",children:r.jsx("input",{type:"text",value:R,onChange:de=>$(de.target.value),placeholder:"feature",disabled:h,className:"editor-input bg-background/95 font-sans"})}),r.jsx(Va,{label:"Priority",children:r.jsxs("select",{value:L,onChange:de=>K(de.target.value),disabled:h,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"—"}),r.jsx("option",{value:"low",children:"low"}),r.jsx("option",{value:"medium",children:"medium"}),r.jsx("option",{value:"high",children:"high"}),r.jsx("option",{value:"critical",children:"critical"})]})})]}),y?r.jsx(Xw,{message:y}):null,r.jsx(Qw,{onCancel:()=>s(!1),submitting:h,submitLabel:"Promote"})]})}),r.jsx(Eh,{value:"existing",children:r.jsxs("form",{onSubmit:F,className:"space-y-4",children:[r.jsx(Va,{label:"Project",children:r.jsx(Jw,{value:B,onChange:de=>{O(de),se("")},projects:G,error:w,disabled:h})}),r.jsx(Va,{label:ee?"Assignment (loading...)":"Assignment",children:r.jsxs("select",{value:W,onChange:de=>se(de.target.value),disabled:h||!B||ee,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:B?"Select assignment...":"Pick a project first"}),(z??[]).map(de=>r.jsxs("option",{value:de.slug,children:[de.title," (",de.status,")"]},de.slug))]})}),y?r.jsx(Xw,{message:y}):null,r.jsx(Qw,{onCancel:()=>s(!1),submitting:h,submitLabel:"Promote"})]})})]})]})})}function Va({label:e,children:t}){return r.jsxs("label",{className:"block space-y-1.5",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Jw({value:e,onChange:t,projects:n,error:s,disabled:a,allowOneOff:l}){return s?r.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load projects: ",s]}):r.jsxs("select",{value:e,onChange:c=>t(c.target.value),disabled:a,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"Select project..."}),l?r.jsx("option",{value:nN,children:"One-off (no project)"}):null,n.map(c=>r.jsxs("option",{value:c.slug,children:[c.title," (",c.slug,")"]},c.slug))]})}function Xw({message:e}){return r.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function Qw({onCancel:e,submitting:t,submitLabel:n}){return r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:e,disabled:t,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:t,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:t?"Submitting...":n})]})}function rN({open:e,selectedIds:t,scope:n,onOpenChange:s,onDone:a}){const[l,c]=f.useState("project"),[u,p]=f.useState(""),[m,h]=f.useState(""),[g,y]=f.useState(!1),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null);f.useEffect(()=>{if(!e){c("project"),p(""),h(""),E(null),w(null);return}let $=!1;return(async()=>{try{const L=await fetch("/api/projects");if(!L.ok)throw new Error(`HTTP ${L.status}`);const K=await L.json();$||C(K.filter(B=>!B.archived))}catch(L){$||w(L instanceof Error?L.message:String(L))}})(),()=>{$=!0}},[e]);const N=f.useMemo(()=>k?n.kind==="project"?k.filter($=>$.slug!==n.projectId):k:[],[k,n]);function T(){if(l==="global")return{global:!0};if(l==="workspace"){const $=u.trim();return $?{workspace:$}:"Workspace name is required."}return m?{project:m}:"Pick a target project."}async function D($,L){try{return n.kind==="workspace"?await VP(n.workspace,$,L):await __(n.projectId,$,L),{ok:!0}}catch(K){return{ok:!1,error:K instanceof Error?K.message:String(K)}}}async function R($){$.preventDefault(),w(null);const L=T();if(typeof L=="string"){w(L);return}y(!0),E(null);const K=[],B=[];for(const O of t){const W=await D(O,L);W.ok?K.push(O):B.push({id:O,error:W.error})}y(!1),a(),B.length===0?s(!1):E({succeeded:K,failed:B})}return r.jsx(ar,{open:e,onOpenChange:$=>g?void 0:s($),children:r.jsx(Kn,{className:"max-w-xl",children:r.jsxs("form",{onSubmit:R,className:"space-y-4",children:[r.jsxs(Zr,{children:[r.jsxs(qn,{children:["Move ",t.length," todo",t.length===1?"":"s"]}),r.jsxs(gs,{children:["Move the selected todo",t.length===1?"":"s"," to a different scope. id, tags, branch, timestamps, and plan dir are preserved."]})]}),r.jsxs("fieldset",{className:"space-y-2",disabled:g,children:[r.jsx("legend",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground mb-1",children:"Target scope"}),r.jsx(Hm,{kind:"project",checked:l==="project",onChange:()=>c("project"),label:"Project"}),r.jsx(Hm,{kind:"workspace",checked:l==="workspace",onChange:()=>c("workspace"),label:"Workspace"}),r.jsx(Hm,{kind:"global",checked:l==="global",onChange:()=>c("global"),label:"Global"})]}),l==="project"?r.jsx(Zw,{label:"Target project",children:r.jsxs("select",{value:m,onChange:$=>h($.target.value),disabled:g,className:"editor-textarea w-full bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"Select project..."}),N.map($=>r.jsxs("option",{value:$.slug,children:[$.title," (",$.slug,")"]},$.slug))]})}):null,l==="workspace"?r.jsx(Zw,{label:"Target workspace name",children:r.jsx("input",{type:"text",value:u,onChange:$=>p($.target.value),disabled:g,placeholder:"e.g. syntaur",className:"editor-textarea w-full bg-background/95 font-sans"})}):null,j?r.jsx(H_,{message:j}):null,b?r.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground space-y-1",children:[r.jsxs("div",{className:"font-medium",children:["Moved ",b.succeeded.length," of ",t.length,"; ",b.failed.length," failed."]}),r.jsx("ul",{className:"text-xs space-y-0.5",children:b.failed.map($=>r.jsxs("li",{children:["[t:",$.id,"] ",$.error]},$.id))})]}):null,r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>s(!1),disabled:g,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:b?"Close":"Cancel"}),b===null?r.jsx("button",{type:"submit",disabled:g,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:g?"Moving...":"Move"}):null]})]})})})}function Zw({label:e,children:t}){return r.jsxs("label",{className:"block space-y-1.5",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Hm({kind:e,checked:t,onChange:n,label:s}){return r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[r.jsx("input",{type:"radio",name:"move-target-kind",value:e,checked:t,onChange:n}),r.jsx("span",{children:s})]})}function H_({message:e}){return r.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function mx({label:e,count:t,expanded:n,onToggle:s,isDropTarget:a=!1,onDragOver:l,onDragLeave:c,onDrop:u,children:p}){return r.jsxs("div",{className:Se("rounded-lg border border-border/60 bg-card/40 transition",a&&"ring-2 ring-ring/30"),onDragOver:l,onDragLeave:c,onDrop:u,children:[r.jsxs("button",{type:"button",onClick:s,"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2.5 text-left",children:[r.jsx(br,{className:Se("h-4 w-4 text-muted-foreground transition-transform",!n&&"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:e}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:t})]}),n&&r.jsx("div",{className:"space-y-1 px-2 pb-2",children:p})]})}const sN=[{id:"open-blocked",label:"Open / Blocked",statuses:["open","blocked"],dropStatus:"open",defaultCollapsed:!1},{id:"in-progress",label:"In Progress",statuses:["in_progress"],dropStatus:"in_progress",defaultCollapsed:!1},{id:"done",label:"Done",statuses:["completed"],dropStatus:"completed",defaultCollapsed:!0}];function lf(e){switch(e){case"in_progress":return"in-progress";case"completed":return"done";case"open":case"blocked":default:return"open-blocked"}}function hx(e){const t={"open-blocked":[],"in-progress":[],done:[]};for(const n of e)t[lf(n.status)].push(n);return sN.map(n=>({config:n,items:t[n.id]}))}const oN="syntaur.todos.sections.collapsed.v1",ej=Object.fromEntries(sN.map(e=>[e.id,e.defaultCollapsed]));function Wm(){if(typeof window>"u"||!window.localStorage)return{};try{const e=window.localStorage.getItem(oN);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function W_(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(oN,JSON.stringify(e))}catch{}}function gx(e){const[t,n]=f.useState(()=>Wm()[e]??{});f.useEffect(()=>{n(Wm()[e]??{})},[e]);const s=f.useCallback(l=>t[l]??ej[l],[t]),a=f.useCallback(l=>{const c=Wm(),u=c[e]??{},p=u[l]??ej[l],m={...u,[l]:!p};c[e]=m,W_(c),n(m)},[e]);return{isCollapsed:s,toggle:a}}function K_({projectId:e}){const{data:t,loading:n,error:s,refetch:a}=E_(e),[l,c]=f.useState(""),[u,p]=f.useState(""),[m,h]=f.useState(""),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(new Set),[N,T]=f.useState(!1),[D,R]=f.useState(!1),[$,L]=f.useState(null),K=f.useRef(null);mo("list:todos");const B=gx("project:"+e),[O,W]=f.useState(null),[se,z]=f.useState(null),H=f.useRef(null);function ee(Y,pe){Y.stopPropagation(),navigator.clipboard.writeText(pe),E(pe),setTimeout(()=>E(Q=>Q===pe?null:Q),1500)}const ne=f.useMemo(()=>{if(!(t!=null&&t.items))return[];const Y=new Set;for(const pe of t.items)for(const Q of pe.tags)Y.add(Q);return Array.from(Y).sort()},[t]),M=f.useMemo(()=>{if(!(t!=null&&t.items))return[];let Y=t.items;if(l.trim()){const pe=l.toLowerCase();Y=Y.filter(Q=>Q.description.toLowerCase().includes(pe)||Q.tags.some(ye=>ye.toLowerCase().includes(pe))||Q.id.includes(pe))}return u&&(Y=Y.filter(pe=>pe.status===u)),m&&(Y=Y.filter(pe=>pe.tags.includes(m))),Y},[t,l,u,m]);f.useEffect(()=>{C(new Set)},[l,u,m,e]);const G=f.useMemo(()=>M.filter(Y=>k.has(Y.id)).length,[M,k]),A=M.length>0&&G===M.length,F=G>0&&!A;function Z(Y){C(pe=>{const Q=new Set(pe);return Q.has(Y)?Q.delete(Y):Q.add(Y),Q})}function I(){C(Y=>{const pe=new Set(Y);if(A)for(const Q of M)pe.delete(Q.id);else for(const Q of M)pe.add(Q.id);return pe})}function de(){C(new Set)}const ge=$?[$]:Array.from(k);function V(){C(new Set),L(null),a()}function ae(){C(new Set),a()}async function me(){g.trim()&&(await T_(e,g.trim()),y(""),a())}async function ve(Y,pe,Q){Y.stopPropagation(),window.confirm(`Delete "${Q}"? This can't be undone.`)&&(await $_(e,pe),a())}async function ke(Y,pe){switch(pe){case"open":await D_(e,Y);break;case"in_progress":await A_(e,Y);break;case"completed":await R_(e,Y);break;case"blocked":await P_(e,Y);break}a()}async function he(Y,pe){await L_(e,Y,pe),a()}async function Je(Y,pe){await O_(e,Y,pe),a()}async function Ye(Y,pe){await I_(e,Y,pe),a()}const ot=hx(M),J=ot.filter(Y=>!B.isCollapsed(Y.config.id)).flatMap(Y=>Y.items),{hotkeyRowProps:Ie}=ac(J,{scope:"list:todos",bindO:!1,onOpen:Y=>w(Y.id)});Ht({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var Y;return(Y=K.current)==null?void 0:Y.focus()}}),Ht({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>a()});const[Ne,Oe]=hs(),Xe=Ne.get("focus");f.useEffect(()=>{if(!Xe||!(t!=null&&t.items))return;const Y=t.items.find(Q=>Q.id===Xe);if(!Y)return;const pe=lf(Y.status);B.isCollapsed(pe)&&B.toggle(pe)},[Xe,t==null?void 0:t.items]),f.useEffect(()=>{if(!Xe)return;const Y=document.querySelector(`[data-todo-id="${window.CSS.escape(Xe)}"]`);if(!Y)return;Y.scrollIntoView({block:"nearest"}),Y.classList.add("ring-2","ring-primary/60");const pe=window.setTimeout(()=>{Y.classList.remove("ring-2","ring-primary/60"),Oe(Q=>{const ye=new URLSearchParams(Q);return ye.delete("focus"),ye},{replace:!0})},1500);return()=>window.clearTimeout(pe)},[Xe,J.length,Oe]);const Me=O?(t==null?void 0:t.items.find(Y=>Y.id===O))??null:null;function nt(Y,pe){const Q=H.current;if(Q!=null&&Q.closest(mi)){Y.preventDefault();return}Y.dataTransfer.effectAllowed="move",Y.dataTransfer.setData("text/plain",pe),W(pe)}function Ke(){W(null),z(null)}function gt(Y,pe){!Me||pe.statuses.includes(Me.status)||(Y.preventDefault(),Y.dataTransfer.dropEffect="move",z(pe.id))}function Rt(Y,pe){se===pe.id&&!Y.currentTarget.contains(Y.relatedTarget)&&z(null)}function at(Y,pe){Y.preventDefault();const Q=Me;Ke(),!(!Q||pe.statuses.includes(Q.status))&&ke(Q.id,pe.dropStatus)}if(n)return r.jsx(mt,{label:"Loading todos..."});if(s)return r.jsx(wt,{error:s});const ie=(t==null?void 0:t.counts)||{open:0,in_progress:0,blocked:0,total:0};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[r.jsx(An,{label:"Open",value:ie.open,icon:Dr}),r.jsx(An,{label:"In Progress",value:ie.in_progress,icon:Dr,tone:"info"}),r.jsx(An,{label:"Blocked",value:ie.blocked,icon:ag,tone:"warn"}),r.jsx(An,{label:"Total",value:ie.total,icon:Dr})]}),r.jsx("div",{className:"surface-panel p-3",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",placeholder:"Add a todo...",value:g,onChange:Y=>y(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&me(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),r.jsxs("button",{onClick:me,disabled:!g.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add"]})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(fo,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx("input",{ref:K,type:"text",placeholder:"Search...",value:l,onChange:Y=>c(Y.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),r.jsxs("select",{value:u,onChange:Y=>p(Y.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[r.jsx("option",{value:"",children:"All statuses"}),r.jsx("option",{value:"open",children:"Open"}),r.jsx("option",{value:"in_progress",children:"In Progress"}),r.jsx("option",{value:"completed",children:"Completed"}),r.jsx("option",{value:"blocked",children:"Blocked"})]}),ne.length>0&&r.jsxs("select",{value:m,onChange:Y=>h(Y.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[r.jsx("option",{value:"",children:"All tags"}),ne.map(Y=>r.jsxs("option",{value:Y,children:["#",Y]},Y))]})]}),k.size>0?r.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[r.jsxs("span",{className:"text-sm font-medium",children:[k.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>T(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),r.jsx("button",{type:"button",onClick:()=>{L(null),R(!0)},className:"shell-action",children:"Move to…"}),r.jsx("button",{type:"button",onClick:de,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,M.length>0&&r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[r.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:A,ref:Y=>{Y&&(Y.indeterminate=F)},onChange:I,className:"h-4 w-4 cursor-pointer accent-foreground"}),r.jsxs("span",{children:["Select all in current filter (",M.length,")"]})]}),r.jsx("div",{className:"space-y-3",children:(()=>{let Y=-1;return ot.map(({config:pe,items:Q})=>{const ye=!B.isCollapsed(pe.id);return r.jsx(mx,{label:pe.label,count:Q.length,expanded:ye,onToggle:()=>B.toggle(pe.id),isDropTarget:se===pe.id,onDragOver:Pe=>gt(Pe,pe),onDragLeave:Pe=>Rt(Pe,pe),onDrop:Pe=>at(Pe,pe),children:ye&&Q.map(Pe=>(Y+=1,r.jsx(ZS,{item:Pe,copiedId:b,selected:k.has(Pe.id),editing:j===Pe.id,onBeginEdit:lt=>w(lt),onEndEdit:()=>w(null),onPatchDescription:he,onAddAttachments:Je,onDeleteAttachment:Ye,attachmentUrl:(lt,te)=>JS(e,lt,te),onToggleSelected:lt=>Z(lt),onMoveOne:(lt,te)=>{te.stopPropagation(),L(lt),R(!0)},onStatusChange:ke,onCopyId:ee,onDelete:ve,hotkeyRowProps:Ie(Y),onDragOrigin:lt=>{H.current=lt.target},onDragStart:nt,onDragEnd:Ke,isDragging:O===Pe.id},Pe.id)))},pe.id)})})()}),r.jsx(px,{open:N,selectedIds:Array.from(k),scope:{kind:"project",projectId:e},onOpenChange:T,onDone:ae}),r.jsx(rN,{open:D,selectedIds:ge,scope:{kind:"project",projectId:e},onOpenChange:Y=>{R(Y),Y||L(null)},onDone:V})]})}const q_={title:"Assignment",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},tj=new Set(["title"]);function aN({visibility:e,onChange:t}){const[n,s]=f.useState(!1);function a(c){if(tj.has(c))return;const p=e.hidden.includes(c)?e.hidden.filter(m=>m!==c):[...e.hidden,c];t({hidden:p})}const l=e.hidden.length;return r.jsxs(ar,{open:n,onOpenChange:s,children:[r.jsx($3,{asChild:!0,children:r.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Show or hide table columns",children:[r.jsx(aR,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsxs("span",{children:["Columns",l>0?` (${Sm.length-l}/${Sm.length})`:""]})]})}),r.jsxs(Kn,{className:"max-w-sm",children:[r.jsx(Zr,{children:r.jsx(qn,{children:"Columns"})}),r.jsx("div",{className:"space-y-2",children:Sm.map(c=>{const u=e.hidden.includes(c),p=tj.has(c);return r.jsxs("label",{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm ${p?"opacity-60":"cursor-pointer hover:bg-background/80"}`,children:[r.jsx("input",{type:"checkbox",checked:!u,onChange:()=>a(c),disabled:p,className:"h-4 w-4 rounded border-border accent-foreground"}),r.jsx("span",{children:q_[c]}),p?r.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"always shown"}):null]},c)})})]})]})}const ui={...Vl,custom:!1},iN=`view-prefs.cache.v${Vl.version}`;let Gl=G_(),Ha=null;const Yl=new Set;let lN=0;function xx(){return++lN}function yx(e){return e===lN}function G_(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(iN);if(!e)return null;const t=JSON.parse(e);return t.version!==Vl.version?null:t}catch{return null}}function Y_(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(iN,JSON.stringify(e))}catch{}}function bx(e){Gl=e,Y_(e);for(const t of Yl)t(e)}function vx(e){if(!e||typeof e!="object")return ui;const t=e;return t.version!==Vl.version||!t.global||!t.projects?ui:{version:Vl.version,global:t.global,projects:t.projects,custom:t.custom===!0}}function wx(){if(Ha)return Ha;const e=xx();return Ha=fetch("/api/view-prefs").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=vx(t);return yx(e)&&bx(n),Ha=null,Gl??n}).catch(()=>(Ha=null,Gl??ui)),Ha}function cN(e){const[t,n]=f.useState(()=>Gl??ui);return f.useEffect(()=>{let s=!1;return wx().then(a=>{s||n(a)}),Yl.add(n),()=>{s=!0,Yl.delete(n)}},[]),r1(t,e??null)}function J_(){const[e,t]=f.useState(()=>Gl??ui);return f.useEffect(()=>{let n=!1;return wx().then(s=>{n||t(s)}),Yl.add(t),()=>{n=!0,Yl.delete(t)}},[]),e}async function uN(e){const t=xx(),n=await fetch("/api/view-prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const a=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(a.error??"Failed to save view-prefs")}const s=vx(await n.json());return yx(t)&&bx(s),s}function dN(e){return uN({global:e})}function fN(e,t){return uN({projects:{[e]:t}})}async function X_(){const e=xx(),t=await fetch("/api/view-prefs",{method:"DELETE"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=vx(await t.json());return yx(e)&&bx(n),n}const nj=80;function pN({open:e,onOpenChange:t,initialName:n="",onSubmit:s,title:a="Save view"}){const[l,c]=f.useState(n),[u,p]=f.useState(!1),[m,h]=f.useState(null);f.useEffect(()=>{e&&(c(n),h(null),p(!1))},[e,n]);const g=l.trim(),y=g.length>0&&g.length<=nj;return r.jsx(ar,{open:e,onOpenChange:t,children:r.jsx(Kn,{className:"max-w-md",children:r.jsxs("form",{className:"space-y-4",onSubmit:async b=>{if(b.preventDefault(),!(!y||u)){p(!0),h(null);try{await s(g)}catch(E){h(E instanceof Error?E.message:String(E)),p(!1)}}},children:[r.jsx(Zr,{children:r.jsx(qn,{children:a})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("input",{type:"text",value:l,autoFocus:!0,required:!0,maxLength:nj,onChange:b=>c(b.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),m?r.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:m}):null]}),r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:u,children:"Cancel"}),r.jsx("button",{type:"submit",disabled:!y||u,className:"shell-action shell-action--cta disabled:opacity-50",children:u?"Saving…":"Save"})]})]})})})}function mN({scope:e,loadedViewId:t,onApply:n,onOpenSaveDialog:s}){const{views:a,loading:l}=Vd(),[c,u]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{if(!c)return;function y(E){p.current&&!p.current.contains(E.target)&&u(!1)}function b(E){E.key==="Escape"&&u(!1)}return document.addEventListener("mousedown",y),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",b)}},[c]);const m=f.useMemo(()=>a.filter(y=>o1(y,e)),[a,e]),h=t?a.find(y=>y.id===t)??null:null,g=l?"Saved views…":h?h.name:"Saved views";return r.jsxs("div",{className:"relative",ref:p,children:[r.jsxs("button",{type:"button",disabled:l,onClick:()=>u(y=>!y),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":c,title:"Saved views",children:[r.jsx("span",{className:"max-w-[160px] truncate",children:g}),r.jsx(br,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),c&&r.jsx("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:m.length===0?r.jsxs("div",{className:"px-3 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"mb-2",children:"No saved views yet — Save the current view to start."}),r.jsx("button",{type:"button",onClick:()=>{u(!1),s()},className:"shell-action w-full justify-center",children:"Save current view"})]}):m.map(y=>{const b=y.id===t;return r.jsxs("button",{type:"button",onClick:()=>{u(!1),n(y)},className:Se("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",b&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:b?r.jsx(Xr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),r.jsx("span",{className:"truncate",children:y.name})]},y.id)})})]})}const Q_={__unassigned__:"Unassigned",__standalone__:"No project"};function Pn({options:e,value:t,onChange:n,allLabel:s="Any",className:a,disabled:l,ariaLabel:c}){const[u,p]=f.useState(!1),m=f.useRef(null),h=f.useRef(null),g=f.useRef([]),y=f.useMemo(()=>{const C=new Set(e.map(T=>T.value)),N=t.filter(T=>!C.has(T)).map(T=>({value:T,label:Q_[T]??T}));return[...e,...N]},[e,t]),b=f.useMemo(()=>new Set(t),[t]);f.useEffect(()=>{if(!u)return;function C(N){m.current&&!m.current.contains(N.target)&&p(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u]),f.useEffect(()=>{var C;u&&((C=g.current[0])==null||C.focus())},[u]);const E=f.useMemo(()=>{if(t.length===0)return s;if(t.length===1){const C=y.find(N=>N.value===t[0]);return C?C.label:t[0]}return`${t.length} selected`},[t,y,s]);function j(C){n(b.has(C)?t.filter(N=>N!==C):[...t,C])}function w(C){var T;const N=Math.max(0,Math.min(C,y.length-1));(T=g.current[N])==null||T.focus()}function k(C){var R;const N=g.current,T=document.activeElement,D=N.findIndex($=>$===T);C.key==="ArrowDown"?(C.preventDefault(),w(D<0?0:D+1)):C.key==="ArrowUp"?(C.preventDefault(),w(D<0?y.length-1:D-1)):C.key==="Home"?(C.preventDefault(),w(0)):C.key==="End"?(C.preventDefault(),w(y.length-1)):C.key==="Escape"&&(C.preventDefault(),p(!1),(R=h.current)==null||R.focus())}return r.jsxs("div",{className:"relative",ref:m,children:[r.jsxs("button",{type:"button",ref:h,disabled:l,"aria-haspopup":"menu","aria-expanded":u,"aria-label":c,onClick:()=>p(C=>!C),onKeyDown:C=>{!u&&(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),p(!0))},className:Se("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",a),children:[r.jsx("span",{className:"truncate",children:E}),r.jsx(br,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),u?r.jsxs("div",{role:"menu","aria-label":c,onKeyDown:k,className:"absolute left-0 top-full z-30 mt-1 max-h-72 min-w-[200px] overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===y.length,onClick:()=>n(y.map(C=>C.value)),children:"Select all"}),r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===0,onClick:()=>n([]),children:"Clear"})]}),y.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):y.map((C,N)=>{const T=b.has(C.value);return r.jsxs("button",{ref:D=>{g.current[N]=D},type:"button",role:"menuitemcheckbox","aria-checked":T,tabIndex:-1,onClick:()=>j(C.value),className:Se("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",T?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:Se("flex h-4 w-4 shrink-0 items-center justify-center rounded border",T?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:T?r.jsx(Xr,{className:"h-3 w-3"}):null}),r.jsx("span",{className:"truncate",children:C.label})]},C.value)})]}):null]})}const rj={last_24h:"Last 24 hours",last_7d:"Last 7 days",last_30d:"Last 30 days",last_90d:"Last 90 days",older_7d:"Older than 7 days",older_30d:"Older than 30 days"},Z_=["updated","created"];function jx({value:e,onChange:t,className:n,ariaLabel:s="Date range filter"}){const[a,l]=f.useState(!1),c=f.useRef(null),u=(e==null?void 0:e.field)??"updated",p=!!(e&&!e.preset&&(e.from||e.to)),[m,h]=f.useState(p);f.useEffect(()=>h(p),[p]),f.useEffect(()=>{if(!a)return;function k(N){c.current&&!c.current.contains(N.target)&&l(!1)}function C(N){N.key==="Escape"&&l(!1)}return document.addEventListener("mousedown",k),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",C)}},[a]);const g=!!(e&&(e.preset||e.from||e.to)),y=f.useMemo(()=>!g||!e?"Any date":e.preset?`${u}: ${rj[e.preset]??e.preset}`:`${u}: ${e.from||"…"} → ${e.to||"…"}`,[g,e,u]);function b(k){t(e?{...e,field:k}:{field:k,preset:"",from:"",to:""})}function E(k){h(!1),t({field:u,preset:k,from:"",to:""})}function j(){h(!1),t(null)}function w(k,C){const N={field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...N,[k]:C})}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":a,"aria-label":s,onClick:()=>l(k=>!k),className:Se("editor-input inline-flex items-center justify-between gap-1.5 text-left",g&&"border-foreground/40 text-foreground",n),children:[r.jsx("span",{className:"truncate",children:y}),r.jsx(br,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),a?r.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border border-border/70 bg-background p-2 shadow-lg",children:[r.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:Z_.map(k=>r.jsx("button",{type:"button","aria-pressed":u===k,onClick:()=>b(k),className:Se("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",u===k?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:k},k))}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Km,{label:"Any date",selected:!g,onClick:j}),ID.map(k=>r.jsx(Km,{label:rj[k],selected:(e==null?void 0:e.preset)===k,onClick:()=>E(k)},k)),r.jsx(Km,{label:"Custom range…",selected:m,onClick:()=>{h(!0),t({field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),m?r.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",r.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:k=>w("from",k.target.value),className:"editor-input w-40"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",r.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:k=>w("to",k.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Km({label:e,selected:t,onClick:n}){return r.jsxs("button",{type:"button",onClick:n,className:Se("flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm transition hover:bg-foreground/5",t?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{children:e}),t?r.jsx(Xr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const eF=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search"]);function tF(e,t){const n={};for(const[s,a]of Object.entries(e))eF.has(s)||(n[s]=a);return{...n,...t}}function kx(e,t,n){return{...e,viewMode:t.viewMode,filters:tF(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function nF(e,t){var m;const n={},s=tt(e.status);s.length&&(n.status=s);const a=tt(e.type);a.length&&(n.type=a);const l=tt(e.priority);l.length&&(n.priority=l);const c=tt(e.assignee);c.length&&(n.assignee=c);const u=tt(e.tags);if(u.length&&(n.tags=u),t&&t!=="all")n.project=[t];else{const h=tt(e.project);h.length&&(n.project=h)}e.activity&&e.activity!=="all"&&(n.activity=e.activity),e.dateRange&&(n.dateRange=e.dateRange);const p=(m=e.search)==null?void 0:m.trim();return p&&(n.search=p),n}function Jl(e){const t={viewMode:e.state.viewMode,filters:nF(e.state.filters,e.context.projectSlug),sortField:e.state.sortField,sortDirection:e.state.sortDirection,listSectionVisibility:{collapsed:[...e.state.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...e.state.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...e.state.tableColumnVisibility.hidden]}};return{name:e.name.trim(),workspace:e.context.workspace,config:t}}const Wa={viewMode:"kanban",sortField:"updated",sortDirection:"desc"};function hN(e,t){const{config:n}=Jl({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:e.viewMode,filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}});return{workspace:t,config:n}}function Xl(e){if(!e)return;if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function gN(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function xN(e,t){var s,a,l,c,u,p,m,h,g,y,b,E,j,w;const{config:n}=e;if((s=t.setViewMode)==null||s.call(t,n.viewMode),(a=t.setStatusFilter)==null||a.call(t,tt(n.filters.status)),(l=t.setTypeFilter)==null||l.call(t,tt(n.filters.type)),(c=t.setPriorityFilter)==null||c.call(t,tt(n.filters.priority)),(u=t.setAssigneeFilter)==null||u.call(t,tt(n.filters.assignee)),(p=t.setProjectFilter)==null||p.call(t,tt(n.filters.project)),(m=t.setTagsFilter)==null||m.call(t,tt(n.filters.tags)),(h=t.setDateRange)==null||h.call(t,gN(n.filters.dateRange)),(g=t.setSearch)==null||g.call(t,n.filters.search??""),t.setActivityFilter){const k=n.filters.activity??"all";t.setActivityFilter(k==="fresh"||k==="stale"?k:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(b=t.setSortDirection)==null||b.call(t,n.sortDirection),(E=t.setListSectionVisibility)==null||E.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(j=t.setKanbanColumnVisibility)==null||j.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(w=t.setTableColumnVisibility)==null||w.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Xu(e){return e?`/w/${e}/views`:"/views"}function yN(e){return`${Xu(e.workspace)}/${encodeURIComponent(e.id)}`}function bN(e){const t=e.workspace?`/w/${e.workspace}`:"",n=tt(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&s1(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const rF=["critical","high","medium","low"],sF={last_24h:"last 24 hours",last_7d:"last 7 days",last_30d:"last 30 days",last_90d:"last 90 days",older_7d:"older than 7 days",older_30d:"older than 30 days"};function oF(e){if(e.preset)return`${e.field} ${sF[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function vN(e){var s;const t=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=tt(e[a]);l.length&&t.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&t.push(`activity=${e.activity}`),e.dateRange&&t.push(oF(e.dateRange));const n=(s=e.search)==null?void 0:s.trim();return n&&t.push(`search="${n}"`),t.join(" · ")||"no filters"}const aF=new Set(["overview","assignments","todos","dependencies","knowledge"]),sj="__unknown_type__";function oj(){const{slug:e,workspace:t}=$t(),n=ln(),s=Dt();mo("project"),Ht({keys:"a",scope:"project",description:"Create assignment",handler:()=>s(`${n}/projects/${e}/create/assignment`)}),Ht({keys:"e",scope:"project",description:"Edit project",handler:()=>s(`${n}/projects/${e}/edit`)});const{data:a,loading:l,error:c,refetch:u}=F0(e),p=Zo(),m=ef(),{data:h}=oc(),[g,y]=hs(),b=g.get("tab"),E=b&&aF.has(b)?b:"overview";function j(re){y(Ae=>{const Qe=new URLSearchParams(Ae);return re==="overview"?Qe.delete("tab"):Qe.set("tab",re),Qe},{replace:!0})}const w=e?`p:${e}`:null,k=cN(w),[C,N]=f.useState(()=>km(k.defaultView)),[T,D]=f.useState(()=>tt(k.filters.status)),[R,$]=f.useState(()=>tt(k.filters.assignee)),[L,K]=f.useState(()=>tt(k.filters.priority)),[B,O]=f.useState(()=>tt(k.filters.type)),[W,se]=f.useState(()=>tt(k.filters.tags)),[z,H]=f.useState(null),[ee,ne]=f.useState(()=>k.grouping),[M,G]=f.useState(()=>k.sortField),[A,F]=f.useState(()=>k.sortDirection),[Z,I]=f.useState(()=>({collapsed:[]})),[de,ge]=f.useState(()=>({hidden:[]})),[V,ae]=f.useState(()=>({hidden:[]})),[me,ve]=f.useState(null),[ke,he]=f.useState(!1),[Je,Ye]=f.useState(!1),{toast:ot,showToast:J,dismissToast:Ie}=ta(),Ne={kind:"project",slug:e??"",workspace:t??null},Oe=g.get("loadView"),{view:Xe,loading:Me,error:nt}=Go(Oe),{view:Ke,loading:gt,error:Rt}=Go(me),at=f.useRef(null);f.useEffect(()=>{me&&!gt&&!Rt&&!Ke&&ve(null)},[Ke,Rt,me,gt]),f.useEffect(()=>{ve(null),at.current=null,H(null)},[e,t]),f.useEffect(()=>{N(km(k.defaultView)),D(tt(k.filters.status)),$(tt(k.filters.assignee)),K(tt(k.filters.priority)),O(tt(k.filters.type)),se(tt(k.filters.tags)),ne(k.grouping),G(k.sortField),F(k.sortDirection)},[e,k.defaultView,k.filters.status,k.filters.assignee,k.filters.priority,k.filters.type,k.filters.tags,k.grouping,k.sortField,k.sortDirection]);const ie=f.useCallback(re=>{w&&fN(w,re).catch(Ae=>{console.warn("Failed to persist project view prefs:",Ae)})},[w]),Y=f.useCallback(re=>{N(re),ie({defaultView:re})},[ie]),pe=f.useCallback(re=>{D(re),ie({filters:{status:re}})},[ie]),Q=f.useCallback(re=>{$(re),ie({filters:{assignee:re}})},[ie]),ye=f.useCallback(re=>{K(re),ie({filters:{priority:re}})},[ie]),Pe=f.useCallback(re=>{O(re),ie({filters:{type:re}})},[ie]),lt=f.useCallback(re=>{se(re),ie({filters:{tags:re}})},[ie]),te=f.useCallback(re=>{ne(re),ie({grouping:re})},[ie]),be=f.useCallback(re=>{G(re),ie({sortField:re})},[ie]),Le=f.useCallback(re=>{F(re),ie({sortDirection:re})},[ie]),it=f.useCallback(()=>({viewMode:C,filters:{status:T,priority:L,type:B,assignee:R,tags:W,project:"all",activity:"all",dateRange:Xl(z)},sortField:M,sortDirection:A,listSectionVisibility:Z,kanbanColumnVisibility:de,tableColumnVisibility:V}),[C,T,L,B,R,W,z,M,A,Z,de,V]),_e=f.useCallback(re=>{xN(re,{setViewMode:Ae=>N(km(Ae)),setStatusFilter:pe,setPriorityFilter:ye,setTypeFilter:Pe,setAssigneeFilter:Q,setTagsFilter:lt,setDateRange:H,setSortField:be,setSortDirection:Le,setListSectionVisibility:I,setKanbanColumnVisibility:ge,setTableColumnVisibility:ae}),ve(re.id)},[pe,ye,Pe,Q,lt,be,Le]),bt=f.useCallback(re=>{_e(re),at.current=re.id,y(Ae=>{const Qe=new URLSearchParams(Ae);return Qe.set("loadView",re.id),Qe},{replace:!0})},[_e,y]),_t=f.useCallback(async re=>{try{const Ae=Jl({name:re,context:{workspace:t??null,projectSlug:e??null},state:it()}),Qe=await Wd(Ae),Ft=Qe.views[Qe.views.length-1];ve((Ft==null?void 0:Ft.id)??null),Ft&&(at.current=Ft.id,y(hn=>{const Ct=new URLSearchParams(hn);return Ct.set("loadView",Ft.id),Ct},{replace:!0})),he(!1),Ye(!1),J(`Saved view "${re}"`,"success")}catch(Ae){throw J(Ae instanceof Error?Ae.message:"Failed to save view","error"),Ae}},[it,y,J,e,t]),Gt=f.useCallback(async()=>{if(!(!me||!Ke))try{const re=tt(Ke.config.filters.project)[0]??null,Ae=Jl({name:Ke.name,context:{workspace:t??null,projectSlug:re},state:it()}),Qe=kx(Ke.config,Ae.config,Ae.config);await Lg(me,{config:Qe}),J("View updated","success")}catch(re){J(re instanceof Error?re.message:"Failed to update view","error")}},[it,Ke,me,J,t]);f.useEffect(()=>{if(!Oe){at.current=null;return}if(at.current!==Oe&&(me&&me!==Oe&&ve(null),!Me)){if(nt){J("Couldn't load saved view — try again","error");return}if(Xe){if(at.current=Oe,!o1(Xe,{kind:"project",slug:e??"",workspace:t??null})){s(bN(Xe),{replace:!0});return}_e(Xe),y(re=>{const Ae=new URLSearchParams(re);return Ae.delete("loadView"),Ae},{replace:!0});return}at.current=Oe,J("Saved view no longer exists","error"),y(re=>{const Ae=new URLSearchParams(re);return Ae.delete("loadView"),Ae},{replace:!0})}},[Oe,Xe,Me,nt,me,_e,y,J,s,e,t]);function ue(re){M===re?Le(A==="asc"?"desc":"asc"):(be(re),Le("asc"))}const Be=f.useMemo(()=>a?Object.fromEntries(a.assignments.flatMap(re=>{const Ae=`${n}/projects/${a.slug}/assignments/${re.slug}`;return[[re.slug,Ae],[re.title,Ae]]})):{},[a]);async function Fe(re){await fetch(`/api/projects/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:re})}),u()}async function Nt(re){try{const Ae=await fetch(`/api/projects/${e}/${re?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Ae.ok){const Qe=await Ae.json().catch(()=>null);J((Qe==null?void 0:Qe.error)||`HTTP ${Ae.status}`,"error");return}u(),J(re?"Project archived":"Project restored","success")}catch(Ae){J(Ae instanceof Error?Ae.message:"Failed to update archive state","error")}}async function $n(re){await fetch(`/api/projects/${e}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:re})}),u()}if(l)return r.jsx(mt,{label:"Loading project workspace…"});if(c||!a)return r.jsx(wt,{error:c||"Project not found."});const Yt=(()=>{const re=new Set;for(const Qe of a.assignments)Qe.assignee&&re.add(Qe.assignee);const Ae=[{value:"__unassigned__",label:"Unassigned"}];for(const Qe of Array.from(re).sort())Ae.push({value:Qe,label:Qe});return Ae})(),sn=Array.from(new Set(a.assignments.flatMap(re=>re.tags??[]))).sort().map(re=>({value:re,label:re})),Wt=a.assignments.filter(re=>Kg(re,{status:T,priority:L,type:B,assignee:R,tags:W,dateRange:Xl(z)})),Gn=uc(Wt,M,A),xt=new Set(m.definitions.map(re=>re.id)),jn=ee==="type"?[...m.definitions.map(re=>({id:re.id,title:ii(m,re.id),description:re.description})),...Wt.some(re=>!re.type||!xt.has(re.type))?[{id:sj,title:"Other",description:"Assignments with no recognized type."}]:[]]:G1(p.order).map(re=>({id:re,title:cc(p,re),description:Zd(re)}));function Pt({field:re,children:Ae}){const Qe=M===re;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>ue(re),className:"inline-flex items-center gap-1 hover:text-foreground",children:[Ae,Qe?A==="asc"?r.jsx(c0,{className:"h-3 w-3"}):r.jsx(br,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":k.density,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:a.status}),a.statusOverride&&r.jsx("button",{type:"button",className:"shell-action border-warning-foreground/40 text-warning-foreground",onClick:()=>Fe(null),title:"Clear manual status override and return to derived status",children:"Clear Override"}),r.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm",value:"",onChange:re=>{re.target.value&&Fe(re.target.value)},title:"Override project status",children:[r.jsx("option",{value:"",children:"Set Status…"}),p.statuses.map(re=>r.jsx("option",{value:re.id,children:re.label},re.id)),r.jsx("option",{value:"active",children:"Active"})]}),r.jsx("button",{type:"button",className:"shell-action",onClick:()=>Nt(!a.archived),title:a.archived?"Restore this project and its cascade-hidden assignments":"Archive this project (hides it and its assignments from normal views)",children:a.archived?"Restore":"Archive"}),h&&h.workspaces.length>0&&r.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm",value:"",onChange:re=>{re.target.value==="_ungrouped"?$n(null):re.target.value&&$n(re.target.value)},title:"Move project to a different workspace",children:[r.jsx("option",{value:"",children:"Move to Workspace…"}),h.workspaces.filter(re=>re!==a.workspace).map(re=>r.jsx("option",{value:re,children:re},re)),a.workspace&&r.jsx("option",{value:"_ungrouped",children:"Ungrouped"})]}),r.jsxs(Ee,{className:"shell-action",to:`${n}/projects/${a.slug}/edit`,children:[r.jsx(gv,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Project"})]}),r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${n}/projects/${a.slug}/create/assignment`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Assignment"})]}),r.jsx(Jg,{externalIds:a.externalIds}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Created ",Dn(a.created),". Last source update ",Lr(a.updated),"."]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-5",children:[r.jsx(An,{label:"Assignments",value:a.progress.total}),r.jsx(An,{label:"In Progress",value:a.progress.in_progress??0,tone:"info"}),r.jsx(An,{label:"Review",value:a.progress.review??0,tone:"info"}),r.jsx(An,{label:"Blocked",value:a.progress.blocked??0,tone:"warn"}),r.jsx(An,{label:"Completed",value:a.progress.completed??0,tone:"success"})]}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(Qg,{value:E,onValueChange:j,items:[{value:"overview",label:"Overview",content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Project Overview",children:r.jsx(fn,{content:a.body,emptyState:"This project does not have overview content yet."})})})},{value:"assignments",label:"Assignments",count:a.assignments.filter(re=>!re.archived).length,content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Assignment Queue",description:"Board and table views over the source assignment files.",actions:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(Pn,{ariaLabel:"Status filter",className:"max-w-[170px]",allLabel:"All statuses",options:p.statuses.map(re=>({value:re.id,label:re.label})),value:T,onChange:pe}),r.jsx(Pn,{ariaLabel:"Assignee filter",className:"max-w-[170px]",allLabel:"All assignees",options:Yt,value:R,onChange:Q}),r.jsx(Pn,{ariaLabel:"Priority filter",className:"max-w-[170px]",allLabel:"All priorities",options:[{value:"critical",label:"Critical"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],value:L,onChange:ye}),r.jsx(Pn,{ariaLabel:"Type filter",className:"max-w-[170px]",allLabel:"All types",options:m.definitions.map(re=>({value:re.id,label:ii(m,re.id)})),value:B,onChange:Pe}),r.jsx(Pn,{ariaLabel:"Tags filter",className:"max-w-[170px]",allLabel:"Any tags",options:sn,value:W,onChange:lt}),r.jsx(jx,{className:"max-w-[190px]",value:z,onChange:H}),C==="kanban"&&r.jsxs("select",{value:ee==="type"?"type":"status",onChange:re=>te(re.target.value),className:"editor-input max-w-[170px]",title:"Group kanban by",children:[r.jsx("option",{value:"status",children:"Group: Status"}),r.jsx("option",{value:"type",children:"Group: Type"})]}),r.jsx(nf,{value:C,onChange:re=>Y(re),options:[{value:"kanban",label:"Kanban"},{value:"table",label:"Table"}]}),r.jsx(mN,{scope:Ne,loadedViewId:me,onApply:bt,onOpenSaveDialog:()=>{Ye(!1),he(!0)}}),r.jsx("button",{type:"button",onClick:()=>{Ke?Gt():(Ye(!1),he(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:Ke?`Update ${Ke.name}`:"Save current view",children:Ke?`Update '${Ke.name}'`:"Save view"}),Ke?r.jsx("button",{type:"button",onClick:()=>{Ye(!0),he(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),children:Wt.length===0?r.jsx(St,{title:"No assignments match these filters",description:"Clear the current filters or create a new assignment for this project.",actions:r.jsx(Ee,{className:"shell-action shell-action--cta",to:`${n}/projects/${a.slug}/create/assignment`,children:"Create Assignment"})}):C==="kanban"?r.jsx(Qd,{columns:jn,items:Gn,getItemId:re=>re.slug,getColumnId:re=>ee==="type"?re.type&&xt.has(re.type)?re.type:sj:re.status,dragDisabled:!0,renderCard:re=>r.jsx(iF,{projectSlug:a.slug,assignment:re}),emptyMessage:re=>`No ${re.title.toLowerCase()} assignments.`,hiddenColumnIds:de.hidden,onHideColumn:re=>ge(Ae=>({hidden:Ae.hidden.includes(re)?Ae.hidden.filter(Ft=>Ft!==re):[...Ae.hidden,re]}))}):(()=>{const re=new Set(V.hidden),Ae=Qe=>Qe==="title"||!re.has(Qe);return r.jsxs("div",{className:"overflow-x-auto",children:[r.jsx("div",{className:"mb-3 flex items-center justify-end",children:r.jsx(aN,{visibility:V,onChange:ae})}),r.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[Ae("title")?r.jsx(Pt,{field:"title",children:"Assignment"}):null,Ae("status")?r.jsx(Pt,{field:"status",children:"Status"}):null,r.jsx("th",{className:"pb-3 font-medium",children:"Type"}),Ae("priority")?r.jsx(Pt,{field:"priority",children:"Priority"}):null,Ae("assignee")?r.jsx(Pt,{field:"assignee",children:"Assignee"}):null,Ae("dependencies")?r.jsx(Pt,{field:"dependencies",children:"Dependencies"}):null,Ae("created")?r.jsx(Pt,{field:"created",children:"Created"}):null,Ae("updated")?r.jsx(Pt,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:Gn.map(Qe=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[Ae("title")?r.jsx("td",{className:"py-4",children:r.jsx(Ee,{to:`${n}/projects/${a.slug}/assignments/${Qe.slug}`,className:"font-semibold text-foreground hover:text-primary",children:Qe.title})}):null,Ae("status")?r.jsx("td",{className:"py-4",children:r.jsx(pn,{status:Qe.status})}):null,r.jsx("td",{className:"py-4",children:r.jsx(ea,{type:Qe.type,compact:!0})}),Ae("priority")?r.jsx("td",{className:"py-4 capitalize text-muted-foreground",children:Qe.priority}):null,Ae("assignee")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Qe.assignee??"—"}):null,Ae("dependencies")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Qe.dependsOn.length}):null,Ae("created")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(Qe.created)}):null,Ae("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(Qe.updated)}):null]},Qe.slug))})]})]})})()})})},{value:"todos",label:"Todos",content:r.jsx(K_,{projectId:a.slug})},{value:"dependencies",label:"Dependencies",content:a.dependencyGraph?r.jsx(We,{title:"Dependency Graph",description:"Rendered from the derived graph when available, with a source-based fallback.",children:r.jsx(sO,{definition:a.dependencyGraph,nodeRoutes:Be})}):r.jsx(St,{title:"No dependency graph yet",description:"Dependencies appear here once assignments declare dependsOn relationships."})},{value:"knowledge",label:"Knowledge",content:r.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[r.jsx(We,{title:"Resources",description:"Shared project references.",actions:r.jsxs(Ee,{className:"shell-action",to:`/resources/new?project=${a.slug}`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Resource"})]}),children:a.resources.length===0?r.jsx(St,{title:"No resources yet",description:"Resources live at the project level and stay available to every assignment."}):r.jsx("div",{className:"space-y-3",children:a.resources.map(re=>r.jsxs(Ee,{to:`/projects/${a.slug}/resources/${re.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:re.name}),r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[re.category," · ",re.source]})]},re.slug))})}),r.jsx(We,{title:"Memories",description:"Learnings and patterns captured during the project.",actions:r.jsxs(Ee,{className:"shell-action",to:`/memories/new?project=${a.slug}`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Memory"})]}),children:a.memories.length===0?r.jsx(St,{title:"No memories yet",description:"Memories capture patterns discovered during execution so later assignments can reuse them."}):r.jsx("div",{className:"space-y-3",children:a.memories.map(re=>r.jsxs(Ee,{to:`/projects/${a.slug}/memories/${re.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:re.name}),r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[re.scope," · ",re.source]})]},re.slug))})})]})}]})}),r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Progress Summary",children:r.jsx(gd,{progress:a.progress,showLegend:!0})}),r.jsx(We,{title:"Attention",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Blocked"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.blockedCount})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Failed"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.failedCount})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Unanswered questions"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.openQuestions})]})]})}),r.jsx(We,{title:"Quick Links",children:r.jsxs("div",{className:"space-y-2 text-sm",children:[r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${a.slug}/edit`,children:[r.jsx(gv,{className:"h-4 w-4"}),"Edit project source"]}),r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${a.slug}/create/assignment`,children:[r.jsx(rn,{className:"h-4 w-4"}),"Create assignment"]}),r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:"/help",children:[r.jsx(QT,{className:"h-4 w-4"}),"Review project rules"]}),r.jsxs("button",{type:"button",onClick:()=>j("dependencies"),className:"flex items-center gap-2 text-primary hover:underline",children:[r.jsx(tg,{className:"h-4 w-4"}),"Jump to dependencies"]})]})}),a.archived?r.jsxs(We,{title:"Archive Metadata",children:[r.jsxs("p",{className:"text-sm leading-6 text-muted-foreground",children:["Archived ",a.archivedAt?Lr(a.archivedAt):"with no timestamp recorded","."]}),a.archivedReason?r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.archivedReason}):null]}):null]})]}),r.jsx(na,{toast:ot,onDismiss:Ie}),r.jsx(pN,{open:ke,onOpenChange:re=>{he(re),re||Ye(!1)},initialName:Je&&Ke?`${Ke.name} (copy)`:"",title:Je?"Save as new view":"Save view",onSubmit:_t})]})}function iF({projectSlug:e,assignment:t}){const n=ln();return r.jsxs(Ee,{to:`${n}/projects/${e}/assignments/${t.slug}`,className:"vp-card block rounded-lg border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:t.title}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:t.id,children:[t.id.slice(0,8),r.jsx("span",{onClick:s=>{s.preventDefault(),s.stopPropagation()},children:r.jsx($r,{value:t.id})})]}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Dn(t.updated)]})]}),r.jsx(pn,{status:t.status})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ea,{type:t.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:t.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:t.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[t.dependsOn.length," dependencies"]})]})]})}function wN({sessionId:e,disabled:t=!1,disabledReason:n,onError:s,onNotice:a}){const[l,c]=f.useState(!1),[u,p]=f.useState(!1);async function m(){if(!(t||u)){p(!0);try{const h=await fetch(`/api/launch/command?session=${encodeURIComponent(e)}&mode=resume`);if(!h.ok){const y=await h.json().catch(()=>null);throw new Error((y==null?void 0:y.error)??`HTTP ${h.status}`)}const g=await h.json().catch(()=>null);if(!g||typeof g.command!="string")throw new Error("Malformed response from launch command endpoint");if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(g.command),c(!0),setTimeout(()=>c(!1),1500),typeof g.fallbackWarning=="string"&&g.fallbackWarning&&(a==null||a(g.fallbackWarning))}catch(h){s==null||s(h instanceof Error?h:new Error(String(h)))}finally{p(!1)}}}return t?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:n??"Copy launch command unavailable","aria-label":"Copy launch command",children:r.jsx(xv,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:m,disabled:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded disabled:cursor-wait",title:l?"Copied!":"Copy launch command (cd + resume)","aria-label":"Copy launch command",children:l?r.jsx(Xr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(xv,{className:"h-3 w-3","aria-hidden":"true"})})}function jl(e,t,n,s){let a=`syntaur://open?${e.kind}=${encodeURIComponent(e.id)}`;return e.kind==="session"&&t&&(a+=`&mode=${encodeURIComponent(t)}`),n&&(a+=`&terminal=${encodeURIComponent(n)}`),s&&e.kind==="assignment"&&(a+=`&agent=${encodeURIComponent(s)}`),a}function lF(e){return e.kind==="session"?{method:"POST",url:`/api/agent-sessions/${encodeURIComponent(e.id)}/worktree/recreate`}:e.projectSlug&&e.assignmentSlug?{method:"POST",url:`/api/projects/${encodeURIComponent(e.projectSlug)}/assignments/${encodeURIComponent(e.assignmentSlug)}/worktree/recreate`}:{method:"POST",url:`/api/assignments/${encodeURIComponent(e.id)}/worktree/recreate`}}function cF(e){if(!e.trim())return"Branch name is required.";if(/\s/.test(e))return"Branch name cannot contain whitespace.";if(/[\x00-\x1F\x7F~^:?*[\\]/.test(e))return"Branch name cannot contain any of: ~ ^ : ? * [ \\ or control characters.";if(e.startsWith("-"))return'Branch name cannot start with "-".';if(e.startsWith("/")||e.endsWith("/"))return'Branch name cannot start or end with "/".';if(e.endsWith("."))return'Branch name cannot end with ".".';if(e.includes(".."))return'Branch name cannot contain "..".';if(e.includes("@{"))return'Branch name cannot contain "@{".';if(e==="@")return'Branch name cannot be "@".';for(const t of e.split("/")){if(!t)return'Branch name cannot contain empty path segments (e.g. "a//b").';if(t.startsWith("."))return'Branch name segments cannot start with ".".';if(t.endsWith(".lock"))return'Branch name segments cannot end with ".lock".'}return null}async function jN(e,t,n,s){const a=await fetch(`/api/projects/${e}/assignments/${t}/transitions/${n.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{reason:s}:{})}),l=await a.json().catch(()=>null);if(!a.ok)throw new Error((l==null?void 0:l.error)||`HTTP ${a.status}`);return l.assignment}async function kN(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})}),a=await s.json().catch(()=>null);if(!s.ok)throw new Error((a==null?void 0:a.error)||`HTTP ${s.status}`);return a.assignment}async function uF(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}`,{method:"DELETE"}),s=await n.json().catch(()=>null);if(!n.ok)throw new Error((s==null?void 0:s.error)||`HTTP ${n.status}`)}function SN(e){return e.requiresReason||e.command==="block"}async function dF(e){const t=await fetch(`/api/projects/${e.projectSlug}/assignments/${e.assignmentSlug}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}async function fF(e){const t=await fetch(`/api/assignments/${e.id}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}class Sx extends Error{constructor(t,n){super(t),this.stderr=n,this.name="CreateWorktreeError"}}async function Nx(e){const t=await e.json().catch(()=>null);return new Sx((t==null?void 0:t.error)||`HTTP ${e.status}`,t==null?void 0:t.stderr)}async function pF(e){const t=await fetch(`/api/projects/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function mF(e){const t=await fetch(`/api/assignments/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function hF(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw await Nx(s);return(await s.json()).assignment}async function gF(e,t){const n=await fetch(`/api/assignments/${e}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await Nx(n);return(await n.json()).assignment}async function xF(e){const{url:t}=lF(e),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!n.ok)throw await Nx(n);return await n.json()}async function cf(e){const t=await e.json().catch(()=>null);if(!e.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${e.status}`);return t}async function yF(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/repository-branches?repo=${encodeURIComponent(n)}`);return cf(s)}async function bF(e,t){const n=await fetch(`/api/assignments/${e}/repository-branches?repo=${encodeURIComponent(t)}`);return cf(n)}async function vF(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}/source-assignments`);return(await cf(n)).sourceAssignments}async function wF(e){const t=await fetch(`/api/assignments/${e}/source-assignments`);return(await cf(t)).sourceAssignments}function NN(){const[e,t]=f.useState(!1),[n,s]=f.useState(null),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState(null),[h,g]=f.useState(null),[y,b]=f.useState(!1),[E,j]=f.useState(null),[w,k]=f.useState(null);async function C(R,$,L){if(!e){t(!0);try{const K=await fetch("/api/launch/preflight",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:{kind:R.kind,id:R.id}})});if(!K.ok){window.location.href=jl(R,$,void 0,L);return}const B=await K.json();if(B.ok){window.location.href=jl(R,$,void 0,L);return}if(B.reason==="workspace-path-invalid"){B.recreate?(m(B.recreate),g({target:R,mode:$,agentId:L})):u(B.message);return}s(B),l({target:R,mode:$,agentId:L})}catch(K){console.warn("preflight failed, firing without override:",K),window.location.href=jl(R,$,void 0,L)}finally{t(!1)}}}function N(){!n||!a||(window.location.href=jl(a.target,a.mode,n.suggestedFallback,a.agentId),s(null),l(null))}async function T(){if(!(!p||!h||y)){b(!0),j(null);try{const R=await xF({kind:p.kind,id:p.id,projectSlug:p.projectSlug,assignmentSlug:p.assignmentSlug}),{target:$,mode:L,agentId:K}=h;m(null),g(null),window.location.href=jl($,L,void 0,K),!R.exact&&!R.alreadyExisted&&k(`Recreated from ${R.baseUsed} — the original branch couldn't be restored exactly, but the directory is back and your agent is opening.`)}catch(R){j(R instanceof Sx&&R.stderr?`${R.message}
544
544
  ${R.stderr}`:R instanceof Error?R.message:String(R))}finally{b(!1)}}}const D=r.jsxs(r.Fragment,{children:[r.jsx(Ga,{open:n!==null,onOpenChange:R=>!R&&(s(null),l(null)),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsxs(Uo,{children:[n==null?void 0:n.terminal," is not installed"]}),r.jsxs(Vo,{children:["Open in ",r.jsx("strong",{children:n==null?void 0:n.suggestedFallback})," instead? You can change the default in"," ",r.jsx(Ee,{to:"/settings",className:"underline hover:text-foreground",onClick:()=>{s(null),l(null)},children:"Settings"}),"."]})]}),r.jsxs(Ja,{children:[r.jsx(Ul,{className:"shell-action mt-0",children:"Cancel"}),r.jsxs(oo,{className:"shell-action mt-0 shell-action--cta",onClick:R=>{R.preventDefault(),N()},children:["Open in ",n==null?void 0:n.suggestedFallback]})]})]})}),r.jsx(Ga,{open:c!==null,onOpenChange:R=>!R&&u(null),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Can't open in agent"}),r.jsxs(Vo,{children:[c," Set a valid worktree or repository, then try again."]})]}),r.jsx(Ja,{children:r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",onClick:()=>u(null),children:"OK"})})]})}),r.jsx(Ga,{open:p!==null,onOpenChange:R=>{!R&&!y&&(m(null),g(null),j(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Worktree was deleted"}),r.jsxs(Vo,{children:["The worktree at ",r.jsx("code",{children:p==null?void 0:p.deletedPath})," no longer exists. Recreate it",p!=null&&p.branch?r.jsxs(r.Fragment,{children:[" ","on branch ",r.jsx("code",{children:p.branch})]}):null," ","so this can open?"]})]}),E&&r.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-muted p-2 text-xs text-destructive",children:E}),r.jsxs(Ja,{children:[r.jsx(Ul,{className:"shell-action mt-0",disabled:y,children:"No"}),r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",disabled:y,onClick:R=>{R.preventDefault(),T()},children:y?"Recreating…":"Yes, recreate"})]})]})}),r.jsx(Ga,{open:w!==null,onOpenChange:R=>!R&&k(null),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Worktree recreated"}),r.jsx(Vo,{children:w})]}),r.jsx(Ja,{children:r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",onClick:()=>k(null),children:"OK"})})]})})]});return{open:C,pending:e,dialogs:D}}function CN({session:e,onMarkStopped:t}){const n=NN(),s={kind:"session",id:e.sessionId},a="size-3.5",l=Se("shell-action","inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50"),c="inline-flex outline-none focus-visible:ring-1 focus-visible:ring-ring rounded-sm",u=!e.resumeSupported&&!e.forkSupported;return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{delayDuration:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1",children:[u&&r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{tabIndex:0,className:c,children:r.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:l,children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Reopen"})]})})}),r.jsx(gr,{side:"top",children:"Reopen unavailable — this agent has no resume/fork command configured"})]}),e.resumeSupported&&(e.isLive?r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{tabIndex:0,className:c,children:r.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:l,children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Resume"})]})})}),r.jsx(gr,{side:"top",children:"Session appears active — fork instead to avoid transcript corruption"})]}):r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,disabled:n.pending,onClick:()=>void n.open(s,"resume"),children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Resume"})]})}),r.jsx(gr,{side:"top",children:"Continue this session in its agent (same session id, same transcript)"})]})),e.forkSupported&&r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,disabled:n.pending,onClick:()=>void n.open(s,"fork"),children:[r.jsx(fR,{className:a}),r.jsx("span",{children:"Fork"})]})}),r.jsx(gr,{side:"top",children:"Branch a new session from this point — safe even when the original is still running"})]}),e.status==="active"&&r.jsxs(Pr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,onClick:()=>t(e.sessionId),children:[r.jsx(og,{className:a}),r.jsx("span",{children:"Mark stopped"})]})}),r.jsx(gr,{side:"top",children:e.resumeSupported?"Tell the dashboard this session has ended so Resume re-enables":"Tell the dashboard this session has ended"})]})]})}),n.dialogs]})}async function jF(e){await fetch(`/api/agent-sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})})}function EN({sessions:e,loading:t,error:n,onError:s,onNotice:a}){return t&&!e?null:n&&!e?r.jsx(We,{title:"Agent Sessions",children:r.jsx(St,{title:"Couldn't load sessions",description:n})}):!e||e.length===0?r.jsx(We,{title:"Agent Sessions",children:r.jsx(St,{title:"No agent sessions yet",description:"Sessions appear here when an agent registers one via /grab-assignment or syntaur track-session."})}):r.jsx(We,{title:"Agent Sessions",children:r.jsx("div",{className:"space-y-2",children:e.map(l=>r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Ad,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"font-medium text-foreground",children:l.agent}),r.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:l.sessionId,children:[l.sessionId.slice(0,8),r.jsx($r,{value:l.sessionId}),r.jsx(wN,{sessionId:l.sessionId,disabled:!l.resumeSupported,disabledReason:"Resume not supported for this agent",onError:s,onNotice:a})]})]}),r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(pn,{status:l.status}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Lr(l.started)})]}),r.jsx(CN,{session:l,onMarkStopped:jF})]},l.sessionId))})})}const qm="Cost / Usage";function TN({summary:e,error:t}){return t&&!e?r.jsx(We,{title:qm,children:r.jsx(St,{title:"Couldn't load usage",description:t})}):e?e.lastEventDay===null?r.jsx(We,{title:qm,children:r.jsx(St,{title:"No usage recorded yet",description:"Cost and token totals appear here once the usage collector records activity for this assignment."})}):r.jsx(We,{title:qm,children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(aj,{label:"Total cost",value:od(e.totalCost)}),r.jsx(aj,{label:"Total tokens",value:sd(e.totalTokens)})]}),e.byModel.length>1?r.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),r.jsx("div",{className:"space-y-1",children:e.byModel.map(n=>r.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(Od,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono text-xs text-foreground",title:n.model,children:n.model})]}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[sd(n.totalTokens)," · ",od(n.totalCost)]})]},n.model))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last usage recorded ",dP(e.lastEventDay)]})]})}):null}function aj({label:e,value:t}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("p",{className:"text-lg font-semibold tabular-nums text-foreground",children:t})]})}function RN({open:e,action:t,assignmentTitle:n,loading:s=!1,onConfirm:a,onOpenChange:l}){const[c,u]=f.useState("");f.useEffect(()=>{e||u("")},[e,t==null?void 0:t.command]);const p=f.useMemo(()=>t&&t.command==="block"?"Blocked Reason":"Reason",[t]);if(!t)return null;const m=`${t.label} "${n}"`,h=s?"Applying...":t.label,g=c.trim()||void 0;return r.jsx(ar,{open:e,onOpenChange:y=>s?void 0:l(y),children:r.jsx(Kn,{className:"max-w-xl",children:r.jsxs("form",{className:"space-y-5",onSubmit:y=>{y.preventDefault(),a(g)},children:[r.jsxs(Zr,{children:[r.jsx(qn,{children:m}),r.jsx(gs,{children:t.description})]}),t.warning?r.jsx("div",{className:"rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:t.warning}):null,r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:p}),r.jsx("textarea",{value:c,onChange:y=>u(y.target.value),autoFocus:!0,rows:4,disabled:s,placeholder:"Optional context for why this assignment is blocked.",className:"editor-textarea min-h-[120px] bg-background/95 font-sans"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave this blank to continue without a written reason."})]}),r.jsxs(Ls,{children:[r.jsx("button",{type:"button",onClick:()=>l(!1),disabled:s,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:s,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h})]})]})})})}function sa({open:e,title:t,description:n,confirmLabel:s,cancelLabel:a="Cancel",loading:l=!1,destructive:c=!1,onConfirm:u,onOpenChange:p}){return r.jsx(Ga,{open:e,onOpenChange:m=>l?void 0:p(m),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:t}),r.jsx(Vo,{children:n})]}),r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:l,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:a}),r.jsx(oo,{disabled:l,className:`shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90":"shell-action--cta"}`,onClick:m=>{m.preventDefault(),u()},children:l?"Working...":s})]})]})})}const kF=/^[a-z0-9][a-z0-9_-]*$/,PN=["first","last","none"];class AN extends Error{constructor(n,s){super(n);Qb(this,"fieldErrors");this.name="AgentsConfigError",this.fieldErrors=s}}const Cx={agents:[],custom:!1};let Xa=null,Ka=null,vd=0;const _h=new Set;function DN(e){Xa=e;for(const t of _h)t(e)}function SF(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.id!="string"||t.id.length===0||typeof t.label!="string"||typeof t.command!="string")return null;const n={id:t.id,label:t.label,command:t.command};return Array.isArray(t.args)&&t.args.every(s=>typeof s=="string")&&(n.args=t.args),typeof t.promptArgPosition=="string"&&PN.includes(t.promptArgPosition)&&(n.promptArgPosition=t.promptArgPosition),typeof t.resolveFromShellAliases=="boolean"&&(n.resolveFromShellAliases=t.resolveFromShellAliases),typeof t.default=="boolean"&&(n.default=t.default),typeof t.model=="string"&&(n.model=t.model),typeof t.playbook=="string"&&(n.playbook=t.playbook),n}function Ex(e){if(!e||typeof e!="object")return Cx;const t=e,n=Array.isArray(t.agents)?t.agents:[],s=[];for(const a of n){const l=SF(a);l&&s.push(l)}return{agents:s,custom:t.custom===!0}}function NF(){if(Xa)return Promise.resolve(Xa);if(Ka)return Ka;const e=++vd;return Ka=fetch("/api/config/agents").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{Ka=null;const n=Ex(t);return e!==vd?Xa??n:(Xa=n,n)}).catch(()=>(Ka=null,Cx)),Ka}function $N(){const[e,t]=f.useState(()=>Xa??Cx);return f.useEffect(()=>{let n=!1;return NF().then(s=>{n||t(s)}),_h.add(t),()=>{n=!0,_h.delete(t)}},[]),e}async function LN(e){const t=await e.json().catch(()=>null),n=(t==null?void 0:t.error)??`HTTP ${e.status}`;return new AN(n,t==null?void 0:t.fieldErrors)}async function CF(e){++vd;const t=await fetch("/api/config/agents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:e})});if(!t.ok)throw await LN(t);const n=Ex(await t.json());return DN(n),n}async function EF(){++vd;const e=await fetch("/api/config/agents",{method:"DELETE"});if(!e.ok)throw await LN(e);const t=Ex(await e.json());return DN(t),t}function ON({target:e,worktreePath:t=null,repository:n=null,size:s="default",title:a}){const l=e.kind==="assignment"&&!t&&!n,c=NN(),p=$N().agents,[m,h]=f.useState(null);f.useEffect(()=>{p.length!==0&&h(D=>D&&p.some($=>$.id===D)?D:(p.find($=>$.default)??p[0]).id)},[p]);const g=e.kind==="assignment"&&p.length>1,y=p.find(D=>D.id===m)??null,b=f.useRef(null),[E,j]=f.useState(!1);f.useEffect(()=>{if(!E)return;function D($){b.current&&!b.current.contains($.target)&&j(!1)}function R($){$.key==="Escape"&&j(!1)}return document.addEventListener("mousedown",D),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",R)}},[E]);function w(D){c.open(e,void 0,D)}const k=e.kind==="assignment"?"Open this assignment in your configured terminal + agent":"Resume this session in its agent",C="Set a workspace path first — see the Workspace Before Code playbook",N=Se("shell-action",s==="compact"&&"inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50");if(l)return r.jsxs("button",{type:"button",disabled:!0,title:C,className:N,"aria-disabled":!0,children:[r.jsx(Za,{className:"size-3.5"}),r.jsx("span",{children:"Open in agent"})]});const T=e.kind==="session"?"Open":"Open in agent";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative inline-flex",ref:b,children:[r.jsxs("div",{className:"inline-flex items-stretch",children:[r.jsxs("button",{type:"button",onClick:()=>w(m??void 0),disabled:c.pending,title:(a??k)+(g&&y?` (${y.label})`:""),className:Se(N,g&&"rounded-r-none"),children:[r.jsx(Za,{className:"size-3.5"}),r.jsx("span",{children:T})]}),g&&r.jsx("button",{type:"button",onClick:()=>j(D=>!D),disabled:c.pending,"aria-haspopup":"menu","aria-expanded":E,"aria-label":"Choose which agent to launch",title:"Choose which agent to launch",className:Se(N,"-ml-px rounded-l-none",s==="compact"?"px-1":"px-1.5"),children:r.jsx(br,{className:Se("size-3.5 opacity-70 transition-transform",E&&"rotate-180")})})]}),E&&g&&r.jsxs("div",{role:"menu","aria-label":"Open with agent",className:"absolute right-0 top-full z-30 mt-1 min-w-[180px] overflow-hidden rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsx("div",{className:"px-2.5 pb-1 pt-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Open with agent"}),p.map(D=>r.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":D.id===m,onClick:()=>{h(D.id),j(!1),w(D.id)},className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent",children:[r.jsx(Xr,{className:Se("size-3.5 shrink-0",D.id===m?"opacity-100":"opacity-0")}),r.jsx("span",{className:"truncate",children:D.label}),D.default&&r.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:"default"})]},D.id))]})]}),c.dialogs]})}const Gm="w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";function IN({projectSlug:e,assignmentSlug:t,assignmentId:n,defaultBranch:s,defaultParentBranch:a="main",onCreated:l}){const c=e&&t?{kind:"project-nested",projectSlug:e,assignmentSlug:t}:{kind:"standalone",assignmentId:n},[u,p]=f.useState(!1),[m,h]=f.useState("new-branch"),[g,y]=f.useState(null),[b,E]=f.useState(null),[j,w]=f.useState(""),[k,C]=f.useState(!1),[N,T]=f.useState(""),[D,R]=f.useState([]),[$,L]=f.useState(!1),[K,B]=f.useState(null),[O,W]=f.useState(""),[se,z]=f.useState(null),[H,ee]=f.useState(null),[ne,M]=f.useState(""),[G,A]=f.useState(s),[F,Z]=f.useState(!1),[I,de]=f.useState(null);f.useEffect(()=>{if(!u)return;let J=!1;return h("new-branch"),y(null),E(null),w(""),C(!1),T(""),R([]),L(!1),B(null),W(""),z(null),ee(null),M(""),A(s),de(null),(c.kind==="project-nested"?pF(c.projectSlug):mF(c.assignmentId)).then(Oe=>{if(!J)if(y(Oe),Oe.length===0)C(!0);else{const Xe=Oe.find(nt=>nt.source==="project"),Me=Oe.find(nt=>nt.source==="sibling");w((Xe==null?void 0:Xe.path)??(Me==null?void 0:Me.path)??Oe[0].path)}}).catch(Oe=>{J||(E(Oe.message),y([]),C(!0))}),(c.kind==="project-nested"?vF(c.projectSlug,c.assignmentSlug):wF(c.assignmentId)).then(Oe=>{J||z(Oe)}).catch(Oe=>{J||(ee(Oe.message),z([]))}),()=>{J=!0}},[u,s,a,e,t,n]);const ge=m==="branch-off"?(se??[]).find(J=>J.id===ne)??null:null,V=m==="branch-off"?(ge==null?void 0:ge.repository)??"":k?N.trim():j;f.useEffect(()=>{if(!u||m!=="new-branch")return;if(!V){R([]),B(null),L(!1),W("");return}let J=!1;return L(!0),B(null),W(""),(c.kind==="project-nested"?yF(c.projectSlug,c.assignmentSlug,V):bF(c.assignmentId,V)).then(Ne=>{if(J)return;R(Ne.branches);const Oe=(Ne.defaultBranch&&Ne.branches.includes(Ne.defaultBranch)?Ne.defaultBranch:Ne.branches.includes(a)?a:Ne.branches[0])??"";W(Oe),L(!1)}).catch(Ne=>{J||(R([]),B(Ne.message),L(!1))}),()=>{J=!0}},[u,m,V,a,e,t,n]);const ae=cF(G.trim()),me=f.useMemo(()=>!V||!G.trim()?"":`${V.replace(/\/+$/,"")}/.worktrees/${G.trim()}`,[V,G]),ve=g!==null&&g.length===0,ke=se!==null&&se.length===0,he=J=>{J!==m&&(h(J),M(""),de(null),J==="branch-off"&&(W(""),R([]),B(null),L(!1)))},Je=J=>{M(J);const Ie=(se??[]).find(Ne=>Ne.id===J);W((Ie==null?void 0:Ie.branch)??"")},Ye=F||ae!==null||!V||!O.trim()||(m==="new-branch"?g===null||$:se===null||!ne),ot=async()=>{Z(!0),de(null);try{const J={repository:V,branch:G.trim(),parentBranch:O.trim()};c.kind==="project-nested"?await hF(c.projectSlug,c.assignmentSlug,J):await gF(c.assignmentId,J),p(!1),l()}catch(J){J instanceof Sx?de({message:J.message,stderr:J.stderr}):J instanceof Error?de({message:J.message}):de({message:String(J)})}finally{Z(!1)}};return r.jsxs(ar,{open:u,onOpenChange:J=>F?void 0:p(J),children:[r.jsxs("button",{type:"button",className:"shell-action inline-flex items-center gap-1.5",onClick:()=>p(!0),children:[r.jsx(dR,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{children:"Create worktree"})]}),r.jsxs(Kn,{children:[r.jsxs(Zr,{children:[r.jsx(qn,{children:"Create worktree"}),r.jsxs(gs,{children:["Creates a git worktree at ",r.jsx("code",{children:"<repo>/.worktrees/<branch>"})," and records the workspace fields on this assignment's frontmatter."]})]}),r.jsxs("div",{className:"grid gap-4 text-sm",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-1 rounded-md border border-border/70 p-1",children:[r.jsx("button",{type:"button",disabled:F,onClick:()=>he("new-branch"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${m==="new-branch"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"New branch from repo"}),r.jsx("button",{type:"button",disabled:F,onClick:()=>he("branch-off"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${m==="branch-off"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"Branch off another assignment"})]}),m==="new-branch"?r.jsxs(r.Fragment,{children:[ve?r.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:["No repositories configured for this project. Enter a repo path below, or add a"," ",r.jsx("code",{children:"repositories:"})," list to ",r.jsx("code",{children:"project.md"}),"."]}):null,b?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load repository candidates: ",b]}):null,r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Repository"}),r.jsx("select",{className:Gm,value:j,onChange:J=>w(J.target.value),disabled:F||g===null||k,children:(g??[]).map(J=>r.jsxs("option",{value:J.path,children:[J.path,J.source==="project"?" (project)":J.sourceAssignmentSlug?` (sibling — ${J.sourceAssignmentSlug})`:" (sibling)"]},`${J.source}:${J.path}`))}),ve?null:r.jsx("button",{type:"button",className:"justify-self-start text-[11px] text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:F,onClick:()=>C(J=>!J),children:k?"Use a listed repository":"Enter a custom repository path (advanced)"}),k?r.jsx("input",{className:"mt-1 w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",placeholder:"/absolute/path/to/repo",value:N,onChange:J=>T(J.target.value),disabled:F}):null]}),r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Parent branch"}),r.jsx("select",{className:Gm,value:O,onChange:J=>W(J.target.value),disabled:F||$||D.length===0,children:$?r.jsx("option",{value:"",children:"Loading branches…"}):D.length===0?r.jsx("option",{value:"",children:K?"Could not load branches":V?"No branches found":"— pick a repository —"}):D.map(J=>r.jsx("option",{value:J,children:J},J))}),K?r.jsxs("span",{className:"text-[11px] text-error-foreground",children:["Could not load branches: ",K]}):null]})]}):r.jsxs(r.Fragment,{children:[H?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load assignments: ",H]}):null,ke?r.jsx("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:"No other assignments with a configured workspace to branch off. Create a worktree for one first, or use “New branch from repo”."}):r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Source assignment"}),r.jsxs("select",{className:Gm,value:ne,onChange:J=>Je(J.target.value),disabled:F||se===null,children:[r.jsx("option",{value:"",children:"— select an assignment —"}),(se??[]).map(J=>r.jsxs("option",{value:J.id,children:[J.title," (",J.branch,")"]},J.id))]})]}),ge?r.jsxs("div",{className:"grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2 text-xs",children:[r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("span",{className:"font-medium text-muted-foreground",children:"Repository (from source)"}),r.jsx("code",{className:"break-all",children:ge.repository})]}),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("span",{className:"font-medium text-muted-foreground",children:"Parent branch (from source)"}),r.jsx("code",{children:ge.branch})]})]}):null]}),r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"New branch name"}),r.jsx("input",{className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",value:G,onChange:J=>A(J.target.value),disabled:F}),ae?r.jsx("span",{className:"text-[11px] text-error-foreground",children:ae}):null]}),r.jsxs("div",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Worktree path"}),r.jsx("code",{className:"rounded-md border border-border bg-muted px-2 py-1 text-xs break-all",children:me||r.jsx("span",{className:"opacity-60",children:"— pick a repo & branch —"})})]}),I?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:[r.jsx("div",{className:"font-medium",children:I.message}),I.stderr?r.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-[11px] opacity-90",children:I.stderr}):null]}):null]}),r.jsxs(Ls,{children:[r.jsx(O3,{disabled:F,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",disabled:Ye,onClick:()=>void ot(),className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:F?"Working…":"Create worktree"})]})]})]})}function TF(e){const t=e.split(`
545
545
  `),n=t.findIndex(c=>/^##\s+Acceptance Criteria\s*$/i.test(c.trim()));if(n===-1)return{acceptanceCriteria:[],summaryBody:e};let s=t.length;for(let c=n+1;c<t.length;c+=1)if(/^#{1,2}\s+\S/.test(t[c].trim())){s=c;break}const a=t.slice(n+1,s).map(c=>c.match(/^\s*[-*]\s+\[( |x|X)\]\s+(.*)$/)).filter(c=>!!c).map(c=>({checked:c[1].toLowerCase()==="x",text:c[2].trim()})),l=[...t.slice(0,n),...t.slice(s)].join(`
546
546
  `).replace(/\n{3,}/g,`
@@ -552,7 +552,7 @@ ${R.stderr}`:R instanceof Error?R.message:String(R))}finally{b(!1)}}}const D=r.j
552
552
  `).trim(),l=[...t.slice(0,n),...t.slice(s)].join(`
553
553
  `).replace(/\n{3,}/g,`
554
554
 
555
- `).trim();return{hasSection:!0,todosMarkdown:a,remaining:l}}function PF({projectSlug:e,dependencies:t,blockedReason:n}){const[s,a]=f.useState(!1);if(t.length===0)return null;const l=t.filter(u=>u.status!=="completed"&&u.status!=="review"),c=l.length===0;return c&&!s?r.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex w-full items-center gap-2 rounded-lg border border-success-foreground/30 bg-success/70 px-4 py-2.5 text-left transition hover:bg-success",children:[r.jsx(Zh,{className:"h-4 w-4 shrink-0 text-success-foreground"}),r.jsxs("span",{className:"text-sm font-medium text-success-foreground",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),r.jsx(br,{className:"ml-auto h-4 w-4 text-success-foreground"})]}):r.jsxs("div",{className:"space-y-3",children:[l.length>0&&r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3",children:[r.jsx(lh,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning-foreground"}),r.jsxs("div",{className:"text-sm text-warning-foreground",children:[r.jsxs("strong",{children:[l.length," ",l.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&r.jsxs("p",{className:"mt-1 text-warning-foreground/80",children:["Blocked reason: ",n]})]})]}),r.jsx(We,{title:"Dependencies",description:`${t.length-l.length} of ${t.length} resolved`,actions:c?r.jsx("button",{type:"button",onClick:()=>a(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:r.jsx("div",{className:"divide-y divide-border/40",children:t.map(u=>r.jsxs(Ee,{to:`/projects/${e}/assignments/${u.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(pn,{status:u.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:u.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:u.slug})]}),u.assignee&&r.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:u.assignee}),r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},u.slug))})})]})}function AF({links:e}){const t=ln();if(e.length===0)return null;const n=e.filter(a=>!a.isReverse),s=e.filter(a=>a.isReverse);return r.jsx(We,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:r.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(a=>r.jsxs(Ee,{to:`${t}/projects/${a.projectSlug}/assignments/${a.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(a0,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(pn,{status:a.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:a.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.slug})]}),r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${a.slug}`)),s.map(a=>r.jsxs(Ee,{to:`${t}/projects/${a.projectSlug}/assignments/${a.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(td,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(pn,{status:a.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:a.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.slug})]}),r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${a.slug}`))]})})}function DF(e){const t=new Map;for(const s of e)t.set(s.id,{entry:s,replies:[]});const n=[];for(const s of e){const a=t.get(s.id);s.replyTo&&t.has(s.replyTo)?t.get(s.replyTo).replies.push(a):n.push(a)}return n}function $F(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function MN({projectSlug:e,assignmentSlug:t,entries:n}){const[s,a]=f.useState(n);f.useEffect(()=>{a(n)},[n]);const l=f.useMemo(()=>DF(s),[s]),[c,u]=f.useState(""),[p,m]=f.useState("note"),[h,g]=f.useState(!1),[y,b]=f.useState(null);async function E(w){var N;if(w.preventDefault(),!c.trim())return;g(!0),b(null);const k=`tmp-${Date.now()}`,C={id:k,timestamp:new Date().toISOString(),author:"human",type:p,body:c,resolved:p==="question"?!1:void 0};a(T=>[...T,C]);try{const T=await fetch($F(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:c,type:p})});if(!T.ok){const $=await T.text();throw new Error($||`HTTP ${T.status}`)}const D=await T.json().catch(()=>null),R=(N=D==null?void 0:D.comment)==null?void 0:N.id;a($=>$.map(L=>L.id===k?{...L,id:R??L.id}:L)),u(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(T){b(T instanceof Error?T.message:String(T)),a(D=>D.filter(R=>R.id!==k))}finally{g(!1)}}async function j(w,k){a(C=>C.map(N=>N.id===w?{...N,resolved:k}:N));try{const C=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(w)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(w)}/resolved`,N=await fetch(C,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:k})});if(!N.ok)throw new Error(`HTTP ${N.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(C){b(C instanceof Error?C.message:String(C)),a(N=>N.map(T=>T.id===w?{...T,resolved:!k}:T))}}return r.jsx(We,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:r.jsxs("div",{className:"space-y-4",children:[l.map(w=>r.jsx(_N,{node:w,onToggleResolved:j,depth:0},w.entry.id)),r.jsxs("form",{onSubmit:E,className:"mt-6 space-y-2 border-t border-border pt-4",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Add comment"}),r.jsx("textarea",{value:c,onChange:w=>u(w.target.value),className:"w-full rounded border border-border bg-background p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:p,onChange:w=>m(w.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs",children:[r.jsx("option",{value:"note",children:"note"}),r.jsx("option",{value:"question",children:"question"}),r.jsx("option",{value:"feedback",children:"feedback"})]}),r.jsx("button",{type:"submit",disabled:h||!c.trim(),className:"shell-action",children:h?"Posting…":"Post comment"}),y?r.jsx("span",{className:"text-xs text-error-foreground",children:y}):null]})]})]})})}function _N({node:e,depth:t,onToggleResolved:n}){const{entry:s,replies:a}=e,l=s.type==="question";return r.jsxs("div",{className:Se("space-y-2",t>0&&"ml-4 border-l border-border pl-4"),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-mono",children:s.id}),r.jsx("span",{children:"·"}),r.jsx("span",{children:s.timestamp}),r.jsx("span",{children:"·"}),r.jsx("span",{className:"font-medium text-foreground",children:s.author}),r.jsx("span",{children:"·"}),r.jsx("span",{className:Se("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",l&&"bg-warning text-warning-foreground",s.type==="feedback"&&"bg-info text-info-foreground",s.type==="note"&&"bg-muted text-muted-foreground"),children:s.type}),l?r.jsxs("button",{type:"button",onClick:()=>n(s.id,!s.resolved),className:Se("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",s.resolved?"bg-success text-success-foreground hover:bg-success/80":"bg-muted text-muted-foreground hover:bg-muted/80"),title:s.resolved?"Mark unresolved":"Mark resolved",children:[s.resolved?r.jsx(Zh,{className:"h-3 w-3"}):r.jsx(nR,{className:"h-3 w-3"}),s.resolved?"resolved":"open"]}):null,s.replyTo?r.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx(kR,{className:"h-3 w-3"}),s.replyTo]}):null]}),r.jsx(fn,{content:s.body}),a.length>0?r.jsx("div",{className:"space-y-2",children:a.map(c=>r.jsx(_N,{node:c,depth:t+1,onToggleResolved:n},c.entry.id))}):null]})}const LF=["review","complete","shape","plan-ready","implement","unblock","start","block","fail","reopen"];function ij(){var lt,te,be,Le,it,_e,bt,_t,Gt;const{slug:e,aslug:t}=$t(),n=Dt(),s=ln(),[a,l]=hs(),[c,u]=f.useState(null),{toast:p,showToast:m,dismissToast:h}=ta(),[g,y]=f.useState(null),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null),[N,T]=f.useState(!1),[D,R]=f.useState(!1),[$,L]=f.useState(0),K=a.get("tab")??"summary",B=Zo(),{data:O,loading:W,error:se,refetch:z}=jP(e,t),{data:H}=F0(e),{data:ee}=dg(),{data:ne,loading:M,error:G}=SP(e,t),{data:A,loading:F,error:Z}=CP(e,t),I=f.useMemo(()=>{if(!O||!H)return[];const ue=new Map(H.assignments.map(Be=>[Be.slug,Be]));return O.dependsOn.map(Be=>{const Fe=ue.get(Be);return{slug:Be,title:(Fe==null?void 0:Fe.title)??Be,status:(Fe==null?void 0:Fe.status)??"pending",priority:(Fe==null?void 0:Fe.priority)??"medium",assignee:(Fe==null?void 0:Fe.assignee)??null}})},[O,H]),de=I.filter(ue=>ue.status!=="completed"&&ue.status!=="review");mo("assignment");const ge=f.useMemo(()=>((H==null?void 0:H.assignments)??[]).map(ue=>ue.slug),[H]),V=t?ge.indexOf(t):-1,ae=V>0?ge[V-1]:null,me=V>=0&&V<ge.length-1?ge[V+1]:null,ve=`${s}/projects/${e}/assignments/${t}`;Ht({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${ve}/edit`)}),Ht({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${ve}/plan/edit`)}),Ht({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${ve}/handoff/edit`)}),Ht({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${ve}/decision-record/edit`)}),Ht({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${ve}/scratchpad/edit`)}),Ht({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ae,handler:()=>ae&&n(`${s}/projects/${e}/assignments/${ae}`)}),Ht({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!me,handler:()=>me&&n(`${s}/projects/${e}/assignments/${me}`)});const ke=f.useMemo(()=>O?TF(O.body):{acceptanceCriteria:[],summaryBody:""},[O]),he=f.useMemo(()=>RF(ke.summaryBody),[ke.summaryBody]),Je=ke.acceptanceCriteria,Ye=Je.filter(ue=>ue.checked).length,ot=Je.length>0&&Ye===Je.length,J=f.useRef(ot),Ie=f.useRef(!1);if(f.useEffect(()=>{if(O){if(!Ie.current){J.current=ot,Ie.current=!0;return}ot&&!J.current&&L(ue=>ue+1),J.current=ot}},[ot,O]),W)return r.jsx(mt,{label:"Loading assignment workspace…"});if(se||!O||!e||!t)return r.jsx(wt,{error:se||"Assignment not found."});const Ne=e,Oe=t,Xe=Je.length>0?{checked:Ye,total:Je.length}:void 0,Me=O.availableTransitions??[],nt=Me.filter(ue=>!ue.disabled&&ue.targetStatus!==O.status),Ke=LF.map(ue=>nt.find(Be=>Be.command===ue)).find(Boolean)??nt[0]??null,gt=[];if(ee!=null&&ee.sessions)for(const ue of ee.sessions)for(const Be of ue.windows)for(const Fe of Be.panes)((lt=Fe.assignment)==null?void 0:lt.project)===e&&((te=Fe.assignment)==null?void 0:te.slug)===t&&gt.push({sessionName:ue.name,command:Fe.command,urls:Fe.urls});async function Rt(ue){u(null);try{await kN(Ne,Oe,ue),z()}catch(Be){u(Be.message)}}async function at(ue){u(null);try{const Be=await fetch(`/api/projects/${Ne}/assignments/${Oe}/${ue?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Be.ok){const Fe=await Be.json().catch(()=>null);throw new Error((Fe==null?void 0:Fe.error)||`HTTP ${Be.status}`)}z(),m(ue?"Assignment archived":"Assignment restored","success")}catch(Be){u(Be.message)}}async function ie(){R(!0);try{await uF(Ne,Oe),n(`${s}/projects/${Ne}`)}catch(ue){u(ue.message),R(!1),T(!1)}}async function Y(ue,Be){u(null),y(ue.command);try{return await jN(Ne,Oe,ue,Be),z(),!0}catch(Fe){return u(Fe.message),!1}finally{y(null)}}function pe(ue){if(SN(ue)){E(ue);return}Y(ue)}async function Q(ue,Be){w(null),C(ue);try{const Fe=await fetch(`/api/projects/${Ne}/assignments/${Oe}/acceptance-criteria/${ue}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:Be})}),Nt=await Fe.json();if(!Fe.ok)throw new Error(Nt.error||`HTTP ${Fe.status}`);z()}catch(Fe){w(Fe.message)}finally{C(null)}}const ye=[...nt.filter(ue=>ue!==Ke).map(ue=>({key:`transition-${ue.command}`,label:ue.label,onSelect:()=>pe(ue),disabled:g===ue.command})),...Me.filter(ue=>ue.disabled||ue.targetStatus===O.status).map(ue=>({key:`transition-${ue.command}`,label:ue.label,disabled:!0,disabledReason:ue.targetStatus===O.status?`Already ${O.status.replace(/_/g," ")}`:ue.disabledReason??ue.warning??ue.description})),...B.statuses.map(ue=>({key:`override-${ue.id}`,label:`Override → ${ue.label}`,onSelect:()=>Rt(ue.id),disabled:ue.id===O.status,disabledReason:ue.id===O.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:uR,href:`${s}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:NR,href:`${s}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:um,href:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:nd,href:`${s}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:pR,href:`${s}/projects/${e}/assignments/${t}/decision-record/edit`},{key:O.archived?"unarchive":"archive",label:O.archived?"Restore assignment":"Archive assignment",icon:O.archived?ed:Dd,onSelect:()=>at(!O.archived)},{key:"delete",label:"Delete assignment",icon:or,destructive:!0,onSelect:()=>T(!0)}],Pe=(Ke==null?void 0:Ke.command)==="review";return r.jsxs("div",{className:"space-y-5",children:[r.jsx(na,{toast:p,onDismiss:h}),r.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:O.status,progress:Xe}),r.jsx(ea,{type:O.type}),r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:O.title}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",N0(O.updated)]}),de.length>0&&r.jsxs("span",{className:"text-xs text-warning-foreground",children:["⚠ ",de.length," unmet dep",de.length===1?"":"s"]}),r.jsx(Jg,{externalIds:O.externalIds}),r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[r.jsx(ON,{target:{kind:"assignment",id:O.id},worktreePath:((be=O.workspace)==null?void 0:be.worktreePath)??null,repository:((Le=O.workspace)==null?void 0:Le.repository)??null}),!((it=O.workspace)!=null&&it.worktreePath)&&e&&t&&r.jsx(IN,{projectSlug:e,assignmentSlug:t,defaultBranch:`syntaur/${e}/${t}`,onCreated:()=>z()}),Ke&&r.jsx("button",{type:"button",title:Ke.warning||Ke.description,disabled:g===Ke.command,onClick:()=>pe(Ke),className:Se("shell-action disabled:cursor-not-allowed disabled:opacity-50",Ke.warning&&"border-warning-foreground/40",Pe&&$>0&&"send-to-review-glow"),children:r.jsx("span",{children:g===Ke.command?"Working…":Ke.label})},Pe?`review-${$}`:Ke.command),r.jsx(Wg,{items:ye,align:"end"})]})]}),c?r.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:c}):null,O.blockedReason?r.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[r.jsx("strong",{children:"Blocked reason:"})," ",O.blockedReason]}):null]}),I.length>0&&r.jsx(PF,{projectSlug:e,dependencies:I,blockedReason:O.blockedReason}),O.enrichedLinks&&O.enrichedLinks.length>0&&r.jsx(AF,{links:O.enrichedLinks}),O.referencedBy&&O.referencedBy.length>0&&r.jsx(We,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:r.jsx("ul",{className:"space-y-2",children:O.referencedBy.map(ue=>{const Be=ue.sourceProjectSlug===null?`/assignments/${ue.sourceId}`:`${s}/projects/${ue.sourceProjectSlug}/assignments/${ue.sourceSlug}`;return r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:Be,className:"text-foreground hover:text-primary",children:ue.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",ue.mentions," mention",ue.mentions===1?"":"s",")"]}),ue.sourceProjectSlug===null?r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"}):null]},ue.sourceId)})})}),r.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(Qg,{value:K,onValueChange:ue=>l({tab:ue}),items:[{value:"summary",label:"Summary",content:r.jsxs("div",{className:"space-y-5",children:[ke.acceptanceCriteria.length>0?r.jsx(We,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:r.jsxs("div",{className:"space-y-3",children:[j?r.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:j}):null,ke.acceptanceCriteria.map((ue,Be)=>{const Fe=k!==null;return r.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[r.jsx("input",{type:"checkbox",checked:ue.checked,disabled:Fe,onChange:Nt=>Q(Be,Nt.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),r.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":ue.checked,children:ue.text})]},`${Be}-${ue.text}`)})]})}):null,he.hasSection?r.jsx(We,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:r.jsx(fn,{content:he.todosMarkdown,emptyState:"No todos yet."})}):null,r.jsx(We,{title:"Assignment Summary",children:r.jsx(fn,{content:he.remaining,emptyState:ke.acceptanceCriteria.length>0||he.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:O.plan?1:0,content:O.plan?r.jsx("div",{className:"space-y-5",children:r.jsxs(We,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/plan/edit`,children:[r.jsx(um,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Plan"})]}),children:[r.jsx("div",{className:"mb-4",children:r.jsx(pn,{status:O.plan.status})}),r.jsx(fn,{content:O.plan.body,emptyState:"No plan content yet."})]})}):r.jsx(St,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:O.scratchpad?1:0,content:O.scratchpad?r.jsx(We,{title:"Scratchpad",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[r.jsx(um,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Scratchpad"})]}),children:r.jsx(fn,{content:O.scratchpad.body,emptyState:"Scratchpad is empty."})}):r.jsx(St,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((_e=O.handoff)==null?void 0:_e.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.handoff?r.jsx(We,{children:r.jsx(fn,{content:O.handoff.body,emptyState:"No handoff history yet."})}):r.jsx(St,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((bt=O.progress)==null?void 0:bt.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.progress&&O.progress.entries.length>0?r.jsx(We,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:r.jsx("ol",{className:"space-y-4",children:O.progress.entries.map((ue,Be)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:ue.timestamp}),r.jsx(fn,{content:ue.body})]},`${ue.timestamp}-${Be}`))})}):r.jsx(St,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((_t=O.comments)==null?void 0:_t.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.comments&&O.comments.entries.length>0?r.jsx(MN,{projectSlug:e,assignmentSlug:t,entries:O.comments.entries}):r.jsx(St,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((Gt=O.decisionRecord)==null?void 0:Gt.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.decisionRecord?r.jsx(We,{children:r.jsx(fn,{content:O.decisionRecord.body,emptyState:"No decision history yet."})}):r.jsx(St,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),r.jsxs("div",{className:"min-w-0 space-y-5",children:[r.jsx(We,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(to,{label:"ID",value:O.id,copyable:!0}),r.jsx(to,{label:"Priority",value:O.priority}),O.assignee&&r.jsx(to,{label:"Assignee",value:O.assignee}),r.jsx(to,{label:"Updated",value:`${S0(O.updated)} · Created ${k0(O.created)}`}),O.workspace.repository&&r.jsx(to,{label:"Repository",value:O.workspace.repository,copyable:!0}),O.workspace.worktreePath&&r.jsx(to,{label:"Worktree",value:O.workspace.worktreePath,copyable:!0}),O.workspace.branch&&r.jsx(to,{label:"Branch",value:O.workspace.branch,copyable:!0}),O.workspace.parentBranch&&r.jsx(to,{label:"Parent branch",value:O.workspace.parentBranch,copyable:!0}),O.externalIds.map((ue,Be)=>r.jsx(OF,{entry:ue},`${ue.system}:${ue.id}:${Be}`))]})}),gt.length>0&&r.jsx(We,{title:"Servers",children:r.jsx("div",{className:"space-y-2",children:gt.map((ue,Be)=>r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-sm",children:[r.jsx("span",{className:"min-w-0 max-w-full truncate rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",title:ue.command,children:ue.command}),r.jsx("span",{className:"min-w-0 max-w-full truncate text-xs text-muted-foreground",title:ue.sessionName,children:ue.sessionName}),ue.urls.map(Fe=>r.jsxs("a",{href:Fe,target:"_blank",rel:"noopener noreferrer",title:Fe,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[r.jsx("span",{className:"min-w-0 truncate",children:Fe.replace("http://localhost:",":")}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]},Fe))]},Be))})}),r.jsx(EN,{sessions:ne==null?void 0:ne.sessions,loading:M,error:G,onError:ue=>m(ue.message,"error"),onNotice:ue=>m(ue,"success")}),r.jsx(TN,{summary:A==null?void 0:A.summary,loading:F,error:Z})]})]}),r.jsx(RN,{open:b!==null,action:b,assignmentTitle:O.title,loading:g===(b==null?void 0:b.command),onOpenChange:ue=>{ue||E(null)},onConfirm:async ue=>{if(!b)return;await Y(b,ue)&&E(null)}}),r.jsx(sa,{open:N,title:"Delete assignment?",description:`This will permanently delete "${O.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:D,onOpenChange:ue=>{ue||T(!1)},onConfirm:ie})]})}function to({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"block min-w-0 truncate",title:t,children:t}),n&&t!=="—"&&r.jsx($r,{value:t})]})]})}function OF({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function IF(){var R,$,L,K,B,O,W,se;const{id:e}=$t(),[t,n]=hs(),s=t.get("tab")??"summary",{data:a,loading:l,error:c,refetch:u}=kP(e),{data:p,loading:m,error:h}=NP(e),{data:g,loading:y,error:b}=EP(a==null?void 0:a.slug),[E,j]=f.useState(!1),[w,k]=f.useState(null),{toast:C,showToast:N,dismissToast:T}=ta();async function D(z){if(e){k(null);try{const H=await fetch(`/api/assignments/${e}/${z?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!H.ok){const ee=await H.json().catch(()=>null);throw new Error((ee==null?void 0:ee.error)||`HTTP ${H.status}`)}u(),N(z?"Assignment archived":"Assignment restored","success")}catch(H){k(H instanceof Error?H.message:"Archive failed")}}}return l?r.jsx(mt,{}):c?r.jsx(wt,{error:c}):a?r.jsxs("div",{className:"space-y-6",children:[r.jsx(na,{toast:C,onDismiss:T}),r.jsxs("header",{className:"space-y-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:a.status}),r.jsx(ea,{type:a.type}),r.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:a.id}),r.jsx(Jg,{externalIds:a.externalIds}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(ON,{target:{kind:"assignment",id:a.id},worktreePath:((R=a.workspace)==null?void 0:R.worktreePath)??null,repository:(($=a.workspace)==null?void 0:$.repository)??null,size:"compact"}),!((L=a.workspace)!=null&&L.worktreePath)&&r.jsx(IN,{assignmentId:a.id,defaultBranch:`syntaur/${a.slug}`,onCreated:()=>u()}),r.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:[r.jsx($d,{className:"h-3 w-3"}),"Move to workspace…"]}),r.jsx(Ee,{to:`/assignments/${a.id}/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit"}),r.jsxs("button",{type:"button",onClick:()=>D(!a.archived),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:a.archived?"Restore this assignment":"Archive this assignment",children:[a.archived?r.jsx(ed,{className:"h-3 w-3"}):r.jsx(Dd,{className:"h-3 w-3"}),a.archived?"Restore":"Archive"]})]})]}),r.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:a.title}),a.blockedReason?r.jsxs("p",{className:"text-sm text-warning-foreground",children:["Blocked: ",a.blockedReason]}):null,w?r.jsx("p",{className:"text-sm text-status-failed-foreground",children:w}):null]}),r.jsx(We,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(no,{label:"ID",value:a.id,copyable:!0}),r.jsx(no,{label:"Priority",value:a.priority}),a.assignee&&r.jsx(no,{label:"Assignee",value:a.assignee}),r.jsx(no,{label:"Updated",value:`${S0(a.updated)} · Created ${k0(a.created)}`}),a.workspace.repository&&r.jsx(no,{label:"Repository",value:a.workspace.repository,copyable:!0}),a.workspace.worktreePath&&r.jsx(no,{label:"Worktree",value:a.workspace.worktreePath,copyable:!0}),a.workspace.branch&&r.jsx(no,{label:"Branch",value:a.workspace.branch,copyable:!0}),a.workspace.parentBranch&&r.jsx(no,{label:"Parent branch",value:a.workspace.parentBranch,copyable:!0}),a.externalIds.map((z,H)=>r.jsx(MF,{entry:z},`${z.system}:${z.id}:${H}`))]})}),a.referencedBy&&a.referencedBy.length>0?r.jsx(We,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:r.jsx("ul",{className:"space-y-2",children:a.referencedBy.map(z=>r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:z.sourceProjectSlug===null?`/assignments/${z.sourceId}`:`/projects/${z.sourceProjectSlug}/assignments/${z.sourceSlug}`,className:"text-foreground hover:text-primary",children:z.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",z.mentions," mention",z.mentions===1?"":"s",")"]})]},z.sourceId))})}):null,r.jsx(EN,{sessions:p==null?void 0:p.sessions,loading:m,error:h,onError:z=>N(z.message,"error"),onNotice:z=>N(z,"success")}),r.jsx(TN,{summary:g==null?void 0:g.summary,loading:y,error:b}),r.jsx(Qg,{value:s,onValueChange:z=>n({tab:z}),items:[{value:"summary",label:"Summary",content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Assignment",children:r.jsx(fn,{content:a.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((K=a.progress)==null?void 0:K.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:a.progress&&a.progress.entries.length>0?r.jsx(We,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:r.jsx("ol",{className:"space-y-4",children:a.progress.entries.map((z,H)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:z.timestamp}),r.jsx(fn,{content:z.body})]},`${z.timestamp}-${H}`))})}):r.jsx(St,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((B=a.comments)==null?void 0:B.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:r.jsx(MN,{projectSlug:null,assignmentSlug:a.id,entries:((O=a.comments)==null?void 0:O.entries)??[]})})},{value:"plan",label:"Plan",content:r.jsx("div",{className:"space-y-5",children:a.plan?r.jsxs(We,{children:[r.jsx(fn,{content:a.plan.body,emptyState:"Plan file exists but is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/plan/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit plan"})})]}):r.jsx(St,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:r.jsx("div",{className:"space-y-5",children:a.scratchpad?r.jsxs(We,{children:[r.jsx(fn,{content:a.scratchpad.body,emptyState:"Scratchpad is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/scratchpad/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit scratchpad"})})]}):r.jsx(St,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((W=a.handoff)==null?void 0:W.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:a.handoff?r.jsxs(We,{children:[r.jsx(fn,{content:a.handoff.body,emptyState:"No handoff history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/handoff/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append handoff"})})]}):r.jsx(St,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((se=a.decisionRecord)==null?void 0:se.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:a.decisionRecord?r.jsxs(We,{children:[r.jsx(fn,{content:a.decisionRecord.body,emptyState:"No decision history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/decision-record/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append decision"})})]}):r.jsx(St,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]}),r.jsx(Yg,{open:E,onOpenChange:j,currentWorkspace:a.projectWorkspace,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async z=>{const H=await fetch(`/api/assignments/${encodeURIComponent(a.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:z})});if(!H.ok){const ee=await H.json().catch(()=>({}));throw new Error(ee.error||"Failed to move assignment")}u()}})]}):r.jsx(wt,{error:"Assignment not found"})}function no({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&r.jsx($r,{value:t})]})]})}function MF({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function _F({currentStatus:e,availableTransitions:t,onSelect:n,disabled:s=!1}){const[a,l]=f.useState(!1),[c,u]=f.useState(null),[p,m]=f.useState(0),h=f.useRef(null),g=f.useRef(null),y=f.useId(),b=hd(e),E=b.icon,j=f.useCallback(T=>{l(!1),T&&requestAnimationFrame(()=>{var D;(D=h.current)==null||D.focus()})},[]),w=f.useCallback(()=>{var D;const T=(D=h.current)==null?void 0:D.getBoundingClientRect();T&&u({top:T.top,left:T.left,width:T.width,bottom:T.bottom})},[]);f.useLayoutEffect(()=>{a&&w()},[a,w]),f.useEffect(()=>{if(!a)return;const T=()=>w();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[a,w]),f.useEffect(()=>{if(!a)return;const T=D=>{var $,L;const R=D.target;R&&(($=g.current)!=null&&$.contains(R)||(L=h.current)!=null&&L.contains(R)||j(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[a,j]),f.useEffect(()=>{a&&m(0)},[a,t.length]);function k(T){(T.key==="Enter"||T.key===" "||T.key==="ArrowDown")&&(T.preventDefault(),l(!0))}function C(T){if(t.length===0){T.key==="Escape"&&(T.preventDefault(),j(!0));return}if(T.key==="ArrowDown")T.preventDefault(),m(D=>(D+1)%t.length);else if(T.key==="ArrowUp")T.preventDefault(),m(D=>(D-1+t.length)%t.length);else if(T.key==="Home")T.preventDefault(),m(0);else if(T.key==="End")T.preventDefault(),m(t.length-1);else if(T.key==="Enter"){T.preventDefault();const D=t[p];D&&(n(D),j(!0))}else T.key==="Escape"&&(T.preventDefault(),j(!0))}function N(T){n(T),j(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:h,type:"button","data-no-drag":!0,disabled:s,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?y:void 0,onClick:()=>{s||l(T=>!T)},onKeyDown:k,title:`Status: ${b.label}. Click to change.`,className:Se(H1(e),"cursor-pointer transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",s&&"cursor-not-allowed opacity-60"),children:[r.jsx(E,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:b.label})]}),a&&c&&typeof document<"u"?Rs.createPortal(r.jsx("div",{ref:g,id:y,role:"menu",tabIndex:-1,autoFocus:!0,onKeyDown:C,style:{position:"fixed",top:c.bottom+6,left:c.left,minWidth:Math.max(c.width,180),zIndex:60},className:"rounded-md border border-border/70 bg-popover py-1 text-sm text-popover-foreground shadow-lg",children:t.length===0?r.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No transitions available from this status."}):t.map((T,D)=>{const R=hd(T.targetStatus),$=R.icon,L=D===p;return r.jsxs("button",{type:"button",role:"menuitem","data-no-drag":!0,onMouseEnter:()=>m(D),onClick:()=>N(T),title:T.warning||T.description,className:Se("flex w-full flex-col items-stretch gap-0.5 px-3 py-1.5 text-left text-sm transition",L?"bg-foreground/5":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:"flex items-center justify-between gap-2",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx($,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate",children:T.label})]}),r.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:R.label})]}),T.warning?r.jsx("span",{className:"text-[11px] leading-snug text-warning-foreground",children:T.warning}):null]},`${T.command}:${T.targetStatus}`)})}),document.body):null]})}function FN({title:e,detailHref:t,onSave:n,disabled:s=!1}){const[a,l]=f.useState(!1);return a?r.jsx(FF,{initialTitle:e,disabled:s,onSave:n,onExit:()=>l(!1)}):r.jsxs("div",{className:"group flex items-baseline gap-1.5",children:[r.jsx("button",{type:"button","data-no-drag":!0,disabled:s,onClick:()=>{s||l(!0)},className:Se("text-left text-base font-semibold text-foreground transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",s&&"cursor-not-allowed opacity-60"),title:"Click to rename",children:e}),r.jsx(Ee,{to:t,"data-no-drag":!0,"aria-label":"Open detail page",title:"Open detail page",onClick:c=>c.stopPropagation(),className:"text-muted-foreground opacity-0 transition group-hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",children:r.jsx(yi,{className:"h-3.5 w-3.5"})})]})}function FF({initialTitle:e,disabled:t,onSave:n,onExit:s}){const a=f.useRef(e),[l,c]=f.useState(e),[u,p]=f.useState(!1),[m,h]=f.useState(!1),g=f.useRef(null),y=f.useRef(!1);f.useEffect(()=>{const w=g.current;w&&(w.focus(),w.select())},[]);const b=f.useCallback(()=>{var w;h(!0),window.setTimeout(()=>h(!1),260),(w=g.current)==null||w.focus()},[]),E=f.useCallback(async()=>{if(y.current)return;const w=l.trim();if(w.length===0){b();return}if(w===a.current){s();return}y.current=!0,p(!0);try{await n(w)}catch{}finally{p(!1),s()}},[l,s,n,b]);function j(w){w.key==="Enter"?(w.preventDefault(),E()):w.key==="Escape"&&(w.preventDefault(),y.current=!0,s())}return r.jsx("input",{ref:g,type:"text","data-no-drag":!0,disabled:t||u,value:l,onChange:w=>c(w.target.value),onKeyDown:j,onBlur:()=>void E(),className:Se("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-base font-semibold text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",m&&"syntaur-input-shake",u&&"opacity-70")})}function zN(e){const t=Dt(),n=f.useRef(null),s=f.useRef(!1),a=f.useCallback(()=>{const c=n.current,u=!!(c!=null&&c.querySelector('[aria-expanded="true"]')),p=!!document.querySelector('[role="menu"]'),m=document.activeElement,h=!!(m&&(c!=null&&c.contains(m))&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"));s.current=u||p||h},[]),l=f.useCallback(c=>{if(s.current)return;const u=c.target;!u||u.closest(mi)||t(e)},[t,e]);return{containerRef:n,onMouseDown:a,onClick:l}}const lj=Ag;function cj(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function zF(e,t){return e.toString()===t.toString()}function uj(){const{workspace:e}=$t(),t=ln(),n=Dt(),s=f.useRef(null);mo("list:assignments");const{data:a,loading:l,error:c,refetch:u}=Md(),p=Zo(),m=ef(),[h,g]=hs(),y=e?`w:${e}`:null,b=cN(y),E=f.useRef(void 0),j=f.useMemo(()=>G1(p.order),[p]),w=f.useMemo(()=>{const _={};for(const le of j)_[le]=cc(p,le);return _},[j,p]),k=f.useMemo(()=>j.map(_=>({id:_,title:w[_]??_,description:Zd(_)})),[j,w]),C=f.useMemo(()=>m.definitions.map(_=>({id:_.id,title:ii(m,_.id),description:_.description})),[m]),N="__unknown_type__",T=f.useMemo(()=>new Set(["all",...j]),[j]),D=h.get("view"),R=h.get("status"),$=h.get("stale"),L=D&&lj.includes(D)?D:"kanban";function K(_){if(!_)return[];const le=[];for(const xe of _.split(",")){const $e=xe.trim();!$e||$e==="all"||!T.has($e)||le.includes($e)||le.push($e)}return le}const B=f.useCallback(_=>{g(le=>{const xe=new URLSearchParams(le);return _==="kanban"?xe.delete("view"):xe.set("view",_),xe})},[g]),[O,W]=f.useState(""),[se,z]=f.useState(()=>K(R)),[H,ee]=f.useState(()=>tt(b.filters.priority)),[ne,M]=f.useState(()=>tt(b.filters.type)),[G,A]=f.useState(()=>tt(b.filters.assignee)),[F,Z]=f.useState(()=>tt(b.filters.project)),[I,de]=f.useState(()=>tt(b.filters.tags)),[ge,V]=f.useState(null),[ae,me]=f.useState(()=>cj($)),[ve,ke]=f.useState(()=>b.sortField),[he,Je]=f.useState(()=>b.sortDirection),[Ye,ot]=f.useState(()=>({hidden:[]})),[J,Ie]=f.useState(()=>({hidden:[]})),[Ne,Oe]=f.useState(()=>b.grouping),Xe=Ne==="type"?"type":"status",[Me,nt]=f.useState(()=>new Set),[Ke,gt]=f.useState([]),{toast:Rt,showToast:at,dismissToast:ie}=ta(),[Y,pe]=f.useState(null),[Q,ye]=f.useState(null),[Pe,lt]=f.useState(null),[te,be]=f.useState(null),[Le,it]=f.useState(null),[_e,bt]=f.useState(null),[_t,Gt]=f.useState(null),[ue,Be]=f.useState(null),[Fe,Nt]=f.useState(null),[$n,Yt]=f.useState(!1),[sn,Wt]=f.useState(!1),Gn=e?{kind:"workspace",workspace:e}:{kind:"global"},xt=h.get("loadView"),{view:jn,loading:Pt,error:re}=Go(xt),{view:Ae,loading:Qe,error:Ft}=Go(Fe),hn=f.useRef(null);f.useEffect(()=>{gt((a==null?void 0:a.assignments)??[])},[a]),f.useEffect(()=>{Fe&&!Qe&&!Ft&&!Ae&&Nt(null)},[Ae,Ft,Fe,Qe]),f.useEffect(()=>{Nt(null),hn.current=null,V(null),W("")},[e]),f.useEffect(()=>{const _=K(R);MD(_,se)||z(_);const le=cj($);le!==ae&&me(le)},[ae,$,se,R]),f.useEffect(()=>{E.current===y&&g(_=>{const le=new URLSearchParams(_);return se.length===0?le.delete("status"):le.set("status",se.join(",")),ae==="all"?le.delete("stale"):ae==="stale"?le.set("stale","1"):le.set("stale","0"),zF(_,le)?_:le})},[ae,y,g,se]),f.useEffect(()=>{ee(tt(b.filters.priority)),M(tt(b.filters.type)),A(tt(b.filters.assignee)),Z(tt(b.filters.project)),de(tt(b.filters.tags)),ke(b.sortField),Je(b.sortDirection),Oe(b.grouping)},[b.filters.priority,b.filters.type,b.filters.assignee,b.filters.project,b.filters.tags,b.sortField,b.sortDirection,b.grouping]),f.useEffect(()=>{if(E.current===y)return;let _=!1;return wx().then(le=>{if(_||E.current===y)return;const xe=r1(le,y),$e=xe.defaultView,ct=tt(xe.filters.status),pt=xe.filters.activity??"all",yt=new URLSearchParams(window.location.search);let cn=!1;const on=new URLSearchParams(yt);yt.get("view")===null&&$e!=="kanban"&&lj.includes($e)&&(on.set("view",$e),cn=!0),yt.get("status")===null&&ct.length>0&&(on.set("status",ct.join(",")),z(ct),cn=!0),yt.get("stale")===null&&pt!=="all"&&(on.set("stale",pt==="stale"?"1":"0"),me(pt),cn=!0),cn&&g(on,{replace:!0}),queueMicrotask(()=>{E.current=y})}),()=>{_=!0}},[y]);const Ct=f.useCallback(_=>{(y===null?dN(_):fN(y,_)).catch(xe=>{console.warn("Failed to persist view prefs:",xe)})},[y]),jf=f.useCallback(_=>{B(_),Ct({defaultView:_})},[B,Ct]),Ai=f.useCallback(_=>{z(_),Ct({filters:{status:_}})},[Ct]),_r=f.useCallback(_=>{ee(_),Ct({filters:{priority:_}})},[Ct]),oa=f.useCallback(_=>{M(_),Ct({filters:{type:_}})},[Ct]),aa=f.useCallback(_=>{A(_),Ct({filters:{assignee:_}})},[Ct]),Di=f.useCallback(_=>{Z(_),Ct({filters:{project:_}})},[Ct]),ia=f.useCallback(_=>{de(_),Ct({filters:{tags:_}})},[Ct]),la=f.useCallback(_=>{me(_),Ct({filters:{activity:_}})},[Ct]),ca=f.useCallback(_=>{ke(_),Ct({sortField:_})},[Ct]),go=f.useCallback(_=>{Je(_),Ct({sortDirection:_})},[Ct]),kf=f.useCallback(_=>{Oe(_),Ct({grouping:_})},[Ct]),ua=f.useCallback(()=>({viewMode:L,filters:{status:se,priority:H,type:ne,assignee:G,project:F,tags:I,activity:ae,dateRange:Xl(ge),search:O},sortField:ve,sortDirection:he,listSectionVisibility:{collapsed:[...Me]},kanbanColumnVisibility:Ye,tableColumnVisibility:J}),[L,se,H,ne,G,F,I,ae,ge,O,ve,he,Me,Ye,J]),Lt=f.useCallback(_=>{xN(_,{setViewMode:B,setStatusFilter:Ai,setPriorityFilter:_r,setTypeFilter:oa,setAssigneeFilter:aa,setProjectFilter:Di,setTagsFilter:ia,setActivityFilter:la,setDateRange:V,setSearch:W,setSortField:ca,setSortDirection:go,setListSectionVisibility:le=>nt(new Set(le.collapsed)),setKanbanColumnVisibility:ot,setTableColumnVisibility:Ie}),Nt(_.id)},[B,Ai,_r,oa,aa,Di,ia,la,ca,go]),Sf=f.useCallback(_=>{Lt(_),hn.current=_.id,g(le=>{const xe=new URLSearchParams(le);return xe.set("loadView",_.id),xe},{replace:!0})},[Lt,g]),$i=f.useCallback(async _=>{try{const le=Jl({name:_,context:{workspace:e??null,projectSlug:null},state:ua()}),xe=await Wd(le),$e=xe.views[xe.views.length-1];Nt(($e==null?void 0:$e.id)??null),$e&&(hn.current=$e.id,g(ct=>{const pt=new URLSearchParams(ct);return pt.set("loadView",$e.id),pt},{replace:!0})),Yt(!1),Wt(!1),at(`Saved view "${_}"`,"success")}catch(le){throw at(le instanceof Error?le.message:"Failed to save view","error"),le}},[ua,g,at,e]),xc=f.useCallback(async()=>{if(!(!Fe||!Ae))try{const _=Jl({name:Ae.name,context:{workspace:e??null,projectSlug:null},state:ua()}),le=kx(Ae.config,_.config,_.config);await Lg(Fe,{config:le}),at("View updated","success")}catch(_){at(_ instanceof Error?_.message:"Failed to update view","error")}},[ua,Ae,Fe,at,e]);f.useEffect(()=>{if(!xt){hn.current=null;return}if(hn.current!==xt&&(Fe&&Fe!==xt&&Nt(null),!Pt)){if(re){at("Couldn't load saved view — try again","error");return}if(jn){hn.current=xt,Lt(jn),g(_=>{const le=new URLSearchParams(_);return le.delete("loadView"),le},{replace:!0});return}hn.current=xt,at("Saved view no longer exists","error"),g(_=>{const le=new URLSearchParams(_);return le.delete("loadView"),le},{replace:!0})}},[xt,jn,Pt,re,Fe,Lt,g,at]);const Bn=f.useMemo(()=>Ke.filter(_=>e?e==="_ungrouped"?_.projectWorkspace===null:_.projectWorkspace===e:!0),[Ke,e]),Nf=f.useMemo(()=>Array.from(new Set(Bn.map(_=>_.status))).sort(),[Bn]),yc=f.useMemo(()=>Array.from(new Set(Bn.map(_=>_.priority))).sort(),[Bn]),da=f.useMemo(()=>Array.from(new Set(Bn.map(_=>_.assignee??"__unassigned__"))).sort(),[Bn]),vr=f.useMemo(()=>Array.from(new Map(Bn.filter(_=>_.projectSlug!==null).map(_=>[_.projectSlug,_.projectTitle]))).sort(([,_],[,le])=>_.localeCompare(le)),[Bn]),Cf=f.useMemo(()=>Array.from(new Set(Bn.flatMap(_=>_.tags??[]))).sort(),[Bn]),jt=f.useMemo(()=>Ke.filter(_=>Kg(_,{status:se,priority:H,type:ne,assignee:G,project:F,tags:I,activity:ae,dateRange:Xl(ge)},{workspace:e,search:O})),[ae,Ke,O,se,H,ne,G,F,I,ge,e]),xo=f.useMemo(()=>uc(jt,ve,he),[jt,ve,he]),Li=f.useMemo(()=>{if(Ne==="none")return[{id:"__all__",label:"All assignments",items:jt}];if(Ne==="type"){const _=m.definitions.map($e=>({id:$e.id,label:ii(m,$e.id),items:jt.filter(ct=>ct.type===$e.id)})),le=new Set(m.definitions.map($e=>$e.id)),xe=jt.filter($e=>!$e.type||!le.has($e.type));return xe.length>0&&_.push({id:N,label:"Other",items:xe}),_}if(Ne==="priority")return["critical","high","medium","low"].map(le=>({id:le,label:le.charAt(0).toUpperCase()+le.slice(1),items:jt.filter(xe=>xe.priority===le)}));if(Ne==="assignee")return Array.from(new Set(jt.map(le=>le.assignee??"__unassigned__"))).sort().map(le=>({id:le,label:le==="__unassigned__"?"Unassigned":le,items:jt.filter(xe=>(xe.assignee??"__unassigned__")===le)}));if(Ne==="project"){const _=new Map;for(const le of jt){const xe=le.projectSlug??"__standalone__",$e=le.projectTitle??"Standalone";_.has(xe)||_.set(xe,$e)}return Array.from(_.entries()).sort(([,le],[,xe])=>le.localeCompare(xe)).map(([le,xe])=>({id:le,label:xe,items:jt.filter($e=>($e.projectSlug??"__standalone__")===le)}))}return j.map(_=>({id:_,label:w[_]??_,items:jt.filter(le=>le.status===_)}))},[Ne,jt,m,j,w]),Ef=f.useMemo(()=>{const _=new Set(m.definitions.map(xe=>xe.id));return jt.some(xe=>!xe.type||!_.has(xe.type))?[...C,{id:N,title:"Other",description:"Assignments with no recognized type."}]:C},[C,m,jt]),{visibleItems:fa,visibleIndexByKey:yo}=f.useMemo(()=>{let _;if(L==="table")_=xo;else if(L==="kanban"){const xe=new Set(m.definitions.map($e=>$e.id));Xe==="type"?_=[...m.definitions.flatMap($e=>jt.filter(ct=>ct.type===$e.id)),...jt.filter($e=>!$e.type||!xe.has($e.type))]:_=j.flatMap($e=>jt.filter(ct=>ct.status===$e))}else _=Li.flatMap(xe=>xe.items);const le=new Map;return _.forEach((xe,$e)=>le.set(tn(xe),$e)),{visibleItems:_,visibleIndexByKey:le}},[L,xo,Li,Xe,m,jt,j]),{hotkeyRowProps:ys}=ac(fa,{scope:"list:assignments",onOpen:_=>{if(_.projectSlug===null){n(`/assignments/${_.id}`);return}const le=_.projectWorkspace?`/w/${_.projectWorkspace}`:t;n(`${le}/projects/${_.projectSlug}/assignments/${_.slug}`)}});if(Ht({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var _;return(_=s.current)==null?void 0:_.focus()}}),Ht({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>u()}),l)return r.jsx(mt,{label:"Loading assignments board…"});if(c||!a)return r.jsx(wt,{error:c||"Assignments board is unavailable."});async function bo({item:_,toColumnId:le,action:xe,reason:$e}){pe(tn(_));const ct=Ke;gt(pt=>pt.map(yt=>tn(yt)===tn(_)?{...yt,status:le,blockedReason:le==="blocked"?$e??yt.blockedReason:null}:yt));try{if(_.projectSlug===null){if(!xe)throw new Error("Standalone assignments require a transition action, not status override.");const yt=await fetch(`/api/assignments/${encodeURIComponent(_.id)}/transitions/${encodeURIComponent(xe.command)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($e?{reason:$e}:{})});if(!yt.ok)throw new Error((await yt.json()).error??`HTTP ${yt.status}`);const on=(await yt.json()).assignment;gt(kn=>kn.map(Un=>tn(Un)===tn(_)?{...Un,status:on.status,blockedReason:on.blockedReason,availableTransitions:on.availableTransitions,updated:on.updated}:Un));return}const pt=xe?await jN(_.projectSlug,_.slug,xe,$e):await kN(_.projectSlug,_.slug,le);return gt(yt=>yt.map(cn=>tn(cn)===tn(_)?{...cn,status:pt.status,blockedReason:pt.blockedReason,availableTransitions:pt.availableTransitions,updated:pt.updated}:cn)),u(),!0}catch(pt){return gt(ct),at(pt.message,"error"),!1}finally{pe(null)}}async function vo({item:_,toColumnId:le,action:xe}){if(_.status===le)return;const $e=xe??kl(_,le);if($e!=null&&$e.disabled){at($e.disabledReason||`Cannot move this assignment to ${le}.`,"error");return}if($e&&SN($e)){be({item:_,toColumnId:le,action:$e});return}await bo({item:_,toColumnId:le,action:$e})}async function Oi(_,le){if(le===_.title)return;const xe=tn(_),$e=Ke;gt(ct=>ct.map(pt=>tn(pt)===xe?{...pt,title:le}:pt)),pe(xe);try{const ct=_.projectSlug===null?await fF({id:_.id,title:le}):await dF({projectSlug:_.projectSlug,assignmentSlug:_.slug,title:le});gt(pt=>pt.map(yt=>tn(yt)===xe?{...yt,title:ct.title,updated:ct.updated}:yt)),u()}catch(ct){throw gt($e),at(ct.message,"error"),ct}finally{pe(null)}}function Ii(_){nt(le=>{const xe=new Set(le);return xe.has(_)?xe.delete(_):xe.add(_),xe})}function bc(_){ve===_?go(he==="asc"?"desc":"asc"):(ca(_),go("asc"))}const Ln=Q?Ke.find(_=>tn(_)===Q)??null:null;function wo(_,le){_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",le),ye(le)}function Mi(){ye(null),lt(null)}function _i(_,le){if(!Ln)return;const xe=kl(Ln,le);Ln.status===le||xe!=null&&xe.disabled||(_.preventDefault(),_.dataTransfer.dropEffect="move",lt(le))}function Et(_,le){Pe===le&&!_.currentTarget.contains(_.relatedTarget)&&lt(null)}function vc(_,le){if(_.preventDefault(),!Ln||Ln.status===le){Mi();return}Mi(),vo({item:Ln,toColumnId:le})}function es({field:_,children:le}){const xe=ve===_;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>bc(_),className:"inline-flex items-center gap-1 hover:text-foreground",children:[le,xe?he==="asc"?r.jsx(c0,{className:"h-3 w-3"}):r.jsx(br,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":b.density,children:[r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Ee,{to:`${t}/assignments/new`,className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[r.jsx(rn,{className:"h-4 w-4"}),"New Assignment"]})}),r.jsxs(qg,{children:[r.jsx(tf,{ref:s,value:O,onChange:W,placeholder:"Search assignments or projects"}),r.jsx(Pn,{ariaLabel:"Status filter",className:"max-w-[180px]",allLabel:"All statuses",options:Nf.map(_=>({value:_,label:w[_]??_})),value:se,onChange:Ai}),r.jsx(Pn,{ariaLabel:"Priority filter",className:"max-w-[180px]",allLabel:"All priorities",options:yc.map(_=>({value:_,label:_[0].toUpperCase()+_.slice(1)})),value:H,onChange:_r}),r.jsx(Pn,{ariaLabel:"Type filter",className:"max-w-[180px]",allLabel:"All types",options:m.definitions.map(_=>({value:_.id,label:ii(m,_.id)})),value:ne,onChange:oa}),r.jsx(Pn,{ariaLabel:"Assignee filter",className:"max-w-[180px]",allLabel:"All assignees",options:[{value:"__unassigned__",label:"Unassigned"},...da.filter(_=>_!=="__unassigned__").map(_=>({value:_,label:_}))],value:G,onChange:aa}),r.jsx(Pn,{ariaLabel:"Project filter",className:"max-w-[180px]",allLabel:"All projects",options:[{value:"__standalone__",label:"Standalone"},...vr.map(([_,le])=>({value:_,label:le}))],value:F,onChange:Di}),r.jsx(Pn,{ariaLabel:"Tags filter",className:"max-w-[180px]",allLabel:"Any tags",options:Cf.map(_=>({value:_,label:_})),value:I,onChange:ia}),r.jsx(jx,{className:"max-w-[200px]",value:ge,onChange:V}),r.jsxs("select",{value:ae,onChange:_=>la(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All activity"}),r.jsx("option",{value:"stale",children:"Stale only"}),r.jsx("option",{value:"fresh",children:"Fresh only"})]}),r.jsx("select",{value:L==="kanban"?Xe:Ne,onChange:_=>kf(_.target.value),className:"editor-input max-w-[180px]",title:"Group by",children:OD.map(_=>{const le=L==="kanban"&&_!=="status"&&_!=="type",xe=_==="none"?"No grouping":`Group: ${_.charAt(0).toUpperCase()+_.slice(1)}`;return r.jsx("option",{value:_,disabled:le,children:le?`${xe} (list only)`:xe},_)})}),r.jsx(nf,{value:L,onChange:_=>jf(_),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]}),L==="table"?r.jsx(aN,{visibility:J,onChange:Ie}):null,r.jsx(mN,{scope:Gn,loadedViewId:Fe,onApply:Sf,onOpenSaveDialog:()=>{Wt(!1),Yt(!0)}}),r.jsx("button",{type:"button",onClick:()=>{Ae?xc():(Wt(!1),Yt(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:Ae?`Update ${Ae.name}`:"Save current view",children:Ae?`Update '${Ae.name}'`:"Save view"}),Ae?r.jsx("button",{type:"button",onClick:()=>{Wt(!0),Yt(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),a.assignments.length===0?r.jsx(St,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${t}/projects`,children:[r.jsx(eg,{className:"h-4 w-4"}),r.jsx("span",{children:"Browse Projects"})]})}):jt.length===0?r.jsx(St,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again."}):L==="table"?(()=>{const _=new Set(J.hidden),le=xe=>xe==="title"||!_.has(xe);return r.jsx(We,{title:`${xo.length} assignment${xo.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[le("title")?r.jsx(es,{field:"title",children:"Assignment"}):null,le("status")?r.jsx(es,{field:"status",children:"Status"}):null,r.jsx("th",{className:"py-2 pr-4 text-xs font-medium uppercase tracking-wider",children:"Type"}),le("priority")?r.jsx(es,{field:"priority",children:"Priority"}):null,le("assignee")?r.jsx(es,{field:"assignee",children:"Assignee"}):null,le("dependencies")?r.jsx(es,{field:"dependencies",children:"Dependencies"}):null,le("created")?r.jsx(es,{field:"created",children:"Created"}):null,le("updated")?r.jsx(es,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:xo.map((xe,$e)=>r.jsxs(UF,{detailHref:Kl(xe),className:"cursor-pointer border-b border-border/50 transition hover:bg-muted/40 last:border-0",...ys($e),children:[le("title")?r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(FN,{title:xe.title,detailHref:Kl(xe),onSave:ct=>Oi(xe,ct),disabled:Y===tn(xe)}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:xe.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:xe.id,children:[xe.id.slice(0,8),r.jsx($r,{value:xe.id})]})]}):null,le("status")?r.jsx("td",{className:"py-4 pr-4",children:r.jsx("select",{value:xe.status,disabled:Y===tn(xe),onChange:ct=>vo({item:xe,toColumnId:ct.target.value}),className:Se("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,(md[xe.status]??md.pending).className,Y===tn(xe)&&"animate-pulse opacity-60"),children:j.map(ct=>{const pt=xe.status===ct?void 0:kl(xe,ct),yt=(pt==null?void 0:pt.disabled)??!1;return r.jsx("option",{value:ct,disabled:yt,title:yt?(pt==null?void 0:pt.disabledReason)??void 0:void 0,children:w[ct]},ct)})})}):null,r.jsx("td",{className:"py-4 pr-4",children:r.jsx(ea,{type:xe.type,compact:!0})}),le("priority")?r.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:xe.priority}):null,le("assignee")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:xe.assignee??"Unassigned"}):null,le("dependencies")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:xe.dependsOn.length}):null,le("created")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:Dn(xe.created)}):null,le("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(xe.updated)}):null]},tn(xe)))})]})})})})():L==="list"?r.jsx("div",{className:"space-y-3",children:Li.map(({id:_,label:le,items:xe})=>{var on;if(xe.length===0&&!(Ln&&Ne==="status"))return null;const $e=!Me.has(_),ct=Ne==="status",pt=ct&&Ln?Ln.status!==_&&!((on=kl(Ln,_))!=null&&on.disabled):!1,yt=ct&&Ln?Ln.status!==_&&!pt:!1,cn=ct&&Pe===_;return r.jsxs("div",{className:Se("rounded-lg border border-border/60 bg-card/90 transition",cn&&pt&&"ring-2 ring-ring/30",yt&&"border-dashed opacity-65"),onDragOver:ct?kn=>_i(kn,_):void 0,onDragLeave:ct?kn=>Et(kn,_):void 0,onDrop:ct?kn=>vc(kn,_):void 0,children:[r.jsxs("button",{type:"button",onClick:()=>Ii(_),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[r.jsx(br,{className:`h-4 w-4 text-muted-foreground transition-transform ${$e?"":"-rotate-90"}`}),r.jsx("span",{className:"font-semibold text-foreground",children:le}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:xe.length})]}),$e&&xe.length>0&&r.jsx("div",{className:"space-y-3 px-4 pb-4",children:xe.map(kn=>{const Un=tn(kn),Fr=Q===Un,wc=yo.get(Un)??-1,jo=ct;return r.jsx("div",{draggable:jo,onDragStart:jo?wr=>wo(wr,Un):void 0,onDragEnd:jo?Mi:void 0,...wc>=0?ys(wc):{},className:Se("transition",jo&&"cursor-grab active:cursor-grabbing",Fr&&"scale-[0.98] opacity-50"),children:r.jsx(dj,{assignment:kn,dragging:Fr,transitioning:Y===Un,onPillSelect:wr=>void vo({item:kn,toColumnId:wr.targetStatus,action:wr}),onRenameTitle:wr=>Oi(kn,wr)})},Un)})})]},_)})}):r.jsx(Qd,{columns:Xe==="type"?Ef:k,items:jt,getItemId:tn,getColumnId:_=>Xe==="type"?_.type&&m.definitions.some(le=>le.id===_.type)?_.type:N:_.status,canDrop:({item:_,fromColumnId:le,toColumnId:xe})=>{if(le===xe)return{allowed:!0};const $e=kl(_,xe);return $e!=null&&$e.disabled?{allowed:!1,reason:$e.disabledReason||$e.description}:{allowed:!0,reason:$e?$e.warning||$e.description:`Move to ${xe} (direct status change).`}},onMove:Xe==="type"?void 0:({item:_,toColumnId:le})=>vo({item:_,toColumnId:le}),dragDisabled:Xe==="type",getExternalDragData:_=>_.projectSlug===null?{type:"standalone-assignment",id:_.id}:{type:"project-assignment",id:_.id},onCardContextMenu:(_,le)=>{le.preventDefault(),it({item:_,anchor:{x:le.clientX,y:le.clientY}})},emptyMessage:_=>`No ${_.title.toLowerCase()} assignments.`,hiddenColumnIds:Ye.hidden,onHideColumn:_=>ot(le=>({hidden:le.hidden.includes(_)?le.hidden.filter($e=>$e!==_):[...le.hidden,_]})),renderCard:(_,{dragging:le})=>{const xe=yo.get(tn(_))??-1;return r.jsx("div",{...xe>=0?ys(xe):{},children:r.jsx(dj,{assignment:_,dragging:le,transitioning:Y===tn(_),onPillSelect:$e=>void vo({item:_,toColumnId:$e.targetStatus,action:$e}),onRenameTitle:$e=>Oi(_,$e)})})}}),r.jsx(na,{toast:Rt,onDismiss:ie}),r.jsx(pN,{open:$n,onOpenChange:_=>{Yt(_),_||Wt(!1)},initialName:sn&&Ae?`${Ae.name} (copy)`:"",title:sn?"Save as new view":"Save view",onSubmit:$i}),r.jsx(RN,{open:te!==null,action:(te==null?void 0:te.action)??null,assignmentTitle:(te==null?void 0:te.item.title)??"Assignment",loading:Y===(te?tn(te.item):null),onOpenChange:_=>{_||be(null)},onConfirm:async _=>{if(!te)return;const le=te;await bo({item:le.item,toColumnId:le.toColumnId,action:le.action,reason:_})&&be(null)}}),r.jsx(Y1,{anchor:(Le==null?void 0:Le.anchor)??null,items:Le?BF(Le.item,{onEdit:()=>{const _=Le.item,le=_.projectSlug===null?`/assignments/${_.id}`:`${_.projectWorkspace?`/w/${_.projectWorkspace}`:t}/projects/${_.projectSlug}/assignments/${_.slug}`;n(le)},onDelete:()=>bt(Le.item),onMove:()=>Be(Le.item)}):[],onClose:()=>it(null)}),r.jsx(sa,{open:_e!==null,title:"Delete assignment?",description:_e?`"${_e.title}" will be permanently removed. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:_t!==null,onOpenChange:_=>{!_&&_t===null&&bt(null)},onConfirm:async()=>{if(!_e||_e.projectSlug===null){bt(null);return}const _=tn(_e);Gt(_);try{const le=await fetch(`/api/projects/${encodeURIComponent(_e.projectSlug)}/assignments/${encodeURIComponent(_e.slug)}`,{method:"DELETE"});if(!le.ok){const xe=await le.json().catch(()=>({}));throw new Error(xe.error||"Failed to delete assignment")}bt(null),u()}catch(le){alert(le instanceof Error?le.message:"Failed to delete assignment")}finally{Gt(null)}}}),r.jsx(Yg,{open:ue!==null,onOpenChange:_=>{_||Be(null)},currentWorkspace:(ue==null?void 0:ue.projectWorkspace)??null,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async _=>{if(!ue)return;const le=await fetch(`/api/assignments/${encodeURIComponent(ue.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:_})});if(!le.ok){const xe=await le.json().catch(()=>({}));throw new Error(xe.error||"Failed to move assignment")}u()}})]})}function BF(e,t){const n=[{key:"edit",label:"Edit",icon:bi,onSelect:t.onEdit}];return e.projectSlug!==null?n.push({key:"delete",label:"Delete",icon:or,destructive:!0,onSelect:t.onDelete}):n.push({key:"move",label:"Move to workspace…",icon:$d,onSelect:t.onMove}),n}function UF({detailHref:e,children:t,className:n,...s}){const a=zN(e);return r.jsx("tr",{...s,ref:a.containerRef,className:n,onMouseDown:a.onMouseDown,onClick:a.onClick,children:t})}function dj({assignment:e,dragging:t,transitioning:n,onPillSelect:s,onRenameTitle:a}){var p;const l=Kl(e),c=!!(s&&a),u=zN(l);return r.jsxs("div",{ref:c?u.containerRef:void 0,className:Se("vp-card rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",c&&"cursor-pointer"),onMouseDown:c?u.onMouseDown:void 0,onClick:c?u.onClick:void 0,children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[c?r.jsx(FN,{title:e.title,detailHref:l,onSave:a,disabled:n}):r.jsx(Ee,{to:l,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(p=e.id)==null?void 0:p.slice(0,8),e.id&&r.jsx($r,{value:e.id})]})]}),c?r.jsx(_F,{currentStatus:e.status,availableTransitions:e.availableTransitions,onSelect:s,disabled:n}):r.jsx(pn,{status:e.status})]}),e.blockedReason?r.jsx("p",{className:"mt-3 rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground",children:e.blockedReason}):null,r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ea,{type:e.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," dependencies"]})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),r.jsx("span",{children:Dn(e.updated)})]})]})}function kl(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function tn(e){return e.id||e.slug||"unknown"}function Mr(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],s=e.slice(t[0].length),a=n.split(`
555
+ `).trim();return{hasSection:!0,todosMarkdown:a,remaining:l}}function PF({projectSlug:e,dependencies:t,blockedReason:n}){const[s,a]=f.useState(!1);if(t.length===0)return null;const l=t.filter(u=>u.status!=="completed"&&u.status!=="review"),c=l.length===0;return c&&!s?r.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex w-full items-center gap-2 rounded-lg border border-success-foreground/30 bg-success/70 px-4 py-2.5 text-left transition hover:bg-success",children:[r.jsx(Zh,{className:"h-4 w-4 shrink-0 text-success-foreground"}),r.jsxs("span",{className:"text-sm font-medium text-success-foreground",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),r.jsx(br,{className:"ml-auto h-4 w-4 text-success-foreground"})]}):r.jsxs("div",{className:"space-y-3",children:[l.length>0&&r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3",children:[r.jsx(lh,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning-foreground"}),r.jsxs("div",{className:"text-sm text-warning-foreground",children:[r.jsxs("strong",{children:[l.length," ",l.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&r.jsxs("p",{className:"mt-1 text-warning-foreground/80",children:["Blocked reason: ",n]})]})]}),r.jsx(We,{title:"Dependencies",description:`${t.length-l.length} of ${t.length} resolved`,actions:c?r.jsx("button",{type:"button",onClick:()=>a(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:r.jsx("div",{className:"divide-y divide-border/40",children:t.map(u=>r.jsxs(Ee,{to:`/projects/${e}/assignments/${u.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(pn,{status:u.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:u.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:u.slug})]}),u.assignee&&r.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:u.assignee}),r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},u.slug))})})]})}function AF({links:e}){const t=ln();if(e.length===0)return null;const n=e.filter(a=>!a.isReverse),s=e.filter(a=>a.isReverse);return r.jsx(We,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:r.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(a=>r.jsxs(Ee,{to:`${t}/projects/${a.projectSlug}/assignments/${a.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(a0,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(pn,{status:a.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:a.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.slug})]}),r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${a.slug}`)),s.map(a=>r.jsxs(Ee,{to:`${t}/projects/${a.projectSlug}/assignments/${a.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(td,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(pn,{status:a.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:a.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.slug})]}),r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${a.slug}`))]})})}function DF(e){const t=new Map;for(const s of e)t.set(s.id,{entry:s,replies:[]});const n=[];for(const s of e){const a=t.get(s.id);s.replyTo&&t.has(s.replyTo)?t.get(s.replyTo).replies.push(a):n.push(a)}return n}function $F(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function MN({projectSlug:e,assignmentSlug:t,entries:n}){const[s,a]=f.useState(n);f.useEffect(()=>{a(n)},[n]);const l=f.useMemo(()=>DF(s),[s]),[c,u]=f.useState(""),[p,m]=f.useState("note"),[h,g]=f.useState(!1),[y,b]=f.useState(null);async function E(w){var N;if(w.preventDefault(),!c.trim())return;g(!0),b(null);const k=`tmp-${Date.now()}`,C={id:k,timestamp:new Date().toISOString(),author:"human",type:p,body:c,resolved:p==="question"?!1:void 0};a(T=>[...T,C]);try{const T=await fetch($F(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:c,type:p})});if(!T.ok){const $=await T.text();throw new Error($||`HTTP ${T.status}`)}const D=await T.json().catch(()=>null),R=(N=D==null?void 0:D.comment)==null?void 0:N.id;a($=>$.map(L=>L.id===k?{...L,id:R??L.id}:L)),u(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(T){b(T instanceof Error?T.message:String(T)),a(D=>D.filter(R=>R.id!==k))}finally{g(!1)}}async function j(w,k){a(C=>C.map(N=>N.id===w?{...N,resolved:k}:N));try{const C=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(w)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(w)}/resolved`,N=await fetch(C,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:k})});if(!N.ok)throw new Error(`HTTP ${N.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(C){b(C instanceof Error?C.message:String(C)),a(N=>N.map(T=>T.id===w?{...T,resolved:!k}:T))}}return r.jsx(We,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:r.jsxs("div",{className:"space-y-4",children:[l.map(w=>r.jsx(_N,{node:w,onToggleResolved:j,depth:0},w.entry.id)),r.jsxs("form",{onSubmit:E,className:"mt-6 space-y-2 border-t border-border pt-4",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Add comment"}),r.jsx("textarea",{value:c,onChange:w=>u(w.target.value),className:"w-full rounded border border-border bg-background p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:p,onChange:w=>m(w.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs",children:[r.jsx("option",{value:"note",children:"note"}),r.jsx("option",{value:"question",children:"question"}),r.jsx("option",{value:"feedback",children:"feedback"})]}),r.jsx("button",{type:"submit",disabled:h||!c.trim(),className:"shell-action",children:h?"Posting…":"Post comment"}),y?r.jsx("span",{className:"text-xs text-error-foreground",children:y}):null]})]})]})})}function _N({node:e,depth:t,onToggleResolved:n}){const{entry:s,replies:a}=e,l=s.type==="question";return r.jsxs("div",{className:Se("space-y-2",t>0&&"ml-4 border-l border-border pl-4"),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-mono",children:s.id}),r.jsx("span",{children:"·"}),r.jsx("span",{children:s.timestamp}),r.jsx("span",{children:"·"}),r.jsx("span",{className:"font-medium text-foreground",children:s.author}),r.jsx("span",{children:"·"}),r.jsx("span",{className:Se("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",l&&"bg-warning text-warning-foreground",s.type==="feedback"&&"bg-info text-info-foreground",s.type==="note"&&"bg-muted text-muted-foreground"),children:s.type}),l?r.jsxs("button",{type:"button",onClick:()=>n(s.id,!s.resolved),className:Se("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",s.resolved?"bg-success text-success-foreground hover:bg-success/80":"bg-muted text-muted-foreground hover:bg-muted/80"),title:s.resolved?"Mark unresolved":"Mark resolved",children:[s.resolved?r.jsx(Zh,{className:"h-3 w-3"}):r.jsx(nR,{className:"h-3 w-3"}),s.resolved?"resolved":"open"]}):null,s.replyTo?r.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx(kR,{className:"h-3 w-3"}),s.replyTo]}):null]}),r.jsx(fn,{content:s.body}),a.length>0?r.jsx("div",{className:"space-y-2",children:a.map(c=>r.jsx(_N,{node:c,depth:t+1,onToggleResolved:n},c.entry.id))}):null]})}const LF=["review","complete","shape","plan-ready","implement","unblock","start","block","fail","reopen"];function ij(){var lt,te,be,Le,it,_e,bt,_t,Gt;const{slug:e,aslug:t}=$t(),n=Dt(),s=ln(),[a,l]=hs(),[c,u]=f.useState(null),{toast:p,showToast:m,dismissToast:h}=ta(),[g,y]=f.useState(null),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null),[N,T]=f.useState(!1),[D,R]=f.useState(!1),[$,L]=f.useState(0),K=a.get("tab")??"summary",B=Zo(),{data:O,loading:W,error:se,refetch:z}=jP(e,t),{data:H}=F0(e),{data:ee}=dg(),{data:ne,loading:M,error:G}=SP(e,t),{data:A,loading:F,error:Z}=CP(e,t),I=f.useMemo(()=>{if(!O||!H)return[];const ue=new Map(H.assignments.map(Be=>[Be.slug,Be]));return O.dependsOn.map(Be=>{const Fe=ue.get(Be);return{slug:Be,title:(Fe==null?void 0:Fe.title)??Be,status:(Fe==null?void 0:Fe.status)??"pending",priority:(Fe==null?void 0:Fe.priority)??"medium",assignee:(Fe==null?void 0:Fe.assignee)??null}})},[O,H]),de=I.filter(ue=>ue.status!=="completed"&&ue.status!=="review");mo("assignment");const ge=f.useMemo(()=>((H==null?void 0:H.assignments)??[]).map(ue=>ue.slug),[H]),V=t?ge.indexOf(t):-1,ae=V>0?ge[V-1]:null,me=V>=0&&V<ge.length-1?ge[V+1]:null,ve=`${s}/projects/${e}/assignments/${t}`;Ht({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${ve}/edit`)}),Ht({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${ve}/plan/edit`)}),Ht({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${ve}/handoff/edit`)}),Ht({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${ve}/decision-record/edit`)}),Ht({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${ve}/scratchpad/edit`)}),Ht({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ae,handler:()=>ae&&n(`${s}/projects/${e}/assignments/${ae}`)}),Ht({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!me,handler:()=>me&&n(`${s}/projects/${e}/assignments/${me}`)});const ke=f.useMemo(()=>O?TF(O.body):{acceptanceCriteria:[],summaryBody:""},[O]),he=f.useMemo(()=>RF(ke.summaryBody),[ke.summaryBody]),Je=ke.acceptanceCriteria,Ye=Je.filter(ue=>ue.checked).length,ot=Je.length>0&&Ye===Je.length,J=f.useRef(ot),Ie=f.useRef(!1);if(f.useEffect(()=>{if(O){if(!Ie.current){J.current=ot,Ie.current=!0;return}ot&&!J.current&&L(ue=>ue+1),J.current=ot}},[ot,O]),W)return r.jsx(mt,{label:"Loading assignment workspace…"});if(se||!O||!e||!t)return r.jsx(wt,{error:se||"Assignment not found."});const Ne=e,Oe=t,Xe=Je.length>0?{checked:Ye,total:Je.length}:void 0,Me=O.availableTransitions??[],nt=Me.filter(ue=>!ue.disabled&&ue.targetStatus!==O.status),Ke=LF.map(ue=>nt.find(Be=>Be.command===ue)).find(Boolean)??nt[0]??null,gt=[];if(ee!=null&&ee.sessions)for(const ue of ee.sessions)for(const Be of ue.windows)for(const Fe of Be.panes)((lt=Fe.assignment)==null?void 0:lt.project)===e&&((te=Fe.assignment)==null?void 0:te.slug)===t&&gt.push({sessionName:ue.name,command:Fe.command,urls:Fe.urls});async function Rt(ue){u(null);try{await kN(Ne,Oe,ue),z()}catch(Be){u(Be.message)}}async function at(ue){u(null);try{const Be=await fetch(`/api/projects/${Ne}/assignments/${Oe}/${ue?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Be.ok){const Fe=await Be.json().catch(()=>null);throw new Error((Fe==null?void 0:Fe.error)||`HTTP ${Be.status}`)}z(),m(ue?"Assignment archived":"Assignment restored","success")}catch(Be){u(Be.message)}}async function ie(){R(!0);try{await uF(Ne,Oe),n(`${s}/projects/${Ne}`)}catch(ue){u(ue.message),R(!1),T(!1)}}async function Y(ue,Be){u(null),y(ue.command);try{return await jN(Ne,Oe,ue,Be),z(),!0}catch(Fe){return u(Fe.message),!1}finally{y(null)}}function pe(ue){if(SN(ue)){E(ue);return}Y(ue)}async function Q(ue,Be){w(null),C(ue);try{const Fe=await fetch(`/api/projects/${Ne}/assignments/${Oe}/acceptance-criteria/${ue}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:Be})}),Nt=await Fe.json();if(!Fe.ok)throw new Error(Nt.error||`HTTP ${Fe.status}`);z()}catch(Fe){w(Fe.message)}finally{C(null)}}const ye=[...nt.filter(ue=>ue!==Ke).map(ue=>({key:`transition-${ue.command}`,label:ue.label,onSelect:()=>pe(ue),disabled:g===ue.command})),...Me.filter(ue=>ue.disabled||ue.targetStatus===O.status).map(ue=>({key:`transition-${ue.command}`,label:ue.label,disabled:!0,disabledReason:ue.targetStatus===O.status?`Already ${O.status.replace(/_/g," ")}`:ue.disabledReason??ue.warning??ue.description})),...B.statuses.map(ue=>({key:`override-${ue.id}`,label:`Override → ${ue.label}`,onSelect:()=>Rt(ue.id),disabled:ue.id===O.status,disabledReason:ue.id===O.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:uR,href:`${s}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:NR,href:`${s}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:um,href:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:nd,href:`${s}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:pR,href:`${s}/projects/${e}/assignments/${t}/decision-record/edit`},{key:O.archived?"unarchive":"archive",label:O.archived?"Restore assignment":"Archive assignment",icon:O.archived?ed:Dd,onSelect:()=>at(!O.archived)},{key:"delete",label:"Delete assignment",icon:or,destructive:!0,onSelect:()=>T(!0)}],Pe=(Ke==null?void 0:Ke.command)==="review";return r.jsxs("div",{className:"space-y-5",children:[r.jsx(na,{toast:p,onDismiss:h}),r.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:O.status,progress:Xe}),r.jsx(ea,{type:O.type}),r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:O.title}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",N0(O.updated)]}),de.length>0&&r.jsxs("span",{className:"text-xs text-warning-foreground",children:["⚠ ",de.length," unmet dep",de.length===1?"":"s"]}),r.jsx(Jg,{externalIds:O.externalIds}),r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[r.jsx(ON,{target:{kind:"assignment",id:O.id},worktreePath:((be=O.workspace)==null?void 0:be.worktreePath)??null,repository:((Le=O.workspace)==null?void 0:Le.repository)??null}),!((it=O.workspace)!=null&&it.worktreePath)&&e&&t&&r.jsx(IN,{projectSlug:e,assignmentSlug:t,defaultBranch:`syntaur/${e}/${t}`,onCreated:()=>z()}),Ke&&r.jsx("button",{type:"button",title:Ke.warning||Ke.description,disabled:g===Ke.command,onClick:()=>pe(Ke),className:Se("shell-action disabled:cursor-not-allowed disabled:opacity-50",Ke.warning&&"border-warning-foreground/40",Pe&&$>0&&"send-to-review-glow"),children:r.jsx("span",{children:g===Ke.command?"Working…":Ke.label})},Pe?`review-${$}`:Ke.command),r.jsx(Wg,{items:ye,align:"end"})]})]}),c?r.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:c}):null,O.blockedReason?r.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[r.jsx("strong",{children:"Blocked reason:"})," ",O.blockedReason]}):null]}),I.length>0&&r.jsx(PF,{projectSlug:e,dependencies:I,blockedReason:O.blockedReason}),O.enrichedLinks&&O.enrichedLinks.length>0&&r.jsx(AF,{links:O.enrichedLinks}),O.referencedBy&&O.referencedBy.length>0&&r.jsx(We,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:r.jsx("ul",{className:"space-y-2",children:O.referencedBy.map(ue=>{const Be=ue.sourceProjectSlug===null?`/assignments/${ue.sourceId}`:`${s}/projects/${ue.sourceProjectSlug}/assignments/${ue.sourceSlug}`;return r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:Be,className:"text-foreground hover:text-primary",children:ue.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",ue.mentions," mention",ue.mentions===1?"":"s",")"]}),ue.sourceProjectSlug===null?r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"}):null]},ue.sourceId)})})}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(Qg,{value:K,onValueChange:ue=>l({tab:ue}),items:[{value:"summary",label:"Summary",content:r.jsxs("div",{className:"space-y-5",children:[ke.acceptanceCriteria.length>0?r.jsx(We,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:r.jsxs("div",{className:"space-y-3",children:[j?r.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:j}):null,ke.acceptanceCriteria.map((ue,Be)=>{const Fe=k!==null;return r.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[r.jsx("input",{type:"checkbox",checked:ue.checked,disabled:Fe,onChange:Nt=>Q(Be,Nt.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),r.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":ue.checked,children:ue.text})]},`${Be}-${ue.text}`)})]})}):null,he.hasSection?r.jsx(We,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:r.jsx(fn,{content:he.todosMarkdown,emptyState:"No todos yet."})}):null,r.jsx(We,{title:"Assignment Summary",children:r.jsx(fn,{content:he.remaining,emptyState:ke.acceptanceCriteria.length>0||he.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:O.plan?1:0,content:O.plan?r.jsx("div",{className:"space-y-5",children:r.jsxs(We,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/plan/edit`,children:[r.jsx(um,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Plan"})]}),children:[r.jsx("div",{className:"mb-4",children:r.jsx(pn,{status:O.plan.status})}),r.jsx(fn,{content:O.plan.body,emptyState:"No plan content yet."})]})}):r.jsx(St,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:O.scratchpad?1:0,content:O.scratchpad?r.jsx(We,{title:"Scratchpad",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[r.jsx(um,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Scratchpad"})]}),children:r.jsx(fn,{content:O.scratchpad.body,emptyState:"Scratchpad is empty."})}):r.jsx(St,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((_e=O.handoff)==null?void 0:_e.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.handoff?r.jsx(We,{children:r.jsx(fn,{content:O.handoff.body,emptyState:"No handoff history yet."})}):r.jsx(St,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((bt=O.progress)==null?void 0:bt.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.progress&&O.progress.entries.length>0?r.jsx(We,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:r.jsx("ol",{className:"space-y-4",children:O.progress.entries.map((ue,Be)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:ue.timestamp}),r.jsx(fn,{content:ue.body})]},`${ue.timestamp}-${Be}`))})}):r.jsx(St,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((_t=O.comments)==null?void 0:_t.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.comments&&O.comments.entries.length>0?r.jsx(MN,{projectSlug:e,assignmentSlug:t,entries:O.comments.entries}):r.jsx(St,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((Gt=O.decisionRecord)==null?void 0:Gt.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:O.decisionRecord?r.jsx(We,{children:r.jsx(fn,{content:O.decisionRecord.body,emptyState:"No decision history yet."})}):r.jsx(St,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),r.jsxs("div",{className:"min-w-0 space-y-5",children:[r.jsx(We,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(to,{label:"ID",value:O.id,copyable:!0}),r.jsx(to,{label:"Priority",value:O.priority}),O.assignee&&r.jsx(to,{label:"Assignee",value:O.assignee}),r.jsx(to,{label:"Updated",value:`${S0(O.updated)} · Created ${k0(O.created)}`}),O.workspace.repository&&r.jsx(to,{label:"Repository",value:O.workspace.repository,copyable:!0}),O.workspace.worktreePath&&r.jsx(to,{label:"Worktree",value:O.workspace.worktreePath,copyable:!0}),O.workspace.branch&&r.jsx(to,{label:"Branch",value:O.workspace.branch,copyable:!0}),O.workspace.parentBranch&&r.jsx(to,{label:"Parent branch",value:O.workspace.parentBranch,copyable:!0}),O.externalIds.map((ue,Be)=>r.jsx(OF,{entry:ue},`${ue.system}:${ue.id}:${Be}`))]})}),gt.length>0&&r.jsx(We,{title:"Servers",children:r.jsx("div",{className:"space-y-2",children:gt.map((ue,Be)=>r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-sm",children:[r.jsx("span",{className:"min-w-0 max-w-full truncate rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",title:ue.command,children:ue.command}),r.jsx("span",{className:"min-w-0 max-w-full truncate text-xs text-muted-foreground",title:ue.sessionName,children:ue.sessionName}),ue.urls.map(Fe=>r.jsxs("a",{href:Fe,target:"_blank",rel:"noopener noreferrer",title:Fe,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[r.jsx("span",{className:"min-w-0 truncate",children:Fe.replace("http://localhost:",":")}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]},Fe))]},Be))})}),r.jsx(EN,{sessions:ne==null?void 0:ne.sessions,loading:M,error:G,onError:ue=>m(ue.message,"error"),onNotice:ue=>m(ue,"success")}),r.jsx(TN,{summary:A==null?void 0:A.summary,loading:F,error:Z})]})]}),r.jsx(RN,{open:b!==null,action:b,assignmentTitle:O.title,loading:g===(b==null?void 0:b.command),onOpenChange:ue=>{ue||E(null)},onConfirm:async ue=>{if(!b)return;await Y(b,ue)&&E(null)}}),r.jsx(sa,{open:N,title:"Delete assignment?",description:`This will permanently delete "${O.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:D,onOpenChange:ue=>{ue||T(!1)},onConfirm:ie})]})}function to({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"block min-w-0 truncate",title:t,children:t}),n&&t!=="—"&&r.jsx($r,{value:t})]})]})}function OF({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function IF(){var R,$,L,K,B,O,W,se;const{id:e}=$t(),[t,n]=hs(),s=t.get("tab")??"summary",{data:a,loading:l,error:c,refetch:u}=kP(e),{data:p,loading:m,error:h}=NP(e),{data:g,loading:y,error:b}=EP(a==null?void 0:a.slug),[E,j]=f.useState(!1),[w,k]=f.useState(null),{toast:C,showToast:N,dismissToast:T}=ta();async function D(z){if(e){k(null);try{const H=await fetch(`/api/assignments/${e}/${z?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!H.ok){const ee=await H.json().catch(()=>null);throw new Error((ee==null?void 0:ee.error)||`HTTP ${H.status}`)}u(),N(z?"Assignment archived":"Assignment restored","success")}catch(H){k(H instanceof Error?H.message:"Archive failed")}}}return l?r.jsx(mt,{}):c?r.jsx(wt,{error:c}):a?r.jsxs("div",{className:"space-y-6",children:[r.jsx(na,{toast:C,onDismiss:T}),r.jsxs("header",{className:"space-y-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(pn,{status:a.status}),r.jsx(ea,{type:a.type}),r.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:a.id}),r.jsx(Jg,{externalIds:a.externalIds}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(ON,{target:{kind:"assignment",id:a.id},worktreePath:((R=a.workspace)==null?void 0:R.worktreePath)??null,repository:(($=a.workspace)==null?void 0:$.repository)??null,size:"compact"}),!((L=a.workspace)!=null&&L.worktreePath)&&r.jsx(IN,{assignmentId:a.id,defaultBranch:`syntaur/${a.slug}`,onCreated:()=>u()}),r.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:[r.jsx($d,{className:"h-3 w-3"}),"Move to workspace…"]}),r.jsx(Ee,{to:`/assignments/${a.id}/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit"}),r.jsxs("button",{type:"button",onClick:()=>D(!a.archived),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:a.archived?"Restore this assignment":"Archive this assignment",children:[a.archived?r.jsx(ed,{className:"h-3 w-3"}):r.jsx(Dd,{className:"h-3 w-3"}),a.archived?"Restore":"Archive"]})]})]}),r.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:a.title}),a.blockedReason?r.jsxs("p",{className:"text-sm text-warning-foreground",children:["Blocked: ",a.blockedReason]}):null,w?r.jsx("p",{className:"text-sm text-status-failed-foreground",children:w}):null]}),r.jsx(We,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(no,{label:"ID",value:a.id,copyable:!0}),r.jsx(no,{label:"Priority",value:a.priority}),a.assignee&&r.jsx(no,{label:"Assignee",value:a.assignee}),r.jsx(no,{label:"Updated",value:`${S0(a.updated)} · Created ${k0(a.created)}`}),a.workspace.repository&&r.jsx(no,{label:"Repository",value:a.workspace.repository,copyable:!0}),a.workspace.worktreePath&&r.jsx(no,{label:"Worktree",value:a.workspace.worktreePath,copyable:!0}),a.workspace.branch&&r.jsx(no,{label:"Branch",value:a.workspace.branch,copyable:!0}),a.workspace.parentBranch&&r.jsx(no,{label:"Parent branch",value:a.workspace.parentBranch,copyable:!0}),a.externalIds.map((z,H)=>r.jsx(MF,{entry:z},`${z.system}:${z.id}:${H}`))]})}),a.referencedBy&&a.referencedBy.length>0?r.jsx(We,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:r.jsx("ul",{className:"space-y-2",children:a.referencedBy.map(z=>r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:z.sourceProjectSlug===null?`/assignments/${z.sourceId}`:`/projects/${z.sourceProjectSlug}/assignments/${z.sourceSlug}`,className:"text-foreground hover:text-primary",children:z.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",z.mentions," mention",z.mentions===1?"":"s",")"]})]},z.sourceId))})}):null,r.jsx(EN,{sessions:p==null?void 0:p.sessions,loading:m,error:h,onError:z=>N(z.message,"error"),onNotice:z=>N(z,"success")}),r.jsx(TN,{summary:g==null?void 0:g.summary,loading:y,error:b}),r.jsx(Qg,{value:s,onValueChange:z=>n({tab:z}),items:[{value:"summary",label:"Summary",content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Assignment",children:r.jsx(fn,{content:a.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((K=a.progress)==null?void 0:K.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:a.progress&&a.progress.entries.length>0?r.jsx(We,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:r.jsx("ol",{className:"space-y-4",children:a.progress.entries.map((z,H)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:z.timestamp}),r.jsx(fn,{content:z.body})]},`${z.timestamp}-${H}`))})}):r.jsx(St,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((B=a.comments)==null?void 0:B.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:r.jsx(MN,{projectSlug:null,assignmentSlug:a.id,entries:((O=a.comments)==null?void 0:O.entries)??[]})})},{value:"plan",label:"Plan",content:r.jsx("div",{className:"space-y-5",children:a.plan?r.jsxs(We,{children:[r.jsx(fn,{content:a.plan.body,emptyState:"Plan file exists but is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/plan/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit plan"})})]}):r.jsx(St,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:r.jsx("div",{className:"space-y-5",children:a.scratchpad?r.jsxs(We,{children:[r.jsx(fn,{content:a.scratchpad.body,emptyState:"Scratchpad is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/scratchpad/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit scratchpad"})})]}):r.jsx(St,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((W=a.handoff)==null?void 0:W.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:a.handoff?r.jsxs(We,{children:[r.jsx(fn,{content:a.handoff.body,emptyState:"No handoff history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/handoff/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append handoff"})})]}):r.jsx(St,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((se=a.decisionRecord)==null?void 0:se.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:a.decisionRecord?r.jsxs(We,{children:[r.jsx(fn,{content:a.decisionRecord.body,emptyState:"No decision history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${a.id}/decision-record/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append decision"})})]}):r.jsx(St,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]}),r.jsx(Yg,{open:E,onOpenChange:j,currentWorkspace:a.projectWorkspace,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async z=>{const H=await fetch(`/api/assignments/${encodeURIComponent(a.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:z})});if(!H.ok){const ee=await H.json().catch(()=>({}));throw new Error(ee.error||"Failed to move assignment")}u()}})]}):r.jsx(wt,{error:"Assignment not found"})}function no({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&r.jsx($r,{value:t})]})]})}function MF({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function _F({currentStatus:e,availableTransitions:t,onSelect:n,disabled:s=!1}){const[a,l]=f.useState(!1),[c,u]=f.useState(null),[p,m]=f.useState(0),h=f.useRef(null),g=f.useRef(null),y=f.useId(),b=hd(e),E=b.icon,j=f.useCallback(T=>{l(!1),T&&requestAnimationFrame(()=>{var D;(D=h.current)==null||D.focus()})},[]),w=f.useCallback(()=>{var D;const T=(D=h.current)==null?void 0:D.getBoundingClientRect();T&&u({top:T.top,left:T.left,width:T.width,bottom:T.bottom})},[]);f.useLayoutEffect(()=>{a&&w()},[a,w]),f.useEffect(()=>{if(!a)return;const T=()=>w();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[a,w]),f.useEffect(()=>{if(!a)return;const T=D=>{var $,L;const R=D.target;R&&(($=g.current)!=null&&$.contains(R)||(L=h.current)!=null&&L.contains(R)||j(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[a,j]),f.useEffect(()=>{a&&m(0)},[a,t.length]);function k(T){(T.key==="Enter"||T.key===" "||T.key==="ArrowDown")&&(T.preventDefault(),l(!0))}function C(T){if(t.length===0){T.key==="Escape"&&(T.preventDefault(),j(!0));return}if(T.key==="ArrowDown")T.preventDefault(),m(D=>(D+1)%t.length);else if(T.key==="ArrowUp")T.preventDefault(),m(D=>(D-1+t.length)%t.length);else if(T.key==="Home")T.preventDefault(),m(0);else if(T.key==="End")T.preventDefault(),m(t.length-1);else if(T.key==="Enter"){T.preventDefault();const D=t[p];D&&(n(D),j(!0))}else T.key==="Escape"&&(T.preventDefault(),j(!0))}function N(T){n(T),j(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:h,type:"button","data-no-drag":!0,disabled:s,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?y:void 0,onClick:()=>{s||l(T=>!T)},onKeyDown:k,title:`Status: ${b.label}. Click to change.`,className:Se(H1(e),"cursor-pointer transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",s&&"cursor-not-allowed opacity-60"),children:[r.jsx(E,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:b.label})]}),a&&c&&typeof document<"u"?Rs.createPortal(r.jsx("div",{ref:g,id:y,role:"menu",tabIndex:-1,autoFocus:!0,onKeyDown:C,style:{position:"fixed",top:c.bottom+6,left:c.left,minWidth:Math.max(c.width,180),zIndex:60},className:"rounded-md border border-border/70 bg-popover py-1 text-sm text-popover-foreground shadow-lg",children:t.length===0?r.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No transitions available from this status."}):t.map((T,D)=>{const R=hd(T.targetStatus),$=R.icon,L=D===p;return r.jsxs("button",{type:"button",role:"menuitem","data-no-drag":!0,onMouseEnter:()=>m(D),onClick:()=>N(T),title:T.warning||T.description,className:Se("flex w-full flex-col items-stretch gap-0.5 px-3 py-1.5 text-left text-sm transition",L?"bg-foreground/5":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:"flex items-center justify-between gap-2",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx($,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate",children:T.label})]}),r.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:R.label})]}),T.warning?r.jsx("span",{className:"text-[11px] leading-snug text-warning-foreground",children:T.warning}):null]},`${T.command}:${T.targetStatus}`)})}),document.body):null]})}function FN({title:e,detailHref:t,onSave:n,disabled:s=!1}){const[a,l]=f.useState(!1);return a?r.jsx(FF,{initialTitle:e,disabled:s,onSave:n,onExit:()=>l(!1)}):r.jsxs("div",{className:"group flex items-baseline gap-1.5",children:[r.jsx("button",{type:"button","data-no-drag":!0,disabled:s,onClick:()=>{s||l(!0)},className:Se("text-left text-base font-semibold text-foreground transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",s&&"cursor-not-allowed opacity-60"),title:"Click to rename",children:e}),r.jsx(Ee,{to:t,"data-no-drag":!0,"aria-label":"Open detail page",title:"Open detail page",onClick:c=>c.stopPropagation(),className:"text-muted-foreground opacity-0 transition group-hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",children:r.jsx(yi,{className:"h-3.5 w-3.5"})})]})}function FF({initialTitle:e,disabled:t,onSave:n,onExit:s}){const a=f.useRef(e),[l,c]=f.useState(e),[u,p]=f.useState(!1),[m,h]=f.useState(!1),g=f.useRef(null),y=f.useRef(!1);f.useEffect(()=>{const w=g.current;w&&(w.focus(),w.select())},[]);const b=f.useCallback(()=>{var w;h(!0),window.setTimeout(()=>h(!1),260),(w=g.current)==null||w.focus()},[]),E=f.useCallback(async()=>{if(y.current)return;const w=l.trim();if(w.length===0){b();return}if(w===a.current){s();return}y.current=!0,p(!0);try{await n(w)}catch{}finally{p(!1),s()}},[l,s,n,b]);function j(w){w.key==="Enter"?(w.preventDefault(),E()):w.key==="Escape"&&(w.preventDefault(),y.current=!0,s())}return r.jsx("input",{ref:g,type:"text","data-no-drag":!0,disabled:t||u,value:l,onChange:w=>c(w.target.value),onKeyDown:j,onBlur:()=>void E(),className:Se("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-base font-semibold text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",m&&"syntaur-input-shake",u&&"opacity-70")})}function zN(e){const t=Dt(),n=f.useRef(null),s=f.useRef(!1),a=f.useCallback(()=>{const c=n.current,u=!!(c!=null&&c.querySelector('[aria-expanded="true"]')),p=!!document.querySelector('[role="menu"]'),m=document.activeElement,h=!!(m&&(c!=null&&c.contains(m))&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"));s.current=u||p||h},[]),l=f.useCallback(c=>{if(s.current)return;const u=c.target;!u||u.closest(mi)||t(e)},[t,e]);return{containerRef:n,onMouseDown:a,onClick:l}}const lj=Ag;function cj(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function zF(e,t){return e.toString()===t.toString()}function uj(){const{workspace:e}=$t(),t=ln(),n=Dt(),s=f.useRef(null);mo("list:assignments");const{data:a,loading:l,error:c,refetch:u}=Md(),p=Zo(),m=ef(),[h,g]=hs(),y=e?`w:${e}`:null,b=cN(y),E=f.useRef(void 0),j=f.useMemo(()=>G1(p.order),[p]),w=f.useMemo(()=>{const _={};for(const le of j)_[le]=cc(p,le);return _},[j,p]),k=f.useMemo(()=>j.map(_=>({id:_,title:w[_]??_,description:Zd(_)})),[j,w]),C=f.useMemo(()=>m.definitions.map(_=>({id:_.id,title:ii(m,_.id),description:_.description})),[m]),N="__unknown_type__",T=f.useMemo(()=>new Set(["all",...j]),[j]),D=h.get("view"),R=h.get("status"),$=h.get("stale"),L=D&&lj.includes(D)?D:"kanban";function K(_){if(!_)return[];const le=[];for(const xe of _.split(",")){const $e=xe.trim();!$e||$e==="all"||!T.has($e)||le.includes($e)||le.push($e)}return le}const B=f.useCallback(_=>{g(le=>{const xe=new URLSearchParams(le);return _==="kanban"?xe.delete("view"):xe.set("view",_),xe})},[g]),[O,W]=f.useState(""),[se,z]=f.useState(()=>K(R)),[H,ee]=f.useState(()=>tt(b.filters.priority)),[ne,M]=f.useState(()=>tt(b.filters.type)),[G,A]=f.useState(()=>tt(b.filters.assignee)),[F,Z]=f.useState(()=>tt(b.filters.project)),[I,de]=f.useState(()=>tt(b.filters.tags)),[ge,V]=f.useState(null),[ae,me]=f.useState(()=>cj($)),[ve,ke]=f.useState(()=>b.sortField),[he,Je]=f.useState(()=>b.sortDirection),[Ye,ot]=f.useState(()=>({hidden:[]})),[J,Ie]=f.useState(()=>({hidden:[]})),[Ne,Oe]=f.useState(()=>b.grouping),Xe=Ne==="type"?"type":"status",[Me,nt]=f.useState(()=>new Set),[Ke,gt]=f.useState([]),{toast:Rt,showToast:at,dismissToast:ie}=ta(),[Y,pe]=f.useState(null),[Q,ye]=f.useState(null),[Pe,lt]=f.useState(null),[te,be]=f.useState(null),[Le,it]=f.useState(null),[_e,bt]=f.useState(null),[_t,Gt]=f.useState(null),[ue,Be]=f.useState(null),[Fe,Nt]=f.useState(null),[$n,Yt]=f.useState(!1),[sn,Wt]=f.useState(!1),Gn=e?{kind:"workspace",workspace:e}:{kind:"global"},xt=h.get("loadView"),{view:jn,loading:Pt,error:re}=Go(xt),{view:Ae,loading:Qe,error:Ft}=Go(Fe),hn=f.useRef(null);f.useEffect(()=>{gt((a==null?void 0:a.assignments)??[])},[a]),f.useEffect(()=>{Fe&&!Qe&&!Ft&&!Ae&&Nt(null)},[Ae,Ft,Fe,Qe]),f.useEffect(()=>{Nt(null),hn.current=null,V(null),W("")},[e]),f.useEffect(()=>{const _=K(R);MD(_,se)||z(_);const le=cj($);le!==ae&&me(le)},[ae,$,se,R]),f.useEffect(()=>{E.current===y&&g(_=>{const le=new URLSearchParams(_);return se.length===0?le.delete("status"):le.set("status",se.join(",")),ae==="all"?le.delete("stale"):ae==="stale"?le.set("stale","1"):le.set("stale","0"),zF(_,le)?_:le})},[ae,y,g,se]),f.useEffect(()=>{ee(tt(b.filters.priority)),M(tt(b.filters.type)),A(tt(b.filters.assignee)),Z(tt(b.filters.project)),de(tt(b.filters.tags)),ke(b.sortField),Je(b.sortDirection),Oe(b.grouping)},[b.filters.priority,b.filters.type,b.filters.assignee,b.filters.project,b.filters.tags,b.sortField,b.sortDirection,b.grouping]),f.useEffect(()=>{if(E.current===y)return;let _=!1;return wx().then(le=>{if(_||E.current===y)return;const xe=r1(le,y),$e=xe.defaultView,ct=tt(xe.filters.status),pt=xe.filters.activity??"all",yt=new URLSearchParams(window.location.search);let cn=!1;const on=new URLSearchParams(yt);yt.get("view")===null&&$e!=="kanban"&&lj.includes($e)&&(on.set("view",$e),cn=!0),yt.get("status")===null&&ct.length>0&&(on.set("status",ct.join(",")),z(ct),cn=!0),yt.get("stale")===null&&pt!=="all"&&(on.set("stale",pt==="stale"?"1":"0"),me(pt),cn=!0),cn&&g(on,{replace:!0}),queueMicrotask(()=>{E.current=y})}),()=>{_=!0}},[y]);const Ct=f.useCallback(_=>{(y===null?dN(_):fN(y,_)).catch(xe=>{console.warn("Failed to persist view prefs:",xe)})},[y]),jf=f.useCallback(_=>{B(_),Ct({defaultView:_})},[B,Ct]),Ai=f.useCallback(_=>{z(_),Ct({filters:{status:_}})},[Ct]),_r=f.useCallback(_=>{ee(_),Ct({filters:{priority:_}})},[Ct]),oa=f.useCallback(_=>{M(_),Ct({filters:{type:_}})},[Ct]),aa=f.useCallback(_=>{A(_),Ct({filters:{assignee:_}})},[Ct]),Di=f.useCallback(_=>{Z(_),Ct({filters:{project:_}})},[Ct]),ia=f.useCallback(_=>{de(_),Ct({filters:{tags:_}})},[Ct]),la=f.useCallback(_=>{me(_),Ct({filters:{activity:_}})},[Ct]),ca=f.useCallback(_=>{ke(_),Ct({sortField:_})},[Ct]),go=f.useCallback(_=>{Je(_),Ct({sortDirection:_})},[Ct]),kf=f.useCallback(_=>{Oe(_),Ct({grouping:_})},[Ct]),ua=f.useCallback(()=>({viewMode:L,filters:{status:se,priority:H,type:ne,assignee:G,project:F,tags:I,activity:ae,dateRange:Xl(ge),search:O},sortField:ve,sortDirection:he,listSectionVisibility:{collapsed:[...Me]},kanbanColumnVisibility:Ye,tableColumnVisibility:J}),[L,se,H,ne,G,F,I,ae,ge,O,ve,he,Me,Ye,J]),Lt=f.useCallback(_=>{xN(_,{setViewMode:B,setStatusFilter:Ai,setPriorityFilter:_r,setTypeFilter:oa,setAssigneeFilter:aa,setProjectFilter:Di,setTagsFilter:ia,setActivityFilter:la,setDateRange:V,setSearch:W,setSortField:ca,setSortDirection:go,setListSectionVisibility:le=>nt(new Set(le.collapsed)),setKanbanColumnVisibility:ot,setTableColumnVisibility:Ie}),Nt(_.id)},[B,Ai,_r,oa,aa,Di,ia,la,ca,go]),Sf=f.useCallback(_=>{Lt(_),hn.current=_.id,g(le=>{const xe=new URLSearchParams(le);return xe.set("loadView",_.id),xe},{replace:!0})},[Lt,g]),$i=f.useCallback(async _=>{try{const le=Jl({name:_,context:{workspace:e??null,projectSlug:null},state:ua()}),xe=await Wd(le),$e=xe.views[xe.views.length-1];Nt(($e==null?void 0:$e.id)??null),$e&&(hn.current=$e.id,g(ct=>{const pt=new URLSearchParams(ct);return pt.set("loadView",$e.id),pt},{replace:!0})),Yt(!1),Wt(!1),at(`Saved view "${_}"`,"success")}catch(le){throw at(le instanceof Error?le.message:"Failed to save view","error"),le}},[ua,g,at,e]),xc=f.useCallback(async()=>{if(!(!Fe||!Ae))try{const _=Jl({name:Ae.name,context:{workspace:e??null,projectSlug:null},state:ua()}),le=kx(Ae.config,_.config,_.config);await Lg(Fe,{config:le}),at("View updated","success")}catch(_){at(_ instanceof Error?_.message:"Failed to update view","error")}},[ua,Ae,Fe,at,e]);f.useEffect(()=>{if(!xt){hn.current=null;return}if(hn.current!==xt&&(Fe&&Fe!==xt&&Nt(null),!Pt)){if(re){at("Couldn't load saved view — try again","error");return}if(jn){hn.current=xt,Lt(jn),g(_=>{const le=new URLSearchParams(_);return le.delete("loadView"),le},{replace:!0});return}hn.current=xt,at("Saved view no longer exists","error"),g(_=>{const le=new URLSearchParams(_);return le.delete("loadView"),le},{replace:!0})}},[xt,jn,Pt,re,Fe,Lt,g,at]);const Bn=f.useMemo(()=>Ke.filter(_=>e?e==="_ungrouped"?_.projectWorkspace===null:_.projectWorkspace===e:!0),[Ke,e]),Nf=f.useMemo(()=>Array.from(new Set(Bn.map(_=>_.status))).sort(),[Bn]),yc=f.useMemo(()=>Array.from(new Set(Bn.map(_=>_.priority))).sort(),[Bn]),da=f.useMemo(()=>Array.from(new Set(Bn.map(_=>_.assignee??"__unassigned__"))).sort(),[Bn]),vr=f.useMemo(()=>Array.from(new Map(Bn.filter(_=>_.projectSlug!==null).map(_=>[_.projectSlug,_.projectTitle]))).sort(([,_],[,le])=>_.localeCompare(le)),[Bn]),Cf=f.useMemo(()=>Array.from(new Set(Bn.flatMap(_=>_.tags??[]))).sort(),[Bn]),jt=f.useMemo(()=>Ke.filter(_=>Kg(_,{status:se,priority:H,type:ne,assignee:G,project:F,tags:I,activity:ae,dateRange:Xl(ge)},{workspace:e,search:O})),[ae,Ke,O,se,H,ne,G,F,I,ge,e]),xo=f.useMemo(()=>uc(jt,ve,he),[jt,ve,he]),Li=f.useMemo(()=>{if(Ne==="none")return[{id:"__all__",label:"All assignments",items:jt}];if(Ne==="type"){const _=m.definitions.map($e=>({id:$e.id,label:ii(m,$e.id),items:jt.filter(ct=>ct.type===$e.id)})),le=new Set(m.definitions.map($e=>$e.id)),xe=jt.filter($e=>!$e.type||!le.has($e.type));return xe.length>0&&_.push({id:N,label:"Other",items:xe}),_}if(Ne==="priority")return["critical","high","medium","low"].map(le=>({id:le,label:le.charAt(0).toUpperCase()+le.slice(1),items:jt.filter(xe=>xe.priority===le)}));if(Ne==="assignee")return Array.from(new Set(jt.map(le=>le.assignee??"__unassigned__"))).sort().map(le=>({id:le,label:le==="__unassigned__"?"Unassigned":le,items:jt.filter(xe=>(xe.assignee??"__unassigned__")===le)}));if(Ne==="project"){const _=new Map;for(const le of jt){const xe=le.projectSlug??"__standalone__",$e=le.projectTitle??"Standalone";_.has(xe)||_.set(xe,$e)}return Array.from(_.entries()).sort(([,le],[,xe])=>le.localeCompare(xe)).map(([le,xe])=>({id:le,label:xe,items:jt.filter($e=>($e.projectSlug??"__standalone__")===le)}))}return j.map(_=>({id:_,label:w[_]??_,items:jt.filter(le=>le.status===_)}))},[Ne,jt,m,j,w]),Ef=f.useMemo(()=>{const _=new Set(m.definitions.map(xe=>xe.id));return jt.some(xe=>!xe.type||!_.has(xe.type))?[...C,{id:N,title:"Other",description:"Assignments with no recognized type."}]:C},[C,m,jt]),{visibleItems:fa,visibleIndexByKey:yo}=f.useMemo(()=>{let _;if(L==="table")_=xo;else if(L==="kanban"){const xe=new Set(m.definitions.map($e=>$e.id));Xe==="type"?_=[...m.definitions.flatMap($e=>jt.filter(ct=>ct.type===$e.id)),...jt.filter($e=>!$e.type||!xe.has($e.type))]:_=j.flatMap($e=>jt.filter(ct=>ct.status===$e))}else _=Li.flatMap(xe=>xe.items);const le=new Map;return _.forEach((xe,$e)=>le.set(tn(xe),$e)),{visibleItems:_,visibleIndexByKey:le}},[L,xo,Li,Xe,m,jt,j]),{hotkeyRowProps:ys}=ac(fa,{scope:"list:assignments",onOpen:_=>{if(_.projectSlug===null){n(`/assignments/${_.id}`);return}const le=_.projectWorkspace?`/w/${_.projectWorkspace}`:t;n(`${le}/projects/${_.projectSlug}/assignments/${_.slug}`)}});if(Ht({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var _;return(_=s.current)==null?void 0:_.focus()}}),Ht({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>u()}),l)return r.jsx(mt,{label:"Loading assignments board…"});if(c||!a)return r.jsx(wt,{error:c||"Assignments board is unavailable."});async function bo({item:_,toColumnId:le,action:xe,reason:$e}){pe(tn(_));const ct=Ke;gt(pt=>pt.map(yt=>tn(yt)===tn(_)?{...yt,status:le,blockedReason:le==="blocked"?$e??yt.blockedReason:null}:yt));try{if(_.projectSlug===null){if(!xe)throw new Error("Standalone assignments require a transition action, not status override.");const yt=await fetch(`/api/assignments/${encodeURIComponent(_.id)}/transitions/${encodeURIComponent(xe.command)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($e?{reason:$e}:{})});if(!yt.ok)throw new Error((await yt.json()).error??`HTTP ${yt.status}`);const on=(await yt.json()).assignment;gt(kn=>kn.map(Un=>tn(Un)===tn(_)?{...Un,status:on.status,blockedReason:on.blockedReason,availableTransitions:on.availableTransitions,updated:on.updated}:Un));return}const pt=xe?await jN(_.projectSlug,_.slug,xe,$e):await kN(_.projectSlug,_.slug,le);return gt(yt=>yt.map(cn=>tn(cn)===tn(_)?{...cn,status:pt.status,blockedReason:pt.blockedReason,availableTransitions:pt.availableTransitions,updated:pt.updated}:cn)),u(),!0}catch(pt){return gt(ct),at(pt.message,"error"),!1}finally{pe(null)}}async function vo({item:_,toColumnId:le,action:xe}){if(_.status===le)return;const $e=xe??kl(_,le);if($e!=null&&$e.disabled){at($e.disabledReason||`Cannot move this assignment to ${le}.`,"error");return}if($e&&SN($e)){be({item:_,toColumnId:le,action:$e});return}await bo({item:_,toColumnId:le,action:$e})}async function Oi(_,le){if(le===_.title)return;const xe=tn(_),$e=Ke;gt(ct=>ct.map(pt=>tn(pt)===xe?{...pt,title:le}:pt)),pe(xe);try{const ct=_.projectSlug===null?await fF({id:_.id,title:le}):await dF({projectSlug:_.projectSlug,assignmentSlug:_.slug,title:le});gt(pt=>pt.map(yt=>tn(yt)===xe?{...yt,title:ct.title,updated:ct.updated}:yt)),u()}catch(ct){throw gt($e),at(ct.message,"error"),ct}finally{pe(null)}}function Ii(_){nt(le=>{const xe=new Set(le);return xe.has(_)?xe.delete(_):xe.add(_),xe})}function bc(_){ve===_?go(he==="asc"?"desc":"asc"):(ca(_),go("asc"))}const Ln=Q?Ke.find(_=>tn(_)===Q)??null:null;function wo(_,le){_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",le),ye(le)}function Mi(){ye(null),lt(null)}function _i(_,le){if(!Ln)return;const xe=kl(Ln,le);Ln.status===le||xe!=null&&xe.disabled||(_.preventDefault(),_.dataTransfer.dropEffect="move",lt(le))}function Et(_,le){Pe===le&&!_.currentTarget.contains(_.relatedTarget)&&lt(null)}function vc(_,le){if(_.preventDefault(),!Ln||Ln.status===le){Mi();return}Mi(),vo({item:Ln,toColumnId:le})}function es({field:_,children:le}){const xe=ve===_;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>bc(_),className:"inline-flex items-center gap-1 hover:text-foreground",children:[le,xe?he==="asc"?r.jsx(c0,{className:"h-3 w-3"}):r.jsx(br,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":b.density,children:[r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Ee,{to:`${t}/assignments/new`,className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[r.jsx(rn,{className:"h-4 w-4"}),"New Assignment"]})}),r.jsxs(qg,{children:[r.jsx(tf,{ref:s,value:O,onChange:W,placeholder:"Search assignments or projects"}),r.jsx(Pn,{ariaLabel:"Status filter",className:"max-w-[180px]",allLabel:"All statuses",options:Nf.map(_=>({value:_,label:w[_]??_})),value:se,onChange:Ai}),r.jsx(Pn,{ariaLabel:"Priority filter",className:"max-w-[180px]",allLabel:"All priorities",options:yc.map(_=>({value:_,label:_[0].toUpperCase()+_.slice(1)})),value:H,onChange:_r}),r.jsx(Pn,{ariaLabel:"Type filter",className:"max-w-[180px]",allLabel:"All types",options:m.definitions.map(_=>({value:_.id,label:ii(m,_.id)})),value:ne,onChange:oa}),r.jsx(Pn,{ariaLabel:"Assignee filter",className:"max-w-[180px]",allLabel:"All assignees",options:[{value:"__unassigned__",label:"Unassigned"},...da.filter(_=>_!=="__unassigned__").map(_=>({value:_,label:_}))],value:G,onChange:aa}),r.jsx(Pn,{ariaLabel:"Project filter",className:"max-w-[180px]",allLabel:"All projects",options:[{value:"__standalone__",label:"Standalone"},...vr.map(([_,le])=>({value:_,label:le}))],value:F,onChange:Di}),r.jsx(Pn,{ariaLabel:"Tags filter",className:"max-w-[180px]",allLabel:"Any tags",options:Cf.map(_=>({value:_,label:_})),value:I,onChange:ia}),r.jsx(jx,{className:"max-w-[200px]",value:ge,onChange:V}),r.jsxs("select",{value:ae,onChange:_=>la(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All activity"}),r.jsx("option",{value:"stale",children:"Stale only"}),r.jsx("option",{value:"fresh",children:"Fresh only"})]}),r.jsx("select",{value:L==="kanban"?Xe:Ne,onChange:_=>kf(_.target.value),className:"editor-input max-w-[180px]",title:"Group by",children:OD.map(_=>{const le=L==="kanban"&&_!=="status"&&_!=="type",xe=_==="none"?"No grouping":`Group: ${_.charAt(0).toUpperCase()+_.slice(1)}`;return r.jsx("option",{value:_,disabled:le,children:le?`${xe} (list only)`:xe},_)})}),r.jsx(nf,{value:L,onChange:_=>jf(_),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]}),L==="table"?r.jsx(aN,{visibility:J,onChange:Ie}):null,r.jsx(mN,{scope:Gn,loadedViewId:Fe,onApply:Sf,onOpenSaveDialog:()=>{Wt(!1),Yt(!0)}}),r.jsx("button",{type:"button",onClick:()=>{Ae?xc():(Wt(!1),Yt(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:Ae?`Update ${Ae.name}`:"Save current view",children:Ae?`Update '${Ae.name}'`:"Save view"}),Ae?r.jsx("button",{type:"button",onClick:()=>{Wt(!0),Yt(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),a.assignments.length===0?r.jsx(St,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${t}/projects`,children:[r.jsx(eg,{className:"h-4 w-4"}),r.jsx("span",{children:"Browse Projects"})]})}):jt.length===0?r.jsx(St,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again."}):L==="table"?(()=>{const _=new Set(J.hidden),le=xe=>xe==="title"||!_.has(xe);return r.jsx(We,{title:`${xo.length} assignment${xo.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[le("title")?r.jsx(es,{field:"title",children:"Assignment"}):null,le("status")?r.jsx(es,{field:"status",children:"Status"}):null,r.jsx("th",{className:"py-2 pr-4 text-xs font-medium uppercase tracking-wider",children:"Type"}),le("priority")?r.jsx(es,{field:"priority",children:"Priority"}):null,le("assignee")?r.jsx(es,{field:"assignee",children:"Assignee"}):null,le("dependencies")?r.jsx(es,{field:"dependencies",children:"Dependencies"}):null,le("created")?r.jsx(es,{field:"created",children:"Created"}):null,le("updated")?r.jsx(es,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:xo.map((xe,$e)=>r.jsxs(UF,{detailHref:Kl(xe),className:"cursor-pointer border-b border-border/50 transition hover:bg-muted/40 last:border-0",...ys($e),children:[le("title")?r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(FN,{title:xe.title,detailHref:Kl(xe),onSave:ct=>Oi(xe,ct),disabled:Y===tn(xe)}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:xe.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:xe.id,children:[xe.id.slice(0,8),r.jsx($r,{value:xe.id})]})]}):null,le("status")?r.jsx("td",{className:"py-4 pr-4",children:r.jsx("select",{value:xe.status,disabled:Y===tn(xe),onChange:ct=>vo({item:xe,toColumnId:ct.target.value}),className:Se("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,(md[xe.status]??md.pending).className,Y===tn(xe)&&"animate-pulse opacity-60"),children:j.map(ct=>{const pt=xe.status===ct?void 0:kl(xe,ct),yt=(pt==null?void 0:pt.disabled)??!1;return r.jsx("option",{value:ct,disabled:yt,title:yt?(pt==null?void 0:pt.disabledReason)??void 0:void 0,children:w[ct]},ct)})})}):null,r.jsx("td",{className:"py-4 pr-4",children:r.jsx(ea,{type:xe.type,compact:!0})}),le("priority")?r.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:xe.priority}):null,le("assignee")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:xe.assignee??"Unassigned"}):null,le("dependencies")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:xe.dependsOn.length}):null,le("created")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:Dn(xe.created)}):null,le("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Dn(xe.updated)}):null]},tn(xe)))})]})})})})():L==="list"?r.jsx("div",{className:"space-y-3",children:Li.map(({id:_,label:le,items:xe})=>{var on;if(xe.length===0&&!(Ln&&Ne==="status"))return null;const $e=!Me.has(_),ct=Ne==="status",pt=ct&&Ln?Ln.status!==_&&!((on=kl(Ln,_))!=null&&on.disabled):!1,yt=ct&&Ln?Ln.status!==_&&!pt:!1,cn=ct&&Pe===_;return r.jsxs("div",{className:Se("rounded-lg border border-border/60 bg-card/90 transition",cn&&pt&&"ring-2 ring-ring/30",yt&&"border-dashed opacity-65"),onDragOver:ct?kn=>_i(kn,_):void 0,onDragLeave:ct?kn=>Et(kn,_):void 0,onDrop:ct?kn=>vc(kn,_):void 0,children:[r.jsxs("button",{type:"button",onClick:()=>Ii(_),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[r.jsx(br,{className:`h-4 w-4 text-muted-foreground transition-transform ${$e?"":"-rotate-90"}`}),r.jsx("span",{className:"font-semibold text-foreground",children:le}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:xe.length})]}),$e&&xe.length>0&&r.jsx("div",{className:"space-y-3 px-4 pb-4",children:xe.map(kn=>{const Un=tn(kn),Fr=Q===Un,wc=yo.get(Un)??-1,jo=ct;return r.jsx("div",{draggable:jo,onDragStart:jo?wr=>wo(wr,Un):void 0,onDragEnd:jo?Mi:void 0,...wc>=0?ys(wc):{},className:Se("transition",jo&&"cursor-grab active:cursor-grabbing",Fr&&"scale-[0.98] opacity-50"),children:r.jsx(dj,{assignment:kn,dragging:Fr,transitioning:Y===Un,onPillSelect:wr=>void vo({item:kn,toColumnId:wr.targetStatus,action:wr}),onRenameTitle:wr=>Oi(kn,wr)})},Un)})})]},_)})}):r.jsx(Qd,{columns:Xe==="type"?Ef:k,items:jt,getItemId:tn,getColumnId:_=>Xe==="type"?_.type&&m.definitions.some(le=>le.id===_.type)?_.type:N:_.status,canDrop:({item:_,fromColumnId:le,toColumnId:xe})=>{if(le===xe)return{allowed:!0};const $e=kl(_,xe);return $e!=null&&$e.disabled?{allowed:!1,reason:$e.disabledReason||$e.description}:{allowed:!0,reason:$e?$e.warning||$e.description:`Move to ${xe} (direct status change).`}},onMove:Xe==="type"?void 0:({item:_,toColumnId:le})=>vo({item:_,toColumnId:le}),dragDisabled:Xe==="type",getExternalDragData:_=>_.projectSlug===null?{type:"standalone-assignment",id:_.id}:{type:"project-assignment",id:_.id},onCardContextMenu:(_,le)=>{le.preventDefault(),it({item:_,anchor:{x:le.clientX,y:le.clientY}})},emptyMessage:_=>`No ${_.title.toLowerCase()} assignments.`,hiddenColumnIds:Ye.hidden,onHideColumn:_=>ot(le=>({hidden:le.hidden.includes(_)?le.hidden.filter($e=>$e!==_):[...le.hidden,_]})),renderCard:(_,{dragging:le})=>{const xe=yo.get(tn(_))??-1;return r.jsx("div",{...xe>=0?ys(xe):{},children:r.jsx(dj,{assignment:_,dragging:le,transitioning:Y===tn(_),onPillSelect:$e=>void vo({item:_,toColumnId:$e.targetStatus,action:$e}),onRenameTitle:$e=>Oi(_,$e)})})}}),r.jsx(na,{toast:Rt,onDismiss:ie}),r.jsx(pN,{open:$n,onOpenChange:_=>{Yt(_),_||Wt(!1)},initialName:sn&&Ae?`${Ae.name} (copy)`:"",title:sn?"Save as new view":"Save view",onSubmit:$i}),r.jsx(RN,{open:te!==null,action:(te==null?void 0:te.action)??null,assignmentTitle:(te==null?void 0:te.item.title)??"Assignment",loading:Y===(te?tn(te.item):null),onOpenChange:_=>{_||be(null)},onConfirm:async _=>{if(!te)return;const le=te;await bo({item:le.item,toColumnId:le.toColumnId,action:le.action,reason:_})&&be(null)}}),r.jsx(Y1,{anchor:(Le==null?void 0:Le.anchor)??null,items:Le?BF(Le.item,{onEdit:()=>{const _=Le.item,le=_.projectSlug===null?`/assignments/${_.id}`:`${_.projectWorkspace?`/w/${_.projectWorkspace}`:t}/projects/${_.projectSlug}/assignments/${_.slug}`;n(le)},onDelete:()=>bt(Le.item),onMove:()=>Be(Le.item)}):[],onClose:()=>it(null)}),r.jsx(sa,{open:_e!==null,title:"Delete assignment?",description:_e?`"${_e.title}" will be permanently removed. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:_t!==null,onOpenChange:_=>{!_&&_t===null&&bt(null)},onConfirm:async()=>{if(!_e||_e.projectSlug===null){bt(null);return}const _=tn(_e);Gt(_);try{const le=await fetch(`/api/projects/${encodeURIComponent(_e.projectSlug)}/assignments/${encodeURIComponent(_e.slug)}`,{method:"DELETE"});if(!le.ok){const xe=await le.json().catch(()=>({}));throw new Error(xe.error||"Failed to delete assignment")}bt(null),u()}catch(le){alert(le instanceof Error?le.message:"Failed to delete assignment")}finally{Gt(null)}}}),r.jsx(Yg,{open:ue!==null,onOpenChange:_=>{_||Be(null)},currentWorkspace:(ue==null?void 0:ue.projectWorkspace)??null,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async _=>{if(!ue)return;const le=await fetch(`/api/assignments/${encodeURIComponent(ue.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:_})});if(!le.ok){const xe=await le.json().catch(()=>({}));throw new Error(xe.error||"Failed to move assignment")}u()}})]})}function BF(e,t){const n=[{key:"edit",label:"Edit",icon:bi,onSelect:t.onEdit}];return e.projectSlug!==null?n.push({key:"delete",label:"Delete",icon:or,destructive:!0,onSelect:t.onDelete}):n.push({key:"move",label:"Move to workspace…",icon:$d,onSelect:t.onMove}),n}function UF({detailHref:e,children:t,className:n,...s}){const a=zN(e);return r.jsx("tr",{...s,ref:a.containerRef,className:n,onMouseDown:a.onMouseDown,onClick:a.onClick,children:t})}function dj({assignment:e,dragging:t,transitioning:n,onPillSelect:s,onRenameTitle:a}){var p;const l=Kl(e),c=!!(s&&a),u=zN(l);return r.jsxs("div",{ref:c?u.containerRef:void 0,className:Se("vp-card rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",c&&"cursor-pointer"),onMouseDown:c?u.onMouseDown:void 0,onClick:c?u.onClick:void 0,children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[c?r.jsx(FN,{title:e.title,detailHref:l,onSave:a,disabled:n}):r.jsx(Ee,{to:l,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(p=e.id)==null?void 0:p.slice(0,8),e.id&&r.jsx($r,{value:e.id})]})]}),c?r.jsx(_F,{currentStatus:e.status,availableTransitions:e.availableTransitions,onSelect:s,disabled:n}):r.jsx(pn,{status:e.status})]}),e.blockedReason?r.jsx("p",{className:"mt-3 rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground",children:e.blockedReason}):null,r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ea,{type:e.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," dependencies"]})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),r.jsx("span",{children:Dn(e.updated)})]})]})}function kl(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function tn(e){return e.id||e.slug||"unknown"}function Mr(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],s=e.slice(t[0].length),a=n.split(`
556
556
  `),l=[],c=new Map;let u=null,p=[];const m=()=>{u&&(l.push(u),c.set(u,p))};for(const h of a){const g=h.match(/^([A-Za-z_][A-Za-z0-9_-]*):/);if(g&&!h.startsWith(" ")){m(),u=g[1],p=[h];continue}u&&p.push(h)}return m(),{order:l,blocks:c,body:s}}function Ni(e){return`---
557
557
  ${e.order.map(n=>e.blocks.get(n)).filter(n=>!!n).flat().join(`
558
558
  `)}