gru-ai 0.1.0

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 (143) hide show
  1. package/.claude/skills/brainstorm/SKILL.md +340 -0
  2. package/.claude/skills/code-review-excellence/SKILL.md +198 -0
  3. package/.claude/skills/directive/SKILL.md +121 -0
  4. package/.claude/skills/directive/docs/pipeline/00-delegation-and-triage.md +181 -0
  5. package/.claude/skills/directive/docs/pipeline/01-checkpoint.md +34 -0
  6. package/.claude/skills/directive/docs/pipeline/02-read-directive.md +38 -0
  7. package/.claude/skills/directive/docs/pipeline/03-read-context.md +15 -0
  8. package/.claude/skills/directive/docs/pipeline/04-challenge.md +38 -0
  9. package/.claude/skills/directive/docs/pipeline/05-planning.md +64 -0
  10. package/.claude/skills/directive/docs/pipeline/06-technical-audit.md +88 -0
  11. package/.claude/skills/directive/docs/pipeline/07-plan-approval.md +145 -0
  12. package/.claude/skills/directive/docs/pipeline/07b-project-brainstorm.md +85 -0
  13. package/.claude/skills/directive/docs/pipeline/08-worktree-and-state.md +50 -0
  14. package/.claude/skills/directive/docs/pipeline/09-execute-projects.md +709 -0
  15. package/.claude/skills/directive/docs/pipeline/10-wrapup.md +242 -0
  16. package/.claude/skills/directive/docs/pipeline/11-completion-gate.md +75 -0
  17. package/.claude/skills/directive/docs/reference/rules/casting-rules.md +78 -0
  18. package/.claude/skills/directive/docs/reference/rules/failure-handling.md +20 -0
  19. package/.claude/skills/directive/docs/reference/rules/phase-definitions.md +42 -0
  20. package/.claude/skills/directive/docs/reference/rules/scope-and-dod.md +30 -0
  21. package/.claude/skills/directive/docs/reference/schemas/audit-output.md +44 -0
  22. package/.claude/skills/directive/docs/reference/schemas/brainstorm-output.md +52 -0
  23. package/.claude/skills/directive/docs/reference/schemas/challenger-output.md +13 -0
  24. package/.claude/skills/directive/docs/reference/schemas/checkpoint.md +18 -0
  25. package/.claude/skills/directive/docs/reference/schemas/current-json.md +5 -0
  26. package/.claude/skills/directive/docs/reference/schemas/directive-json.md +143 -0
  27. package/.claude/skills/directive/docs/reference/schemas/investigation-output.md +37 -0
  28. package/.claude/skills/directive/docs/reference/schemas/plan-schema.md +103 -0
  29. package/.claude/skills/directive/docs/reference/templates/architect-prompt.md +66 -0
  30. package/.claude/skills/directive/docs/reference/templates/auditor-prompt.md +53 -0
  31. package/.claude/skills/directive/docs/reference/templates/brainstorm-prompt.md +68 -0
  32. package/.claude/skills/directive/docs/reference/templates/challenger-prompt.md +35 -0
  33. package/.claude/skills/directive/docs/reference/templates/digest.md +134 -0
  34. package/.claude/skills/directive/docs/reference/templates/investigator-prompt.md +51 -0
  35. package/.claude/skills/directive/docs/reference/templates/planner-prompt.md +130 -0
  36. package/.claude/skills/frontend-design/SKILL.md +42 -0
  37. package/.claude/skills/gruai-agents/SKILL.md +161 -0
  38. package/.claude/skills/gruai-config/SKILL.md +61 -0
  39. package/.claude/skills/healthcheck/SKILL.md +216 -0
  40. package/.claude/skills/report/SKILL.md +380 -0
  41. package/.claude/skills/scout/SKILL.md +452 -0
  42. package/.claude/skills/seo-audit/SKILL.md +107 -0
  43. package/.claude/skills/walkthrough/SKILL.md +274 -0
  44. package/.claude/skills/webapp-testing/SKILL.md +96 -0
  45. package/LICENSE +21 -0
  46. package/README.md +206 -0
  47. package/cli/templates/CLAUDE.md.template +57 -0
  48. package/cli/templates/agent-roles/backend.md +47 -0
  49. package/cli/templates/agent-roles/cmo.md +52 -0
  50. package/cli/templates/agent-roles/content.md +48 -0
  51. package/cli/templates/agent-roles/coo.md +66 -0
  52. package/cli/templates/agent-roles/cpo.md +52 -0
  53. package/cli/templates/agent-roles/cto.md +63 -0
  54. package/cli/templates/agent-roles/data.md +46 -0
  55. package/cli/templates/agent-roles/design.md +46 -0
  56. package/cli/templates/agent-roles/frontend.md +47 -0
  57. package/cli/templates/agent-roles/fullstack.md +47 -0
  58. package/cli/templates/agent-roles/qa.md +46 -0
  59. package/cli/templates/backlog.json.template +3 -0
  60. package/cli/templates/directive.json.template +9 -0
  61. package/cli/templates/directive.md.template +23 -0
  62. package/cli/templates/goals-index.md +21 -0
  63. package/cli/templates/gruai.config.json.template +12 -0
  64. package/cli/templates/lessons.md +16 -0
  65. package/cli/templates/vision.md +35 -0
  66. package/cli/templates/welcome-directive/directive.json +9 -0
  67. package/cli/templates/welcome-directive/directive.md +53 -0
  68. package/dist/assets/GamePage-C5XQQOQH.js +49 -0
  69. package/dist/assets/README.md +17 -0
  70. package/dist/assets/characters/char_0.png +0 -0
  71. package/dist/assets/characters/char_1.png +0 -0
  72. package/dist/assets/characters/char_10.png +0 -0
  73. package/dist/assets/characters/char_11.png +0 -0
  74. package/dist/assets/characters/char_2.png +0 -0
  75. package/dist/assets/characters/char_3.png +0 -0
  76. package/dist/assets/characters/char_4.png +0 -0
  77. package/dist/assets/characters/char_5.png +0 -0
  78. package/dist/assets/characters/char_6.png +0 -0
  79. package/dist/assets/characters/char_7.png +0 -0
  80. package/dist/assets/characters/char_8.png +0 -0
  81. package/dist/assets/characters/char_9.png +0 -0
  82. package/dist/assets/index-CnTPDqpP.js +12 -0
  83. package/dist/assets/index-gR5q7ikB.css +1 -0
  84. package/dist/assets/office/furniture.png +0 -0
  85. package/dist/assets/office/room-builder.png +0 -0
  86. package/dist/index.html +16 -0
  87. package/dist-server/scripts/intelligence-trends.d.ts +100 -0
  88. package/dist-server/scripts/intelligence-trends.js +365 -0
  89. package/dist-server/server/actions/cleanup.d.ts +4 -0
  90. package/dist-server/server/actions/cleanup.js +30 -0
  91. package/dist-server/server/actions/send-input.d.ts +6 -0
  92. package/dist-server/server/actions/send-input.js +147 -0
  93. package/dist-server/server/actions/terminal.d.ts +4 -0
  94. package/dist-server/server/actions/terminal.js +427 -0
  95. package/dist-server/server/config.d.ts +9 -0
  96. package/dist-server/server/config.js +217 -0
  97. package/dist-server/server/db.d.ts +7 -0
  98. package/dist-server/server/db.js +79 -0
  99. package/dist-server/server/hooks/event-receiver.d.ts +11 -0
  100. package/dist-server/server/hooks/event-receiver.js +36 -0
  101. package/dist-server/server/index.d.ts +1 -0
  102. package/dist-server/server/index.js +552 -0
  103. package/dist-server/server/notifications/macos.d.ts +5 -0
  104. package/dist-server/server/notifications/macos.js +22 -0
  105. package/dist-server/server/notifications/notifier.d.ts +17 -0
  106. package/dist-server/server/notifications/notifier.js +110 -0
  107. package/dist-server/server/parsers/process-discovery.d.ts +39 -0
  108. package/dist-server/server/parsers/process-discovery.js +776 -0
  109. package/dist-server/server/parsers/session-scanner.d.ts +56 -0
  110. package/dist-server/server/parsers/session-scanner.js +390 -0
  111. package/dist-server/server/parsers/session-state.d.ts +68 -0
  112. package/dist-server/server/parsers/session-state.js +696 -0
  113. package/dist-server/server/parsers/session-state.test.d.ts +1 -0
  114. package/dist-server/server/parsers/session-state.test.js +950 -0
  115. package/dist-server/server/parsers/task-parser.d.ts +10 -0
  116. package/dist-server/server/parsers/task-parser.js +97 -0
  117. package/dist-server/server/parsers/team-parser.d.ts +3 -0
  118. package/dist-server/server/parsers/team-parser.js +67 -0
  119. package/dist-server/server/platform/__tests__/claude-code.test.d.ts +1 -0
  120. package/dist-server/server/platform/__tests__/claude-code.test.js +311 -0
  121. package/dist-server/server/platform/claude-code.d.ts +34 -0
  122. package/dist-server/server/platform/claude-code.js +94 -0
  123. package/dist-server/server/platform/index.d.ts +5 -0
  124. package/dist-server/server/platform/index.js +1 -0
  125. package/dist-server/server/platform/types.d.ts +190 -0
  126. package/dist-server/server/platform/types.js +9 -0
  127. package/dist-server/server/state/aggregator.d.ts +42 -0
  128. package/dist-server/server/state/aggregator.js +1080 -0
  129. package/dist-server/server/state/work-item-types.d.ts +555 -0
  130. package/dist-server/server/state/work-item-types.js +168 -0
  131. package/dist-server/server/types.d.ts +237 -0
  132. package/dist-server/server/types.js +1 -0
  133. package/dist-server/server/watchers/claude-watcher.d.ts +17 -0
  134. package/dist-server/server/watchers/claude-watcher.js +130 -0
  135. package/dist-server/server/watchers/context-watcher.d.ts +22 -0
  136. package/dist-server/server/watchers/context-watcher.js +125 -0
  137. package/dist-server/server/watchers/directive-watcher.d.ts +46 -0
  138. package/dist-server/server/watchers/directive-watcher.js +497 -0
  139. package/dist-server/server/watchers/session-watcher.d.ts +18 -0
  140. package/dist-server/server/watchers/session-watcher.js +126 -0
  141. package/dist-server/server/watchers/state-watcher.d.ts +36 -0
  142. package/dist-server/server/watchers/state-watcher.js +369 -0
  143. package/package.json +68 -0
@@ -0,0 +1,49 @@
1
+ import{r as f,u as J,j as r,R as vs,a as Si,A as bt,b as ae,c as Ei}from"./index-CnTPDqpP.js";const ji=[{id:"ceo",name:"CEO",title:"CEO",role:"Chief Executive Officer",description:"Sets direction, reviews proposals, approves work",agentFile:null,reportsTo:null,domains:["Strategy","Direction","Approval"],color:"text-foreground",bgColor:"bg-foreground/10",borderColor:"border-foreground/30",dotColor:"bg-foreground",isCsuite:!0,game:{palette:0,seatId:"seat-1",position:{row:3,col:5},color:"gold",isPlayer:!0}},{id:"sarah",name:"Sarah Chen",title:"CTO",role:"Chief Technology Officer",description:"Architecture, security, code quality, technology intelligence",agentFile:"sarah-cto.md",reportsTo:"ceo",domains:["Architecture","Security","Code Quality","Tech Intelligence"],color:"text-violet-400",bgColor:"bg-violet-500/15",borderColor:"border-violet-500/40",dotColor:"bg-violet-500",isCsuite:!0,game:{palette:1,seatId:"seat-3",position:{row:14,col:5},color:"purple"}},{id:"marcus",name:"Marcus Rivera",title:"CPO",role:"Chief Product Officer",description:"Product strategy, UX, feature prioritization, market intelligence",agentFile:"marcus-cpo.md",reportsTo:"ceo",domains:["Product Strategy","UX","Prioritization","Market Intelligence"],color:"text-blue-400",bgColor:"bg-blue-500/15",borderColor:"border-blue-500/40",dotColor:"bg-blue-500",isCsuite:!0,game:{palette:3,seatId:"seat-4",position:{row:14,col:8},color:"orange"}},{id:"morgan",name:"Morgan Park",title:"COO",role:"Chief Operating Officer",description:"Orchestration, planning, casting, ecosystem intelligence",agentFile:"morgan-coo.md",reportsTo:"ceo",domains:["Planning","Casting","Sequencing","Ecosystem Intelligence"],color:"text-emerald-400",bgColor:"bg-emerald-500/15",borderColor:"border-emerald-500/40",dotColor:"bg-emerald-500",isCsuite:!0,game:{palette:2,seatId:"seat-12",position:{row:20,col:8},color:"green"}},{id:"priya",name:"Priya Sharma",title:"CMO",role:"Chief Marketing Officer",description:"Growth, SEO, positioning, growth intelligence",agentFile:"priya-cmo.md",reportsTo:"ceo",domains:["Growth","SEO","Positioning","Growth Intelligence"],color:"text-amber-400",bgColor:"bg-amber-500/15",borderColor:"border-amber-500/40",dotColor:"bg-amber-500",isCsuite:!0,game:{palette:4,seatId:"seat-5",position:{row:14,col:11},color:"pink"}},{id:"riley",name:"Riley Kim",title:"FE",role:"Frontend Developer",description:"React, Tailwind, component architecture, UI implementation",agentFile:"riley-frontend.md",reportsTo:"sarah",domains:["React","Tailwind","Components","UI"],color:"text-pink-400",bgColor:"bg-pink-500/15",borderColor:"border-pink-500/40",dotColor:"bg-pink-500",isCsuite:!1,game:{palette:6,seatId:"seat-6",position:{row:14,col:14},color:"pink"}},{id:"jordan",name:"Jordan Okafor",title:"BE",role:"Backend Developer",description:"Server, API, database, infrastructure implementation",agentFile:"jordan-backend.md",reportsTo:"sarah",domains:["Server","API","Database","Infra"],color:"text-teal-400",bgColor:"bg-teal-500/15",borderColor:"border-teal-500/40",dotColor:"bg-teal-500",isCsuite:!1,game:{palette:7,seatId:"seat-7",position:{row:17,col:5},color:"teal"}},{id:"casey",name:"Casey Liu",title:"DE",role:"Data Engineer",description:"Data pipelines, indexing, state management, parsers",agentFile:"casey-data.md",reportsTo:"sarah",domains:["Pipelines","Indexing","State","Parsers"],color:"text-cyan-400",bgColor:"bg-cyan-500/15",borderColor:"border-cyan-500/40",dotColor:"bg-cyan-500",isCsuite:!1,game:{palette:8,seatId:"seat-8",position:{row:17,col:8},color:"cyan"}},{id:"taylor",name:"Taylor Reeves",title:"CB",role:"Content Builder",description:"MDX, copywriting, SEO content, documentation",agentFile:"taylor-content.md",reportsTo:"priya",domains:["MDX","Copywriting","SEO Content","Docs"],color:"text-orange-400",bgColor:"bg-orange-500/15",borderColor:"border-orange-500/40",dotColor:"bg-orange-500",isCsuite:!1,game:{palette:9,seatId:"seat-9",position:{row:17,col:11},color:"orange"}},{id:"sam",name:"Sam Nakamura",title:"QA",role:"QA Engineer",description:"Testing, validation, quality assurance, edge cases",agentFile:"sam-qa.md",reportsTo:"sarah",domains:["Testing","Validation","QA","Edge Cases"],color:"text-lime-400",bgColor:"bg-lime-500/15",borderColor:"border-lime-500/40",dotColor:"bg-lime-500",isCsuite:!1,game:{palette:10,seatId:"seat-10",position:{row:17,col:14},color:"lime"}},{id:"quinn",name:"Quinn Torres",title:"UX",role:"UI/UX Designer",description:"UI design, design review, wireframes, visual consistency, usability",agentFile:"quinn-design.md",reportsTo:"marcus",domains:["UI Design","UX","Wireframes","Visual Review"],color:"text-rose-400",bgColor:"bg-rose-500/15",borderColor:"border-rose-500/40",dotColor:"bg-rose-500",isCsuite:!1,game:{palette:12,seatId:"seat-13",position:{row:20,col:11},color:"rose"}},{id:"devon",name:"Devon Lee",title:"FS",role:"Full-Stack Engineer",description:"Cross-domain work spanning frontend and backend",agentFile:"devon-fullstack.md",reportsTo:"sarah",domains:["Full-Stack","Cross-Domain"],color:"text-indigo-400",bgColor:"bg-indigo-500/15",borderColor:"border-indigo-500/40",dotColor:"bg-indigo-500",isCsuite:!1,game:{palette:11,seatId:"seat-11",position:{row:20,col:5},color:"indigo"}}],Ai=[{id:"engineering",name:"Engineering",description:"Architecture, backend, data, full-stack engineering",leadAgentId:"sarah",memberAgentIds:["sarah","jordan","casey","devon"],color:"text-violet-400",bgColor:"bg-violet-500/10",borderColor:"border-violet-500/30"},{id:"product",name:"Product",description:"Frontend, UX, quality assurance",leadAgentId:"marcus",memberAgentIds:["marcus","riley","quinn","sam"],color:"text-blue-400",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30"},{id:"growth",name:"Growth",description:"Content, SEO, marketing, positioning",leadAgentId:"priya",memberAgentIds:["priya","taylor"],color:"text-amber-400",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30"},{id:"operations",name:"Operations",description:"Planning, orchestration, execution",leadAgentId:"morgan",memberAgentIds:["morgan"],color:"text-emerald-400",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/30"}],xn={agents:ji,teams:Ai},pe=xn.agents.filter(e=>e.game!==null).map((e,t)=>({id:t+1,agentName:e.name.split(" ")[0],agentRole:e.title,palette:e.game.palette,hueShift:e.game.hueShift??0,seatId:e.game.seatId,position:{row:e.game.position.row,col:e.game.position.col},color:e.game.color,isPlayer:!!e.game.isPlayer}));Object.fromEntries(pe.map(e=>[e.agentName==="Marcus"?"X":e.agentName[0],e.agentName]));const pr=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const Ti=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Xi=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const Hs=e=>{const t=Xi(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Ri={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Di=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const Ii=f.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:o="",children:a,iconNode:l,...i},c)=>f.createElement("svg",{ref:c,...Ri,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:pr("lucide",o),...!a&&!Di(i)&&{"aria-hidden":"true"},...i},[...l.map(([d,u])=>f.createElement(d,u)),...Array.isArray(a)?a:[a]]));const H=(e,t)=>{const n=f.forwardRef(({className:s,...o},a)=>f.createElement(Ii,{ref:a,iconNode:t,className:pr(`lucide-${Ti(Hs(e))}`,`lucide-${e}`,s),...o}));return n.displayName=Hs(e),n};const Pi=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ln=H("activity",Pi);const _i=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],hr=H("arrow-left",_i);const Mi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],Fi=H("ban",Mi);const Oi=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Li=H("bell",Oi);const Bi=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Pt=H("book-open",Bi);const $i=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Gi=H("brain",$i);const Wi=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Cs=H("check",Wi);const Hi=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],st=H("chevron-down",Hi);const Ui=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Be=H("chevron-right",Ui);const Yi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ee=H("circle-check",Yi);const zi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],kt=H("circle-x",zi);const Vi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ot=H("circle",Vi);const Ki=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],Zi=H("clipboard-list",Ki);const qi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Lt=H("clock",qi);const Qi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],Ji=H("crosshair",Qi);const el=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],tl=H("crown",el);const nl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ks=H("external-link",nl);const sl=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ol=H("file-text",sl);const rl=[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]],gr=H("fish",rl);const al=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],il=H("folder-kanban",al);const ll=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],xr=H("folder-open",ll);const cl=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],os=H("git-branch",cl);const dl=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],ul=H("history",dl);const fl=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],ml=H("inbox",fl);const pl=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],br=H("lightbulb",pl);const hl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pe=H("loader-circle",hl);const gl=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],yr=H("map",gl);const xl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],bl=H("maximize-2",xl);const yl=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],wl=H("minimize-2",yl);const vl=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Cl=H("pencil",vl);const kl=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Nt=H("play",kl);const Nl=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Sl=H("refresh-cw",Nl);const El=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],rs=H("scroll-text",El);const jl=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Al=H("search",jl);const Tl=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Xl=H("server",Tl);const Rl=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],Ns=H("skip-forward",Rl);const Dl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Il=H("square",Dl);const Pl=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],_l=H("swords",Pl);const Ml=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],wr=H("terminal",Ml);const Fl=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Ol=H("trending-up",Fl);const Ll=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],$e=H("triangle-alert",Ll);const Bl=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],St=H("users",Bl);const $l=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],vr=H("wifi-off",$l);const Gl=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Cr=H("wifi",Gl);const Wl=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],cn=H("x",Wl);const Hl=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],yt=H("zap",Hl),Ul=3600*1e3;function Tn(e){return e?Date.now()-new Date(e).getTime()<Ul:!1}function kr(){const e=J(s=>s.sessions),t=J(s=>s.directiveState),n=J(s=>s.activeDirectives);return f.useMemo(()=>{let s=0;for(const c of e)c.isSubagent||c.status==="done"||(c.status==="waiting-approval"||c.status==="waiting-input"||c.status==="error")&&Tn(c.lastActivity)&&s++;let o=0;for(const c of e)c.isSubagent||c.status==="done"||(c.status==="error"&&Tn(c.lastActivity)||c.status==="waiting-approval"&&Tn(c.lastActivity))&&o++;const a=n&&n.length>0?n:t?[t]:[];for(const c of a)if(c.status==="awaiting_completion")o++;else if(c.pipelineSteps){for(const d of c.pipelineSteps)if(d.needsAction){o++;break}}let l=0;for(const c of a)if(c.status==="failed")l++;else if(c.pipelineSteps){for(const d of c.pipelineSteps)if(d.status==="failed"){l++;break}}return{team:s,tasks:o,status:l,log:0}},[e,t,n])}function Yl(e){return e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})}function zl(e){const t=e.toLocaleDateString("en-US",{weekday:"short"}),n=e.toLocaleDateString("en-US",{month:"short"}),s=e.getDate();return`${t}, ${n} ${s}`}const me={bg:"#5C3D2E",bgLight:"#6B4C3B",text:"#F5ECD7",textDim:"#C4A265",border:"#3D2B1F",highlight:"#C4A265",buttonBg:"#4A2F20",buttonActive:"#3D2B1F",buttonBorder:"inset -1px -1px 0 0 #2A1A10, inset 1px 1px 0 0 #7A5A42",buttonBorderActive:"inset 1px 1px 0 0 #2A1A10, inset -1px -1px 0 0 #7A5A42"};function Tt({icon:e,label:t,onClick:n,active:s,ariaLabel:o,badge:a,glow:l}){return r.jsxs("button",{type:"button",onClick:n,"aria-label":o,className:"flex items-center gap-1.5 px-2.5 py-1 font-mono text-[12px] select-none transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-400",style:{backgroundColor:s?me.buttonActive:me.buttonBg,color:s?me.highlight:me.text,imageRendering:"pixelated",borderRadius:"2px",boxShadow:[s?me.buttonBorderActive:me.buttonBorder,l?`0 0 8px ${me.highlight}40`:""].filter(Boolean).join(", "),...s?{textShadow:`0 0 6px ${me.highlight}40`}:{}},children:[r.jsx("span",{"aria-hidden":"true",className:"flex items-center",children:e}),t&&r.jsx("span",{children:t}),a!==void 0&&a>0&&r.jsx("span",{className:"ml-0.5 min-w-[18px] text-center px-1 rounded text-[10px] font-bold leading-tight",style:{backgroundColor:"#B83A2A",color:"#fff",boxShadow:"inset -1px -1px 0 0 #8A2010, inset 1px 1px 0 0 #D05040"},children:a})]})}function Vl({onPanelRequest:e,gameContainerRef:t,activePanel:n}){const s=kr(),[o,a]=f.useState(!1);f.useEffect(()=>{const m=()=>a(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",m),()=>document.removeEventListener("fullscreenchange",m)},[]);const l=f.useCallback(()=>{document.fullscreenElement?document.exitFullscreen():(t?.current??document.documentElement).requestFullscreen()},[t]),[i,c]=f.useState(()=>new Date);f.useEffect(()=>{const m=setInterval(()=>c(new Date),1e3);return()=>clearInterval(m)},[]),s.team+s.tasks;const d=zl(i),u=Yl(i);return r.jsxs("header",{className:"px-3 sm:px-4 py-1.5 flex items-center justify-between text-sm select-none",style:{backgroundColor:me.bg,color:me.text,imageRendering:"pixelated",borderBottom:`2px solid ${me.border}`,boxShadow:`inset 0 1px 0 0 ${me.bgLight}`},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-mono font-bold text-base tracking-tight",style:{color:me.highlight,textShadow:`0 1px 2px ${me.border}`},children:"Office"}),r.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-400 inline-block",style:{boxShadow:"0 0 4px #34d399"},"aria-label":"Connected"})]}),r.jsxs("div",{className:"hidden sm:flex items-center gap-2 font-mono text-xs",style:{color:me.textDim},children:[r.jsx("span",{children:d}),r.jsx("span",{style:{color:me.border},"aria-hidden":"true",children:"•"}),r.jsx("span",{className:"tabular-nums",style:{color:me.text},children:u})]}),r.jsx("span",{className:"sm:hidden font-mono text-xs tabular-nums",style:{color:me.text},children:u}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Tt,{icon:r.jsx(St,{className:"h-3.5 w-3.5"}),label:"Team",onClick:()=>e?.("team"),active:n==="team",ariaLabel:"Team overview",badge:s.team>0?s.team:void 0}),r.jsx(Tt,{icon:r.jsx(yt,{className:"h-3.5 w-3.5"}),label:"Tasks",onClick:()=>e?.("tasks"),active:n==="tasks",ariaLabel:"Tasks and directives",badge:s.tasks>0?s.tasks:void 0}),r.jsx(Tt,{icon:r.jsx(ln,{className:"h-3.5 w-3.5"}),label:"Status",onClick:()=>e?.("status"),active:n==="status",ariaLabel:"System status",badge:s.status>0?s.status:void 0}),r.jsx(Tt,{icon:r.jsx(rs,{className:"h-3.5 w-3.5"}),label:"Log",onClick:()=>e?.("log"),active:n==="log",ariaLabel:"Activity log"}),r.jsx(Tt,{icon:o?r.jsx(wl,{className:"h-3.5 w-3.5"}):r.jsx(bl,{className:"h-3.5 w-3.5"}),label:"",onClick:l,ariaLabel:o?"Exit fullscreen":"Enter fullscreen"})]})]})}const I=16,Xn=24,Rn=14,Us=48,Gt=.15,Ys=.3,Dn=2,In=20,as=3,is=6,Kl=120,Zl=240,zs=8,ql=15,Vs=.3,Ql=4,Nr=.3,Xt=6,Sr=16,Ks=24,Jl=30,ec=180,Zs=.3,qs="#ccffcc",tc=.6,Qs=.5,Js=.33,eo=.66,dn=6,nc=.5,Pn=.001,sc=1,oc=.5,to=.5,rc=10,ls=24,Er="#808080",ac="rgba(0, 127, 212, 0.35)",ic="rgba(0, 200, 80, 0.35)",lc="rgba(220, 50, 50, 0.35)",cc=.1,no=.5,so=.3,jr=28,Ar=10,_n=2,dc=1,uc=.6,Tr=9,fc=2,mc={gold:"#FFD700",purple:"#8B5CF6",green:"#10B981",orange:"#F97316",pink:"#EC4899",teal:"#14B8A6",cyan:"#06B6D4",lime:"#84CC16",indigo:"#6366F1",rose:"#F43F5E"},pc=.1,hc=2,gc=.3,oo=30,ro=60,ao=6,xc=45,bc=271,yc=3,wc=2,io=8,vc=24,Cc=.5,lo=2,kc=5,co=3,Wt="#FFD700",Nc=.6,nn=.3,Sc="rgba(255, 50, 50, 0.4)",Ec=2,jc=.15,Ac=.1,Tc=3,Te={WALL:0,FLOOR_1:1,FLOOR_2:2,FLOOR_3:3,FLOOR_4:4,VOID:8},Y={IDLE:"idle",WALK:"walk",TYPE:"type"},L={DOWN:0,LEFT:1,RIGHT:2,UP:3},$={DESK:"desk",BOOKSHELF:"bookshelf",PLANT:"plant",COOLER:"cooler",WHITEBOARD:"whiteboard",CHAIR:"chair",PC:"pc",LAMP:"lamp",COUCH:"couch",SERVER_RACK:"server_rack",COFFEE_TABLE:"coffee_table",FILING_CABINET:"filing_cabinet",MONITOR:"monitor",LAPTOP:"laptop",EXEC_CHAIR:"exec_chair",VENDING_MACHINE:"vending_machine",AC_UNIT:"ac_unit",WALL_ART:"wall_art",COPIER:"copier",TV_SCREEN:"tv_screen",PRINTER:"printer"},Xr=[24,146,146,146,146,146,146,146,146,146,146,146,146,146,146,146,12,178,178,178,178,178,178,178,178,178,178,178,178,178,178,26,40,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,28,194,194,194,194,194,194,194,194,194,194,194,194,194,194,42,40,155,124,124,124,124,124,124,124,124,156,156,156,156,156,156,28,91,92,92,92,92,92,92,92,92,92,92,92,92,92,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,171,172,172,172,172,172,172,172,172,172,172,172,172,172,172,28,107,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,177,178,178,178,178,178,178,178,178,178,178,178,172,172,178,185,178,178,178,178,178,108,108,108,178,178,178,178,178,178,42,40,193,194,194,194,194,194,194,194,194,194,194,194,139,140,194,201,194,194,194,194,194,107,108,108,194,194,194,194,194,194,42,40,91,92,92,92,92,92,92,92,92,92,92,92,108,108,92,92,92,92,92,92,92,93,108,108,92,92,92,92,92,92,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,107,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,42,40,81,82,82,82,82,82,82,82,82,82,82,82,82,110,111,111,111,82,82,82,82,82,82,82,82,82,82,82,82,83,42,40,98,98,98,98,98,98,98,98,98,98,98,98,98,110,111,111,111,98,98,98,98,98,98,98,98,98,98,98,98,99,42,40,94,95,95,95,95,95,95,95,95,95,95,95,95,96,111,111,111,95,95,95,95,95,95,95,95,95,95,95,95,95,42,40,110,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,42,40,110,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,42,40,110,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,42,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58],Xc=[0,0,417,418,0,424,425,426,427,458,459,428,429,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,424,425,0,0,423,433,434,449,440,441,442,443,474,475,0,0,0,841,842,0,0,0,0,0,0,0,0,0,0,0,0,0,440,441,0,0,439,156,156,465,388,457,156,156,156,0,0,0,0,857,858,0,343,0,0,0,0,0,0,0,0,0,0,0,456,457,0,0,455,172,172,172,404,172,0,0,0,0,0,0,0,873,874,0,359,0,0,0,387,0,0,0,387,0,0,0,0,0,0,0,171,172,172,172,404,172,0,0,0,0,885,523,499,500,501,0,375,0,0,0,403,0,0,0,403,0,0,0,0,0,0,0,171,172,172,172,172,172,0,0,0,885,885,523,515,516,517,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,171,172,275,275,275,276,0,0,0,0,531,885,531,532,533,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,171,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1021,1022,0,0,0,0,0,0,0,0,0,0,0,0,391,0,359,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1037,1038,0,0,0,0,0,0,0,0,0,0,0,0,407,0,375,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,394,395,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,477,0,0,410,411,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,493,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,509,0,355,0,0,356,0,0,356,0,0,356,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,641,642,371,644,645,372,647,645,372,647,645,372,647,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,657,658,659,660,661,662,663,661,662,663,661,662,663,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,673,674,675,676,677,678,679,677,678,679,677,678,679,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,356,0,0,355,0,0,355,0,0,355,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,641,642,372,644,645,371,647,645,371,647,645,371,647,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,657,658,659,660,661,662,663,661,662,663,661,662,663,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,673,674,675,676,677,678,679,677,678,679,677,678,679,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Rc=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,394,395,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,411,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,225,227,227,227,227,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,241,243,243,243,243,243,244,0,0,0,0,0,0,0,0,0,0,777,231,232,232,232,232,232,232,232,233,926,0,0,0,0,257,259,259,259,259,259,260,0,0,0,0,0,0,0,0,0,0,793,247,248,248,248,248,248,248,248,249,942,0,0,0,0,273,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,263,264,264,264,264,264,264,264,265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,709,710,711,709,710,711,709,710,711,709,710,711,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,712,713,714,712,713,714,712,713,714,712,713,714,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,729,730,728,729,730,728,729,730,728,729,730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,709,710,711,709,710,711,709,710,711,709,710,711,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,712,713,714,712,713,714,712,713,714,712,713,714,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,729,730,728,729,730,728,729,730,728,729,730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Dc=[0,0,0,0,0,0,0,0,0,0,0,0,0,392,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,408,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,595,596,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,611,612,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,359,0,0,0,0,0,0,0,627,628,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,375,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,347,0,0,348,0,0,348,491,0,348,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,380,0,0,438,0,0,0,0,0,450,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,893,894,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,909,910,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,599,600,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,540,348,0,0,348,491,0,348,0,0,348,491,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,604,648,0,0,422,0,0,648,511,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,620,664,0,0,0,0,0,664,527,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ic=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,477,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,493,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,509,0,0,0,0,0,0,0,0,0,0,0,0,451,0,0,0,0,0,0,0,357,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,467,380,421,398,399,400,348,0,373,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,450,0,0,414,415,416,364,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,431,0,380,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,354,0,0,0,354,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,370,0,0,0,370,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,431,432,0,447,0,430,431,0,0,447,480,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,354,0,0,463,0,0,354,0,0,463,496,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,370,0,0,370,0,0,370,0,0,370,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,430,431,0,0,431,432,0,447,448,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,354,0,0,354,0,0,354,0,0,354,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,370,0,0,370,0,0,370,0,0,370,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Pc=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,354,0,0,0,0,0,354,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,370,0,0,0,0,0,370,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],_c=new Set([12,24,26,28,40,42,56,57,58,146,162,177,178,185,193,194,201]);function Mc(e){return e.map(t=>_c.has(t)?Te.WALL:Te.FLOOR_1)}const Fc=Mc(Xr),Ne=L.DOWN,Oe=L.UP,Oc=L.LEFT,Lc=L.RIGHT,Bc=[{col:5,row:3,dir:Ne},{col:9,row:4,dir:Oc},{col:5,row:14,dir:Ne},{col:8,row:14,dir:Ne},{col:11,row:14,dir:Ne},{col:14,row:14,dir:Ne},{col:5,row:17,dir:Oe},{col:8,row:17,dir:Oe},{col:11,row:17,dir:Oe},{col:14,row:17,dir:Oe},{col:5,row:20,dir:Ne},{col:8,row:20,dir:Ne},{col:11,row:20,dir:Ne},{col:14,row:20,dir:Ne},{col:5,row:23,dir:Oe},{col:8,row:23,dir:Oe},{col:11,row:23,dir:Oe},{col:14,row:23,dir:Oe},{col:15,row:5,dir:Ne},{col:18,row:5,dir:Lc},{col:21,row:4,dir:Ne},{col:25,row:4,dir:Ne},{col:28,row:5,dir:Ne},{col:21,row:7,dir:Oe},{col:25,row:7,dir:Oe}],$c={version:1,cols:32,rows:32,tiles:Fc,furniture:[],gidLayers:[Xr,Xc,Rc,Dc,Ic,Pc],seatPositions:Bc};function Se(e,t,n,s){const o=n.length,a=o>0?n[0].length:0;if(t<0||t>=o||e<0||e>=a)return!1;const l=n[t][e];return!(l===Te.WALL||l===Te.VOID||s.has(`${e},${t}`))}function uo(e,t){const n=e.length,s=n>0?e[0].length:0,o=[];for(let a=0;a<n;a++)for(let l=0;l<s;l++)Se(l,a,e,t)&&o.push({col:l,row:a});return o}function ze(e,t,n,s,o,a){if(e===n&&t===s)return[];const l=(x,b)=>`${x},${b}`,i=l(e,t),c=l(n,s);if(!Se(n,s,o,a))return[];const u=new Set;u.add(i);const m=new Map,h=[{col:e,row:t}],p=[{dc:0,dr:-1},{dc:0,dr:1},{dc:-1,dr:0},{dc:1,dr:0}];for(;h.length>0;){const x=h.shift(),b=l(x.col,x.row);if(b===c){const w=[];let y=c;for(;y!==i;){const[S,N]=y.split(",").map(Number);w.unshift({col:S,row:N}),y=m.get(y)}return w}for(const w of p){const y=x.col+w.dc,S=x.row+w.dr,N=l(y,S);u.has(N)||Se(y,S,o,a)&&(u.add(N),m.set(N,b),h.push({col:y,row:S}))}}return[]}const Gc=(e,t,n)=>null,Wc=e=>Ql,Hc=new Set(["Read","Grep","Glob","WebFetch","WebSearch"]);function Uc(e){return e?Hc.has(e):!1}function Qe(e,t){return{x:e*I+I/2,y:t*I+I/2}}function Mn(e,t,n,s){const o=n-e,a=s-t;return o>0?L.RIGHT:o<0?L.LEFT:a>0?L.DOWN:L.UP}function Ht(e,t,n,s,o=0){const a=s?s.seatCol:1,l=s?s.seatRow:1,i=Qe(a,l);return{id:e,state:Y.TYPE,dir:s?s.facingDir:L.DOWN,x:i.x,y:i.y,tileCol:a,tileRow:l,path:[],moveProgress:0,currentTool:null,palette:t,hueShift:o,frame:0,frameTimer:0,wanderTimer:0,wanderCount:0,wanderLimit:cs(as,is),isActive:!0,seatId:n,bubbleType:null,bubbleTimer:0,seatTimer:0,isSubagent:!1,parentAgentId:null,matrixEffect:null,matrixEffectTimer:0,matrixEffectSeeds:[],agentStatus:"offline",sessionInfo:{},pendingStatus:null,statusChangeTimer:0,hasError:!1,isPlayerControlled:!1,lingerTimer:0,isBusy:!1,routingZone:null,originalSeatId:null,personalityTimer:0,personalityFrame:-1,personalityThreshold:8+Math.random()*7,isNearPlayer:!1,blockedTile:null}}function fo(e){e.personalityFrame=-1,e.personalityTimer=0,e.personalityThreshold=8+Math.random()*7}function Fn(e){let t=0,n=0;return(e.has("w")||e.has("arrowup"))&&(n-=1),(e.has("s")||e.has("arrowdown"))&&(n+=1),(e.has("a")||e.has("arrowleft"))&&(t-=1),(e.has("d")||e.has("arrowright"))&&(t+=1),t===0&&n===0?null:(t!==0&&n!==0&&(t=0),{dc:t,dr:n})}function Yc(e,t,n,s,o,a,l){if(e.frameTimer+=t,e.isPlayerControlled){if(e.state===Y.WALK){if(e.frameTimer>=Gt&&(e.frameTimer-=Gt,e.frame=(e.frame+1)%4),e.path.length===0){const m=l?Fn(l):null;if(m){const h=e.tileCol+m.dc,p=e.tileRow+m.dr;if(Se(h,p,o,a))e.path=[{col:h,row:p}],e.moveProgress=0;else{e.blockedTile={col:h,row:p};const x=Qe(e.tileCol,e.tileRow);e.x=x.x,e.y=x.y,e.state=Y.IDLE,e.frame=0,e.frameTimer=0}}else{const h=Qe(e.tileCol,e.tileRow);e.x=h.x,e.y=h.y,e.state=Y.IDLE,e.frame=0,e.frameTimer=0}return}const i=e.path[0];e.dir=Mn(e.tileCol,e.tileRow,i.col,i.row),e.moveProgress+=Us/I*t;const c=Qe(e.tileCol,e.tileRow),d=Qe(i.col,i.row),u=Math.min(e.moveProgress,1);if(e.x=c.x+(d.x-c.x)*u,e.y=c.y+(d.y-c.y)*u,e.moveProgress>=1&&(e.tileCol=i.col,e.tileRow=i.row,e.x=d.x,e.y=d.y,e.path.shift(),e.moveProgress=0,e.path.length===0&&l)){const m=Fn(l);if(m){const h=e.tileCol+m.dc,p=e.tileRow+m.dr;Se(h,p,o,a)&&(e.path=[{col:h,row:p}],e.moveProgress=0)}}}else if(e.state===Y.IDLE&&l&&l.size>0){const i=Fn(l);if(i){const c=e.tileCol+i.dc,d=e.tileRow+i.dr;Se(c,d,o,a)?(e.path=[{col:c,row:d}],e.moveProgress=0,e.state=Y.WALK,e.frame=0,e.frameTimer=0,e.dir=Mn(e.tileCol,e.tileRow,c,d)):e.blockedTile={col:c,row:d}}}return}switch(e.state){case Y.TYPE:{if(e.personalityFrame>=0&&fo(e),e.frameTimer>=Ys&&(e.frameTimer-=Ys,e.frame=(e.frame+1)%2),!e.isActive&&!e.routingZone){if(e.seatTimer>0){e.seatTimer-=t;break}e.seatTimer=0,e.state=Y.IDLE,e.frame=0,e.frameTimer=0,e.wanderTimer=Ut(Dn,In),e.wanderCount=0,e.wanderLimit=cs(as,is)}break}case Y.IDLE:{if(e.personalityFrame<0&&(e.frame=0),e.seatTimer<0&&(e.seatTimer=0),e.isPlayerControlled||(e.personalityFrame===-1?(e.personalityTimer+=t,e.personalityTimer>=e.personalityThreshold&&(e.personalityFrame=0,e.frameTimer=0)):e.frameTimer>=Vs&&(e.frameTimer-=Vs,e.personalityFrame++,e.personalityFrame>=Wc(e.palette)&&(e.personalityFrame=-1,e.personalityTimer=0,e.personalityThreshold=zs+Math.random()*(ql-zs),e.frame=0))),e.isActive){if(!e.seatId){e.state=Y.TYPE,e.frame=0,e.frameTimer=0;break}const i=s.get(e.seatId);if(i){const c=ze(e.tileCol,e.tileRow,i.seatCol,i.seatRow,o,a);c.length>0?(e.path=c,e.moveProgress=0,e.state=Y.WALK,e.frame=0,e.frameTimer=0):(e.state=Y.TYPE,e.dir=i.facingDir,e.frame=0,e.frameTimer=0)}break}if(e.routingZone&&e.seatId){const i=s.get(e.seatId);i&&e.tileCol===i.seatCol&&e.tileRow===i.seatRow&&(e.state=Y.TYPE,e.dir=i.facingDir,e.frame=0,e.frameTimer=0);break}if(e.routingZone)break;if(e.wanderTimer-=t,e.wanderTimer<=0){if(e.wanderCount>=e.wanderLimit&&e.seatId){const i=s.get(e.seatId);if(i){const c=ze(e.tileCol,e.tileRow,i.seatCol,i.seatRow,o,a);if(c.length>0){e.path=c,e.moveProgress=0,e.state=Y.WALK,e.frame=0,e.frameTimer=0;break}}}if(n.length>0){const i=n[Math.floor(Math.random()*n.length)],c=ze(e.tileCol,e.tileRow,i.col,i.row,o,a);c.length>0&&(e.path=c,e.moveProgress=0,e.state=Y.WALK,e.frame=0,e.frameTimer=0,e.wanderCount++)}e.wanderTimer=Ut(Dn,In)}break}case Y.WALK:{if(e.personalityFrame>=0&&fo(e),e.frameTimer>=Gt&&(e.frameTimer-=Gt,e.frame=(e.frame+1)%4),e.path.length===0){const m=Qe(e.tileCol,e.tileRow);if(e.x=m.x,e.y=m.y,e.isActive)if(!e.seatId)e.state=Y.TYPE;else{const h=s.get(e.seatId);h&&e.tileCol===h.seatCol&&e.tileRow===h.seatRow?(e.state=Y.TYPE,e.dir=h.facingDir):e.state=Y.IDLE}else{if(e.seatId){const h=s.get(e.seatId);if(h&&e.tileCol===h.seatCol&&e.tileRow===h.seatRow){e.state=Y.TYPE,e.dir=h.facingDir,e.seatTimer<0?e.seatTimer=0:e.seatTimer=Ut(Kl,Zl),e.wanderCount=0,e.wanderLimit=cs(as,is),e.frame=0,e.frameTimer=0;break}}e.state=Y.IDLE,e.wanderTimer=Ut(Dn,In)}e.frame=0,e.frameTimer=0;break}const i=e.path[0];e.dir=Mn(e.tileCol,e.tileRow,i.col,i.row),e.moveProgress+=Us/I*t;const c=Qe(e.tileCol,e.tileRow),d=Qe(i.col,i.row),u=Math.min(e.moveProgress,1);if(e.x=c.x+(d.x-c.x)*u,e.y=c.y+(d.y-c.y)*u,e.moveProgress>=1&&(e.tileCol=i.col,e.tileRow=i.row,e.x=d.x,e.y=d.y,e.path.shift(),e.moveProgress=0),e.isActive&&e.seatId){const m=s.get(e.seatId);if(m){const h=e.path[e.path.length-1];if(!h||h.col!==m.seatCol||h.row!==m.seatRow){const p=ze(e.tileCol,e.tileRow,m.seatCol,m.seatRow,o,a);p.length>0&&(e.path=p,e.moveProgress=0)}}}break}}}function zc(e,t){switch(e.state){case Y.TYPE:return Uc(e.currentTool)?t.reading[e.dir][e.frame%2]:t.typing[e.dir][e.frame%2];case Y.WALK:return t.walk[e.dir][e.frame%4];case Y.IDLE:return e.personalityFrame>=0&&Gc(e.palette,e.dir,e.personalityFrame),t.walk[e.dir][1];default:return t.walk[e.dir][1]}}function Ut(e,t){return e+Math.random()*(t-e)}function cs(e,t){return e+Math.floor(Math.random()*(t-e+1))}function On(e,t,n){const s=Math.floor(n*Jl);return(e*7+t*13+s*31&255)<ec}function Rt(){const e=[];for(let t=0;t<Sr;t++)e.push(Math.random());return e}function Vc(e,t,n,s,o,a){const l=t.matrixEffectTimer/Nr,i=t.matrixEffect==="spawn",c=t.matrixEffectTimer,d=Ks+Xt;for(let u=0;u<Sr;u++){const m=(t.matrixEffectSeeds[u]??0)*Zs,p=Math.max(0,Math.min(1,(l-m)/(1-Zs)))*d;for(let x=0;x<Ks;x++){const b=n[x]?.[u],w=b&&b!=="",y=p-x,S=s+u*a,N=o+x*a;if(i){if(y<0)continue;if(y<1)e.fillStyle=qs,e.fillRect(S,N,a,a);else if(y<Xt){const v=y/Xt;if(w){e.fillStyle=b,e.fillRect(S,N,a,a);const k=(1-v)*tc;On(u,x,c)&&(e.fillStyle=`rgba(0, 255, 65, ${k})`,e.fillRect(S,N,a,a))}else if(On(u,x,c)){const k=(1-v)*Qs;e.fillStyle=v<Js?`rgba(0, 255, 65, ${k})`:v<eo?`rgba(0, 170, 40, ${k})`:`rgba(0, 85, 20, ${k})`,e.fillRect(S,N,a,a)}}else w&&(e.fillStyle=b,e.fillRect(S,N,a,a))}else if(y<0)w&&(e.fillStyle=b,e.fillRect(S,N,a,a));else if(y<1)e.fillStyle=qs,e.fillRect(S,N,a,a);else if(y<Xt&&On(u,x,c)){const v=y/Xt,k=(1-v)*Qs;e.fillStyle=v<Js?`rgba(0, 255, 65, ${k})`:v<eo?`rgba(0, 170, 40, ${k})`:`rgba(0, 85, 20, ${k})`,e.fillRect(S,N,a,a)}}}}const Ss={"ceo-office":{id:"ceo-office",label:"Manager Office",bounds:{minCol:1,maxCol:15,minRow:2,maxRow:10},waypoints:[{col:3,row:7},{col:7,row:7},{col:10,row:7},{col:3,row:9},{col:7,row:9}]},meeting:{id:"meeting",label:"Conference Room",bounds:{minCol:17,maxCol:30,minRow:2,maxRow:10},waypoints:[{col:20,row:8},{col:23,row:8},{col:26,row:8},{col:20,row:3},{col:26,row:3}]},workspace:{id:"workspace",label:"Open Workspace",bounds:{minCol:1,maxCol:30,minRow:12,maxRow:25},waypoints:[{col:2,row:13},{col:2,row:18},{col:16,row:13},{col:16,row:18},{col:16,row:24}]},"server-room":{id:"server-room",label:"Server Room",bounds:{minCol:1,maxCol:8,minRow:27,maxRow:30},waypoints:[{col:2,row:28},{col:4,row:29},{col:6,row:28},{col:3,row:30}]},"break-room":{id:"break-room",label:"Break Room",bounds:{minCol:20,maxCol:30,minRow:27,maxRow:30},waypoints:[{col:22,row:28},{col:25,row:29},{col:28,row:28},{col:24,row:30}]},lobby:{id:"lobby",label:"Lobby",bounds:{minCol:1,maxCol:30,minRow:25,maxRow:31},waypoints:[{col:10,row:28},{col:15,row:29},{col:18,row:28}]}},Kc=new Set(["Bash","bash","server","deploy","docker","npm","yarn","bun","prisma","migration"]);function Zc(e){if(!e)return!1;const t=e.toLowerCase();return Kc.has(e)?!0:t.includes("server")||t.includes("deploy")||t.includes("docker")}function qc(e){return e?e.includes("Agent")||e.includes("agent"):!1}function Qc(e,t,n){switch(t){case"working":return qc(n.toolName)?lt("meeting"):Zc(n.toolName)?lt("server-room"):null;case"waiting":return null;case"paused":return null;case"done":return lt("break-room");case"idle":return lt("break-room");case"error":return null;case"offline":return lt("break-room");default:return null}}function lt(e){const t=Ss[e],n=t.waypoints[Math.floor(Math.random()*t.waypoints.length)];return{zoneId:e,waypoint:n}}function Rr(e,t){for(const n of["ceo-office","meeting","workspace","server-room","break-room","lobby"]){const o=Ss[n].bounds;if(e>=o.minCol&&e<=o.maxCol&&t>=o.minRow&&t<=o.maxRow)return n}return null}const ds=new Map;function Dr(e,t,n){const s=ds.get(e);if(s)return s;const o=n.colorize?e0(t,n):Pr(t,n);return ds.set(e,o),o}function Jc(){ds.clear()}function e0(e,t){const{h:n,s,b:o,c:a}=t,l=[];for(const i of e){const c=[];for(const d of i){if(d===""){c.push("");continue}const u=parseInt(d.slice(1,3),16),m=parseInt(d.slice(3,5),16),h=parseInt(d.slice(5,7),16);let p=(.299*u+.587*m+.114*h)/255;if(a!==0){const w=(100+a)/100;p=.5+(p-.5)*w}o!==0&&(p=p+o/200),p=Math.max(0,Math.min(1,p));const x=s/100,b=Ir(n,x,p);c.push(b)}l.push(c)}return l}function Ir(e,t,n){const s=(1-Math.abs(2*n-1))*t,o=e/60,a=s*(1-Math.abs(o%2-1));let l=0,i=0,c=0;o<1?(l=s,i=a,c=0):o<2?(l=a,i=s,c=0):o<3?(l=0,i=s,c=a):o<4?(l=0,i=a,c=s):o<5?(l=a,i=0,c=s):(l=s,i=0,c=a);const d=n-s/2,u=Math.round((l+d)*255),m=Math.round((i+d)*255),h=Math.round((c+d)*255);return`#${Ln(u).toString(16).padStart(2,"0")}${Ln(m).toString(16).padStart(2,"0")}${Ln(h).toString(16).padStart(2,"0")}`.toUpperCase()}function Ln(e){return Math.max(0,Math.min(255,e))}function t0(e,t,n){const s=e/255,o=t/255,a=n/255,l=Math.max(s,o,a),i=Math.min(s,o,a),c=(l+i)/2;if(l===i)return[0,0,c];const d=l-i,u=c>.5?d/(2-l-i):d/(l+i);let m=0;return l===s?m=((o-a)/d+(o<a?6:0))*60:l===o?m=((a-s)/d+2)*60:m=((s-o)/d+4)*60,[m,u,c]}function Pr(e,t){const{h:n,s,b:o,c:a}=t,l=[];for(const i of e){const c=[];for(const d of i){if(d===""){c.push("");continue}const u=parseInt(d.slice(1,3),16),m=parseInt(d.slice(3,5),16),h=parseInt(d.slice(5,7),16),[p,x,b]=t0(u,m,h),w=((p+n)%360+360)%360,y=Math.max(0,Math.min(1,x+s/100));let S=b;if(a!==0){const v=(100+a)/100;S=.5+(S-.5)*v}o!==0&&(S=S+o/200),S=Math.max(0,Math.min(1,S));const N=Ir(w,y,S);c.push(N)}l.push(c)}return l}const R="",Et=[["#808080"]],bn=[new Array(32).fill("#808080")],_r=Array.from({length:32},()=>["#808080"]);Array.from({length:32},()=>new Array(32).fill("#808080"));const n0=bn,s0=_r,o0=Et,Bn=Et,mo=bn,po=Et,$n=Et,ho=Et,r0=bn,a0=_r,i0=bn,Gn=Et,l0=(()=>{const e="#555566",t="#EEEEFF",n="#CCA700";return[[e,e,e,e,e,e,e,e,e,e,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,n,t,n,t,n,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,e,e,e,e,e,e,e,e,e,e],[R,R,R,R,e,e,e,R,R,R,R],[R,R,R,R,R,e,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R]]})(),c0=(()=>{const e="#555566",t="#EEEEFF",n="#44BB66";return[[R,e,e,e,e,e,e,e,e,e,R],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,n,t,e],[e,t,t,t,t,t,t,n,t,t,e],[e,t,t,n,t,t,n,t,t,t,e],[e,t,t,t,n,n,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[e,t,t,t,t,t,t,t,t,t,e],[R,e,e,e,e,e,e,e,e,e,R],[R,R,R,R,e,e,e,R,R,R,R],[R,R,R,R,R,e,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R]]})(),d0=(()=>{const e="#555566",t="#EEEEFF",n="#6688CC";return[[R,e,e,e,e,e,R],[e,t,t,t,t,t,e],[e,t,n,t,n,t,e],[e,t,t,t,t,t,e],[R,e,e,e,e,e,R],[R,R,e,e,R,R,R],[R,R,R,e,R,R,R]]})();let _t=null;function u0(e){_t=e,us.clear()}function f0(e){return e.map(t=>[...t].reverse())}const us=new Map;function m0(e,t){const n={h:t,s:0,b:0,c:0},s=l=>Pr(l,n),o=l=>[s(l[0]),s(l[1]),s(l[2]),s(l[3])],a=l=>[s(l[0]),s(l[1])];return{walk:{[L.DOWN]:o(e.walk[L.DOWN]),[L.UP]:o(e.walk[L.UP]),[L.RIGHT]:o(e.walk[L.RIGHT]),[L.LEFT]:o(e.walk[L.LEFT])},typing:{[L.DOWN]:a(e.typing[L.DOWN]),[L.UP]:a(e.typing[L.UP]),[L.RIGHT]:a(e.typing[L.RIGHT]),[L.LEFT]:a(e.typing[L.LEFT])},reading:{[L.DOWN]:a(e.reading[L.DOWN]),[L.UP]:a(e.reading[L.UP]),[L.RIGHT]:a(e.reading[L.RIGHT]),[L.LEFT]:a(e.reading[L.LEFT])}}}function p0(e,t=0){if(!_t)return null;const n=`${e}:${t}`,s=us.get(n);if(s)return s;const o=_t[e<_t.length?e:e%_t.length],a=o.down,l=o.up,i=o.right,c=f0,d=o.left,u=h=>d?d[h]:c(i[h]);let m={walk:{[L.DOWN]:[a[0],a[1],a[2],a[1]],[L.UP]:[l[0],l[1],l[2],l[1]],[L.RIGHT]:[i[0],i[1],i[2],i[1]],[L.LEFT]:[u(0),u(1),u(2),u(1)]},typing:{[L.DOWN]:[a[3],a[4]],[L.UP]:[l[3],l[4]],[L.RIGHT]:[i[3],i[4]],[L.LEFT]:[u(3),u(4)]},reading:{[L.DOWN]:[a[5],a[6]],[L.UP]:[l[5],l[6]],[L.RIGHT]:[i[5],i[6]],[L.LEFT]:[u(5),u(6)]}};return t!==0&&(m=m0(m,t)),us.set(n,m),m}const Mr=[{type:$.DESK,label:"Desk",footprintW:2,footprintH:1,sprite:n0,isDesk:!0,category:"desks"},{type:$.BOOKSHELF,label:"Bookshelf",footprintW:1,footprintH:2,sprite:s0,isDesk:!1,category:"storage"},{type:$.PLANT,label:"Plant",footprintW:1,footprintH:1,sprite:o0,isDesk:!1,category:"decor"},{type:$.COOLER,label:"Cooler",footprintW:1,footprintH:1,sprite:Bn,isDesk:!1,category:"misc"},{type:$.WHITEBOARD,label:"Whiteboard",footprintW:2,footprintH:1,sprite:mo,isDesk:!1,category:"wall"},{type:$.CHAIR,label:"Chair",footprintW:1,footprintH:1,sprite:po,isDesk:!1,category:"chairs"},{type:$.PC,label:"Monitor",footprintW:1,footprintH:1,sprite:$n,isDesk:!1,category:"electronics",canPlaceOnSurfaces:!0},{type:$.LAMP,label:"Lamp",footprintW:1,footprintH:1,sprite:ho,isDesk:!1,category:"decor",canPlaceOnSurfaces:!0},{type:$.COUCH,label:"Couch",footprintW:2,footprintH:1,sprite:r0,isDesk:!1,category:"misc"},{type:$.SERVER_RACK,label:"Server Rack",footprintW:1,footprintH:2,sprite:a0,isDesk:!1,category:"electronics"},{type:$.COFFEE_TABLE,label:"Coffee Table",footprintW:2,footprintH:1,sprite:i0,isDesk:!1,category:"desks"},{type:$.FILING_CABINET,label:"Filing Cabinet",footprintW:1,footprintH:1,sprite:Gn,isDesk:!1,category:"storage"},{type:$.MONITOR,label:"Monitor",footprintW:1,footprintH:1,sprite:$n,isDesk:!1,category:"electronics",canPlaceOnSurfaces:!0},{type:$.LAPTOP,label:"Laptop",footprintW:1,footprintH:1,sprite:$n,isDesk:!1,category:"electronics",canPlaceOnSurfaces:!0},{type:$.EXEC_CHAIR,label:"Exec Chair",footprintW:1,footprintH:1,sprite:po,isDesk:!1,category:"chairs"},{type:$.VENDING_MACHINE,label:"Vending Machine",footprintW:1,footprintH:2,sprite:Bn,isDesk:!1,category:"misc"},{type:$.AC_UNIT,label:"AC Unit",footprintW:1,footprintH:1,sprite:Bn,isDesk:!1,category:"wall",canPlaceOnWalls:!0},{type:$.WALL_ART,label:"Wall Art",footprintW:1,footprintH:1,sprite:ho,isDesk:!1,category:"wall",canPlaceOnWalls:!0},{type:$.COPIER,label:"Copier",footprintW:1,footprintH:1,sprite:Gn,isDesk:!1,category:"electronics"},{type:$.TV_SCREEN,label:"TV Screen",footprintW:1,footprintH:1,sprite:mo,isDesk:!1,category:"wall",canPlaceOnWalls:!0},{type:$.PRINTER,label:"Printer",footprintW:1,footprintH:1,sprite:Gn,isDesk:!1,category:"electronics"}];function h0(e){const t={[$.DESK]:e.desk_wide,[$.PLANT]:e.plant_medium,[$.COOLER]:e.water_cooler,[$.WHITEBOARD]:e.whiteboard,[$.LAMP]:e.desk_lamp,[$.COUCH]:e.plant_tall,[$.CHAIR]:e.chair_front,[$.BOOKSHELF]:e.bookshelf,[$.PC]:e.monitor_front,[$.SERVER_RACK]:e.server_rack,[$.COFFEE_TABLE]:e.desk_wood,[$.FILING_CABINET]:e.filing_cabinet,[$.MONITOR]:e.monitor_front,[$.LAPTOP]:e.laptop,[$.EXEC_CHAIR]:e.exec_chair_front,[$.VENDING_MACHINE]:e.vending_machine,[$.AC_UNIT]:e.ac_unit,[$.WALL_ART]:e.wall_art,[$.COPIER]:e.copier,[$.TV_SCREEN]:e.tv_screen,[$.PRINTER]:e.printer};for(const n of Mr){const s=t[n.type];s&&(n.sprite=s)}console.log("✓ Applied LimeZu sprites to all furniture catalog entries")}const g0=new Map;function wt(e){return Mr.find(n=>n.type===e)}function x0(e){return g0.get(e)??e}function go(e){const t=[];for(let n=0;n<e.rows;n++){const s=[];for(let o=0;o<e.cols;o++)s.push(e.tiles[n*e.cols+o]);t.push(s)}return t}function Wn(e){const t=new Map;for(const s of e){const o=wt(s.type);if(!o||!o.isDesk)continue;const a=s.row*I+o.sprite.length;for(let l=0;l<o.footprintH;l++)for(let i=0;i<o.footprintW;i++){const c=`${s.col+i},${s.row+l}`,d=t.get(c);(d===void 0||a>d)&&t.set(c,a)}}const n=[];for(const s of e){const o=wt(s.type);if(!o)continue;const a=s.col*I,l=s.row*I,i=o.sprite.length;let c=l+i;if(o.category==="chairs"&&(o.orientation==="back"?c=(s.row+1)*I-1:c=(s.row+1)*I),o.canPlaceOnSurfaces)for(let u=0;u<o.footprintH;u++)for(let m=0;m<o.footprintW;m++){const h=t.get(`${s.col+m},${s.row+u}`);h!==void 0&&h+.5>c&&(c=h+.5)}let d=o.sprite;if(s.color){const{h:u,s:m,b:h,c:p}=s.color;d=Dr(`furn-${s.type}-${u}-${m}-${h}-${p}-${s.color.colorize?1:0}`,o.sprite,s.color)}n.push({sprite:d,type:s.type,x:a,y:l,zY:c})}return n}function xo(e,t){const n=new Set;for(const s of e){const o=wt(s.type);if(!o)continue;const a=o.backgroundTiles||0;for(let l=0;l<o.footprintH;l++)if(!(l<a))for(let i=0;i<o.footprintW;i++){const c=`${s.col+i},${s.row+l}`;t&&t.has(c)||n.add(c)}}return n}function b0(e){switch(e){case"front":return L.DOWN;case"back":return L.UP;case"left":return L.LEFT;case"right":return L.RIGHT;default:return L.DOWN}}function bo(e){const t=new Map,n=new Set;for(const o of e){const a=wt(o.type);if(!(!a||!a.isDesk))for(let l=0;l<a.footprintH;l++)for(let i=0;i<a.footprintW;i++)n.add(`${o.col+i},${o.row+l}`)}const s=[{dc:0,dr:-1,facing:L.UP},{dc:0,dr:1,facing:L.DOWN},{dc:-1,dr:0,facing:L.LEFT},{dc:1,dr:0,facing:L.RIGHT}];for(const o of e){const a=wt(o.type);if(!a||a.category!=="chairs")continue;let l=0;for(let i=0;i<a.footprintH;i++)for(let c=0;c<a.footprintW;c++){const d=o.col+c,u=o.row+i;let m=L.DOWN;if(a.orientation)m=b0(a.orientation);else for(const p of s)if(n.has(`${d+p.dc},${u+p.dr}`)){m=p.facing;break}const h=l===0?o.uid:`${o.uid}:${l}`;t.set(h,{uid:h,seatCol:d,seatRow:u,facingDir:m,assigned:!1}),l++}}return t}function yo(e){const t=new Set;for(const n of e.values())t.add(`${n.seatCol},${n.seatRow}`);return t}function wo(e,t,n,s){const o=new Set;for(const a of n){const l=e[a];if(l)for(let i=0;i<l.length;i++){if(l[i]===0)continue;const c=i%t,d=Math.floor(i/t),u=`${c},${d}`;s&&s.has(u)||o.add(u)}}return o}function vo(e){const t=new Map;for(let n=0;n<e.length;n++){const s=e[n],o=`seat-${n+1}`;t.set(o,{uid:o,seatCol:s.col,seatRow:s.row,facingDir:s.dir,assigned:!1})}return t}const y0={h:35,s:30,b:15,c:0},w0={h:25,s:45,b:5,c:10},v0={h:280,s:40,b:-5,c:0},C0={h:35,s:25,b:10,c:0};function k0(){const e=Te.WALL,t=Te.FLOOR_1,n=Te.FLOOR_2,s=Te.FLOOR_3,o=Te.FLOOR_4,a=[],l=[];for(let c=0;c<Rn;c++)for(let d=0;d<Xn;d++){if(c===0||c===Rn-1){a.push(e),l.push(null);continue}if(d===0||d===Xn-1){a.push(e),l.push(null);continue}if(d===10){c>=4&&c<=6?(a.push(o),l.push(C0)):(a.push(e),l.push(null));continue}if(d>=15&&d<=18&&c>=7&&c<=9){a.push(s),l.push(v0);continue}d<10?(a.push(t),l.push(y0)):(a.push(n),l.push(w0))}const i=[{uid:"desk-left",type:$.DESK,col:4,row:3},{uid:"desk-right",type:$.DESK,col:13,row:3},{uid:"bookshelf-1",type:$.BOOKSHELF,col:1,row:5},{uid:"plant-left",type:$.PLANT,col:1,row:1},{uid:"cooler-1",type:$.COOLER,col:17,row:7},{uid:"plant-right",type:$.PLANT,col:18,row:1},{uid:"whiteboard-1",type:$.WHITEBOARD,col:15,row:0},{uid:"chair-l-top",type:$.CHAIR,col:4,row:2},{uid:"chair-l-bottom",type:$.CHAIR,col:5,row:5},{uid:"chair-l-left",type:$.CHAIR,col:3,row:4},{uid:"chair-l-right",type:$.CHAIR,col:6,row:3},{uid:"chair-r-top",type:$.CHAIR,col:13,row:2},{uid:"chair-r-bottom",type:$.CHAIR,col:14,row:5},{uid:"chair-r-left",type:$.CHAIR,col:12,row:4},{uid:"chair-r-right",type:$.CHAIR,col:15,row:3}];return{version:1,cols:Xn,rows:Rn,tiles:a,tileColors:l,furniture:i}}class N0{layout;tileMap;seats;blockedTiles;furniture;walkableTiles;characters=new Map;selectedAgentId=null;cameraFollowId=null;hoveredAgentId=null;hoveredTile=null;heldKeys=new Set;collisionFlash=null;subagentIdMap=new Map;subagentMeta=new Map;meetingActive=!1;meetingAgents=new Set;reviewPairs=new Map;sessionSubagentsByParent=new Map;nextSubagentId=-1;constructor(t){this.layout=t||k0(),this.tileMap=go(this.layout),this.layout.seatPositions?this.seats=vo(this.layout.seatPositions):this.seats=bo(this.layout.furniture);const n=yo(this.seats);this.layout.gidLayers&&this.layout.gidLayers.length>0?this.blockedTiles=wo(this.layout.gidLayers,this.layout.cols,[1,2],n):this.blockedTiles=xo(this.layout.furniture,n),this.furniture=Wn(this.layout.furniture),this.walkableTiles=uo(this.tileMap,this.blockedTiles)}rebuildFromLayout(t,n){this.layout=t,this.tileMap=go(t),t.seatPositions?this.seats=vo(t.seatPositions):this.seats=bo(t.furniture);const s=yo(this.seats);if(t.gidLayers&&t.gidLayers.length>0?this.blockedTiles=wo(t.gidLayers,t.cols,[1,2],s):this.blockedTiles=xo(t.furniture,s),this.rebuildFurnitureInstances(),this.walkableTiles=uo(this.tileMap,this.blockedTiles),n&&(n.col!==0||n.row!==0))for(const o of this.characters.values())o.tileCol+=n.col,o.tileRow+=n.row,o.x+=n.col*I,o.y+=n.row*I,o.path=[],o.moveProgress=0;for(const o of this.seats.values())o.assigned=!1;for(const o of this.characters.values()){if(o.seatId&&this.seats.has(o.seatId)){const a=this.seats.get(o.seatId);if(!a.assigned){a.assigned=!0,o.tileCol=a.seatCol,o.tileRow=a.seatRow;const l=a.seatCol*I+I/2,i=a.seatRow*I+I/2;o.x=l,o.y=i,o.dir=a.facingDir;continue}}o.seatId=null}for(const o of this.characters.values()){if(o.seatId)continue;const a=this.findFreeSeat();if(a){this.seats.get(a).assigned=!0,o.seatId=a;const l=this.seats.get(a);o.tileCol=l.seatCol,o.tileRow=l.seatRow,o.x=l.seatCol*I+I/2,o.y=l.seatRow*I+I/2,o.dir=l.facingDir}}for(const o of this.characters.values())o.seatId||(o.tileCol<0||o.tileCol>=t.cols||o.tileRow<0||o.tileRow>=t.rows)&&this.relocateCharacterToWalkable(o)}relocateCharacterToWalkable(t){if(this.walkableTiles.length===0)return;const n=this.walkableTiles[Math.floor(Math.random()*this.walkableTiles.length)];t.tileCol=n.col,t.tileRow=n.row,t.x=n.col*I+I/2,t.y=n.row*I+I/2,t.path=[],t.moveProgress=0}getLayout(){return this.layout}ownSeatKey(t){if(!t.seatId)return null;const n=this.seats.get(t.seatId);return n?`${n.seatCol},${n.seatRow}`:null}withOwnSeatUnblocked(t,n){const s=this.ownSeatKey(t);s&&this.blockedTiles.delete(s);const o=n();return s&&this.blockedTiles.add(s),o}findFreeSeat(){for(const[t,n]of this.seats)if(!n.assigned)return t;return null}pickDiversePalette(){const t=new Array(ao).fill(0);for(const l of this.characters.values())l.isSubagent||t[l.palette]++;const n=Math.min(...t),s=[];for(let l=0;l<ao;l++)t[l]===n&&s.push(l);const o=s[Math.floor(Math.random()*s.length)];let a=0;return n>0&&(a=xc+Math.floor(Math.random()*bc)),{palette:o,hueShift:a}}addAgent(t,n,s,o,a,l){if(this.characters.has(t))return;let i,c;if(n!==void 0)i=n,c=s??0;else{const m=this.pickDiversePalette();i=m.palette,c=m.hueShift}let d=null;o&&this.seats.has(o)&&(this.seats.get(o).assigned||(d=o)),d||(d=this.findFreeSeat());let u;if(d){const m=this.seats.get(d);m.assigned=!0,u=Ht(t,i,d,m,c)}else{const m=this.walkableTiles.length>0?this.walkableTiles[Math.floor(Math.random()*this.walkableTiles.length)]:{col:1,row:1};u=Ht(t,i,null,null,c),u.x=m.col*I+I/2,u.y=m.row*I+I/2,u.tileCol=m.col,u.tileRow=m.row}l&&(u.folderName=l),a||(u.matrixEffect="spawn",u.matrixEffectTimer=0,u.matrixEffectSeeds=Rt()),this.characters.set(t,u)}removeAgent(t){const n=this.characters.get(t);if(n&&n.matrixEffect!=="despawn"){if(n.seatId){const s=this.seats.get(n.seatId);s&&(s.assigned=!1)}this.selectedAgentId===t&&(this.selectedAgentId=null),this.cameraFollowId===t&&(this.cameraFollowId=null),n.matrixEffect="despawn",n.matrixEffectTimer=0,n.matrixEffectSeeds=Rt(),n.bubbleType=null}}getSeatAtTile(t,n){for(const[s,o]of this.seats)if(o.seatCol===t&&o.seatRow===n)return s;return null}reassignSeat(t,n){const s=this.characters.get(t);if(!s)return;if(s.seatId){const l=this.seats.get(s.seatId);l&&(l.assigned=!1)}const o=this.seats.get(n);if(!o||o.assigned)return;o.assigned=!0,s.seatId=n;const a=this.withOwnSeatUnblocked(s,()=>ze(s.tileCol,s.tileRow,o.seatCol,o.seatRow,this.tileMap,this.blockedTiles));a.length>0?(s.path=a,s.moveProgress=0,s.state=Y.WALK,s.frame=0,s.frameTimer=0):(s.state=Y.TYPE,s.dir=o.facingDir,s.frame=0,s.frameTimer=0,s.isActive||(s.seatTimer=oo+Math.random()*ro))}sendToSeat(t){const n=this.characters.get(t);if(!n||!n.seatId)return;const s=this.seats.get(n.seatId);if(!s)return;const o=this.withOwnSeatUnblocked(n,()=>ze(n.tileCol,n.tileRow,s.seatCol,s.seatRow,this.tileMap,this.blockedTiles));o.length>0?(n.path=o,n.moveProgress=0,n.state=Y.WALK,n.frame=0,n.frameTimer=0):(n.state=Y.TYPE,n.dir=s.facingDir,n.frame=0,n.frameTimer=0,n.isActive||(n.seatTimer=oo+Math.random()*ro))}standUpFromSeat(t){const n=this.characters.get(t);if(!n)return!1;const s=[{dc:0,dr:-1},{dc:0,dr:1},{dc:-1,dr:0},{dc:1,dr:0}];for(const c of s)if(Se(n.tileCol+c.dc,n.tileRow+c.dr,this.tileMap,this.blockedTiles))return!1;const o=(c,d)=>`${c},${d}`,a=new Set;a.add(o(n.tileCol,n.tileRow));const l=[{col:n.tileCol,row:n.tileRow}],i=[{dc:0,dr:-1},{dc:0,dr:1},{dc:-1,dr:0},{dc:1,dr:0}];for(;l.length>0;){const c=l.shift();for(const d of i){const u=c.col+d.dc,m=c.row+d.dr,h=o(u,m);if(a.has(h))continue;if(a.add(h),Se(u,m,this.tileMap,this.blockedTiles))return n.tileCol=u,n.tileRow=m,n.x=u*I+I/2,n.y=m*I+I/2,n.path=[],n.moveProgress=0,n.state=Y.IDLE,n.frame=0,n.frameTimer=0,!0;const p=this.tileMap.length,x=p>0?this.tileMap[0].length:0;u>=0&&u<x&&m>=0&&m<p&&l.push({col:u,row:m})}}return!1}walkToTile(t,n,s){const o=this.characters.get(t);if(!o||o.isSubagent)return!1;if(!Se(n,s,this.tileMap,this.blockedTiles)){const l=this.ownSeatKey(o);if(!l||l!==`${n},${s}`)return o.isPlayerControlled&&(this.collisionFlash={col:n,row:s,timer:nn}),!1}const a=this.withOwnSeatUnblocked(o,()=>ze(o.tileCol,o.tileRow,n,s,this.tileMap,this.blockedTiles));return a.length===0?(o.isPlayerControlled&&(o.tileCol!==n||o.tileRow!==s)&&(this.collisionFlash={col:n,row:s,timer:nn}),!1):(o.path=a,o.moveProgress=0,o.state=Y.WALK,o.frame=0,o.frameTimer=0,!0)}walkCharacterToTile(t,n,s){const o=this.withOwnSeatUnblocked(t,()=>Se(n,s,this.tileMap,this.blockedTiles)?ze(t.tileCol,t.tileRow,n,s,this.tileMap,this.blockedTiles):[]);return o.length===0?!1:(t.path=o,t.moveProgress=0,t.state=Y.WALK,t.frame=0,t.frameTimer=0,!0)}addSubagent(t,n){const s=`${t}:${n}`;if(this.subagentIdMap.has(s))return this.subagentIdMap.get(s);const o=this.nextSubagentId--,a=this.characters.get(t),l=a?a.palette:0,i=a?a.hueShift:0,c=a?a.tileCol:0,d=a?a.tileRow:0,u=(x,b)=>Math.abs(x-c)+Math.abs(b-d);let m=null,h=1/0;for(const[x,b]of this.seats)if(!b.assigned){const w=u(b.seatCol,b.seatRow);w<h&&(h=w,m=x)}let p;if(m){const x=this.seats.get(m);x.assigned=!0,p=Ht(o,l,m,x,i)}else{let x={col:1,row:1};if(this.walkableTiles.length>0){let b=this.walkableTiles[0],w=u(b.col,b.row);for(let y=1;y<this.walkableTiles.length;y++){const S=u(this.walkableTiles[y].col,this.walkableTiles[y].row);S<w&&(b=this.walkableTiles[y],w=S)}x=b}p=Ht(o,l,null,null,i),p.x=x.col*I+I/2,p.y=x.row*I+I/2,p.tileCol=x.col,p.tileRow=x.row}return p.isSubagent=!0,p.parentAgentId=t,p.matrixEffect="spawn",p.matrixEffectTimer=0,p.matrixEffectSeeds=Rt(),this.characters.set(o,p),this.subagentIdMap.set(s,o),this.subagentMeta.set(o,{parentAgentId:t,parentToolId:n}),o}removeSubagent(t,n){const s=`${t}:${n}`,o=this.subagentIdMap.get(s);if(o===void 0)return;const a=this.characters.get(o);if(a){if(a.matrixEffect==="despawn"){this.subagentIdMap.delete(s),this.subagentMeta.delete(o);return}if(a.seatId){const l=this.seats.get(a.seatId);l&&(l.assigned=!1)}a.matrixEffect="despawn",a.matrixEffectTimer=0,a.matrixEffectSeeds=Rt(),a.bubbleType=null}this.subagentIdMap.delete(s),this.subagentMeta.delete(o),this.selectedAgentId===o&&(this.selectedAgentId=null),this.cameraFollowId===o&&(this.cameraFollowId=null)}removeAllSubagents(t){const n=[];for(const[s,o]of this.subagentIdMap){const a=this.subagentMeta.get(o);if(a&&a.parentAgentId===t){const l=this.characters.get(o);if(l){if(l.matrixEffect==="despawn"){this.subagentMeta.delete(o),n.push(s);continue}if(l.seatId){const i=this.seats.get(l.seatId);i&&(i.assigned=!1)}l.matrixEffect="despawn",l.matrixEffectTimer=0,l.matrixEffectSeeds=Rt(),l.bubbleType=null}this.subagentMeta.delete(o),this.selectedAgentId===o&&(this.selectedAgentId=null),this.cameraFollowId===o&&(this.cameraFollowId=null),n.push(s)}}for(const s of n)this.subagentIdMap.delete(s)}getSubagentId(t,n){return this.subagentIdMap.get(`${t}:${n}`)??null}setAgentActive(t,n){const s=this.characters.get(t);s&&(s.isActive=n,n||(s.seatTimer=-1,s.path=[],s.moveProgress=0),this.rebuildFurnitureInstances())}setAgentStatus(t,n){const s=this.characters.get(t);if(!s)return;const o=s.agentStatus;if(n===o){s.pendingStatus=null,s.statusChangeTimer=0;return}if(s.pendingStatus!==null&&n===o){s.pendingStatus=null,s.statusChangeTimer=0;return}s.pendingStatus=n,s.statusChangeTimer=Cc}setAgentSessionInfo(t,n){const s=this.characters.get(t);s&&(s.sessionInfo=n)}applyAgentStatus(t,n){const s=t.agentStatus;t.agentStatus=n,t.hasError=n==="error";const o=t.isActive,a=n==="working"||n==="waiting";t.isActive=a,n==="waiting"?t.currentTool="Read":n==="working"&&!t.currentTool&&(t.currentTool=null),!a&&o&&(t.seatTimer=-1,t.routingZone||(t.path=[],t.moveProgress=0),s==="working"&&(n==="idle"||n==="offline"||n==="done")&&(t.lingerTimer=lo+Math.random()*(kc-lo))),!t.isPlayerControlled&&!t.isSubagent&&this.routeAgent(t,n),this.rebuildFurnitureInstances()}routeAgent(t,n){if(t.lingerTimer>0||t.routingZone==="meeting"||t.routingZone==="review")return;const s=Qc(t,n,t.sessionInfo);if(!s){if(n==="working"&&(t.routingZone=null,t.seatId)){const o=this.seats.get(t.seatId);o&&(t.tileCol!==o.seatCol||t.tileRow!==o.seatRow)&&this.sendToSeat(t.id)}return}t.routingZone=s.zoneId,this.walkToTile(t.id,s.waypoint.col,s.waypoint.row)}setAgentBusy(t,n){const s=this.characters.get(t);s&&(s.isBusy=n)}setReviewPairs(t){for(const[n]of this.reviewPairs)if(!t.has(n)){const s=this.characters.get(n);s&&!s.isPlayerControlled&&s.routingZone==="review"&&(s.routingZone=null,this.routeAgent(s,s.agentStatus))}for(const[n,s]of t)if(!this.reviewPairs.has(n)||this.reviewPairs.get(n)!==s){const o=this.characters.get(n),a=this.characters.get(s);if(!o||!a||o.isPlayerControlled||o.routingZone==="meeting")continue;this.standUpFromSeat(n);const l=a.seatId?this.seats.get(a.seatId):null,i=l?l.seatCol:a.tileCol,c=l?l.seatRow:a.tileRow,d=[{dc:0,dr:-1},{dc:0,dr:1},{dc:-1,dr:0},{dc:1,dr:0}];let u=!1;for(const m of d){const h=i+m.dc,p=c+m.dr;if(Se(h,p,this.tileMap,this.blockedTiles)&&(u=this.walkToTile(o.id,h,p),u))break}if(!u){const m=new Set,h=[];for(m.add(`${i},${c}`),h.push({col:i,row:c,dist:0});h.length>0;){const p=h.shift();if(p.dist>3)break;for(const x of d){const b=p.col+x.dc,w=p.row+x.dr,y=`${b},${w}`;if(!m.has(y)){if(m.add(y),Se(b,w,this.tileMap,this.blockedTiles)&&(u=this.walkToTile(o.id,b,w),u))break;if(p.dist+1<3){const S=this.tileMap.length,N=S>0?this.tileMap[0].length:0;b>=0&&b<N&&w>=0&&w<S&&h.push({col:b,row:w,dist:p.dist+1})}}}if(u)break}}u&&(o.routingZone="review")}this.reviewPairs=t}setSubagentsByParent(t){this.sessionSubagentsByParent=t}rebuildFurnitureInstances(){const t=new Set;for(const s of this.characters.values()){if(!s.isActive||!s.seatId)continue;const o=this.seats.get(s.seatId);if(!o)continue;const a=o.facingDir===L.RIGHT?1:o.facingDir===L.LEFT?-1:0,l=o.facingDir===L.DOWN?1:o.facingDir===L.UP?-1:0;for(let i=1;i<=yc;i++){const c=o.seatCol+a*i,d=o.seatRow+l*i;t.add(`${c},${d}`)}for(let i=1;i<=wc;i++){const c=o.seatCol+a*i,d=o.seatRow+l*i;a!==0?(t.add(`${c},${d-1}`),t.add(`${c},${d+1}`)):(t.add(`${c-1},${d}`),t.add(`${c+1},${d}`))}}if(t.size===0){this.furniture=Wn(this.layout.furniture);return}const n=this.layout.furniture.map(s=>{const o=wt(s.type);if(!o)return s;for(let a=0;a<o.footprintH;a++)for(let l=0;l<o.footprintW;l++)if(t.has(`${s.col+l},${s.row+a}`)){const i=x0(s.type);return i!==s.type?{...s,type:i}:s}return s});this.furniture=Wn(n)}setAgentTool(t,n){const s=this.characters.get(t);s&&(s.currentTool=n)}showPermissionBubble(t){const n=this.characters.get(t);n&&(n.bubbleType="permission",n.bubbleTimer=0)}clearPermissionBubble(t){const n=this.characters.get(t);n&&n.bubbleType==="permission"&&(n.bubbleType=null,n.bubbleTimer=0)}showWaitingBubble(t){const n=this.characters.get(t);n&&(n.bubbleType="waiting",n.bubbleTimer=hc)}dismissBubble(t){const n=this.characters.get(t);!n||!n.bubbleType||(n.bubbleType==="permission"?(n.bubbleType=null,n.bubbleTimer=0):n.bubbleType==="waiting"&&(n.bubbleTimer=Math.min(n.bubbleTimer,gc)))}update(t){this.collisionFlash&&(this.collisionFlash.timer-=t,this.collisionFlash.timer<=0&&(this.collisionFlash=null));for(const i of this.characters.values()){if(i.pendingStatus!==null&&i.statusChangeTimer>0&&(i.statusChangeTimer-=t,i.statusChangeTimer<=0)){const c=i.pendingStatus;i.pendingStatus=null,i.statusChangeTimer=0,this.applyAgentStatus(i,c)}i.lingerTimer>0&&(i.lingerTimer-=t,i.lingerTimer<=0&&(i.lingerTimer=0,!i.isPlayerControlled&&!i.isSubagent&&this.routeAgent(i,i.agentStatus)))}const n=new Map;for(const[i,c]of this.subagentMeta){const d=this.characters.get(i);if(!d||d.matrixEffect==="despawn")continue;const u=n.get(c.parentAgentId);u?u.push(i):n.set(c.parentAgentId,[i])}for(const[i,c]of this.sessionSubagentsByParent){const d=n.get(i)??[];for(const u of c)!d.includes(u)&&this.characters.has(u)&&d.push(u);d.length>0&&n.set(i,d)}const s=new Set;for(const[i,c]of n)if(c.length>=co){s.add(i);for(const d of c)s.add(d)}const o=s.size>=co;if(o&&!this.meetingActive){this.meetingActive=!0;const i={minCol:17,maxCol:30,minRow:2,maxRow:10},c=[{dc:0,dr:-1},{dc:0,dr:1},{dc:-1,dr:0},{dc:1,dr:0}],d=[];for(const[m,h]of this.seats)h.seatCol>=i.minCol&&h.seatCol<=i.maxCol&&h.seatRow>=i.minRow&&h.seatRow<=i.maxRow&&c.some(x=>Se(h.seatCol+x.dc,h.seatRow+x.dr,this.tileMap,this.blockedTiles))&&d.push(m);let u=0;for(const m of s){const h=this.characters.get(m);if(!(!h||h.isPlayerControlled)){if(h.routingZone="meeting",this.standUpFromSeat(m),u<d.length){const p=d[u++],x=this.seats.get(p);if(x){const b=h.seatId;h.originalSeatId||(h.originalSeatId=b),h.seatId=p;const w=b?this.seats.get(b):null,y=w?`${w.seatCol},${w.seatRow}`:null,S=`${x.seatCol},${x.seatRow}`;y&&this.blockedTiles.delete(y),this.blockedTiles.delete(S);const N=ze(h.tileCol,h.tileRow,x.seatCol,x.seatRow,this.tileMap,this.blockedTiles);y&&this.blockedTiles.add(y),this.blockedTiles.add(S),N.length>0&&(h.path=N,h.moveProgress=0,h.state=Y.WALK,h.frame=0,h.frameTimer=0)}}else{const p=lt("meeting");this.walkCharacterToTile(h,p.waypoint.col,p.waypoint.row)}this.meetingAgents.add(m)}}}else if(o&&this.meetingActive)for(const i of s){if(this.meetingAgents.has(i))continue;const c=this.characters.get(i);if(!c||c.isPlayerControlled||c.routingZone==="meeting")continue;c.routingZone="meeting",this.standUpFromSeat(i);const d=lt("meeting");this.walkCharacterToTile(c,d.waypoint.col,d.waypoint.row),this.meetingAgents.add(i)}else if(!o&&this.meetingActive){for(const i of this.meetingAgents){const c=this.characters.get(i);c&&c.routingZone==="meeting"&&(c.routingZone=null,c.originalSeatId&&(c.seatId=c.originalSeatId,c.originalSeatId=null),!c.isSubagent&&!c.isPlayerControlled&&(this.standUpFromSeat(i),this.routeAgent(c,c.agentStatus)))}this.meetingAgents.clear(),this.meetingActive=!1}const a=[];for(const i of this.characters.values()){if(i.matrixEffect){i.matrixEffectTimer+=t,i.matrixEffectTimer>=Nr&&(i.matrixEffect==="spawn"?(i.matrixEffect=null,i.matrixEffectTimer=0,i.matrixEffectSeeds=[]):a.push(i.id));continue}const c=i.isPlayerControlled?this.heldKeys:void 0;this.withOwnSeatUnblocked(i,()=>Yc(i,t,this.walkableTiles,this.seats,this.tileMap,this.blockedTiles,c)),i.isPlayerControlled&&i.blockedTile&&(this.collisionFlash={col:i.blockedTile.col,row:i.blockedTile.row,timer:nn},i.blockedTile=null),i.bubbleType==="waiting"&&(i.bubbleTimer-=t,i.bubbleTimer<=0&&(i.bubbleType=null,i.bubbleTimer=0))}for(const i of a)this.characters.delete(i);let l=null;for(const i of this.characters.values())if(i.isPlayerControlled&&!i.matrixEffect){l=i;break}for(const i of this.characters.values()){if(i.isPlayerControlled||i.matrixEffect){i.isNearPlayer=!1;continue}if(!l){i.isNearPlayer=!1;continue}const c=Math.max(Math.abs(i.tileCol-l.tileCol),Math.abs(i.tileRow-l.tileRow));i.isNearPlayer=c<=Ec}}getCharacters(){return Array.from(this.characters.values())}getAgentAtSeat(t){for(const n of this.characters.values())if(n.seatId===t&&n.matrixEffect!=="despawn")return n.id;return null}findSeatNearTile(t,n){let s=null,o=1/0;for(const[a,l]of this.seats){const i=Math.abs(l.seatCol-t)+Math.abs(l.seatRow-n);i<o&&i<=2&&(o=i,s=a)}return s}getTileInfoAt(t,n){const s=Math.floor(t/I),o=Math.floor(n/I);if(s<0||s>=this.layout.cols||o<0||o>=this.layout.rows)return null;const a=o*this.layout.cols+s,l=this.layout.gidLayers;if(!l||l.length===0)return null;const i=l[0]?.[a]??0;if(new Set([12,24,26,28,40,42,56,57,58,146,162,177,178,185,193,194,201]).has(i))return{type:"wall",col:s,row:o};const d=l[1]?.[a]??0,u=l[2]?.[a]??0,m=l[3]?.[a]??0;if(!(d!==0||u!==0||m!==0))return null;const p=this.findSeatNearTile(s,o);if(p){const x=this.getAgentAtSeat(p)??void 0;return{type:"desk",col:s,row:o,seatId:p,agentId:x}}if(u>=709&&u<=730)return{type:"conference",col:s,row:o};if(d===885||d===1021||d===1022||d===1037||d===1038)return{type:"server",col:s,row:o};for(const x of this.furniture)if(x.type==="whiteboard"||x.type==="bookshelf"){const b=x.sprite[0]?.length??0,w=x.sprite.length,y=Math.floor(x.x/I),S=Math.floor(x.y/I);if(s>=y&&s<y+Math.ceil(b/I)&&o>=S&&o<S+Math.ceil(w/I))return{type:x.type,col:s,row:o}}return{type:"furniture",col:s,row:o}}getAgentsInZone(t,n,s,o){const a=[];for(const l of this.characters.values())l.matrixEffect!=="despawn"&&l.tileCol>=t&&l.tileCol<=s&&l.tileRow>=n&&l.tileRow<=o&&a.push({id:l.id,agentName:""});return a}getCharacterAt(t,n){const s=this.getCharacters().sort((o,a)=>a.y-o.y);for(const o of s){if(o.matrixEffect==="despawn")continue;const a=o.state===Y.TYPE?dn:0,l=o.y+a,i=o.x-io,c=o.x+io,d=l-vc,u=l;if(t>=i&&t<=c&&n>=d&&n<=u)return o.id}return null}}const Co=new Map,ko=new WeakMap;function S0(e){const t=ko.get(e);if(t)return t;const n=e.length,s=e[0].length,o=[];for(let a=0;a<n+2;a++)o.push(new Array(s+2).fill(""));for(let a=0;a<n;a++)for(let l=0;l<s;l++){if(e[a][l]==="")continue;const i=a+1,c=l+1;o[i-1][c]===""&&(o[i-1][c]="#FFFFFF"),o[i+1][c]===""&&(o[i+1][c]="#FFFFFF"),o[i][c-1]===""&&(o[i][c-1]="#FFFFFF"),o[i][c+1]===""&&(o[i][c+1]="#FFFFFF")}for(let a=0;a<n;a++)for(let l=0;l<s;l++)e[a][l]!==""&&(o[a+1][l+1]="");return ko.set(e,o),o}function Ie(e,t){let n=Co.get(t);n||(n=new WeakMap,Co.set(t,n));const s=n.get(e);if(s)return s;const o=e.length,a=e[0].length,l=document.createElement("canvas");l.width=a*t,l.height=o*t;const i=l.getContext("2d");i.imageSmoothingEnabled=!1;for(let c=0;c<o;c++)for(let d=0;d<a;d++){const u=e[c][d];u!==""&&(i.fillStyle=u,i.fillRect(d*t,c*t,t,t))}return n.set(e,l),l}function ge(e,t){return e.map(n=>[...n].map(s=>s==="."?"":t[s]??""))}const yn={G:"#22c55e",D:"#16a34a",H:"#15803d"},E0=ge(["..GG....",".GGGGG..","GGDHGG..","GGHHGGG.",".GGGGGG.","..GGGG..",".GGGGG..","..GG...."],yn),j0=ge(["...GG...","..GGGG..",".GGDHGG.","GGGHHGG.",".GGGGGG.",".GGGGGG.","..GGGG..","...GG..."],yn),A0=ge(["....GG..","..GGGGG.",".GGDHGG.",".GGHHGG.","GGGGGG..",".GGGGGG.","..GGGG..","..GG...."],yn),T0=ge(["..GGG...",".GGGGG..",".GGDHG..","GGGHHGG.","GGGGGG..",".GGGGG..","..GGGG..","...GG..."],yn),Fr={W:"#FFFFFF",C:"#9ca3af",D:"#6b7280",B:"#78716c",H:"#d4d4d8"},X0=ge([".W......","..W.....",".W......","..DDDD..","..CBBB..","..CCCC.H","..CCCC.H","..DDDD.."],Fr),R0=ge(["..W.....",".W......","..W.....","..DDDD..","..CBBB..","..CCCC.H","..CCCC.H","..DDDD.."],Fr),Or={R:"#ef4444",Y:"#eab308",B:"#111111",W:"#fef08a"},D0={R:"#fecaca",Y:"#fef9c3",B:"#7f1d1d",W:"#FFFFFF"},I0={R:"#b91c1c",Y:"#a16207",B:"#111111",W:"#ca8a04"},wn=["...RR...","...RR...","..RBBR..","..RWBR..",".RWWBWR.",".RWWWWR.","RRWBWRRR","RRRRRRRR"],P0=ge(wn,Or),_0=ge(wn,D0),M0=ge(wn,Or),F0=ge(wn,I0),Lr={Y:"#eab308",S:"#fde68a",G:"#d4d4d8",D:"#a16207"},O0=ge([".YYYYYY.",".YGSSGY.","..GSSG..","...YY...","...YY...","..GGGG..",".YGSSPY.",".YYYYYY."],{...Lr,P:"#fde68a"}),L0=ge([".YYYYYY.",".YGGPGY.","..GGGG..","...YY...","...YY...","..GSSG..",".YGSSGY.",".YYYYYY."],{...Lr,P:"#fde68a"}),B0={X:"#4b5563",D:"#374151"},$0=ge(["D......D","XD....DX",".XD..DX.","..XDDX..","..XDDX..",".XD..DX.","XD....DX","D......D"],B0),G0={B:"#64748b",D:"#475569"},W0=ge(["........","..DB.DB.","..DB.DB.","..DB.DB.","..DB.DB.","..DB.DB.","..DB.DB.","........"],G0),H0={G:"#22c55e",D:"#16a34a"},U0={G:"#16a34a",D:"#15803d"},Br=["........",".......G","......GG",".D...GG.",".DD.GG..","..DGG...","..GG....","........"],Y0=ge(Br,H0),z0=ge(Br,U0),V0={working:[E0,j0,A0,T0],idle:[X0,R0],error:[P0,_0,M0,F0],waiting:[O0,L0],offline:[$0],paused:[W0],done:[Y0,z0]},K0=Array.from({length:I},()=>Array(I).fill(Er));let sn=[];const Z0="#3A3A5C";function q0(e){sn=e,Jc()}function Q0(e){const t=e-1;return t<0?null:t<sn.length?sn[t]:sn.length===0&&e>=1?K0:null}function J0(e,t){const n=`floor-${e}-${t.h}-${t.s}-${t.b}-${t.c}`,s=Q0(e);return s?Dr(n,s,{...t,colorize:!0}):Array.from({length:16},()=>Array(16).fill("#FF00FF"))}function ed(e){const{h:t,s:n,b:s,c:o}=e;let a=.5;if(o!==0){const b=(100+o)/100;a=.5+(a-.5)*b}s!==0&&(a=a+s/200),a=Math.max(0,Math.min(1,a));const l=n/100,i=(1-Math.abs(2*a-1))*l,c=t/60,d=i*(1-Math.abs(c%2-1));let u=0,m=0,h=0;c<1?(u=i,m=d,h=0):c<2?(u=d,m=i,h=0):c<3?(u=0,m=i,h=d):c<4?(u=0,m=d,h=i):c<5?(u=d,m=0,h=i):(u=i,m=0,h=d);const p=a-i/2,x=b=>Math.max(0,Math.min(255,Math.round((b+p)*255)));return`#${x(u).toString(16).padStart(2,"0")}${x(m).toString(16).padStart(2,"0")}${x(h).toString(16).padStart(2,"0")}`}const Es=new Map;let fs=!1;function js(){return fs}function No(e){return new Promise((t,n)=>{const s=new Image;s.onload=()=>t(s),s.onerror=n,s.src=e})}function So(e,t){const n=Math.floor(e.width/I),s=Math.floor(e.height/I),o=document.createElement("canvas");o.width=e.width,o.height=e.height,o.getContext("2d").drawImage(e,0,0);let l=0;for(let i=0;i<s;i++)for(let c=0;c<n;c++){const d=t+i*n+c,u=document.createElement("canvas");u.width=I,u.height=I,u.getContext("2d").drawImage(o,c*I,i*I,I,I,0,0,I,I),Es.set(d,u),l++}return l}async function td(){if(!fs)try{const[e,t]=await Promise.all([No("/assets/office/room-builder.png"),No("/assets/office/furniture.png")]),n=So(e,1),s=So(t,225);fs=!0,console.log(`✓ Tileset cache: ${n} room-builder + ${s} furniture = ${Es.size} tiles`)}catch{console.warn("Tileset cache not available. Using fallback rendering. Run scripts/setup-assets.sh to install premium assets.")}}const Eo=new Map;function $r(e,t){const n=Es.get(e);if(!n)return null;if(t===1)return n;const s=Math.round(t*100);let o=Eo.get(s);o||(o=new Map,Eo.set(s,o));let a=o.get(e);if(a)return a;const l=Math.round(I*t);a=document.createElement("canvas"),a.width=l,a.height=l;const i=a.getContext("2d");return i.imageSmoothingEnabled=!1,i.drawImage(n,0,0,l,l),o.set(e,a),a}const nd="#FFFFFF",sd="";function vn(e){return e.map(t=>t.split("").map(n=>n==="X"?nd:sd))}const od={A:[".XXX.","X...X","X...X","XXXXX","X...X","X...X","....."],B:["XXXX.","X...X","XXXX.","X...X","X...X","XXXX.","....."],C:[".XXX.","X...X","X....","X....","X...X",".XXX.","....."],D:["XXXX.","X...X","X...X","X...X","X...X","XXXX.","....."],E:["XXXXX","X....","XXXX.","X....","X....","XXXXX","....."],F:["XXXXX","X....","XXXX.","X....","X....","X....","....."],G:[".XXX.","X...X","X....","X.XXX","X...X",".XXX.","....."],H:["X...X","X...X","XXXXX","X...X","X...X","X...X","....."],I:[".XXX.","..X..","..X..","..X..","..X..",".XXX.","....."],J:["..XXX","...X.","...X.","...X.","X..X.",".XX..","....."],K:["X...X","X..X.","XXX..","X..X.","X...X","X...X","....."],L:["X....","X....","X....","X....","X....","XXXXX","....."],M:["X...X","XX.XX","X.X.X","X...X","X...X","X...X","....."],N:["X...X","XX..X","X.X.X","X..XX","X...X","X...X","....."],O:[".XXX.","X...X","X...X","X...X","X...X",".XXX.","....."],P:["XXXX.","X...X","XXXX.","X....","X....","X....","....."],Q:[".XXX.","X...X","X...X","X.X.X","X..X.",".XX.X","....."],R:["XXXX.","X...X","XXXX.","X..X.","X...X","X...X","....."],S:[".XXX.","X....",".XXX.","....X","....X","XXXX.","....."],T:["XXXXX","..X..","..X..","..X..","..X..","..X..","....."],U:["X...X","X...X","X...X","X...X","X...X",".XXX.","....."],V:["X...X","X...X","X...X",".X.X.",".X.X.","..X..","....."],W:["X...X","X...X","X.X.X","X.X.X","XX.XX","X...X","....."],X:["X...X",".X.X.","..X..","..X..",".X.X.","X...X","....."],Y:["X...X",".X.X.","..X..","..X..","..X..","..X..","....."],Z:["XXXXX","...X.","..X..",".X...","X....","XXXXX","....."]},rd={a:[".....",".....",".XXX.","...X.",".XXXX","X...X",".XXXX"],b:["X....","X....","XXXX.","X...X","X...X","XXXX.","....."],c:[".....",".....",".XXX.","X....","X....",".XXX.","....."],d:["....X","....X",".XXXX","X...X","X...X",".XXXX","....."],e:[".....",".....",".XXX.","X.XXX","X....",".XXX.","....."],f:["..XX.",".X...","XXXX.",".X...",".X...",".X...","....."],g:[".....",".XXXX","X...X","X...X",".XXXX","....X",".XXX."],h:["X....","X....","XXXX.","X...X","X...X","X...X","....."],i:["..X..",".....",".XX..","..X..","..X..",".XXX.","....."],j:["...X.",".....","..XX.","...X.","...X.","X..X.",".XX.."],k:["X....","X....","X..X.","XXX..","X..X.","X...X","....."],l:[".XX..","..X..","..X..","..X..","..X..",".XXX.","....."],m:[".....",".....","XX.X.","X.X.X","X.X.X","X...X","....."],n:[".....",".....","XXXX.","X...X","X...X","X...X","....."],o:[".....",".....",".XXX.","X...X","X...X",".XXX.","....."],p:[".....","XXXX.","X...X","X...X","XXXX.","X....","X...."],q:[".....",".XXXX","X...X","X...X",".XXXX","....X","....X"],r:[".....",".....","X.XX.","XX...","X....","X....","....."],s:[".....",".....",".XXXX",".XX..","...XX","XXXX.","....."],t:[".X...",".X...","XXXX.",".X...",".X...","..XX.","....."],u:[".....",".....","X...X","X...X","X...X",".XXXX","....."],v:[".....",".....","X...X","X...X",".X.X.","..X..","....."],w:[".....",".....","X...X","X.X.X","X.X.X",".X.X.","....."],x:[".....",".....","X...X",".X.X.",".X.X.","X...X","....."],y:[".....","X...X","X...X","X...X",".XXXX","....X",".XXX."],z:[".....",".....","XXXXX","..X..",".X...","XXXXX","....."]},ad={0:[".XXX.","X..XX","X.X.X","XX..X","X...X",".XXX.","....."],1:["..X..",".XX..","..X..","..X..","..X..",".XXX.","....."],2:[".XXX.","X...X","...X.","..X..",".X...","XXXXX","....."],3:[".XXX.","X...X","..XX.","....X","X...X",".XXX.","....."],4:["...X.","..XX.",".X.X.","XXXXX","...X.","...X.","....."],5:["XXXXX","X....","XXXX.","....X","X...X",".XXX.","....."],6:[".XXX.","X....","XXXX.","X...X","X...X",".XXX.","....."],7:["XXXXX","....X","...X.","..X..","..X..","..X..","....."],8:[".XXX.","X...X",".XXX.","X...X","X...X",".XXX.","....."],9:[".XXX.","X...X","X...X",".XXXX","....X",".XXX.","....."]},id={".":[".....",".....",".....",".....",".....","..X..","....."],":":[".....","..X..",".....",".....","..X..",".....","....."],",":[".....",".....",".....",".....","..X..","..X..",".X..."],"-":[".....",".....",".....","XXXXX",".....",".....","....."],_:[".....",".....",".....",".....",".....",".....","XXXXX"],"!":["..X..","..X..","..X..","..X..",".....","..X..","....."],"?":[".XXX.","X...X","...X.","..X..",".....","..X..","....."],"(":["..X..",".X...",".X...",".X...",".X...","..X..","....."],")":["..X..","...X.","...X.","...X.","...X.","..X..","....."],"/":["....X","...X.","...X.","..X..",".X...",".X...","....."],"'":["..X..","..X..",".....",".....",".....",".....","....."]," ":[".....",".....",".....",".....",".....",".....","....."]},jt=new Map;for(const[e,t]of Object.entries(od))jt.set(e,vn(t));for(const[e,t]of Object.entries(rd))jt.set(e,vn(t));for(const[e,t]of Object.entries(ad))jt.set(e,vn(t));for(const[e,t]of Object.entries(id))jt.set(e,vn(t));const on=5,Gr=7,ms=1,Hn=new Map;function ld(e,t){const n=e+"\0"+t,s=Hn.get(n);if(s)return s;const o=[];for(const i of e){const c=jt.get(i);c&&o.push(c)}if(o.length===0){const i=[[]];return Hn.set(n,i),i}const a=on*o.length+ms*(o.length-1),l=[];for(let i=0;i<Gr;i++){const c=new Array(a).fill("");let d=0;for(const u of o){for(let m=0;m<on;m++)u[i][m]!==""&&(c[d+m]=t);d+=on+ms}l.push(c)}return Hn.set(n,l),l}function jo(e){let t=0;for(const n of e)jt.has(n)&&t++;return t===0?{width:0,height:0}:{width:on*t+ms*(t-1),height:Gr}}function Un(e,t,n,s,o,a){if(a<2)return;const l=ld(t,n);if(l.length===0||l[0].length===0)return;const i=Ie(l,a);e.drawImage(i,s,o)}const cd=[["","#FFD700","","#FFD700","","#FFD700",""],["","#FFD700","#FFC000","#FFD700","#FFC000","#FFD700",""],["#FFD700","#FFD700","#FFC000","#FFD700","#FFC000","#FFD700","#FFD700"],["#FFD700","#FFC000","#FFD700","#FFC000","#FFD700","#FFC000","#FFD700"],["#DAA520","#DAA520","#DAA520","#DAA520","#DAA520","#DAA520","#DAA520"]],Ao=new WeakMap;function To(e){const t=Ao.get(e);if(t)return t;const n=e.length,s=e[0].length,o=[];for(let a=0;a<n+2;a++)o.push(new Array(s+2).fill(""));for(let a=0;a<n;a++)for(let l=0;l<s;l++){if(e[a][l]==="")continue;const i=a+1,c=l+1;o[i-1][c]===""&&(o[i-1][c]=Wt),o[i+1][c]===""&&(o[i+1][c]=Wt),o[i][c-1]===""&&(o[i][c-1]=Wt),o[i][c+1]===""&&(o[i][c+1]=Wt)}for(let a=0;a<n;a++)for(let l=0;l<s;l++)e[a][l]!==""&&(o[a+1][l+1]="");return Ao.set(e,o),o}const ps=3;function dd(e,t,n,s,o,a,l,i){const c=I*o,d=t.length,u=d>0?t[0].length:0,m=l??u;if(i&&i.length>0&&js()){const p=Math.min(ps,i.length);for(let x=0;x<p;x++){const b=i[x];for(let w=0;w<d;w++)for(let y=0;y<u;y++){const S=b[w*m+y];if(!S||S===0)continue;const N=$r(S,o);N&&e.drawImage(N,n+y*c,s+w*c)}}return}for(let p=0;p<d;p++)for(let x=0;x<u;x++){const b=t[p][x];if(b===Te.VOID)continue;if(b===Te.WALL){if(b===Te.WALL){const v=p*m+x,k=a?.[v];e.fillStyle=k?ed(k):Z0}else e.fillStyle=Er;e.fillRect(n+x*c,s+p*c,c,c);continue}const w=p*m+x,y=a?.[w]??{h:0,s:0,b:0,c:0},S=J0(b,y),N=Ie(S,o);e.drawImage(N,n+x*c,s+p*c)}}function ud(e,t,n,s,o,a,l){if(!l||l.length<=ps||!js())return;const i=I*o,c=t.length,d=c>0?t[0].length:0,u=a??d;for(let m=ps;m<l.length;m++){const h=l[m];for(let p=0;p<c;p++)for(let x=0;x<d;x++){const b=h[p*u+x];if(!b||b===0)continue;const w=$r(b,o);w&&e.drawImage(w,n+x*i,s+p*i)}}}function fd(e,t,n,s,o,a,l,i,c){const d=[];for(const u of t){const m=Ie(u.sprite,a),h=s+u.x*a,p=o+u.y*a;d.push({zY:u.zY,draw:x=>{x.drawImage(m,h,p)}})}for(const u of n){const m=p0(u.palette,u.hueShift);if(!m)continue;const h=zc(u,m),p=Ie(h,a),x=u.state===Y.TYPE?dn:0,b=Math.round(s+u.x*a-p.width/2),w=Math.round(o+(u.y+x)*a-p.height),y=u.y+I/2+nc;if(u.matrixEffect){const v=b,k=w,E=h,A=u;d.push({zY:y,draw:j=>{Vc(j,A,E,v,k,a)}});continue}const S=l!==null&&u.id===l,N=i!==null&&u.id===i;if(S||N){const v=S?sc:oc,k=S0(h),E=Ie(k,a),A=b-a,j=w-a;d.push({zY:y-Pn,draw:T=>{T.save(),T.globalAlpha=v,T.drawImage(E,A,j),T.restore()}})}else if(u.isPlayerControlled){const v=To(h),k=Ie(v,a),E=b-a,A=w-a;d.push({zY:y-Pn,draw:j=>{j.save(),j.globalAlpha=Nc,j.drawImage(k,E,A),j.restore()}})}else if(u.isNearPlayer){const v=To(h),k=Ie(v,a),E=b-a,A=w-a,T=jc+Ac*Math.sin((c??0)*Tc);d.push({zY:y-Pn,draw:G=>{G.save(),G.globalAlpha=T,G.drawImage(k,E,A),G.restore()}})}if(d.push({zY:y,draw:v=>{v.drawImage(p,b,w)}}),u.isPlayerControlled){const v=Ie(cd,a),k=v.width,E=v.height,A=Math.round(b+p.width/2-k/2),j=Math.round(w-E);d.push({zY:y+.001,draw:T=>{T.drawImage(v,A,j)}})}}d.sort((u,m)=>u.zY-m.zY);for(const u of d)u.draw(e)}function md(e,t,n,s,o,a,l,i){if(s===null||!o)return;const c=n.get(s);if(c)for(const[d,u]of t){if(u.seatCol!==o.col||u.seatRow!==o.row)continue;const m=I*i,h=a+u.seatCol*m,p=l+u.seatRow*m;c.seatId===d?e.fillStyle=ac:u.assigned?e.fillStyle=lc:e.fillStyle=ic,e.fillRect(h,p,m,m);break}}function pd(e,t){const n=Math.max(0,Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y)),o=n*s,a=Math.min(e.w*e.h,t.w*t.h);return a>0&&o>a*.5}function hd(e,t,n,s,o,a,l){if(o<2)return;const i=[];for(const d of t){if(d.matrixEffect)continue;const u=a.nameMap.get(d.id);if(!u)continue;const m=a.colorMap.get(d.id)??"#FFFFFF",h=jo(u),p=_n+h.width+_n,x=d.state===Y.TYPE?Ar:0,b=n+d.x*o,w=s+(d.y+x-jr)*o,y=Math.floor(p*o),S=Math.floor(Tr*o),N=Math.floor(b-y/2),v=Math.floor(w-S);i.push({ch:d,name:u,brandColor:m,plateW:p,screenX:N,screenY:v,rect:{x:N,y:v,w:y,h:S}})}const c=[];for(const d of i){const u=d.ch.id===l;let m=1;if(!u){for(const b of c)if(pd(d.rect,b)){m=.4;break}}c.push(d.rect),e.save(),e.globalAlpha=m,e.fillStyle=`rgba(0, 0, 0, ${uc})`,e.fillRect(d.screenX,d.screenY,d.rect.w,d.rect.h);const h=d.screenX+Math.floor(_n*o),p=d.screenY+Math.floor(dc*o);Un(e,d.name,d.brandColor,h,p,o);const x=a.statusMap.get(d.ch.id);if(u&&(x==="working"||x==="waiting")){const b=a.taskTextMap.get(d.ch.id);if(b&&b.length>0){const w=b.length>30?b.slice(0,28)+"..":b,y=Math.max(1,Math.floor(o*.7)),S=jo(w),N=Math.floor(1*o),v=Math.floor(d.screenX+d.rect.w/2-Math.floor(S.width*y)/2),k=d.screenY+d.rect.h+N,E=e.globalAlpha;e.globalAlpha=E*.5,Un(e,w,"#000000",v+Math.ceil(y*.5),k+Math.ceil(y*.5),y),e.globalAlpha=E*.9,Un(e,w,d.brandColor,v,k,y),e.globalAlpha=E}}e.restore()}}const gd={working:"#22c55e",idle:"#9ca3af",error:"#ef4444",waiting:"#eab308",paused:"#64748b",done:"#10b981"};function xd(e,t,n,s,o,a){const l=Math.floor(Tr*o),i=fc*o;for(const c of t){if(c.matrixEffect)continue;const d=a.statusMap.get(c.id);if(!d||d==="offline"||!a.nameMap.get(c.id))continue;const m=c.state===Y.TYPE?Ar:0,p=s+(c.y+m-jr)*o-l;if(o<2){const A=gd[d];if(!A)continue;const j=2*o,T=n+c.x*o,G=p-i-j;if(e.save(),d==="error"){const W=a.time*6;e.globalAlpha=.3+.7*(.5+.5*Math.sin(W*Math.PI*2))}e.beginPath(),e.arc(T,G,j,0,Math.PI*2),e.fillStyle=A,e.fill(),e.restore();continue}const x=V0[d];if(!x||x.length===0)continue;let b;switch(d){case"working":b=Math.floor(a.time*3)%4;break;case"idle":b=Math.floor(a.time*1)%2;break;case"error":b=Math.floor(a.time*6)%4;break;case"waiting":b=Math.floor(a.time*1)%2;break;case"paused":b=0;break;case"done":b=Math.floor(a.time*.5)%2;break;default:b=0}const w=x[b],y=Math.min(o,6),S=Ie(w,y),N=S.width,v=S.height,k=Math.floor(n+c.x*o-N/2),E=Math.floor(p-i-v);e.drawImage(S,k,E)}}function bd(e,t,n,s,o){for(const a of t){if(!a.bubbleType)continue;const l=a.bubbleType==="permission"?l0:c0;let i=1;a.bubbleType==="waiting"&&a.bubbleTimer<to&&(i=a.bubbleTimer/to);const c=Ie(l,o),d=a.state===Y.TYPE?rc:0,u=Math.round(n+a.x*o-c.width/2),m=Math.round(s+(a.y+d-ls)*o-c.height-1*o);e.save(),i<1&&(e.globalAlpha=i),e.drawImage(c,u,m),e.restore()}}function yd(e,t,n,s,o,a){if(a.interactionMap.size===0)return;const l=Ie(d0,o),i=new Set;for(const c of t){const d=a.interactionMap.get(c.id);if(d===void 0||i.has(c.id))continue;i.add(c.id),i.add(d);const u=c.state===Y.TYPE?dn:0,m=Math.round(n+c.x*o-l.width/2),h=Math.round(s+(c.y+u-ls)*o-l.height-1*o);e.drawImage(l,m,h);const p=t.find(x=>x.id===d);if(p){const x=p.state===Y.TYPE?dn:0,b=Math.round(n+p.x*o-l.width/2),w=Math.round(s+(p.y+x-ls)*o-l.height-1*o);e.drawImage(l,b,w)}}}function wd(e,t,n,s,o,a,l,i,c,d,u,m,h,p,x,b){e.clearRect(0,0,t,n);const w=h??(s.length>0?s[0].length:0),y=p??s.length,S=w*I*l,N=y*I*l,v=Math.floor((t-S)/2)+Math.round(i),k=Math.floor((n-N)/2)+Math.round(c),E=x&&x.length>0&&js();dd(e,s,v,k,l,m,h,x),d&&md(e,d.seats,d.characters,d.selectedAgentId,d.hoveredTile,v,k,l);const A=d?.collisionFlash??null;if(A&&A.timer>0){const W=I*l,P=v+A.col*W,q=k+A.row*W,K=A.timer/nn;e.save(),e.globalAlpha=K,e.fillStyle=Sc,e.fillRect(P,q,W,W),e.restore()}const j=d?.selectedAgentId??null,T=d?.hoveredAgentId??null,G=b?.time;return fd(e,o,a,v,k,l,j,T,G),E&&ud(e,s,v,k,l,h,x),b&&(hd(e,a,v,k,l,b,j),xd(e,a,v,k,l,b)),bd(e,a,v,k,l),b&&yd(e,a,v,k,l,b),{offsetX:v,offsetY:k}}const vd="/assets/office/singles/Modern_Office_Singles_",Cd={chair_front:101,chair_back:102,chair_left:103,chair_right:104,exec_chair_front:107,exec_chair_back:108,exec_chair_left:109,exec_chair_right:110,monitor_front:130,monitor_left:131,monitor_right:132,laptop:129,laptop_small:134,plant_small:99,plant_medium:98,plant_tall:100,desk_lamp:141,desk_lamp_alt:145,printer:149,whiteboard:170,tv_screen:172,water_cooler:173,vending_machine:175,server_rack:176,bookshelf:182,bookshelf_wide:195,bookshelf_short:181,wall_art:164,wall_art_small:96,ac_unit:196,filing_cabinet:174,desk_wood:7,desk_wide:23,desk_drawer:21,copier:177};function kd(e){return new Promise((t,n)=>{const s=new Image;s.onload=()=>t(s),s.onerror=n,s.src=e})}function Nd(e,t,n,s){return s<128?"":"#"+(1<<24|e<<16|t<<8|n).toString(16).slice(1)}async function Sd(e){const t=await kd(vd+e+".png"),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const s=n.getContext("2d");s.drawImage(t,0,0);const{data:o}=s.getImageData(0,0,t.width,t.height),a=t.width,l=t.height,i=[];for(let p=0;p<l;p++){const x=[];for(let b=0;b<a;b++){const w=(p*a+b)*4;x.push(Nd(o[w],o[w+1],o[w+2],o[w+3]))}i.push(x)}let c=l,d=0,u=a,m=0;for(let p=0;p<l;p++)for(let x=0;x<a;x++)i[p][x]!==""&&(p<c&&(c=p),p>d&&(d=p),x<u&&(u=x),x>m&&(m=x));if(c>d)return[[""]];const h=[];for(let p=c;p<=d;p++)h.push(i[p].slice(u,m+1));return h}let Yt=null;async function Ed(){if(Yt)return Yt;try{const e=Object.entries(Cd),t={};return await Promise.all(e.map(async([n,s])=>{t[n]=await Sd(s)})),Yt=t,console.log(`✓ Loaded ${e.length} LimeZu furniture sprites`),Yt}catch{return console.warn("LimeZu furniture sprites not found. Using fallback rendering. Run scripts/setup-assets.sh to install premium assets."),null}}function Wr(e){return new Promise((t,n)=>{const s=new Image;s.onload=()=>t(s),s.onerror=n,s.src=e})}function jd(e,t,n,s){return s<128?"":"#"+(1<<24|e<<16|t<<8|n).toString(16).slice(1)}function Hr(e,t,n,s,o,a){const l=[];for(let i=0;i<a;i++){const c=[];for(let d=0;d<o;d++){const u=((s+i)*t+(n+d))*4;c.push(jd(e[u],e[u+1],e[u+2],e[u+3]))}l.push(c)}return l}function Ad(e){return e.map(t=>t.map(n=>{if(!n)return"";const s=parseInt(n.slice(1,3),16),o=parseInt(n.slice(3,5),16),a=parseInt(n.slice(5,7),16),i=Math.round(.299*s+.587*o+.114*a).toString(16).padStart(2,"0");return`#${i}${i}${i}`}))}const Td=[[11,10],[11,6],[1,5],[14,6],[14,7],[11,8],[1,9]];async function Xd(e="/assets/office/room-builder.png"){try{const t=await Wr(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const s=n.getContext("2d");s.drawImage(t,0,0);const a=s.getImageData(0,0,t.width,t.height).data,l=16,i=[];for(const[c,d]of Td){const u=Hr(a,t.width,c*l,d*l,l,l);i.push(Ad(u))}q0(i),console.log(`✓ Loaded ${i.length} floor tile patterns from room-builder.png`)}catch{console.warn("Floor tileset not found. Using fallback rendering. Run scripts/setup-assets.sh to install premium assets.")}}async function Rd(e="/assets/characters"){try{const t=[];for(let n=0;n<12;n++){const s=await Wr(`${e}/char_${n}.png`),o=document.createElement("canvas");o.width=s.width,o.height=s.height;const a=o.getContext("2d");a.drawImage(s,0,0);const i=a.getImageData(0,0,s.width,s.height).data,c=16,d=32,u=7,m=[[],[],[]];for(let h=0;h<3;h++)for(let p=0;p<u;p++)m[h].push(Hr(i,s.width,p*c,h*d,c,d));t.push({down:m[0],up:m[1],right:m[2]})}u0(t)}catch(t){console.warn("Failed to load character sprites:",t)}}let Xo=!1;const Ur=[];function Dd(e){Ur.push(e)}function Id(){Xo||(Xo=!0,Xd(),Rd(),td(),Ed().then(e=>{if(e){h0(e);for(const t of Ur)t()}}))}const zt=new Map(pe.map(e=>[e.id,e.isPlayer?"You":e.agentName])),Ke=new Map(pe.map(e=>[e.agentName,e.id])),Ro=new Map(pe.map(e=>[e.id,e.agentName])),Pd=new Map(pe.map(e=>[e.id,mc[e.color]??"#9ca3af"])),_d=pe.find(e=>e.isPlayer)??null,ie=_d?.id??null,Md=1,Fd=8,Do=.15,Od={Read:"reading",Edit:"editing",Write:"writing",Bash:"running",Grep:"searching",Glob:"scanning",Agent:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"checking todos",TodoWrite:"updating todos",TaskOutput:"reading output"};function Ld(e,t){if(!e)return;const n=Od[e]??e.toLowerCase();if(!t)return n;const s=t.includes("/")?t.split("/").filter(Boolean).pop()??t:t;return`${n} ${s}`}function Bd({onAgentClick:e,onItemClick:t,agentStatuses:n,agentSessionInfos:s,agentBusyMap:o,agentInteractions:a,subagentsByParent:l,reviewInteractions:i,selectedAgentName:c}){const d=f.useRef(null),u=f.useRef(null),m=f.useRef(null),h=f.useRef(0),p=f.useRef(0),x=f.useRef({onAgentClick:e,onItemClick:t,agentStatuses:n,agentSessionInfos:s,agentBusyMap:o,agentInteractions:a,subagentsByParent:l,reviewInteractions:i,selectedAgentName:c});x.current={onAgentClick:e,onItemClick:t,agentStatuses:n,agentSessionInfos:s,agentBusyMap:o,agentInteractions:a,subagentsByParent:l,reviewInteractions:i,selectedAgentName:c};const[b,w]=f.useState(3),[y,S]=f.useState(3),N=f.useRef(y);N.current=y;const[v,k]=f.useState(null),E=f.useCallback(()=>{const C=m.current,X=C?C.tileMap[0]?.length??1:1,D=C?C.tileMap.length:1;return{cols:X,rows:D}},[]);f.useEffect(()=>{const C=new N0($c);for(const X of pe)C.addAgent(X.id,X.palette,X.hueShift,X.seatId,!0);if(ie!==null){const X=C.characters.get(ie);X&&(X.isPlayerControlled=!0,X.state=Y.IDLE,X.isActive=!1,X.agentStatus="working")}ie!==null&&(C.cameraFollowId=ie),m.current=C,window.__officeState=C,Id(),Dd(()=>{C.rebuildFurnitureInstances()})},[]),f.useEffect(()=>{const C=m.current;if(C)for(const X of pe){if(X.isPlayer)continue;const D=n[X.agentName]??"offline";C.setAgentStatus(X.id,D)}},[n]),f.useEffect(()=>{const C=m.current;if(!(!C||!s))for(const X of pe){const D=s[X.agentName];D&&C.setAgentSessionInfo(X.id,D)}},[s]),f.useEffect(()=>{const C=m.current;if(!(!C||!o))for(const X of pe)C.setAgentBusy(X.id,o[X.agentName]??!1)},[o]),f.useEffect(()=>{const C=m.current;if(!C)return;const X=new Map;if(l)for(const[D,z]of l){const M=Ke.get(D);if(M===void 0)continue;const F=[];for(const B of z){const U=Ke.get(B);U!==void 0&&F.push(U)}F.length>0&&X.set(M,F)}typeof C.setSubagentsByParent=="function"&&C.setSubagentsByParent(X)},[l]),f.useEffect(()=>{const C=m.current;if(!C)return;const X=new Map;if(i)for(const[D,z]of i){const M=Ke.get(D),F=Ke.get(z);M!==void 0&&F!==void 0&&X.set(M,F)}typeof C.setReviewPairs=="function"&&C.setReviewPairs(X)},[i]),f.useEffect(()=>{const C=m.current;if(C)if(c){const X=pe.find(D=>D.agentName===c);C.selectedAgentId=X?X.id:null}else C.selectedAgentId=null},[c]),f.useEffect(()=>{if(ie===null)return;const C=new Set(["w","a","s","d","arrowup","arrowdown","arrowleft","arrowright"]),X=()=>{const F=document.activeElement;if(!F)return!1;const B=F.tagName.toLowerCase();return B==="input"||B==="textarea"||B==="select"||F.isContentEditable},D=F=>{const B=F.key.toLowerCase();if(!C.has(B)||X())return;F.preventDefault();const U=m.current;if(!U)return;U.heldKeys.add(B);const re=U.characters.get(ie);if(re&&re.isPlayerControlled&&re.state===Y.IDLE&&re.path.length===0){let ee=0,xe=0;switch(B){case"w":case"arrowup":xe=-1;break;case"s":case"arrowdown":xe=1;break;case"a":case"arrowleft":ee=-1;break;case"d":case"arrowright":ee=1;break}const he=re.tileCol+ee,se=re.tileRow+xe;if(!U.walkToTile(ie,he,se)&&U.standUpFromSeat(ie)){const we={col:re.tileCol+ee,row:re.tileRow+xe};U.walkToTile(ie,we.col,we.row)}}},z=F=>{const B=F.key.toLowerCase();if(!C.has(B))return;const U=m.current;U&&U.heldKeys.delete(B)},M=()=>{const F=m.current;F&&F.heldKeys.clear()};return window.addEventListener("keydown",D),window.addEventListener("keyup",z),window.addEventListener("blur",M),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("keydown",D),window.removeEventListener("keyup",z),window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",M)}},[]),f.useEffect(()=>{const C=X=>{if(X.key!=="Escape")return;const D=m.current;D&&(D.selectedAgentId=null,x.current.onAgentClick&&x.current.onAgentClick(""),x.current.onItemClick&&x.current.onItemClick(null))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[]),f.useEffect(()=>{const C=u.current;if(!C)return;const X=C.parentElement;if(!X)return;const D=new ResizeObserver(()=>{const z=X.clientWidth;if(z===0)return;const M=m.current;if(M){const F=M.tileMap[0]?.length??1,B=z/(F*I);w(B),S(U=>{const re=A.current;return Math.abs(U-re)<.01?B:U})}});return D.observe(X),()=>D.disconnect()},[]);const A=f.useRef(b);A.current=b,f.useEffect(()=>{const C=u.current;if(!C)return;const X=C.parentElement;if(!X)return;const D=z=>{if(!z.ctrlKey&&!z.metaKey)return;z.preventDefault();const M=z.deltaY>0?-Do:Do;S(F=>{const B=Math.max(Md,A.current*.5),U=Math.min(Fd,A.current*3);return Math.max(B,Math.min(U,F+M*F))})};return X.addEventListener("wheel",D,{passive:!1}),()=>X.removeEventListener("wheel",D)},[]);const{cols:j,rows:T}=E(),G=j*I*y,W=T*I*y;f.useEffect(()=>{const C=d.current;if(!C)return;const X=window.devicePixelRatio||1;C.width=Math.ceil(G*X),C.height=Math.ceil(W*X),C.style.width=`${Math.ceil(G)}px`,C.style.height=`${Math.ceil(W)}px`},[G,W]),f.useEffect(()=>{const C=D=>{const z=d.current,M=m.current;if(!z||!M){h.current=requestAnimationFrame(C);return}const F=p.current===0?0:Math.min((D-p.current)/1e3,pc);p.current=D,M.update(F);const B=N.current;if(M.cameraFollowId!==null&&F>0){const be=M.characters.get(M.cameraFollowId),fe=u.current?.parentElement;if(be&&fe&&be.state===Y.WALK){const le=be.x*B,ke=be.y*B,Ae=fe.clientWidth,at=fe.clientHeight,We=fe.scrollLeft,He=fe.scrollTop,Bt=Ae*so,$t=at*so,vi=We+Bt,Ci=We+Ae-Bt,ki=He+$t,Ni=He+at-$t;let ut=We,ft=He;if(le<vi?ut=le-Bt:le>Ci&&(ut=le-Ae+Bt),ke<ki?ft=ke-$t:ke>Ni&&(ft=ke-at+$t),ut!==We||ft!==He){const Ws=1-Math.pow(1-cc,F*60);let jn=We+(ut-We)*Ws,An=He+(ft-He)*Ws;Math.abs(jn-ut)<no&&(jn=ut),Math.abs(An-ft)<no&&(An=ft),fe.scrollLeft=jn,fe.scrollTop=An}}}const U=window.devicePixelRatio||1,re=M.tileMap[0]?.length??1,ee=M.tileMap.length??1,xe=re*I*B,he=ee*I*B,se=z.getContext("2d");se.save(),se.scale(U,U),se.imageSmoothingEnabled=!1;const Ce={selectedAgentId:M.selectedAgentId,hoveredAgentId:M.hoveredAgentId,hoveredTile:M.hoveredTile,seats:M.seats,characters:M.characters,collisionFlash:M.collisionFlash},we=x.current.agentStatuses,Ve=new Map;for(const[be,fe]of Object.entries(we)){const le=Ke.get(be);le!==void 0&&Ve.set(le,fe)}ie!==null&&Ve.set(ie,"working");const Ls=new Map,Bs=x.current.agentSessionInfos;if(Bs)for(const[be,fe]of Object.entries(Bs)){const le=fe.taskName??Ld(fe.toolName,fe.detail);if(le){const ke=Ke.get(be);ke!==void 0&&Ls.set(ke,le)}}const At=new Map,$s=x.current.agentInteractions;if($s)for(const[be,fe]of $s){const le=Ke.get(be),ke=Ke.get(fe);le!==void 0&&ke!==void 0&&(At.set(le,ke),At.set(ke,le))}const wi={nameMap:zt,statusMap:Ve,colorMap:Pd,taskTextMap:Ls,interactionMap:At,time:D/1e3},Gs=[];if(At.size>0){const be=M.getCharacters(),fe=new Map(be.map(le=>[le.id,le]));for(const[le,ke]of At){const Ae=fe.get(le),at=fe.get(ke);if(Ae&&at&&Ae.state!==Y.WALK){Gs.push({ch:Ae,dir:Ae.dir});const We=at.x-Ae.x,He=at.y-Ae.y;Math.abs(We)>Math.abs(He)?Ae.dir=We>0?L.RIGHT:L.LEFT:Ae.dir=He>0?L.DOWN:L.UP}}}wd(se,xe,he,M.tileMap,M.furniture,M.getCharacters(),B,0,0,Ce,void 0,M.layout.tileColors,M.layout.cols,M.layout.rows,M.layout.gidLayers,wi);for(const be of Gs)be.ch.dir=be.dir;se.restore(),h.current=requestAnimationFrame(C)};h.current=requestAnimationFrame(C);const X=setInterval(()=>{if(!document.hidden)return;const D=m.current;D&&D.update(1/4)},250);return()=>{cancelAnimationFrame(h.current),clearInterval(X)}},[]),f.useEffect(()=>{if(ie===null)return;const C=requestAnimationFrame(()=>{const X=m.current,D=u.current?.parentElement;if(!X||!D)return;const z=X.characters.get(ie);if(!z)return;const M=N.current,F=z.x*M,B=z.y*M;D.scrollLeft=F-D.clientWidth/2,D.scrollTop=B-D.clientHeight/2});return()=>cancelAnimationFrame(C)},[]);const P=f.useCallback((C,X)=>{const D=N.current;return{worldX:C/D,worldY:X/D}},[]),q=f.useCallback(C=>zt.get(C)??"",[]),K=f.useCallback(C=>Ro.get(C)??"",[]),Q=f.useCallback((C,X)=>{const D=m.current;if(!D)return;const z=D.getCharacterAt(C,X);if(z!==null){D.selectedAgentId=z===D.selectedAgentId?null:z;const F=q(z);F&&x.current.onAgentClick&&x.current.onAgentClick(F);return}const M=D.getTileInfoAt(C,X);if(M&&M.type!=="wall"){D.selectedAgentId=null;let F;M.type==="desk"&&M.agentId!==void 0&&(F=K(M.agentId));const B={type:M.type,col:M.col,row:M.row,agentName:F};x.current.onItemClick&&x.current.onItemClick(B);return}if(ie!==null){const F=Math.floor(C/I),B=Math.floor(X/I);D.walkToTile(ie,F,B)||D.standUpFromSeat(ie)&&D.walkToTile(ie,F,B)}},[q,K]),oe=f.useCallback(C=>{},[]),ue=f.useCallback(C=>{const X=m.current;if(!X)return;const D=C.nativeEvent.offsetX,z=C.nativeEvent.offsetY,{worldX:M,worldY:F}=P(D,z),B=X.getCharacterAt(M,F);X.hoveredAgentId=B;const U=B===null?X.getTileInfoAt(M,F):null,re=B!==null||U!==null&&U.type!=="wall";if(d.current&&(d.current.style.cursor=re?"pointer":"default"),B===null&&!re){const ee=Math.floor(M/I),xe=Math.floor(F/I),he=Rr(ee,xe);if(he){const se=Ss[he],we=X.getAgentsInZone(se.bounds.minCol,se.bounds.minRow,se.bounds.maxCol,se.bounds.maxRow).map(Ve=>zt.get(Ve.id)??"").filter(Ve=>Ve!=="");k({x:D+12,y:z-8,roomName:se.label,agents:we})}else k(null)}else k(null)},[P]),ne=f.useCallback(C=>{const{worldX:X,worldY:D}=P(C.nativeEvent.offsetX,C.nativeEvent.offsetY);Q(X,D)},[P,Q]),V=f.useCallback(()=>{const C=m.current;C&&(C.hoveredAgentId=null),d.current&&(d.current.style.cursor="default"),k(null)},[]);return f.useEffect(()=>{const C=d.current;if(!C)return;function X(B){const U=C.getBoundingClientRect();return{x:B.clientX-U.left,y:B.clientY-U.top}}let D=null;function z(B){B.touches.length===1&&(D=X(B.touches[0]))}function M(B){if(D&&B.touches.length===1){const U=X(B.touches[0]),re=U.x-D.x,ee=U.y-D.y;Math.sqrt(re*re+ee*ee)>=10&&(D=null)}}function F(B){if(B.touches.length===0&&D){const U=m.current;if(U){const re=N.current,ee=D.x/re,xe=D.y/re,he=U.getCharacterAt(ee,xe);if(he!==null){U.selectedAgentId=he===U.selectedAgentId?null:he;const se=zt.get(he)??"";se&&x.current.onAgentClick&&x.current.onAgentClick(se)}else{const se=U.getTileInfoAt(ee,xe);if(se&&se.type!=="wall"){U.selectedAgentId=null;let Ce;se.type==="desk"&&se.agentId!==void 0&&(Ce=Ro.get(se.agentId)),x.current.onItemClick&&x.current.onItemClick({type:se.type,col:se.col,row:se.row,agentName:Ce})}else if(ie!==null){const Ce=Math.floor(ee/I),we=Math.floor(xe/I);U.walkToTile(ie,Ce,we)||U.standUpFromSeat(ie)&&U.walkToTile(ie,Ce,we)}}}}D=null}return C.addEventListener("touchstart",z,{passive:!0}),C.addEventListener("touchmove",M,{passive:!0}),C.addEventListener("touchend",F,{passive:!0}),()=>{C.removeEventListener("touchstart",z),C.removeEventListener("touchmove",M),C.removeEventListener("touchend",F)}},[]),r.jsxs("div",{ref:u,className:"relative",style:{width:Math.ceil(G),height:Math.ceil(W)},children:[r.jsx("canvas",{ref:d,className:"block touch-none outline-none",tabIndex:0,onMouseDown:oe,onMouseMove:ue,onMouseUp:ne,onMouseLeave:V,"aria-label":"Office simulation",role:"img"}),v&&r.jsxs("div",{className:"absolute pointer-events-none bg-black/80 text-white text-xs px-3 py-2 rounded-lg shadow-lg",style:{left:v.x,top:v.y,maxWidth:200},role:"tooltip",children:[r.jsx("div",{className:"font-semibold mb-0.5",children:v.roomName}),v.agents.length>0?r.jsx("div",{className:"text-white/70",children:v.agents.join(", ")}):r.jsx("div",{className:"text-white/50 italic",children:"Empty"})]})]})}function Io(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Cn(...e){return t=>{let n=!1;const s=e.map(o=>{const a=Io(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<s.length;o++){const a=s[o];typeof a=="function"?a():Io(e[o],null)}}}}function je(...e){return f.useCallback(Cn(...e),e)}var $d=Symbol.for("react.lazy"),un=vs[" use ".trim().toString()];function Gd(e){return typeof e=="object"&&e!==null&&"then"in e}function Yr(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===$d&&"_payload"in e&&Gd(e._payload)}function Wd(e){const t=Ud(e),n=f.forwardRef((s,o)=>{let{children:a,...l}=s;Yr(a)&&typeof un=="function"&&(a=un(a._payload));const i=f.Children.toArray(a),c=i.find(zd);if(c){const d=c.props.children,u=i.map(m=>m===c?f.Children.count(d)>1?f.Children.only(null):f.isValidElement(d)?d.props.children:null:m);return r.jsx(t,{...l,ref:o,children:f.isValidElement(d)?f.cloneElement(d,void 0,u):null})}return r.jsx(t,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var Hd=Wd("Slot");function Ud(e){const t=f.forwardRef((n,s)=>{let{children:o,...a}=n;if(Yr(o)&&typeof un=="function"&&(o=un(o._payload)),f.isValidElement(o)){const l=Kd(o),i=Vd(a,o.props);return o.type!==f.Fragment&&(i.ref=s?Cn(s,l):l),f.cloneElement(o,i)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Yd=Symbol("radix.slottable");function zd(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Yd}function Vd(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...i)=>{const c=a(...i);return o(...i),c}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Kd(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function zr(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=zr(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function Vr(){for(var e,t,n=0,s="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=zr(e))&&(s&&(s+=" "),s+=t);return s}const Po=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,_o=Vr,Kr=(e,t)=>n=>{var s;if(t?.variants==null)return _o(e,n?.class,n?.className);const{variants:o,defaultVariants:a}=t,l=Object.keys(o).map(d=>{const u=n?.[d],m=a?.[d];if(u===null)return null;const h=Po(u)||Po(m);return o[d][h]}),i=n&&Object.entries(n).reduce((d,u)=>{let[m,h]=u;return h===void 0||(d[m]=h),d},{}),c=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((d,u)=>{let{class:m,className:h,...p}=u;return Object.entries(p).every(x=>{let[b,w]=x;return Array.isArray(w)?w.includes({...a,...i}[b]):{...a,...i}[b]===w})?[...d,m,h]:d},[]);return _o(e,l,c,n?.class,n?.className)},Zd=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s<e.length;s++)n[s]=e[s];for(let s=0;s<t.length;s++)n[e.length+s]=t[s];return n},qd=(e,t)=>({classGroupId:e,validator:t}),Zr=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),fn="-",Mo=[],Qd="arbitrary..",Jd=e=>{const t=tu(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return eu(l);const i=l.split(fn),c=i[0]===""&&i.length>1?1:0;return qr(i,c,t)},getConflictingClassGroupIds:(l,i)=>{if(i){const c=s[l],d=n[l];return c?d?Zd(d,c):c:d||Mo}return n[l]||Mo}}},qr=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],a=n.nextPart.get(o);if(a){const d=qr(e,t+1,a);if(d)return d}const l=n.validators;if(l===null)return;const i=t===0?e.join(fn):e.slice(t).join(fn),c=l.length;for(let d=0;d<c;d++){const u=l[d];if(u.validator(i))return u.classGroupId}},eu=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?Qd+s:void 0})(),tu=e=>{const{theme:t,classGroups:n}=e;return nu(n,t)},nu=(e,t)=>{const n=Zr();for(const s in e){const o=e[s];As(o,n,s,t)}return n},As=(e,t,n,s)=>{const o=e.length;for(let a=0;a<o;a++){const l=e[a];su(l,t,n,s)}},su=(e,t,n,s)=>{if(typeof e=="string"){ou(e,t,n);return}if(typeof e=="function"){ru(e,t,n,s);return}au(e,t,n,s)},ou=(e,t,n)=>{const s=e===""?t:Qr(t,e);s.classGroupId=n},ru=(e,t,n,s)=>{if(iu(e)){As(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(qd(n,e))},au=(e,t,n,s)=>{const o=Object.entries(e),a=o.length;for(let l=0;l<a;l++){const[i,c]=o[l];As(c,Qr(t,i),n,s)}},Qr=(e,t)=>{let n=e;const s=t.split(fn),o=s.length;for(let a=0;a<o;a++){const l=s[a];let i=n.nextPart.get(l);i||(i=Zr(),n.nextPart.set(l,i)),n=i}return n},iu=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,lu=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const o=(a,l)=>{n[a]=l,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(a){let l=n[a];if(l!==void 0)return l;if((l=s[a])!==void 0)return o(a,l),l},set(a,l){a in n?n[a]=l:o(a,l)}}},hs="!",Fo=":",cu=[],Oo=(e,t,n,s,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:o}),du=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=o=>{const a=[];let l=0,i=0,c=0,d;const u=o.length;for(let b=0;b<u;b++){const w=o[b];if(l===0&&i===0){if(w===Fo){a.push(o.slice(c,b)),c=b+1;continue}if(w==="/"){d=b;continue}}w==="["?l++:w==="]"?l--:w==="("?i++:w===")"&&i--}const m=a.length===0?o:o.slice(c);let h=m,p=!1;m.endsWith(hs)?(h=m.slice(0,-1),p=!0):m.startsWith(hs)&&(h=m.slice(1),p=!0);const x=d&&d>c?d-c:void 0;return Oo(a,p,h,x)};if(t){const o=t+Fo,a=s;s=l=>l.startsWith(o)?a(l.slice(o.length)):Oo(cu,!1,l,void 0,!0)}if(n){const o=s;s=a=>n({className:a,parseClassName:o})}return s},uu=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];let o=[];for(let a=0;a<n.length;a++){const l=n[a],i=l[0]==="[",c=t.has(l);i||c?(o.length>0&&(o.sort(),s.push(...o),o=[]),s.push(l)):o.push(l)}return o.length>0&&(o.sort(),s.push(...o)),s}},fu=e=>({cache:lu(e.cacheSize),parseClassName:du(e),sortModifiers:uu(e),...Jd(e)}),mu=/\s+/,pu=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o,sortModifiers:a}=t,l=[],i=e.trim().split(mu);let c="";for(let d=i.length-1;d>=0;d-=1){const u=i[d],{isExternal:m,modifiers:h,hasImportantModifier:p,baseClassName:x,maybePostfixModifierPosition:b}=n(u);if(m){c=u+(c.length>0?" "+c:c);continue}let w=!!b,y=s(w?x.substring(0,b):x);if(!y){if(!w){c=u+(c.length>0?" "+c:c);continue}if(y=s(x),!y){c=u+(c.length>0?" "+c:c);continue}w=!1}const S=h.length===0?"":h.length===1?h[0]:a(h).join(":"),N=p?S+hs:S,v=N+y;if(l.indexOf(v)>-1)continue;l.push(v);const k=o(y,w);for(let E=0;E<k.length;++E){const A=k[E];l.push(N+A)}c=u+(c.length>0?" "+c:c)}return c},hu=(...e)=>{let t=0,n,s,o="";for(;t<e.length;)(n=e[t++])&&(s=Jr(n))&&(o&&(o+=" "),o+=s);return o},Jr=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=Jr(e[s]))&&(n&&(n+=" "),n+=t);return n},gu=(e,...t)=>{let n,s,o,a;const l=c=>{const d=t.reduce((u,m)=>m(u),e());return n=fu(d),s=n.cache.get,o=n.cache.set,a=i,i(c)},i=c=>{const d=s(c);if(d)return d;const u=pu(c,n);return o(c,u),u};return a=l,(...c)=>a(hu(...c))},xu=[],ce=e=>{const t=n=>n[e]||xu;return t.isThemeGetter=!0,t},ea=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ta=/^\((?:(\w[\w-]*):)?(.+)\)$/i,bu=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,yu=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wu=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,vu=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Cu=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ku=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ze=e=>bu.test(e),Z=e=>!!e&&!Number.isNaN(Number(e)),qe=e=>!!e&&Number.isInteger(Number(e)),Yn=e=>e.endsWith("%")&&Z(e.slice(0,-1)),Ue=e=>yu.test(e),na=()=>!0,Nu=e=>wu.test(e)&&!vu.test(e),Ts=()=>!1,Su=e=>Cu.test(e),Eu=e=>ku.test(e),ju=e=>!_(e)&&!O(e),Au=e=>ot(e,ra,Ts),_=e=>ea.test(e),it=e=>ot(e,aa,Nu),Lo=e=>ot(e,Mu,Z),Tu=e=>ot(e,la,na),Xu=e=>ot(e,ia,Ts),Bo=e=>ot(e,sa,Ts),Ru=e=>ot(e,oa,Eu),Vt=e=>ot(e,ca,Su),O=e=>ta.test(e),Dt=e=>dt(e,aa),Du=e=>dt(e,ia),$o=e=>dt(e,sa),Iu=e=>dt(e,ra),Pu=e=>dt(e,oa),Kt=e=>dt(e,ca,!0),_u=e=>dt(e,la,!0),ot=(e,t,n)=>{const s=ea.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},dt=(e,t,n=!1)=>{const s=ta.exec(e);return s?s[1]?t(s[1]):n:!1},sa=e=>e==="position"||e==="percentage",oa=e=>e==="image"||e==="url",ra=e=>e==="length"||e==="size"||e==="bg-size",aa=e=>e==="length",Mu=e=>e==="number",ia=e=>e==="family-name",la=e=>e==="number"||e==="weight",ca=e=>e==="shadow",Fu=()=>{const e=ce("color"),t=ce("font"),n=ce("text"),s=ce("font-weight"),o=ce("tracking"),a=ce("leading"),l=ce("breakpoint"),i=ce("container"),c=ce("spacing"),d=ce("radius"),u=ce("shadow"),m=ce("inset-shadow"),h=ce("text-shadow"),p=ce("drop-shadow"),x=ce("blur"),b=ce("perspective"),w=ce("aspect"),y=ce("ease"),S=ce("animate"),N=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...v(),O,_],E=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],j=()=>[O,_,c],T=()=>[Ze,"full","auto",...j()],G=()=>[qe,"none","subgrid",O,_],W=()=>["auto",{span:["full",qe,O,_]},qe,O,_],P=()=>[qe,"auto",O,_],q=()=>["auto","min","max","fr",O,_],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Q=()=>["start","end","center","stretch","center-safe","end-safe"],oe=()=>["auto",...j()],ue=()=>[Ze,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],ne=()=>[Ze,"screen","full","dvw","lvw","svw","min","max","fit",...j()],V=()=>[Ze,"screen","full","lh","dvh","lvh","svh","min","max","fit",...j()],C=()=>[e,O,_],X=()=>[...v(),$o,Bo,{position:[O,_]}],D=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",Iu,Au,{size:[O,_]}],M=()=>[Yn,Dt,it],F=()=>["","none","full",d,O,_],B=()=>["",Z,Dt,it],U=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>[Z,Yn,$o,Bo],xe=()=>["","none",x,O,_],he=()=>["none",Z,O,_],se=()=>["none",Z,O,_],Ce=()=>[Z,O,_],we=()=>[Ze,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ue],breakpoint:[Ue],color:[na],container:[Ue],"drop-shadow":[Ue],ease:["in","out","in-out"],font:[ju],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ue],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ue],shadow:[Ue],spacing:["px",Z],text:[Ue],"text-shadow":[Ue],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ze,_,O,w]}],container:["container"],columns:[{columns:[Z,_,O,i]}],"break-after":[{"break-after":N()}],"break-before":[{"break-before":N()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[qe,"auto",O,_]}],basis:[{basis:[Ze,"full","auto",i,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Z,Ze,"auto","initial","none",_]}],grow:[{grow:["",Z,O,_]}],shrink:[{shrink:["",Z,O,_]}],order:[{order:[qe,"first","last","none",O,_]}],"grid-cols":[{"grid-cols":G()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":G()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":q()}],"auto-rows":[{"auto-rows":q()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[...Q(),"normal"]}],"justify-self":[{"justify-self":["auto",...Q()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[...Q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Q(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[...Q(),"baseline"]}],"place-self":[{"place-self":["auto",...Q()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pbs:[{pbs:j()}],pbe:[{pbe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:oe()}],mx:[{mx:oe()}],my:[{my:oe()}],ms:[{ms:oe()}],me:[{me:oe()}],mbs:[{mbs:oe()}],mbe:[{mbe:oe()}],mt:[{mt:oe()}],mr:[{mr:oe()}],mb:[{mb:oe()}],ml:[{ml:oe()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:ue()}],"inline-size":[{inline:["auto",...ne()]}],"min-inline-size":[{"min-inline":["auto",...ne()]}],"max-inline-size":[{"max-inline":["none",...ne()]}],"block-size":[{block:["auto",...V()]}],"min-block-size":[{"min-block":["auto",...V()]}],"max-block-size":[{"max-block":["none",...V()]}],w:[{w:[i,"screen",...ue()]}],"min-w":[{"min-w":[i,"screen","none",...ue()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...ue()]}],h:[{h:["screen","lh",...ue()]}],"min-h":[{"min-h":["screen","lh","none",...ue()]}],"max-h":[{"max-h":["screen","lh",...ue()]}],"font-size":[{text:["base",n,Dt,it]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,_u,Tu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yn,_]}],"font-family":[{font:[Du,Xu,t]}],"font-features":[{"font-features":[_]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,O,_]}],"line-clamp":[{"line-clamp":[Z,"none",O,Lo]}],leading:[{leading:[a,...j()]}],"list-image":[{"list-image":["none",O,_]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",O,_]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:C()}],"text-color":[{text:C()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[Z,"from-font","auto",O,it]}],"text-decoration-color":[{decoration:C()}],"underline-offset":[{"underline-offset":[Z,"auto",O,_]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",O,_]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",O,_]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:X()}],"bg-repeat":[{bg:D()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qe,O,_],radial:["",O,_],conic:[qe,O,_]},Pu,Ru]}],"bg-color":[{bg:C()}],"gradient-from-pos":[{from:M()}],"gradient-via-pos":[{via:M()}],"gradient-to-pos":[{to:M()}],"gradient-from":[{from:C()}],"gradient-via":[{via:C()}],"gradient-to":[{to:C()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-bs":[{"border-bs":B()}],"border-w-be":[{"border-be":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:C()}],"border-color-x":[{"border-x":C()}],"border-color-y":[{"border-y":C()}],"border-color-s":[{"border-s":C()}],"border-color-e":[{"border-e":C()}],"border-color-bs":[{"border-bs":C()}],"border-color-be":[{"border-be":C()}],"border-color-t":[{"border-t":C()}],"border-color-r":[{"border-r":C()}],"border-color-b":[{"border-b":C()}],"border-color-l":[{"border-l":C()}],"divide-color":[{divide:C()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Z,O,_]}],"outline-w":[{outline:["",Z,Dt,it]}],"outline-color":[{outline:C()}],shadow:[{shadow:["","none",u,Kt,Vt]}],"shadow-color":[{shadow:C()}],"inset-shadow":[{"inset-shadow":["none",m,Kt,Vt]}],"inset-shadow-color":[{"inset-shadow":C()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:C()}],"ring-offset-w":[{"ring-offset":[Z,it]}],"ring-offset-color":[{"ring-offset":C()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":C()}],"text-shadow":[{"text-shadow":["none",h,Kt,Vt]}],"text-shadow-color":[{"text-shadow":C()}],opacity:[{opacity:[Z,O,_]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Z]}],"mask-image-linear-from-pos":[{"mask-linear-from":ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":ee()}],"mask-image-linear-from-color":[{"mask-linear-from":C()}],"mask-image-linear-to-color":[{"mask-linear-to":C()}],"mask-image-t-from-pos":[{"mask-t-from":ee()}],"mask-image-t-to-pos":[{"mask-t-to":ee()}],"mask-image-t-from-color":[{"mask-t-from":C()}],"mask-image-t-to-color":[{"mask-t-to":C()}],"mask-image-r-from-pos":[{"mask-r-from":ee()}],"mask-image-r-to-pos":[{"mask-r-to":ee()}],"mask-image-r-from-color":[{"mask-r-from":C()}],"mask-image-r-to-color":[{"mask-r-to":C()}],"mask-image-b-from-pos":[{"mask-b-from":ee()}],"mask-image-b-to-pos":[{"mask-b-to":ee()}],"mask-image-b-from-color":[{"mask-b-from":C()}],"mask-image-b-to-color":[{"mask-b-to":C()}],"mask-image-l-from-pos":[{"mask-l-from":ee()}],"mask-image-l-to-pos":[{"mask-l-to":ee()}],"mask-image-l-from-color":[{"mask-l-from":C()}],"mask-image-l-to-color":[{"mask-l-to":C()}],"mask-image-x-from-pos":[{"mask-x-from":ee()}],"mask-image-x-to-pos":[{"mask-x-to":ee()}],"mask-image-x-from-color":[{"mask-x-from":C()}],"mask-image-x-to-color":[{"mask-x-to":C()}],"mask-image-y-from-pos":[{"mask-y-from":ee()}],"mask-image-y-to-pos":[{"mask-y-to":ee()}],"mask-image-y-from-color":[{"mask-y-from":C()}],"mask-image-y-to-color":[{"mask-y-to":C()}],"mask-image-radial":[{"mask-radial":[O,_]}],"mask-image-radial-from-pos":[{"mask-radial-from":ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":ee()}],"mask-image-radial-from-color":[{"mask-radial-from":C()}],"mask-image-radial-to-color":[{"mask-radial-to":C()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[Z]}],"mask-image-conic-from-pos":[{"mask-conic-from":ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":ee()}],"mask-image-conic-from-color":[{"mask-conic-from":C()}],"mask-image-conic-to-color":[{"mask-conic-to":C()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:X()}],"mask-repeat":[{mask:D()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",O,_]}],filter:[{filter:["","none",O,_]}],blur:[{blur:xe()}],brightness:[{brightness:[Z,O,_]}],contrast:[{contrast:[Z,O,_]}],"drop-shadow":[{"drop-shadow":["","none",p,Kt,Vt]}],"drop-shadow-color":[{"drop-shadow":C()}],grayscale:[{grayscale:["",Z,O,_]}],"hue-rotate":[{"hue-rotate":[Z,O,_]}],invert:[{invert:["",Z,O,_]}],saturate:[{saturate:[Z,O,_]}],sepia:[{sepia:["",Z,O,_]}],"backdrop-filter":[{"backdrop-filter":["","none",O,_]}],"backdrop-blur":[{"backdrop-blur":xe()}],"backdrop-brightness":[{"backdrop-brightness":[Z,O,_]}],"backdrop-contrast":[{"backdrop-contrast":[Z,O,_]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Z,O,_]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Z,O,_]}],"backdrop-invert":[{"backdrop-invert":["",Z,O,_]}],"backdrop-opacity":[{"backdrop-opacity":[Z,O,_]}],"backdrop-saturate":[{"backdrop-saturate":[Z,O,_]}],"backdrop-sepia":[{"backdrop-sepia":["",Z,O,_]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",O,_]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Z,"initial",O,_]}],ease:[{ease:["linear","initial",y,O,_]}],delay:[{delay:[Z,O,_]}],animate:[{animate:["none",S,O,_]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,O,_]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:se()}],"scale-x":[{"scale-x":se()}],"scale-y":[{"scale-y":se()}],"scale-z":[{"scale-z":se()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[O,_,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:we()}],"translate-x":[{"translate-x":we()}],"translate-y":[{"translate-y":we()}],"translate-z":[{"translate-z":we()}],"translate-none":["translate-none"],accent:[{accent:C()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:C()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",O,_]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mbs":[{"scroll-mbs":j()}],"scroll-mbe":[{"scroll-mbe":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pbs":[{"scroll-pbs":j()}],"scroll-pbe":[{"scroll-pbe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",O,_]}],fill:[{fill:["none",...C()]}],"stroke-w":[{stroke:[Z,Dt,it,Lo]}],stroke:[{stroke:["none",...C()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Ou=gu(Fu);function de(...e){return Ou(Vr(e))}function et(e){if(!e)return"never";const t=Date.now(),n=new Date(e).getTime(),s=Math.floor((t-n)/1e3);if(s<0||s<10)return"just now";if(s<60)return`${s}s ago`;const o=Math.floor(s/60);if(o<60)return`${o}m ago`;const a=Math.floor(o/60);if(a<24)return`${a}h ago`;const l=Math.floor(a/24);return l<30?`${l}d ago`:`${Math.floor(l/30)}mo ago`}function Lu(e){switch(e){case"working":return"Working";case"waiting-approval":return"Waiting Approval";case"waiting-input":return"Waiting Input";case"done":return"Done";case"paused":return"Paused";case"idle":return"Idle";case"error":return"Error";default:return e}}const Bu=Kr("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),_e=f.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...o},a)=>{const l=s?Hd:"button";return r.jsx(l,{className:de(Bu({variant:t,size:n,className:e})),ref:a,...o})});_e.displayName="Button";function $u(e){const t=Gu(e),n=f.forwardRef((s,o)=>{const{children:a,...l}=s,i=f.Children.toArray(a),c=i.find(Hu);if(c){const d=c.props.children,u=i.map(m=>m===c?f.Children.count(d)>1?f.Children.only(null):f.isValidElement(d)?d.props.children:null:m);return r.jsx(t,{...l,ref:o,children:f.isValidElement(d)?f.cloneElement(d,void 0,u):null})}return r.jsx(t,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Gu(e){const t=f.forwardRef((n,s)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const l=Yu(o),i=Uu(a,o.props);return o.type!==f.Fragment&&(i.ref=s?Cn(s,l):l),f.cloneElement(o,i)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Wu=Symbol("radix.slottable");function Hu(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Wu}function Uu(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...i)=>{const c=a(...i);return o(...i),c}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Yu(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var zu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=zu.reduce((e,t)=>{const n=$u(`Primitive.${t}`),s=f.forwardRef((o,a)=>{const{asChild:l,...i}=o,c=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(c,{...i,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Vu(e,t){e&&Si.flushSync(()=>e.dispatchEvent(t))}var vt=globalThis?.document?f.useLayoutEffect:()=>{};function Ku(e,t){return f.useReducer((n,s)=>t[n][s]??n,e)}var rt=e=>{const{present:t,children:n}=e,s=Zu(t),o=typeof n=="function"?n({present:s.isPresent}):f.Children.only(n),a=je(s.ref,qu(o));return typeof n=="function"||s.isPresent?f.cloneElement(o,{ref:a}):null};rt.displayName="Presence";function Zu(e){const[t,n]=f.useState(),s=f.useRef(null),o=f.useRef(e),a=f.useRef("none"),l=e?"mounted":"unmounted",[i,c]=Ku(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{const d=Zt(s.current);a.current=i==="mounted"?d:"none"},[i]),vt(()=>{const d=s.current,u=o.current;if(u!==e){const h=a.current,p=Zt(d);e?c("MOUNT"):p==="none"||d?.display==="none"?c("UNMOUNT"):c(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),vt(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,m=p=>{const b=Zt(s.current).includes(CSS.escape(p.animationName));if(p.target===t&&b&&(c("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=p=>{p.target===t&&(a.current=Zt(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:f.useCallback(d=>{s.current=d?getComputedStyle(d):null,n(d)},[])}}function Zt(e){return e?.animationName||"none"}function qu(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Qu(e,t){const n=f.createContext(t),s=a=>{const{children:l,...i}=a,c=f.useMemo(()=>i,Object.values(i));return r.jsx(n.Provider,{value:c,children:l})};s.displayName=e+"Provider";function o(a){const l=f.useContext(n);if(l)return l;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,o]}function da(e,t=[]){let n=[];function s(a,l){const i=f.createContext(l),c=n.length;n=[...n,l];const d=m=>{const{scope:h,children:p,...x}=m,b=h?.[e]?.[c]||i,w=f.useMemo(()=>x,Object.values(x));return r.jsx(b.Provider,{value:w,children:p})};d.displayName=a+"Provider";function u(m,h){const p=h?.[e]?.[c]||i,x=f.useContext(p);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[d,u]}const o=()=>{const a=n.map(l=>f.createContext(l));return function(i){const c=i?.[e]||a;return f.useMemo(()=>({[`__scope${e}`]:{...i,[e]:c}}),[i,c])}};return o.scopeName=e,[s,Ju(o,...t)]}function Ju(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((i,{useScope:c,scopeName:d})=>{const m=c(a)[`__scope${d}`];return{...i,...m}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function Xe(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>t.current?.(...n),[])}var ef=f.createContext(void 0);function tf(e){const t=f.useContext(ef);return e||t||"ltr"}function nf(e,[t,n]){return Math.min(n,Math.max(t,e))}function ye(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function sf(e,t){return f.useReducer((n,s)=>t[n][s]??n,e)}var Xs="ScrollArea",[ua]=da(Xs),[of,De]=ua(Xs),fa=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:a=600,...l}=e,[i,c]=f.useState(null),[d,u]=f.useState(null),[m,h]=f.useState(null),[p,x]=f.useState(null),[b,w]=f.useState(null),[y,S]=f.useState(0),[N,v]=f.useState(0),[k,E]=f.useState(!1),[A,j]=f.useState(!1),T=je(t,W=>c(W)),G=tf(o);return r.jsx(of,{scope:n,type:s,dir:G,scrollHideDelay:a,scrollArea:i,viewport:d,onViewportChange:u,content:m,onContentChange:h,scrollbarX:p,onScrollbarXChange:x,scrollbarXEnabled:k,onScrollbarXEnabledChange:E,scrollbarY:b,onScrollbarYChange:w,scrollbarYEnabled:A,onScrollbarYEnabledChange:j,onCornerWidthChange:S,onCornerHeightChange:v,children:r.jsx(ve.div,{dir:G,...l,ref:T,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":N+"px",...e.style}})})});fa.displayName=Xs;var ma="ScrollAreaViewport",pa=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...a}=e,l=De(ma,n),i=f.useRef(null),c=je(t,i,l.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),r.jsx(ve.div,{"data-radix-scroll-area-viewport":"",...a,ref:c,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});pa.displayName=ma;var Ge="ScrollAreaScrollbar",Rs=f.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=De(Ge,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:l}=o,i=e.orientation==="horizontal";return f.useEffect(()=>(i?a(!0):l(!0),()=>{i?a(!1):l(!1)}),[i,a,l]),o.type==="hover"?r.jsx(rf,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(af,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(ha,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(Ds,{...s,ref:t}):null});Rs.displayName=Ge;var rf=f.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=De(Ge,e.__scopeScrollArea),[a,l]=f.useState(!1);return f.useEffect(()=>{const i=o.scrollArea;let c=0;if(i){const d=()=>{window.clearTimeout(c),l(!0)},u=()=>{c=window.setTimeout(()=>l(!1),o.scrollHideDelay)};return i.addEventListener("pointerenter",d),i.addEventListener("pointerleave",u),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",d),i.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(rt,{present:n||a,children:r.jsx(ha,{"data-state":a?"visible":"hidden",...s,ref:t})})}),af=f.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=De(Ge,e.__scopeScrollArea),a=e.orientation==="horizontal",l=Nn(()=>c("SCROLL_END"),100),[i,c]=sf("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return f.useEffect(()=>{if(i==="idle"){const d=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(d)}},[i,o.scrollHideDelay,c]),f.useEffect(()=>{const d=o.viewport,u=a?"scrollLeft":"scrollTop";if(d){let m=d[u];const h=()=>{const p=d[u];m!==p&&(c("SCROLL"),l()),m=p};return d.addEventListener("scroll",h),()=>d.removeEventListener("scroll",h)}},[o.viewport,a,c,l]),r.jsx(rt,{present:n||i!=="hidden",children:r.jsx(Ds,{"data-state":i==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:ye(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ye(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),ha=f.forwardRef((e,t)=>{const n=De(Ge,e.__scopeScrollArea),{forceMount:s,...o}=e,[a,l]=f.useState(!1),i=e.orientation==="horizontal",c=Nn(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;l(i?d:u)}},10);return Ct(n.viewport,c),Ct(n.content,c),r.jsx(rt,{present:s||a,children:r.jsx(Ds,{"data-state":a?"visible":"hidden",...o,ref:t})})}),Ds=f.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=De(Ge,e.__scopeScrollArea),a=f.useRef(null),l=f.useRef(0),[i,c]=f.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=wa(i.viewport,i.content),u={...s,sizes:i,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:h=>l.current=h};function m(h,p){return mf(h,l.current,i,p)}return n==="horizontal"?r.jsx(lf,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,p=Go(h,i,o.dir);a.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=m(h,o.dir))}}):n==="vertical"?r.jsx(cf,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,p=Go(h,i);a.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=m(h))}}):null}),lf=f.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=De(Ge,e.__scopeScrollArea),[l,i]=f.useState(),c=f.useRef(null),d=je(t,c,a.onScrollbarXChange);return f.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),r.jsx(xa,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":kn(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,m)=>{if(a.viewport){const h=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),Ca(h,m)&&u.preventDefault()}},onResize:()=>{c.current&&a.viewport&&l&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:pn(l.paddingLeft),paddingEnd:pn(l.paddingRight)}})}})}),cf=f.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=De(Ge,e.__scopeScrollArea),[l,i]=f.useState(),c=f.useRef(null),d=je(t,c,a.onScrollbarYChange);return f.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),r.jsx(xa,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":kn(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,m)=>{if(a.viewport){const h=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),Ca(h,m)&&u.preventDefault()}},onResize:()=>{c.current&&a.viewport&&l&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:pn(l.paddingTop),paddingEnd:pn(l.paddingBottom)}})}})}),[df,ga]=ua(Ge),xa=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:a,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:m,...h}=e,p=De(Ge,n),[x,b]=f.useState(null),w=je(t,T=>b(T)),y=f.useRef(null),S=f.useRef(""),N=p.viewport,v=s.content-s.viewport,k=Xe(u),E=Xe(c),A=Nn(m,10);function j(T){if(y.current){const G=T.clientX-y.current.left,W=T.clientY-y.current.top;d({x:G,y:W})}}return f.useEffect(()=>{const T=G=>{const W=G.target;x?.contains(W)&&k(G,v)};return document.addEventListener("wheel",T,{passive:!1}),()=>document.removeEventListener("wheel",T,{passive:!1})},[N,x,v,k]),f.useEffect(E,[s,E]),Ct(x,A),Ct(p.content,A),r.jsx(df,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Xe(a),onThumbPointerUp:Xe(l),onThumbPositionChange:E,onThumbPointerDown:Xe(i),children:r.jsx(ve.div,{...h,ref:w,style:{position:"absolute",...h.style},onPointerDown:ye(e.onPointerDown,T=>{T.button===0&&(T.target.setPointerCapture(T.pointerId),y.current=x.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(T))}),onPointerMove:ye(e.onPointerMove,j),onPointerUp:ye(e.onPointerUp,T=>{const G=T.target;G.hasPointerCapture(T.pointerId)&&G.releasePointerCapture(T.pointerId),document.body.style.webkitUserSelect=S.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),mn="ScrollAreaThumb",ba=f.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ga(mn,e.__scopeScrollArea);return r.jsx(rt,{present:n||o.hasThumb,children:r.jsx(uf,{ref:t,...s})})}),uf=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,a=De(mn,n),l=ga(mn,n),{onThumbPositionChange:i}=l,c=je(t,m=>l.onThumbChange(m)),d=f.useRef(void 0),u=Nn(()=>{d.current&&(d.current(),d.current=void 0)},100);return f.useEffect(()=>{const m=a.viewport;if(m){const h=()=>{if(u(),!d.current){const p=pf(m,i);d.current=p,i()}};return i(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,u,i]),r.jsx(ve.div,{"data-state":l.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:ye(e.onPointerDownCapture,m=>{const p=m.target.getBoundingClientRect(),x=m.clientX-p.left,b=m.clientY-p.top;l.onThumbPointerDown({x,y:b})}),onPointerUp:ye(e.onPointerUp,l.onThumbPointerUp)})});ba.displayName=mn;var Is="ScrollAreaCorner",ya=f.forwardRef((e,t)=>{const n=De(Is,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(ff,{...e,ref:t}):null});ya.displayName=Is;var ff=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=De(Is,n),[a,l]=f.useState(0),[i,c]=f.useState(0),d=!!(a&&i);return Ct(o.scrollbarX,()=>{const u=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(u),c(u)}),Ct(o.scrollbarY,()=>{const u=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(u),l(u)}),d?r.jsx(ve.div,{...s,ref:t,style:{width:a,height:i,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function pn(e){return e?parseInt(e,10):0}function wa(e,t){const n=e/t;return isNaN(n)?0:n}function kn(e){const t=wa(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function mf(e,t,n,s="ltr"){const o=kn(n),a=o/2,l=t||a,i=o-l,c=n.scrollbar.paddingStart+l,d=n.scrollbar.size-n.scrollbar.paddingEnd-i,u=n.content-n.viewport,m=s==="ltr"?[0,u]:[u*-1,0];return va([c,d],m)(e)}function Go(e,t,n="ltr"){const s=kn(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,l=t.content-t.viewport,i=a-s,c=n==="ltr"?[0,l]:[l*-1,0],d=nf(e,c);return va([0,l],[0,i])(d)}function va(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function Ca(e,t){return e>0&&e<t}var pf=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return(function o(){const a={left:e.scrollLeft,top:e.scrollTop},l=n.left!==a.left,i=n.top!==a.top;(l||i)&&t(),n=a,s=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(s)};function Nn(e,t){const n=Xe(e),s=f.useRef(0);return f.useEffect(()=>()=>window.clearTimeout(s.current),[]),f.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function Ct(e,t){const n=Xe(t);vt(()=>{let s=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(s),o.unobserve(e)}}},[e,n])}var ka=fa,hf=pa,gf=ya;const gs=f.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(ka,{ref:s,className:de("relative overflow-hidden",e),...n,children:[r.jsx(hf,{className:"h-full w-full rounded-[inherit] [&>div]:!block",children:t}),r.jsx(Na,{}),r.jsx(gf,{})]}));gs.displayName=ka.displayName;const Na=f.forwardRef(({className:e,orientation:t="vertical",...n},s)=>r.jsx(Rs,{ref:s,orientation:t,className:de("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:r.jsx(ba,{className:"relative flex-1 rounded-full bg-border"})}));Na.displayName=Rs.displayName;async function xf(e,t){const n=await fetch(`${bt}/api/actions/send-input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paneId:e,type:t,input:""})});if(!n.ok)throw new Error(`Request failed: ${n.status}`)}function Ps({paneId:e,sessionStatus:t,terminalApp:n,onAction:s}){const[o,a]=f.useState(null);if(t!=="waiting-input"&&t!=="waiting-approval")return null;if(!(n==="tmux"||n==="iterm2"))return r.jsxs("div",{className:"mt-3 text-xs text-muted-foreground italic",children:["Input not available",n?` (${n})`:""]});async function i(c){if(!o){a(c);try{await xf(e,c),s?.()}catch{}finally{a(null)}}}return r.jsxs("div",{className:"mt-3 flex items-center gap-1.5",children:[r.jsxs(_e,{size:"sm",variant:"outline",className:de("h-7 px-2 text-xs flex-1","text-green-500 border-green-500/30 hover:bg-green-500/10 hover:text-green-500"),onClick:()=>i("approve"),disabled:o!==null,children:[o==="approve"?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(Cs,{className:"h-3 w-3"}),r.jsx("span",{className:"ml-1",children:"Approve"})]}),r.jsxs(_e,{size:"sm",variant:"outline",className:de("h-7 px-2 text-xs flex-1","text-red-500 border-red-500/30 hover:bg-red-500/10 hover:text-red-500"),onClick:()=>i("reject"),disabled:o!==null,children:[o==="reject"?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(cn,{className:"h-3 w-3"}),r.jsx("span",{className:"ml-1",children:"Reject"})]}),r.jsxs(_e,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-1 text-muted-foreground",onClick:()=>i("abort"),disabled:o!==null,children:[o==="abort"?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(Fi,{className:"h-3 w-3"}),r.jsx("span",{className:"ml-1",children:"Abort"})]})]})}const g={bg:"#F5ECD7",card:"#E8D5B0",cardHover:"#E0CCA0",text:"#3D2B1F",textDim:"#4A3328",border:"#C4A265",accent:"#C4A265"},te={backgroundColor:g.card,boxShadow:["0 0 0 1px #A08040","inset 1px 1px 0 0 #C8B090","inset -1px -1px 0 0 #9A7A40"].join(", "),borderRadius:"2px"},tt={backgroundColor:"#EEDCB0",boxShadow:["0 0 0 1px #8B6914","0 1px 0 1px #A08040","inset 1px 1px 0 0 #F5ECD7","inset -1px -1px 0 0 #B8960A"].join(", "),borderRadius:"2px"};function Wo(e){switch(e){case"working":return 0;case"waiting-approval":return 1;case"waiting-input":return 2;case"error":return 3;default:return 4}}function bf(e){switch(e){case"audit":return"bg-status-blue/15 text-status-blue border-status-blue/30";case"design":return"bg-purple-500/15 text-purple-400 border-purple-500/30";case"build":return"bg-status-green/15 text-status-green border-status-green/30";case"review":return"bg-status-yellow/15 text-status-yellow border-status-yellow/30";default:return"bg-secondary text-secondary-foreground border-border"}}function Mt(e){return e?e.includes("opus")?"opus":e.includes("sonnet")?"sonnet":e.includes("haiku")?"haiku":e.replace("claude-","").slice(0,12):null}function Re({children:e,count:t,icon:n,color:s}){return ae.createElement("div",{className:"flex items-center gap-2 py-1"},ae.createElement("div",{className:"h-px flex-1",style:{background:`linear-gradient(to right, transparent, ${g.border})`}}),ae.createElement("div",{className:"flex items-center gap-1.5 shrink-0"},n&&ae.createElement("span",{className:"flex items-center",style:{color:s??g.textDim}},n),ae.createElement("span",{className:"text-[10px] font-bold uppercase tracking-widest font-mono",style:{color:s??g.textDim}},e),t!==void 0&&ae.createElement("span",{className:"text-[10px] font-bold font-mono",style:{color:g.bg,backgroundColor:s??g.textDim,borderRadius:"2px",padding:"0 4px",minWidth:"16px",textAlign:"center",lineHeight:"16px"}},String(t))),ae.createElement("div",{className:"h-px flex-1",style:{background:`linear-gradient(to left, transparent, ${g.border})`}}))}function nt({value:e,max:t,color:n="#5B8C3E",height:s=6,showLabel:o=!1}){const a=t>0?Math.min(100,Math.round(e/t*100)):0;return ae.createElement("div",{className:"flex items-center gap-1.5"},ae.createElement("div",{style:{height:`${s}px`,flex:1,backgroundColor:"#C8B09060",borderRadius:"1px",boxShadow:"inset 1px 1px 0 0 #A0804060, inset -1px -1px 0 0 #F5ECD740",overflow:"hidden",position:"relative"}},ae.createElement("div",{style:{height:"100%",width:`${a}%`,backgroundColor:n,borderRadius:"1px",boxShadow:a>0?`inset 0 1px 0 0 ${n}60`:"none",transition:"width 300ms ease"}})),o&&ae.createElement("span",{className:"text-[9px] font-mono tabular-nums shrink-0",style:{color:g.textDim,minWidth:"28px",textAlign:"right"}},`${a}%`))}function Me({ornament:e=!1}={}){return e?ae.createElement("div",{className:"flex items-center gap-2 my-2",role:"separator"},ae.createElement("div",{className:"h-px flex-1",style:{backgroundColor:g.border}}),ae.createElement("div",{style:{width:"4px",height:"4px",backgroundColor:g.border,transform:"rotate(45deg)"}}),ae.createElement("div",{className:"h-px flex-1",style:{backgroundColor:g.border}})):ae.createElement("div",{className:"h-px w-full my-1.5",style:{background:`linear-gradient(to right, transparent, ${g.border}, transparent)`},role:"separator"})}function hn({status:e,animated:t=!1}){let n="#9CA3AF",s="#fff",o=e;switch(e){case"working":n="#22C55E",s="#052E16",o="Working";break;case"waiting-approval":n="#EAB308",s="#422006",o="Approval";break;case"waiting-input":n="#3B82F6",s="#1E3A5F",o="Input";break;case"error":n="#EF4444",s="#fff",o="Error";break;case"paused":n="#F59E0B",s="#78350F",o="Paused";break;case"idle":n="#9CA3AF",s="#1F2937",o="Idle";break;case"done":n="#10B981",s="#064E3B",o="Done";break}return ae.createElement("span",{className:`text-[9px] font-bold font-mono px-1.5 py-0.5 leading-none ${t?"animate-pulse":""}`,style:{backgroundColor:n,color:s,borderRadius:"2px",boxShadow:`0 1px 0 0 ${n}80`,letterSpacing:"0.02em"}},o)}function Sa(e,t=20){const n=e.split(`
2
+ `).slice(0,t),s=[];let o=0;for(const a of n)if(!a.startsWith("```")){if(a.startsWith("# ")&&o===0){o++;continue}if(a.startsWith("## "))s.push(Ho(o++,"h3","text-xs font-semibold mt-2 mb-0.5",a.slice(3)));else if(a.startsWith("### "))s.push(Ho(o++,"h4","text-xs font-medium mt-1.5 mb-0.5",a.slice(4)));else if(a.startsWith("- ")||a.startsWith("* ")){const l=a.slice(2);s.push(yf(o++,l))}else a.trim()===""?s.push(wf(o++)):a.startsWith("|")||s.push(vf(o++,a))}return s}function Ea(e){return e.split(/(\*\*[^*]+\*\*)/g).map((n,s)=>n.startsWith("**")&&n.endsWith("**")?ae.createElement("strong",{key:s,className:"font-semibold",style:{color:g.text}},n.slice(2,-2)):n)}function Ho(e,t,n,s){return ae.createElement(t,{key:e,className:n,style:{color:g.text}},s)}function yf(e,t){return ae.createElement("div",{key:e,className:"text-[11px] leading-relaxed pl-3 flex gap-1.5 font-mono",style:{color:g.textDim}},ae.createElement("span",{className:"shrink-0",style:{color:g.accent}},"•"),ae.createElement("span",null,...Ea(t)))}function wf(e){return ae.createElement("div",{key:e,className:"h-1"})}function vf(e,t){return ae.createElement("p",{key:e,className:"text-[11px] leading-relaxed font-mono",style:{color:g.textDim}},...Ea(t))}const Uo=50;function ja(e,t){const n=f.useRef(new Map),s=f.useRef({}),o=f.useRef(0);return f.useEffect(()=>{const a=s.current;for(const l of e){const i=t[l];if(!i||!i.active)continue;const c=a[l];if(!(!c||c.tool!==i.tool||c.detail!==i.detail||c.thinking!==i.thinking))continue;const u=i.thinking?"Thinking":i.tool;if(!u)continue;const m={id:`tc-${l}-${++o.current}`,timestamp:i.lastSeen||new Date().toISOString(),tool:u,detail:i.detail??void 0,sessionId:l},h=n.current.get(l)??[];h.push(m),h.length>Uo&&h.splice(0,h.length-Uo),n.current.set(l,h)}s.current={...t}},[t,e]),n}const Cf={edit:"#EAB308",write:"#EAB308",read:"#3B82F6",bash:"#22C55E",grep:"#A855F7",glob:"#A855F7",task:"#F97316",agent:"#F97316",thinking:"#6B7280"};function kf(e){return Cf[e.toLowerCase()]??"#9CA3AF"}function Nf(e){if(!e)return"";const t=e.split("/");return t.length>2?`.../${t.slice(-2).join("/")}`:e.length>50?e.slice(0,47)+"...":e}function Aa({entries:e,maxHeight:t="120px",compact:n}){const s=f.useRef(null),o=f.useRef(!1),a=f.useCallback(()=>{const i=s.current;if(!i)return;const c=i.scrollTop+i.clientHeight>=i.scrollHeight-8;o.current=!c},[]);if(f.useEffect(()=>{const i=s.current;i&&!o.current&&(i.scrollTop=i.scrollHeight)},[e.length]),e.length===0)return null;const l=n?"text-[9px] leading-[14px]":"text-[10px] leading-[16px]";return r.jsx("div",{ref:s,onScroll:a,className:"overflow-y-auto overflow-x-hidden",style:{maxHeight:t,backgroundColor:"#1E1E1E",borderRadius:"2px",padding:n?"2px 4px":"4px 6px",boxShadow:["inset 1px 1px 0 0 #111","inset -1px -1px 0 0 #333","0 0 0 1px #A08040"].join(", ")},children:e.map(i=>{const c=kf(i.tool),d=Nf(i.detail);return r.jsxs("div",{className:`flex items-baseline gap-1 ${l} font-mono`,style:{color:"#A0A0A0"},children:[r.jsx("span",{style:{color:"#555"},children:"$"}),r.jsx("span",{className:"font-semibold shrink-0",style:{color:c},children:i.tool}),d&&r.jsx("span",{className:"truncate min-w-0",style:{color:"#8A8A8A"},children:d})]},i.id)})})}const Sf=xn.teams,Ta={},xs={};for(const e of Sf)for(const t of e.memberAgentIds){const n=xn.agents.find(s=>s.id===t);n&&(Ta[n.name.split(" ")[0]]=e.name)}for(const e of xn.agents)xs[e.name.split(" ")[0]]=e.role;function Ef(e){if(!e)return;const t=e.replace(/^You are [^.]+\.\s*/i,"");if(t===e||!t)return;const n=t.split(/[.\n]/)[0]?.trim();return n?n.length>80?n.slice(0,77)+"...":n:void 0}function jf({counters:e,directiveName:t,directiveStatus:n}){return r.jsxs("div",{className:"space-y-1.5",children:[t&&r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 font-mono",style:te,children:[r.jsx("span",{className:"text-[9px] font-bold px-1.5 py-0.5 leading-none shrink-0",style:{backgroundColor:n==="awaiting_completion"?"#FDE68A":"#BBF7D0",color:n==="awaiting_completion"?"#92400E":"#052E16",borderRadius:"2px"},children:n==="awaiting_completion"?"Review":"Active"}),r.jsx("span",{className:"text-[10px] font-bold truncate",style:{color:g.text},children:t})]}),r.jsx("div",{className:"flex gap-1 flex-wrap",children:e.map(s=>r.jsxs("div",{className:"flex-1 min-w-[60px] flex items-center gap-1 px-1.5 py-1.5 font-mono",style:te,children:[r.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:s.color,boxShadow:s.glow?`0 0 4px ${s.color}80`:"none"}}),r.jsx("span",{className:"text-sm font-bold tabular-nums",style:{color:g.text},children:s.count}),r.jsx("span",{className:"text-[8px] uppercase tracking-wider",style:{color:g.textDim},children:s.label})]},s.label))})]})}function Af(){return r.jsxs("div",{className:"text-center py-5 font-mono",style:te,children:[r.jsx(gr,{className:"h-6 w-6 mx-auto mb-2",style:{color:g.textDim,opacity:.4},"aria-hidden":"true"}),r.jsx("p",{className:"text-xs font-bold",style:{color:g.text},children:"Everyone's loafing"}),r.jsx("p",{className:"text-[10px] mt-0.5",style:{color:g.textDim},children:"No agents are currently working"})]})}function zn({agentStatuses:e,onSelectAgent:t}){const n=J(y=>y.sessions),s=J(y=>y.sessionActivities),o=J(y=>y.directiveState),[a,l]=f.useState(!1),i=f.useMemo(()=>n.filter(y=>y.agentName&&y.status==="working").map(y=>y.id),[n]),c=ja(i,s),d=f.useMemo(()=>{const y=[],S=[];for(const N of pe){if(N.isPlayer)continue;const v=e[N.agentName]??"offline",k=n.filter(E=>E.agentName===N.agentName);if(v==="working"||v==="waiting"||v==="error"||v==="paused"||v==="done"){const A=[...k.filter(V=>V.status!=="done")].sort((V,C)=>new Date(C.lastActivity).getTime()-new Date(V.lastActivity).getTime());let j,T,G,W,P,q;for(const V of A){if(!j&&V.feature&&(j=V.feature),!j){const C=Ef(V.latestPrompt??V.initialPrompt);C&&(j=C)}T||(T=V.lastActivity),!G&&(V.status==="working"||V.status==="waiting-approval"||V.status==="waiting-input")&&(G=V.status,W=V.paneId,P=V.terminalApp),!q&&V.gitBranch&&(q=V.gitBranch)}let K,Q;for(const V of A){const C=s[V.id];if(C?.active&&C.tool){K=C.tool,Q=C.detail;break}}if(!K)for(const V of A){const C=s[V.id];if(C?.active&&C.thinking){K="thinking";break}}const ue=A.find(V=>!V.isSubagent)?.activeSubagentNames??[],ne=A.filter(V=>V.status==="working").map(V=>V.id);y.push({agent:N,status:v,taskName:j,toolName:K,toolDetail:Q,lastActivity:T,sessionStatus:G??"working",paneId:W,terminalApp:P,gitBranch:q,subagentNames:ue,workingSessionIds:ne})}else{const A=[...k].sort((j,T)=>new Date(T.lastActivity).getTime()-new Date(j.lastActivity).getTime())[0];S.push({agent:N,status:v,lastFeature:A?.feature??void 0,lastActivity:A?.lastActivity??void 0,team:Ta[N.agentName],fullRole:xs[N.agentName],sessionCount:k.length})}}return{active:y,inactive:S}},[e,n,s]),u=d.active.filter(y=>y.status==="working").length,m=d.active.filter(y=>y.status==="waiting"||y.status==="error").length,h=d.active.filter(y=>y.status==="paused").length,p=d.active.filter(y=>y.status==="done").length,x=d.inactive.length,b=o?.title??o?.directiveName??null,w=[{label:"Working",count:u,color:"#22C55E",glow:u>0}];return m>0&&w.push({label:"Waiting",count:m,color:"#EAB308"}),h>0&&w.push({label:"Paused",count:h,color:"#F59E0B"}),p>0&&w.push({label:"Done",count:p,color:"#10B981"}),w.push({label:"Idle",count:x,color:"#9CA3AF"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(jf,{counters:w,directiveName:b,directiveStatus:o?.status}),d.active.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Me,{}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(_l,{className:"h-3 w-3"}),count:d.active.length,color:"#5B8C3E",children:"Active"}),d.active.map(y=>{const S=y.sessionStatus==="waiting-approval"||y.sessionStatus==="waiting-input";return r.jsxs("button",{type:"button",className:"w-full text-left p-0 transition-all cursor-pointer group",style:{...tt,position:"relative",overflow:"hidden"},onClick:()=>t?.(y.agent.agentName),"aria-label":`View ${y.agent.agentName} details`,children:[r.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1",style:{backgroundColor:y.agent.color,boxShadow:`1px 0 0 0 ${y.agent.color}40`}}),r.jsxs("div",{className:"pl-3 pr-2 py-2 space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:de("h-2.5 w-2.5 rounded-sm shrink-0",y.status==="working"&&"animate-pulse"),style:{backgroundColor:y.agent.color,boxShadow:y.status==="working"?`0 0 6px ${y.agent.color}80`:`0 0 2px ${y.agent.color}40`}}),r.jsx("span",{className:"text-xs font-bold font-mono truncate",style:{color:g.text},children:y.agent.agentName}),r.jsx("span",{className:"text-[9px] font-mono truncate",style:{color:g.textDim},children:xs[y.agent.agentName]??y.agent.agentRole}),r.jsxs("span",{className:"ml-auto shrink-0 flex items-center gap-1",children:[y.lastActivity&&r.jsx("span",{className:"text-[9px] font-mono tabular-nums",style:{color:g.textDim},children:et(y.lastActivity)}),r.jsx(hn,{status:y.sessionStatus??"working",animated:y.status==="working"})]})]}),y.taskName&&r.jsx("p",{className:"text-[11px] leading-tight font-mono",style:{color:g.text},children:y.taskName}),y.toolName&&r.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-mono",style:{color:"#5B8C3E"},children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0 animate-pulse",style:{backgroundColor:"#5B8C3E"}}),r.jsx("span",{className:"truncate",children:y.toolName==="thinking"?"Thinking...":r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-semibold",children:y.toolName}),y.toolDetail&&r.jsxs("span",{style:{color:g.textDim},children:["(",y.toolDetail,")"]})]})})]}),y.workingSessionIds.length>0&&(()=>{const N=y.workingSessionIds.flatMap(v=>c.current.get(v)??[]);return r.jsx(Aa,{entries:N,maxHeight:"60px",compact:!0})})(),y.gitBranch&&r.jsxs("div",{className:"text-[9px] font-mono truncate",style:{color:g.textDim},children:["⎇ ",y.gitBranch]}),y.subagentNames.length>0&&r.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[y.subagentNames.slice(0,4).map(N=>r.jsx("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded-sm",style:{backgroundColor:"#5B8C3E20",color:"#3D6B26",border:"1px solid #5B8C3E30"},children:N},N)),y.subagentNames.length>4&&r.jsxs("span",{className:"text-[9px] font-mono",style:{color:g.textDim},children:["+",y.subagentNames.length-4]})]}),S&&y.paneId&&r.jsx("div",{onClick:N=>N.stopPropagation(),children:r.jsx(Ps,{paneId:y.paneId,sessionStatus:y.sessionStatus,terminalApp:y.terminalApp})})]})]},y.agent.agentName)})]})]}),d.active.length===0&&r.jsxs(r.Fragment,{children:[r.jsx(Me,{}),r.jsx(Af,{})]}),d.inactive.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Me,{ornament:!0}),r.jsxs("button",{type:"button",className:"w-full flex items-center gap-1.5 py-0.5 cursor-pointer",onClick:()=>l(y=>!y),style:{background:"none",border:"none"},children:[a?r.jsx(st,{className:"h-3 w-3",style:{color:g.textDim}}):r.jsx(Be,{className:"h-3 w-3",style:{color:g.textDim}}),r.jsx(gr,{className:"h-3 w-3",style:{color:g.textDim}}),r.jsx("span",{className:"text-[10px] font-bold font-mono uppercase tracking-wider",style:{color:g.textDim},children:"Loafing"}),r.jsx("span",{className:"text-[9px] font-bold font-mono px-1.5 py-0.5 leading-none",style:{backgroundColor:`${g.accent}20`,color:g.accent,borderRadius:"2px"},children:d.inactive.length})]}),!a&&r.jsx("div",{className:"flex flex-wrap gap-1.5 px-1",children:d.inactive.map(({agent:y,lastActivity:S})=>r.jsxs("button",{type:"button",className:"flex items-center gap-1 px-1.5 py-1 font-mono cursor-pointer transition-colors",style:{backgroundColor:g.card,borderRadius:"2px",border:`1px solid ${g.border}40`},onClick:()=>t?.(y.agentName),onMouseEnter:N=>{N.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:N=>{N.currentTarget.style.backgroundColor=g.card},"aria-label":`View ${y.agentName} details`,children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:y.color,opacity:.6}}),r.jsx("span",{className:"text-[10px]",style:{color:g.text},children:y.agentName}),S&&r.jsx("span",{className:"text-[8px] tabular-nums",style:{color:g.textDim},children:et(S)})]},y.agentName))}),a&&(()=>{const y={};for(const v of d.inactive){const k=v.team??"Other";y[k]||(y[k]=[]),y[k].push(v)}const S=["Engineering","Product","Growth","Operations","Other"],N=Object.keys(y).sort((v,k)=>(S.indexOf(v)===-1?99:S.indexOf(v))-(S.indexOf(k)===-1?99:S.indexOf(k)));return r.jsx("div",{className:"space-y-1.5",children:N.map(v=>r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-1 py-0.5",children:[r.jsx(St,{className:"h-2.5 w-2.5",style:{color:g.accent}}),r.jsx("span",{className:"text-[9px] font-bold font-mono uppercase tracking-wider",style:{color:g.accent},children:v})]}),y[v].map(({agent:k,status:E,lastFeature:A,lastActivity:j,fullRole:T,sessionCount:G})=>r.jsxs("button",{type:"button",className:"w-full text-left p-0 transition-all cursor-pointer",style:{...te,position:"relative",overflow:"hidden"},onClick:()=>t?.(k.agentName),onMouseEnter:W=>{W.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:W=>{W.currentTarget.style.backgroundColor=g.card},"aria-label":`View ${k.agentName} details`,children:[r.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-0.5",style:{backgroundColor:k.color,opacity:E==="idle"?.6:.25}}),r.jsxs("div",{className:"pl-2.5 pr-2 py-1.5 space-y-0.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:k.color,opacity:E==="idle"?.6:.25}}),r.jsx("span",{className:"text-[11px] font-semibold font-mono truncate",style:{color:g.text},children:k.agentName}),r.jsx("span",{className:"text-[9px] font-mono truncate",style:{color:g.textDim},children:T??k.agentRole}),j&&r.jsx("span",{className:"text-[9px] font-mono tabular-nums shrink-0 ml-auto",style:{color:g.textDim},children:et(j)})]}),A&&r.jsxs("div",{className:"text-[10px] font-mono truncate pl-3.5",style:{color:g.textDim},children:["Last: ",A]})]})]},k.agentName))]},v))})})()]})]})}const Vn={CEO:"#8B6914",Sarah:"#7C3AED",Marcus:"#2563EB",Morgan:"#059669",Priya:"#D97706",Riley:"#DB2777",Jordan:"#0D9488",Casey:"#0891B2",Taylor:"#EA580C",Sam:"#65A30D",Quinn:"#E11D48",Devon:"#4F46E5"};function _s(e){if(Vn[e])return Vn[e];const t=e.split(/[,+]/)[0].trim();return Vn[t]??"#2B5EA7"}function Tf(e){switch(e){case"lightweight":return"#BBF7D0";case"medium":return"#FDE68A";case"heavyweight":return"#FECACA";case"strategic":return"#DDD6FE";case"tactical":return"#BFDBFE";default:return"#E5E7EB"}}function Xf(e){switch(e){case"lightweight":return"#14532D";case"medium":return"#713F12";case"heavyweight":return"#7F1D1D";case"strategic":return"#4C1D95";case"tactical":return"#1E3A8A";default:return"#374151"}}function Yo(e){const[t,n]=f.useState("");return f.useEffect(()=>{if(!e){n("");return}const s=()=>{const a=Date.now()-new Date(e).getTime();if(a<0){n("");return}const l=Math.floor(a/6e4),i=Math.floor(a%6e4/1e3);if(l>=60){const c=Math.floor(l/60);n(`${c}h ${l%60}m`)}else l>0?n(`${l}m ${i}s`):n(`${i}s`)};s();const o=setInterval(s,1e3);return()=>clearInterval(o)},[e]),t}function Rf({status:e}){const t="h-3 w-3 shrink-0";switch(e){case"completed":return r.jsx(Ee,{className:`${t} text-green-600`});case"in_progress":return r.jsx(Pe,{className:`${t} text-yellow-600 animate-spin`});case"failed":return r.jsx(kt,{className:`${t} text-red-500`});case"skipped":return r.jsx(Ns,{className:de(t),style:{color:g.textDim}});default:return r.jsx(Ot,{className:de(t),style:{color:g.textDim}})}}function Df({status:e}){const t="h-2.5 w-2.5 shrink-0";switch(e){case"completed":case"done":return r.jsx(Cs,{className:`${t} text-green-600`});case"in_progress":return r.jsx(Nt,{className:`${t} text-yellow-600`});case"failed":return r.jsx(kt,{className:`${t} text-red-500`});case"skipped":return r.jsx(Ns,{className:t,style:{color:g.textDim}});default:return r.jsx(Ot,{className:t,style:{color:g.textDim}})}}function If({project:e}){const t=e.totalTasks??0,n=e.completedTasks??0,s=e.status==="in_progress",o=e.tasks&&e.tasks.length>0,[a,l]=f.useState(!1);return r.jsxs("div",{style:s?tt:te,children:[r.jsxs("button",{type:"button",className:"w-full text-left px-2 py-1.5 space-y-1",onClick:()=>o&&l(i=>!i),"aria-label":`Project: ${e.title}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(Rf,{status:e.status}),r.jsx("span",{className:"text-[11px] font-mono truncate flex-1",style:{color:g.text},children:e.title||e.id}),s&&e.phase&&r.jsx("span",{className:de("text-[9px] font-bold font-mono px-1.5 py-0.5 leading-none shrink-0 border",bf(e.phase)),style:{borderRadius:"2px"},children:e.phase}),o&&(a?r.jsx(st,{className:"h-2.5 w-2.5 shrink-0",style:{color:g.textDim}}):r.jsx(Be,{className:"h-2.5 w-2.5 shrink-0",style:{color:g.textDim}}))]}),t>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(nt,{value:n,max:t,color:e.status==="completed"?"#22C55E":"#C4A265",height:5}),r.jsxs("span",{className:"text-[9px] font-mono tabular-nums shrink-0",style:{color:g.textDim},children:[n,"/",t]})]})]}),a&&o&&r.jsx("div",{className:"px-2 pb-2 space-y-1 border-t",style:{borderColor:"#C4A26540"},children:e.tasks.map((i,c)=>r.jsx(Pf,{task:i},c))})]})}function Pf({task:e}){const t=e.status==="completed"||e.status==="done",n=e.dod&&e.dod.length>0;return r.jsxs("div",{className:"pt-1",children:[r.jsxs("div",{className:"flex items-start gap-1.5 min-w-0",children:[r.jsx(Df,{status:e.status}),r.jsx("span",{className:"text-[10px] font-mono leading-tight flex-1",style:{color:t?"#4A7C3F":g.text},children:e.title}),e.agent&&r.jsx("span",{className:"text-[8px] font-bold font-mono shrink-0",style:{color:_s(e.agent)},children:e.agent})]}),n&&r.jsx("div",{className:"ml-4 mt-0.5 space-y-px",children:e.dod.map((s,o)=>r.jsxs("div",{className:"flex items-start gap-1 text-[8px] font-mono leading-tight",style:{color:s.met?"#4A7C3F":g.textDim},children:[r.jsx("span",{className:"shrink-0",children:s.met?"✓":"○"}),r.jsx("span",{children:s.criterion})]},o))})]})}function Xa({directive:e,defaultExpanded:t=!1,sessions:n,onApprove:s,onFocus:o,onOpenDetail:a,approvingId:l,focusingPane:i}){const c=t||e.status==="awaiting_completion"||e.status==="in_progress",[d,u]=f.useState(c),m=Yo(e.startedAt),h=e.pipelineSteps?.find(E=>E.status==="active"),p=Yo(h?.startedAt),x=f.useMemo(()=>{const E=e.directiveName;return n.find(A=>A.paneId&&!A.isSubagent&&(A.initialPrompt?.includes(E)||A.feature?.includes(E)))},[n,e.directiveName]),b=e.pipelineSteps&&e.pipelineSteps.length>0,w=e.projects.length>0,y=e.status==="awaiting_completion",S=e.status==="failed",N=e.status==="completed",v=e.status==="in_progress",k=y?"#EAB308":S?"#EF4444":"#C4A265";return r.jsxs("div",{className:"relative overflow-hidden",style:{...tt,borderLeft:`3px solid ${k}`},children:[r.jsxs("button",{type:"button",className:"w-full text-left px-2.5 py-2 space-y-1",onClick:()=>u(E=>!E),children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[N?r.jsx(Ee,{className:"h-3 w-3 shrink-0",style:{color:"#22C55E"}}):S?r.jsx(kt,{className:"h-3 w-3 shrink-0",style:{color:"#EF4444"}}):y?r.jsx($e,{className:"h-3 w-3 shrink-0",style:{color:"#EAB308"}}):v?r.jsx(Nt,{className:"h-3 w-3 shrink-0",style:{color:"#3B82F6"}}):r.jsx(Ot,{className:"h-3 w-3 shrink-0",style:{color:g.textDim}}),r.jsx("span",{className:"text-xs font-bold truncate font-mono",style:{color:g.text},children:e.title||e.directiveName}),e.weight&&r.jsx("span",{className:"text-[9px] font-bold font-mono px-1.5 py-0.5 leading-none shrink-0",style:{backgroundColor:Tf(e.weight),color:Xf(e.weight),borderRadius:"2px"},children:e.weight}),r.jsxs("span",{className:"ml-auto flex items-center gap-1 shrink-0",children:[m&&r.jsx("span",{className:"text-[9px] font-mono tabular-nums",style:{color:g.textDim},children:m}),d?r.jsx(st,{className:"h-2.5 w-2.5",style:{color:g.textDim}}):r.jsx(Be,{className:"h-2.5 w-2.5",style:{color:g.textDim}})]})]}),h&&!d&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono",style:{color:g.textDim},children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}),r.jsx("span",{className:"truncate",children:h.label}),p&&r.jsx("span",{className:"ml-auto tabular-nums shrink-0",children:p})]}),y&&!d&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono",children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-yellow-500 shrink-0"}),r.jsx("span",{className:"font-semibold",style:{color:"#6B2E08"},children:"Awaiting CEO sign-off"})]}),!d&&r.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono",style:{color:g.textDim},children:[r.jsxs("span",{children:[r.jsxs("span",{className:"font-bold",style:{color:g.text},children:[e.projects.filter(E=>E.status==="completed").length,"/",e.projects.length]})," ","projects"]}),e.projects.reduce((E,A)=>E+(A.totalTasks??0),0)>0&&r.jsxs("span",{children:[r.jsxs("span",{className:"font-bold",style:{color:g.text},children:[e.projects.reduce((E,A)=>E+(A.completedTasks??0),0),"/",e.projects.reduce((E,A)=>E+(A.totalTasks??0),0)]})," ","tasks"]}),b&&r.jsxs("span",{children:[r.jsxs("span",{className:"font-bold",style:{color:g.text},children:[e.pipelineSteps.filter(E=>E.status==="completed").length,"/",e.pipelineSteps.length]})," ","steps"]})]})]}),d&&r.jsxs("div",{className:"px-2.5 pb-2.5 space-y-2 font-mono",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[9px]",style:{color:g.textDim},children:[e.category&&r.jsxs("span",{children:["Category: ",r.jsx("span",{className:"font-bold",style:{color:g.text},children:e.category})]}),r.jsxs("span",{children:["Phase: ",r.jsx("span",{className:"font-bold",style:{color:g.text},children:e.currentPhase})]}),e.approvalStatus&&r.jsxs("span",{children:["CEO: ",r.jsx("span",{className:"font-bold",style:{color:e.approvalStatus==="approved"?"#4A7C3F":g.text},children:e.approvalStatus})]}),m&&r.jsxs("span",{children:["Elapsed: ",r.jsx("span",{className:"font-bold tabular-nums",style:{color:g.text},children:m})]})]}),(e.triageRationale||e.brainstormSummary||e.planSummary)&&r.jsxs("div",{className:"space-y-1 text-[9px] leading-tight",children:[e.triageRationale&&r.jsxs("div",{className:"px-1.5 py-1",style:{backgroundColor:"#E8D5B040",borderRadius:"2px"},children:[r.jsx("span",{className:"font-bold",style:{color:g.text},children:"Triage: "}),r.jsx("span",{style:{color:g.textDim},children:e.triageRationale})]}),e.brainstormSummary&&r.jsxs("button",{type:"button",className:"w-full text-left px-1.5 py-1 flex items-start gap-1",style:{backgroundColor:"#DDD6FE30",borderRadius:"2px"},onClick:E=>{E.stopPropagation(),e.brainstormContent&&a("brainstorm",e.title||e.directiveName,e.brainstormContent)},disabled:!e.brainstormContent,children:[r.jsx(br,{className:"h-2.5 w-2.5 shrink-0 mt-[1px]",style:{color:"#7C3AED"}}),r.jsxs("span",{children:[r.jsx("span",{className:"font-bold",style:{color:"#7C3AED"},children:"Brainstorm: "}),r.jsx("span",{style:{color:g.textDim},children:e.brainstormSummary})]}),e.brainstormContent&&r.jsx(Be,{className:"h-2.5 w-2.5 shrink-0 mt-[1px] ml-auto",style:{color:"#7C3AED"}})]}),e.planSummary&&r.jsxs("button",{type:"button",className:"w-full text-left px-1.5 py-1 flex items-start gap-1",style:{backgroundColor:"#D1FAE530",borderRadius:"2px"},onClick:E=>{E.stopPropagation(),e.directiveBrief&&a("brief",e.title||e.directiveName,e.directiveBrief)},disabled:!e.directiveBrief,children:[r.jsx(yr,{className:"h-2.5 w-2.5 shrink-0 mt-[1px]",style:{color:"#059669"}}),r.jsxs("span",{children:[r.jsx("span",{className:"font-bold",style:{color:"#059669"},children:"Plan: "}),r.jsx("span",{style:{color:g.textDim},children:e.planSummary})]}),e.directiveBrief&&r.jsx(Be,{className:"h-2.5 w-2.5 shrink-0 mt-[1px] ml-auto",style:{color:"#059669"}})]})]}),h&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",style:{color:g.textDim},children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}),r.jsxs("span",{className:"truncate",children:["Step: ",r.jsx("span",{className:"font-semibold",style:{color:g.text},children:h.label})]}),h.artifacts?.Agent&&r.jsx("span",{className:"font-bold",style:{color:_s(h.artifacts.Agent)},children:h.artifacts.Agent}),p&&r.jsx("span",{className:"ml-auto tabular-nums shrink-0",children:p})]}),b&&r.jsx("div",{className:"p-2",style:te,children:r.jsx(_f,{steps:e.pipelineSteps})}),w&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",style:{color:g.textDim},children:[r.jsx(il,{className:"h-2.5 w-2.5"}),r.jsxs("span",{className:"font-bold",children:["Projects (",e.projects.filter(E=>E.status==="completed").length,"/",e.projects.length,")"]})]}),e.projects.map(E=>r.jsx(If,{project:E},E.id))]}),(y||x)&&r.jsxs("div",{className:"flex gap-1.5",children:[y&&r.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 px-3 text-[11px] flex-1 justify-center gap-1.5 font-mono font-bold",style:{backgroundColor:"#22C55E",color:"#fff",borderRadius:"2px",boxShadow:"0 1px 0 0 #16A34A"},onClick:E=>s(E,e.directiveName),disabled:l===e.directiveName,children:[l===e.directiveName?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(Ee,{className:"h-3 w-3"}),"Approve"]}),x?.paneId&&r.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 px-3 text-[11px] gap-1.5 font-mono font-bold shrink-0",style:{backgroundColor:g.card,color:g.text,borderRadius:"2px",boxShadow:"0 0 0 1px #C4A265"},onClick:()=>o(x.paneId),disabled:i===x.paneId,children:[i===x.paneId?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(ks,{className:"h-3 w-3"}),"Focus"]})]})]})]})}function _f({steps:e}){const t=e.filter(n=>n.status==="completed").length;return r.jsxs("div",{className:"font-mono",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] mb-2",style:{color:g.textDim},children:[r.jsx(nt,{value:t,max:e.length,color:t===e.length?"#22C55E":"#2B5EA7",height:5}),r.jsx("span",{className:"tabular-nums shrink-0",children:r.jsxs("span",{className:"font-bold",style:{color:g.text},children:[t,"/",e.length]})})]}),r.jsx("div",{className:"relative ml-1.5",children:e.map((n,s)=>{const o=n.status==="active",a=n.status==="completed",l=n.status==="skipped",i=n.status==="failed",c=s===e.length-1,u=n.artifacts&&Object.keys(n.artifacts).length>0&&!l&&n.status!=="pending",m=a?"#22C55E":o?"#2B5EA7":"#C4A26560";return r.jsxs("div",{className:"relative",children:[!c&&r.jsx("div",{className:"absolute left-[5px] top-[14px] w-[2px]",style:{backgroundColor:m,bottom:0,...l||e[s+1]?.status==="skipped"?{backgroundImage:`repeating-linear-gradient(to bottom, ${m} 0 3px, transparent 3px 6px)`,backgroundColor:"transparent"}:{}}}),r.jsxs("div",{className:de("relative flex items-start gap-2 pb-1",l&&"opacity-40"),style:o?{backgroundColor:"#E8D5B020",borderRadius:"2px",margin:"0 -2px",padding:"2px 4px 2px 2px"}:void 0,children:[r.jsx("div",{className:"relative z-10 mt-[1px] shrink-0",children:a?r.jsx("div",{className:"h-3 w-3 rounded-full flex items-center justify-center",style:{backgroundColor:"#22C55E"},children:r.jsx(Cs,{className:"h-2 w-2 text-white",strokeWidth:3})}):o?r.jsx("div",{className:"h-3 w-3 rounded-full flex items-center justify-center animate-pulse",style:{backgroundColor:"#2B5EA7"},children:r.jsx(Nt,{className:"h-1.5 w-1.5 text-white"})}):i?r.jsx("div",{className:"h-3 w-3 rounded-full flex items-center justify-center",style:{backgroundColor:"#EF4444"},children:r.jsx(kt,{className:"h-2 w-2 text-white",strokeWidth:3})}):l?r.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:"#C4A26540",border:"1px dashed #C4A265"}}):r.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:"#E8D5B0",border:"2px solid #C4A26560"}})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx("span",{className:de("text-[10px] leading-none",o?"font-bold":a?"font-medium":"",l&&"line-through"),style:{color:o?"#2B5EA7":i?"#DC2626":g.text},children:n.label}),n.artifacts?.Agent&&r.jsx("span",{className:"text-[9px] font-bold shrink-0",style:{color:_s(n.artifacts.Agent)},children:n.artifacts.Agent}),n.needsAction&&r.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 leading-none shrink-0",style:{backgroundColor:"#EAB308",color:"#422006",borderRadius:"2px"},children:"ACTION"})]}),u&&r.jsx("div",{className:"mt-0.5 space-y-0.5",children:Object.entries(n.artifacts).map(([h,p])=>h==="Agent"?null:r.jsxs("div",{className:"flex gap-1 text-[9px] leading-tight",children:[r.jsxs("span",{className:"shrink-0",style:{color:g.textDim},children:[h,":"]}),r.jsx("span",{className:"break-words",style:{color:g.text},children:p})]},h))})]})]})]},n.id)})})]})}function Mf({session:e,onFocus:t,focusingPane:n}){const s=e.feature,o=e.latestPrompt??e.initialPrompt,a=o?o.replace(/^You are [^.]+\.\s*/i,"").slice(0,120).split(`
3
+ `)[0]:null,l=e.status==="waiting-approval"||e.status==="waiting-input",i=e.status==="error",c=i?"#EF4444":l?"#EAB308":"#3B82F6";return r.jsx("div",{className:"relative overflow-hidden",style:{...tt,borderLeft:`3px solid ${c}`,...i?{backgroundColor:"#F5E0D8"}:{}},children:r.jsxs("div",{className:"px-2 py-2.5 space-y-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-mono",children:[r.jsx(hn,{status:e.status}),e.agentName&&r.jsx("span",{className:"font-bold",style:{color:g.text},children:e.agentName}),e.agentRole&&r.jsx("span",{className:"text-[9px] truncate",style:{color:g.textDim},children:e.agentRole}),r.jsx("span",{className:"ml-auto shrink-0 text-[10px]",style:{color:g.textDim},children:et(e.lastActivity)})]}),s&&r.jsx("p",{className:"text-[11px] font-bold leading-tight font-mono",style:{color:g.text},children:s}),a&&r.jsx("p",{className:"text-[10px] line-clamp-2 leading-tight font-mono",style:{color:g.textDim},children:a}),e.gitBranch&&r.jsxs("div",{className:"text-[9px] font-mono truncate",style:{color:g.textDim},children:["⎇ ",e.gitBranch]}),e.slug&&r.jsx("div",{className:"text-[9px] font-mono truncate",style:{color:g.textDim},children:e.slug}),l&&e.paneId&&r.jsx(Ps,{paneId:e.paneId,sessionStatus:e.status,terminalApp:e.terminalApp}),e.paneId&&r.jsxs(_e,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[11px] w-full justify-start gap-1.5 font-mono",style:{color:g.text},onClick:()=>t(e.paneId),disabled:n===e.paneId,children:[n===e.paneId?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(ks,{className:"h-3 w-3"}),"Focus terminal"]})]})})}function zo({sessions:e,onApprove:t,onFocus:n,onOpenDetail:s,approvingId:o,focusingPane:a}){const l=J(u=>u.directiveHistory),i=J(u=>u.activeDirectives),c=f.useMemo(()=>{const u=new Set;for(const m of i??[])u.add(m.directiveName);return u},[i]),d=f.useMemo(()=>(l??[]).filter(u=>!c.has(u.directiveName)).sort((u,m)=>new Date(m.lastUpdated).getTime()-new Date(u.lastUpdated).getTime()).slice(0,5),[l,c]);return d.length===0?null:r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(ul,{className:"h-3 w-3"}),children:"Recent"}),d.map(u=>r.jsx(Xa,{directive:u,defaultExpanded:!1,sessions:e,onApprove:t,onFocus:n,onOpenDetail:s,approvingId:o,focusingPane:a},u.directiveName))]})}function Ff({title:e,icon:t,iconColor:n,content:s,onBack:o}){return r.jsxs("div",{className:"space-y-2 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1 text-[10px] font-bold shrink-0",style:{color:g.textDim},children:[r.jsx(hr,{className:"h-3 w-3"}),"Back"]}),r.jsx("div",{className:"h-px flex-1",style:{backgroundColor:g.border}})]}),r.jsxs("div",{className:"flex items-center gap-1.5 px-1",children:[r.jsx("span",{style:{color:n},children:t}),r.jsx("span",{className:"text-xs font-bold",style:{color:g.text},children:e})]}),r.jsx("div",{className:"px-2 py-2 space-y-0.5 overflow-y-auto",style:{...te,maxHeight:"calc(100vh - 200px)"},children:Sa(s,200)})]})}function Of(){const e=J(x=>x.sessions),t=J(x=>x.directiveState),n=J(x=>x.activeDirectives),s=f.useMemo(()=>n&&n.length>0?n:t?[t]:[],[n,t]),o=f.useMemo(()=>[...s].sort((x,b)=>{const w=y=>y.status==="awaiting_completion"?0:y.status==="in_progress"?1:2;return w(x)-w(b)}),[s]),a=f.useMemo(()=>e.filter(x=>!x.isSubagent&&(x.status==="error"||x.status==="waiting-approval"||x.status==="waiting-input")).sort((x,b)=>{const w=y=>y.status==="error"?0:y.status==="waiting-approval"?1:2;return w(x)-w(b)||new Date(b.lastActivity).getTime()-new Date(x.lastActivity).getTime()}),[e]),[l,i]=f.useState(null),[c,d]=f.useState(null),u=f.useCallback(async x=>{d(x);try{await fetch(`${bt}/api/actions/focus-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paneId:x})})}catch{}finally{d(null)}},[]),[m,h]=f.useState(null),p=f.useCallback(async(x,b)=>{x.stopPropagation(),h(b);try{await fetch(`${bt}/api/actions/directive-complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"approve",directiveName:b})})}catch{}finally{h(null)}},[]);return l?r.jsx(Ff,{title:l.type==="brainstorm"?"Brainstorm":"Directive Brief",icon:l.type==="brainstorm"?r.jsx(br,{className:"h-3.5 w-3.5"}):r.jsx(yr,{className:"h-3.5 w-3.5"}),iconColor:l.type==="brainstorm"?"#7C3AED":"#059669",content:l.content,onBack:()=>i(null)}):o.length===0&&a.length===0?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"text-center py-8 font-mono",style:te,children:[r.jsx(wr,{className:"h-6 w-6 mx-auto mb-2",style:{color:g.textDim,opacity:.4}}),r.jsx("p",{className:"text-xs font-bold",style:{color:g.text},children:"All clear"}),r.jsx("p",{className:"text-[10px] mt-0.5",style:{color:g.textDim},children:"No active directives or pending actions"})]}),r.jsx(zo,{sessions:e,onApprove:p,onFocus:u,onOpenDetail:(x,b,w)=>i({type:x,directiveTitle:b,content:w}),approvingId:m,focusingPane:c})]}):r.jsxs("div",{className:"space-y-3",children:[o.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Re,{icon:r.jsx(Ji,{className:"h-3 w-3"}),count:o.length,children:"Directives"}),o.map((x,b)=>r.jsx(Xa,{directive:x,defaultExpanded:b===0,sessions:e,onApprove:p,onFocus:u,onOpenDetail:(w,y,S)=>i({type:w,directiveTitle:y,content:S}),approvingId:m,focusingPane:c},x.directiveName))]}),a.length>0&&r.jsxs(r.Fragment,{children:[o.length>0&&r.jsx(Me,{ornament:!0}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Re,{icon:r.jsx($e,{className:"h-3 w-3"}),count:a.length,color:"#EAB308",children:"Agent Actions"}),a.map(x=>r.jsx(Mf,{session:x,onFocus:u,focusingPane:c},x.id))]})]}),o.length>0&&r.jsx(Me,{ornament:!0}),r.jsx(zo,{sessions:e,onApprove:p,onFocus:u,onOpenDetail:(x,b,w)=>i({type:x,directiveTitle:b,content:w}),approvingId:m,focusingPane:c})]})}function bs(e){switch(e){case"lightweight":return{bg:"#3B82F6",text:"#fff"};case"medium":return{bg:"#F59E0B",text:"#422006"};case"heavyweight":return{bg:"#EF4444",text:"#fff"};default:return{bg:"#9CA3AF",text:"#1F2937"}}}function Ra(e){switch(e){case"lightweight":return"Light";case"medium":return"Med";case"heavyweight":return"Heavy";default:return e??"?"}}function Lf(e){if(e.pipelineSteps){const t=e.pipelineSteps.find(n=>n.status==="active");if(t)return t.label}return e.currentStepId?e.currentStepId:e.currentPhase||"unknown"}function Bf(e){return!e.pipelineSteps||e.pipelineSteps.length===0?{completed:0,total:0}:{completed:e.pipelineSteps.filter(n=>n.status==="completed"||n.status==="skipped").length,total:e.pipelineSteps.length}}function $f(e){switch(e){case"completed":return r.jsx(Ee,{className:"h-2.5 w-2.5",style:{color:"#22C55E"}});case"active":return r.jsx(Pe,{className:"h-2.5 w-2.5 animate-spin",style:{color:"#3B82F6"}});case"failed":return r.jsx(kt,{className:"h-2.5 w-2.5",style:{color:"#EF4444"}});case"skipped":return r.jsx(Ns,{className:"h-2.5 w-2.5",style:{color:"#9CA3AF"}});default:return r.jsx(Ot,{className:"h-2.5 w-2.5",style:{color:"#9CA3AF40"}})}}function Gf(e){switch(e){case"completed":return"#22C55E";case"in_progress":return"#3B82F6";case"failed":return"#EF4444";case"skipped":return"#9CA3AF";default:return"#9CA3AF"}}function Wf(e){switch(e){case"in_progress":return"Active";case"completed":return"Done";case"failed":return"Failed";case"skipped":return"Skip";default:return e}}function Da(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h ${n%60}m`:`${Math.floor(s/24)}d ${s%24}h`}function qt({label:e,value:t,icon:n,color:s,sub:o}){return r.jsxs("div",{className:"p-2",style:te,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[r.jsx("span",{className:"flex items-center",style:{color:s},"aria-hidden":"true",children:n}),r.jsx("span",{className:"text-[9px] font-bold font-mono uppercase tracking-wider",style:{color:g.textDim},children:e})]}),r.jsxs("div",{className:"flex items-baseline gap-1",children:[r.jsx("span",{className:"text-lg font-bold font-mono tabular-nums leading-none",style:{color:g.text},children:t}),o&&r.jsx("span",{className:"text-[9px] font-mono",style:{color:g.textDim},children:o})]})]})}function Hf({connected:e,activeSessions:t,activeDirectiveCount:n,inFlightProjects:s}){return r.jsxs("div",{className:"grid grid-cols-2 gap-1.5 mb-2",children:[r.jsx(qt,{label:"Connection",value:r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:e?"#22C55E":"#EF4444",boxShadow:e?"0 0 4px #22C55E":"0 0 4px #EF4444"},"aria-hidden":"true"}),r.jsx("span",{className:"text-[11px]",children:e?"Online":"Offline"})]}),icon:e?r.jsx(Cr,{className:"h-3 w-3"}):r.jsx(vr,{className:"h-3 w-3"}),color:e?"#22C55E":"#EF4444"}),r.jsx(qt,{label:"Active Sessions",value:t,icon:r.jsx(St,{className:"h-3 w-3"}),color:"#3B82F6"}),r.jsx(qt,{label:"Directives",value:n,icon:r.jsx(yt,{className:"h-3 w-3"}),color:"#F59E0B"}),r.jsx(qt,{label:"Projects",value:s,sub:"in-flight",icon:r.jsx(xr,{className:"h-3 w-3"}),color:"#8B5CF6"})]})}function Uf({step:e}){return r.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[$f(e.status),r.jsx("span",{className:"text-[9px] font-mono flex-1 truncate",style:{color:e.status==="active"?g.text:e.status==="completed"?"#22C55E":g.textDim,fontWeight:e.status==="active"?600:400},children:e.label}),e.status==="active"&&e.startedAt&&r.jsx("span",{className:"text-[8px] font-mono tabular-nums",style:{color:g.textDim},children:Da(e.startedAt)})]})}function Yf({project:e}){const t=Gf(e.status),n=e.completedTasks??0,s=e.totalTasks??0;return r.jsxs("div",{className:"p-1.5",style:{backgroundColor:`${g.card}80`,borderRadius:"2px",boxShadow:`inset 0 0 0 1px ${g.border}30`},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx(xr,{className:"h-2.5 w-2.5 shrink-0",style:{color:g.accent}}),r.jsx("span",{className:"text-[9px] font-bold font-mono truncate flex-1",style:{color:g.text},children:e.title}),r.jsx("span",{className:"text-[8px] font-bold font-mono px-1 py-0.5 leading-none shrink-0",style:{backgroundColor:t,color:"#fff",borderRadius:"2px"},children:Wf(e.status)})]}),s>0&&r.jsxs("div",{className:"flex items-center gap-2 pl-4",children:[r.jsx(nt,{value:n,max:s,color:t,height:3}),r.jsxs("span",{className:"text-[8px] font-mono tabular-nums shrink-0",style:{color:g.textDim},children:[n,"/",s," tasks"]})]}),e.tasks&&e.tasks.length>0&&r.jsx("div",{className:"pl-4 mt-1 space-y-0.5",children:e.tasks.map((o,a)=>{const l=o.status==="completed",i=o.status==="failed";return r.jsxs("div",{className:"flex items-center gap-1.5",children:[l?r.jsx(Ee,{className:"h-2 w-2 shrink-0",style:{color:"#22C55E"}}):i?r.jsx(kt,{className:"h-2 w-2 shrink-0",style:{color:"#EF4444"}}):r.jsx(Ot,{className:"h-2 w-2 shrink-0",style:{color:"#9CA3AF"}}),r.jsx("span",{className:"text-[8px] font-mono truncate",style:{color:l?"#22C55E":i?"#EF4444":g.textDim,textDecoration:l?"line-through":"none"},children:o.title}),o.agent&&r.jsx("span",{className:"text-[7px] font-mono shrink-0",style:{color:g.textDim},children:o.agent})]},a)})})]})}function zf({directive:e}){const[t,n]=f.useState(!1),s=bs(e.weight),o=Lf(e),a=Bf(e),l=t?st:Be;return r.jsxs("div",{style:{...te,borderLeft:`3px solid ${s.bg}`},children:[r.jsxs("button",{onClick:()=>n(i=>!i),className:"w-full text-left p-2.5 transition-colors",onMouseEnter:i=>{i.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:i=>{i.currentTarget.style.backgroundColor=""},"aria-expanded":t,"aria-label":`Directive: ${e.title??e.directiveName}`,children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx(l,{className:"h-3 w-3 shrink-0",style:{color:g.accent},"aria-hidden":"true"}),r.jsx("span",{className:"text-[10px] font-bold font-mono truncate flex-1",style:{color:g.text},children:e.title??e.directiveName}),r.jsx("span",{className:"text-[8px] font-bold font-mono px-1.5 py-0.5 leading-none shrink-0",style:{backgroundColor:s.bg,color:s.text,borderRadius:"2px",boxShadow:`0 1px 0 0 ${s.bg}80`},children:Ra(e.weight)})]}),r.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r.jsx(ln,{className:"h-2.5 w-2.5 shrink-0",style:{color:g.textDim},"aria-hidden":"true"}),r.jsxs("span",{className:"text-[9px] font-mono",style:{color:g.textDim},children:["Step: ",r.jsx("span",{style:{color:g.text,fontWeight:600},children:o})]}),e.startedAt&&r.jsxs("span",{className:"text-[8px] font-mono tabular-nums ml-auto flex items-center gap-0.5",style:{color:g.textDim},children:[r.jsx(Lt,{className:"h-2.5 w-2.5","aria-hidden":"true"}),Da(e.startedAt)]})]}),e.category&&r.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:r.jsx("span",{className:"text-[8px] font-mono px-1.5 py-0.5 leading-none",style:{backgroundColor:`${g.border}40`,color:g.textDim,borderRadius:"2px"},children:e.category})}),e.totalProjects>0&&r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-[9px] font-mono shrink-0 w-[52px]",style:{color:g.textDim},children:"Projects"}),r.jsx(nt,{value:e.currentProject,max:e.totalProjects,color:"#5B8C3E",height:4}),r.jsxs("span",{className:"text-[9px] font-mono tabular-nums shrink-0",style:{color:g.textDim},children:[e.currentProject,"/",e.totalProjects]})]}),a.total>0&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[9px] font-mono shrink-0 w-[52px]",style:{color:g.textDim},children:"Pipeline"}),r.jsx(nt,{value:a.completed,max:a.total,color:"#3B82F6",height:4}),r.jsxs("span",{className:"text-[9px] font-mono tabular-nums shrink-0",style:{color:g.textDim},children:[a.completed,"/",a.total]})]})]}),t&&r.jsxs("div",{className:"px-2.5 pb-2.5 space-y-2",style:{borderTop:`1px solid ${g.border}40`},children:[r.jsx("div",{className:"pt-1.5"}),e.pipelineSteps&&e.pipelineSteps.length>0&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[8px] font-bold font-mono uppercase tracking-wider block mb-1",style:{color:g.textDim},children:"Pipeline Steps"}),r.jsx("div",{className:"space-y-0",children:e.pipelineSteps.map(i=>r.jsx(Uf,{step:i},i.id))})]}),e.projects&&e.projects.length>0&&r.jsxs("div",{children:[r.jsxs("span",{className:"text-[8px] font-bold font-mono uppercase tracking-wider block mb-1",style:{color:g.textDim},children:["Projects (",e.projects.length,")"]}),r.jsx("div",{className:"space-y-1",children:e.projects.map(i=>r.jsx(Yf,{project:i},i.id))})]}),e.status==="awaiting_completion"&&r.jsxs("div",{className:"flex items-center gap-1.5 p-1.5",style:{backgroundColor:"#EAB30815",borderRadius:"2px",border:"1px solid #EAB30830"},children:[r.jsx($e,{className:"h-3 w-3 shrink-0",style:{color:"#EAB308"}}),r.jsx("span",{className:"text-[9px] font-mono font-bold",style:{color:"#EAB308"},children:"Awaiting CEO completion approval"})]})]})]})}function Vf({directives:e}){return e.length===0?r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(yt,{className:"h-3 w-3"}),count:0,children:"Active Directives"}),r.jsx("div",{className:"text-center py-4 font-mono",style:te,children:r.jsx("p",{className:"text-[11px]",style:{color:g.textDim},children:"No active directives"})})]}):r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(yt,{className:"h-3 w-3"}),count:e.length,children:"Active Directives"}),e.map(t=>r.jsx(zf,{directive:t},t.directiveName))]})}function Kf({directive:e}){const[t,n]=f.useState(!1),s=t?st:Be;return r.jsxs("div",{style:te,children:[r.jsxs("button",{onClick:()=>n(o=>!o),className:"w-full text-left flex items-center gap-2 p-1.5 transition-colors",onMouseEnter:o=>{o.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:o=>{o.currentTarget.style.backgroundColor=""},"aria-expanded":t,children:[r.jsx(s,{className:"h-2.5 w-2.5 shrink-0",style:{color:g.accent},"aria-hidden":"true"}),r.jsx("span",{className:"text-[10px] font-mono truncate flex-1",style:{color:g.text},children:e.title??e.directiveName}),r.jsxs("span",{className:"text-[9px] font-mono shrink-0 flex items-center gap-1",style:{color:g.textDim},children:[r.jsx(Lt,{className:"h-2.5 w-2.5","aria-hidden":"true"}),et(e.lastUpdated)]})]}),t&&r.jsxs("div",{className:"px-2 pb-2 space-y-1",style:{borderTop:`1px solid ${g.border}30`},children:[r.jsx("div",{className:"pt-1"}),r.jsxs("div",{className:"flex items-center gap-2",children:[e.weight&&r.jsx("span",{className:"text-[8px] font-bold font-mono px-1 py-0.5 leading-none",style:{backgroundColor:bs(e.weight).bg,color:bs(e.weight).text,borderRadius:"2px"},children:Ra(e.weight)}),e.category&&r.jsx("span",{className:"text-[8px] font-mono px-1 py-0.5 leading-none",style:{backgroundColor:`${g.border}40`,color:g.textDim,borderRadius:"2px"},children:e.category}),e.totalProjects>0&&r.jsxs("span",{className:"text-[8px] font-mono",style:{color:g.textDim},children:[e.totalProjects," project",e.totalProjects!==1?"s":""]})]}),e.projects&&e.projects.length>0&&r.jsx("div",{className:"space-y-0.5 pl-1",children:e.projects.map(o=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Ee,{className:"h-2 w-2 shrink-0",style:{color:"#22C55E"}}),r.jsx("span",{className:"text-[8px] font-mono truncate",style:{color:g.textDim},children:o.title})]},o.id))})]})]})}function Zf({recentCompleted:e,sevenDayCount:t}){return r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(Ol,{className:"h-3 w-3"}),count:t,color:"#8B5CF6",children:"Velocity (7d)"}),e.length===0?r.jsx("div",{className:"text-center py-3 font-mono",style:te,children:r.jsx("p",{className:"text-[11px]",style:{color:g.textDim},children:"No completed directives yet"})}):r.jsx("div",{className:"space-y-1",children:e.map(n=>r.jsx(Kf,{directive:n},n.directiveName))})]})}function qf({segments:e,total:t,sessions:n}){const[s,o]=f.useState(!1);if(t===0)return r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(ln,{className:"h-3 w-3"}),count:0,children:"Session Health"}),r.jsx("div",{className:"text-center py-3 font-mono",style:te,children:r.jsx("p",{className:"text-[11px]",style:{color:g.textDim},children:"No active sessions"})})]});const a=f.useMemo(()=>{const i=n.filter(d=>!d.isSubagent),c={working:[],waiting:[],error:[],idle:[]};for(const d of i)switch(d.status){case"working":c.working.push(d);break;case"waiting-approval":case"waiting-input":c.waiting.push(d);break;case"error":c.error.push(d);break;default:c.idle.push(d);break}return c},[n]),l=s?st:Be;return r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{icon:r.jsx(ln,{className:"h-3 w-3"}),count:t,children:"Session Health"}),r.jsxs("div",{style:te,children:[r.jsxs("button",{onClick:()=>o(i=>!i),className:"w-full text-left p-2.5 transition-colors",onMouseEnter:i=>{i.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:i=>{i.currentTarget.style.backgroundColor=""},"aria-expanded":s,"aria-label":"Session health details",children:[r.jsx("div",{className:"flex overflow-hidden mb-2",style:{height:"10px",borderRadius:"2px",backgroundColor:"#C8B09060",boxShadow:"inset 1px 1px 0 0 #A0804060, inset -1px -1px 0 0 #F5ECD740"},role:"img","aria-label":`Session distribution: ${e.filter(i=>i.count>0).map(i=>`${i.count} ${i.label}`).join(", ")}`,children:e.map(i=>{if(i.count===0)return null;const c=i.count/t*100;return r.jsx("div",{style:{width:`${c}%`,backgroundColor:i.color,minWidth:i.count>0?"4px":"0",transition:"width 300ms ease"}},i.key)})}),r.jsxs("div",{className:"flex items-center gap-x-3 gap-y-1 flex-wrap",children:[e.map(i=>r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"inline-block h-2 w-2",style:{backgroundColor:i.color,borderRadius:"1px"},"aria-hidden":"true"}),r.jsx("span",{className:"text-[9px] font-mono",style:{color:g.textDim},children:i.label}),r.jsx("span",{className:"text-[9px] font-bold font-mono tabular-nums",style:{color:g.text},children:i.count})]},i.key)),r.jsx(l,{className:"h-3 w-3 ml-auto shrink-0",style:{color:g.accent},"aria-hidden":"true"})]})]}),s&&r.jsxs("div",{className:"px-2.5 pb-2.5 space-y-1.5",style:{borderTop:`1px solid ${g.border}40`},children:[r.jsx("div",{className:"pt-1"}),["working","waiting","error","idle"].map(i=>{const c=a[i];if(!c||c.length===0)return null;const d=e.find(u=>u.key===i);return r.jsxs("div",{children:[r.jsxs("span",{className:"text-[8px] font-bold font-mono uppercase tracking-wider block mb-0.5",style:{color:d?.color??g.textDim},children:[d?.label??i," (",c.length,")"]}),r.jsx("div",{className:"space-y-0.5",children:c.map(u=>r.jsxs("div",{className:"flex items-center gap-1.5 pl-1",children:[r.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:d?.color??"#9CA3AF"}}),r.jsx("span",{className:"text-[9px] font-mono font-bold truncate",style:{color:g.text},children:u.agentName??u.id.slice(0,8)}),u.feature&&r.jsx("span",{className:"text-[8px] font-mono truncate flex-1",style:{color:g.textDim},children:u.feature}),u.lastActivity&&r.jsx("span",{className:"text-[8px] font-mono tabular-nums shrink-0",style:{color:g.textDim},children:et(u.lastActivity)})]},u.id))})]},i)})]})]})]})}function Qf(){const e=J(u=>u.connected),t=J(u=>u.sessions),n=J(u=>u.activeDirectives),s=J(u=>u.directiveHistory),o=f.useMemo(()=>t.filter(u=>u.status==="working"||u.status.startsWith("waiting")).length,[t]),a=f.useMemo(()=>n.reduce((u,m)=>u+m.totalProjects,0),[n]),{recentCompleted:l,sevenDayCount:i}=f.useMemo(()=>{const u=Date.now()-6048e5,m=s.filter(p=>p.status==="completed").sort((p,x)=>new Date(x.lastUpdated).getTime()-new Date(p.lastUpdated).getTime()),h=m.filter(p=>new Date(p.lastUpdated).getTime()>=u);return{recentCompleted:m.slice(0,5),sevenDayCount:h.length}},[s]),{segments:c,totalNonSubagent:d}=f.useMemo(()=>{const u=t.filter(w=>!w.isSubagent);let m=0,h=0,p=0,x=0;for(const w of u)switch(w.status){case"working":m++;break;case"waiting-approval":case"waiting-input":h++;break;case"error":x++;break;case"idle":case"paused":case"done":p++;break}return{segments:[{key:"working",label:"Working",count:m,color:"#22C55E"},{key:"waiting",label:"Waiting",count:h,color:"#EAB308"},{key:"idle",label:"Idle",count:p,color:"#9CA3AF"},{key:"error",label:"Error",count:x,color:"#EF4444"}],totalNonSubagent:u.length}},[t]);return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Hf,{connected:e,activeSessions:o,activeDirectiveCount:n.length,inFlightProjects:a}),r.jsx(Me,{ornament:!0}),r.jsx(Vf,{directives:n}),r.jsx(Me,{}),r.jsx(Zf,{recentCompleted:l,sevenDayCount:i}),r.jsx(Me,{}),r.jsx(qf,{segments:c,total:d,sessions:t})]})}function Jf(e){const t=e.toLowerCase();return t.includes("error")||t.includes("complet")||t.includes("finish")||t.includes("done")?"high":t.includes("approv")||t.includes("reject")||t.includes("denied")?"medium":(t.includes("start")||t.includes("begin"),"low")}function em(e){const t=e.toLowerCase();return t.includes("error")?{icon:r.jsx($e,{className:"h-3 w-3"}),color:"#EF4444"}:t.includes("complet")||t.includes("done")?{icon:r.jsx(Ee,{className:"h-3 w-3"}),color:"#22C55E"}:t.includes("approv")?{icon:r.jsx(Ee,{className:"h-3 w-3"}),color:"#EAB308"}:t.includes("reject")||t.includes("denied")?{icon:r.jsx($e,{className:"h-3 w-3"}),color:"#EAB308"}:t.includes("start")||t.includes("begin")?{icon:r.jsx(Nt,{className:"h-3 w-3"}),color:"#3B82F6"}:{icon:r.jsx(yt,{className:"h-3 w-3"}),color:g.textDim}}function tm(e){const t=[],n=Mt(e.model);if(n&&t.push({label:"Model",value:n}),e.agentRole&&t.push({label:"Role",value:e.agentRole}),e.gitBranch&&t.push({label:"Branch",value:e.gitBranch}),e.feature&&t.push({label:"Feature",value:e.feature}),e.subagentIds&&e.subagentIds.length>0&&t.push({label:"Subagents",value:String(e.subagentIds.length)}),e.activeSubagentNames&&e.activeSubagentNames.length>0&&t.push({label:"Active subs",value:e.activeSubagentNames.join(", ")}),e.cwd){const s=e.cwd.split("/").slice(-2).join("/");t.push({label:"Dir",value:s})}if(e.latestPrompt){const s=e.latestPrompt.length>200?e.latestPrompt.slice(0,197)+"...":e.latestPrompt;t.push({label:"Prompt",value:s})}return t}function nm(e){return e.map(t=>{const{icon:n,color:s}=em(t.type),o=[];if(t.project&&o.push({label:"Project",value:t.project}),t.type&&o.push({label:"Type",value:t.type}),t.sessionId&&o.push({label:"Session",value:t.sessionId.slice(0,12)}),t.metadata)for(const[a,l]of Object.entries(t.metadata))(typeof l=="string"||typeof l=="number")&&o.push({label:a,value:String(l)});return{id:`hook-${t.id}`,timestamp:t.timestamp,icon:n,iconColor:s,description:t.message||`${t.type} event`,detail:t.project?`Project: ${t.project}`:void 0,priority:Jf(t.type),source:"hook",meta:o.length>0?o:void 0}})}function sm(e){const t=[];for(const n of e){if(n.isSubagent)continue;const s=n.agentName??n.slug??n.id.slice(0,8),o=tm(n);n.status==="error"&&t.push({id:`sess-err-${n.id}`,timestamp:n.lastActivity,icon:r.jsx($e,{className:"h-3 w-3"}),iconColor:"#EF4444",description:`${s} encountered an error`,detail:n.feature??n.latestPrompt?.slice(0,80)??void 0,priority:"high",source:"session",meta:o}),n.status==="done"&&t.push({id:`sess-done-${n.id}`,timestamp:n.lastActivity,icon:r.jsx(Ee,{className:"h-3 w-3"}),iconColor:"#22C55E",description:`${s} finished work`,detail:n.feature??void 0,priority:"high",source:"session",meta:o}),(n.status==="waiting-approval"||n.status==="waiting-input")&&t.push({id:`sess-wait-${n.id}`,timestamp:n.lastActivity,icon:r.jsx(Lt,{className:"h-3 w-3"}),iconColor:"#EAB308",description:`${s} waiting for ${n.status==="waiting-approval"?"approval":"input"}`,detail:n.feature??void 0,priority:"high",source:"session",meta:o}),n.status==="working"&&t.push({id:`sess-work-${n.id}`,timestamp:n.lastActivity,icon:r.jsx(Nt,{className:"h-3 w-3"}),iconColor:"#3B82F6",description:`${s} is working`,detail:n.feature??void 0,priority:"low",source:"session",meta:o}),(n.status==="idle"||n.status==="paused")&&t.push({id:`sess-idle-${n.id}`,timestamp:n.lastActivity,icon:r.jsx(Il,{className:"h-3 w-3"}),iconColor:"#9CA3AF",description:`${s} went idle`,priority:"low",source:"session",meta:o.length>0?o:void 0})}return t}function om(e,t){const n=[],s=new Set,o=[...e,...t];for(const a of o){const l=a.title||a.directiveName,i=[a.weight,a.category].filter(Boolean).join("/"),c=i?`[${i}] `:"",d=[];if(a.weight&&d.push({label:"Weight",value:a.weight}),a.category&&d.push({label:"Category",value:a.category}),a.totalProjects>0&&d.push({label:"Projects",value:`${a.currentProject}/${a.totalProjects}`}),a.currentStepId&&d.push({label:"Step",value:a.currentStepId}),a.currentPhase&&d.push({label:"Phase",value:a.currentPhase}),a.pipelineSteps){const u=a.pipelineSteps.filter(m=>m.status==="completed"||m.status==="skipped").length;d.push({label:"Pipeline",value:`${u}/${a.pipelineSteps.length} steps`})}if(a.brainstormSummary&&d.push({label:"Brainstorm",value:a.brainstormSummary}),a.planSummary&&d.push({label:"Plan",value:a.planSummary}),a.triageRationale&&d.push({label:"Triage",value:a.triageRationale}),a.projects&&a.projects.length>0)for(const u of a.projects){const m=u.totalTasks?` (${u.completedTasks??0}/${u.totalTasks} tasks)`:"";d.push({label:"Project",value:`${u.title} — ${u.status}${m}`})}if(a.startedAt){const u=`${a.directiveName}-started`;s.has(u)||(s.add(u),n.push({id:`dir-start-${a.directiveName}`,timestamp:a.startedAt,icon:r.jsx(Nt,{className:"h-3 w-3"}),iconColor:"#8B5CF6",description:`${c}Directive started: ${l}`,priority:"high",source:"directive",meta:d}))}if(a.status==="completed"||a.status==="failed"){const u=`${a.directiveName}-${a.status}`;s.has(u)||(s.add(u),n.push({id:`dir-end-${a.directiveName}`,timestamp:a.lastUpdated,icon:a.status==="completed"?r.jsx(Ee,{className:"h-3 w-3"}):r.jsx($e,{className:"h-3 w-3"}),iconColor:a.status==="completed"?"#22C55E":"#EF4444",description:`${c}Directive ${a.status}: ${l}`,priority:"high",source:"directive",meta:d}))}if(a.status==="awaiting_completion"){const u=`${a.directiveName}-awaiting`;s.has(u)||(s.add(u),n.push({id:`dir-await-${a.directiveName}`,timestamp:a.lastUpdated,icon:r.jsx(Lt,{className:"h-3 w-3"}),iconColor:"#EAB308",description:`${c}Awaiting completion: ${l}`,priority:"medium",source:"directive",meta:d}))}}return n}function rm(e){if(!e?.pipelineSteps)return[];const t=[],n=e.title||e.directiveName;for(const s of e.pipelineSteps){if(!s.startedAt)continue;const o=s.status==="completed"?r.jsx(Ee,{className:"h-3 w-3"}):s.status==="failed"?r.jsx($e,{className:"h-3 w-3"}):s.status==="active"?r.jsx(Lt,{className:"h-3 w-3"}):r.jsx(Be,{className:"h-3 w-3"}),a=s.status==="completed"?"#22C55E":s.status==="failed"?"#EF4444":s.status==="active"?"#EAB308":g.textDim,l=[{label:"Directive",value:n},{label:"Step",value:s.label},{label:"Status",value:s.status}];if(s.artifacts)for(const[i,c]of Object.entries(s.artifacts))l.push({label:i,value:c});t.push({id:`pipe-${s.id}`,timestamp:s.startedAt,icon:o,iconColor:a,description:`Pipeline: ${s.label}`,detail:s.status==="active"?"In progress":s.status,priority:"medium",source:"pipeline",meta:l})}return t}function am(e,t,n){return`${e}:${t??""}:${n??""}`}function im(e,t,n){const s=[],o=new Map(e.map(a=>[a.id,a]));for(const a of e){if(!a.subagentIds||a.subagentIds.length===0)continue;const l=a.agentName??a.slug??a.id.slice(0,8);for(const i of a.subagentIds){const c=o.get(i),d=c?.agentName??c?.slug??i.slice(0,8),u=[{label:"Parent",value:l},{label:"Child",value:d}];if(c){const m=Mt(c.model);m&&u.push({label:"Model",value:m}),c.agentRole&&u.push({label:"Role",value:c.agentRole}),c.feature&&u.push({label:"Feature",value:c.feature})}if(t.current.has(i)||(t.current.add(i),s.push({id:`sub-spawn-${i}-${Date.now()}`,timestamp:c?.lastActivity??new Date().toISOString(),icon:r.jsx(St,{className:"h-3 w-3"}),iconColor:"#3B82F6",description:`${l} spawned subagent ${d}`,detail:c?.feature??void 0,priority:"medium",source:"subagent",meta:u})),c){const m=n.current[i];m&&m!==c.status&&(c.status==="done"?s.push({id:`sub-done-${i}-${Date.now()}`,timestamp:c.lastActivity,icon:r.jsx(Ee,{className:"h-3 w-3"}),iconColor:"#22C55E",description:`Subagent ${d} completed (parent: ${l})`,detail:c.feature??void 0,priority:"medium",source:"subagent",meta:u}):c.status==="error"&&s.push({id:`sub-err-${i}-${Date.now()}`,timestamp:c.lastActivity,icon:r.jsx($e,{className:"h-3 w-3"}),iconColor:"#EF4444",description:`Subagent ${d} error (parent: ${l})`,detail:c.feature??void 0,priority:"high",source:"subagent",meta:u})),n.current[i]=c.status}}}return s}function lm(e){const t=[];for(const n of e){const s=[{label:"Team",value:n.name},{label:"Members",value:String(n.members.length)},{label:"Lead",value:n.leadAgentId}];n.description&&s.push({label:"Description",value:n.description});for(const o of n.members)s.push({label:o.name,value:`${o.agentType} (${o.model})`});t.push({id:`team-create-${n.name}`,timestamp:n.createdAt,icon:r.jsx(St,{className:"h-3 w-3"}),iconColor:"#8B5CF6",description:`Team created: ${n.name}`,detail:`${n.members.length} members, lead: ${n.leadAgentId}`,priority:"medium",source:"team",meta:s}),n.stale&&t.push({id:`team-stale-${n.name}`,timestamp:n.createdAt,icon:r.jsx($e,{className:"h-3 w-3"}),iconColor:"#EAB308",description:`Team stale: ${n.name}`,detail:"Team has gone inactive",priority:"medium",source:"team",meta:s})}return t}function cm(e){const t=new Date(e),n=new Date,s=t.toDateString(),o=n.toDateString(),a=new Date(n);a.setDate(a.getDate()-1);const l=a.toDateString();return s===o?"Today":s===l?"Yesterday":t.toLocaleDateString("en-US",{month:"long",day:"numeric"})}function Vo(e){return new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function dm({mode:e,onChange:t}){const n=[{value:"important",label:"Key"},{value:"activity",label:"Agents"},{value:"all",label:"All"}];return r.jsx("div",{className:"flex font-mono text-[10px]",style:{backgroundColor:"#D4B89680",borderRadius:"2px",boxShadow:"inset 1px 1px 0 0 #A0804040, inset -1px -1px 0 0 #F5ECD740",overflow:"hidden"},role:"radiogroup","aria-label":"Event filter",children:n.map(s=>r.jsx("button",{type:"button",role:"radio","aria-checked":e===s.value,className:"px-2 py-1 font-bold uppercase tracking-wider transition-all",style:{color:e===s.value?g.bg:g.textDim,backgroundColor:e===s.value?"#5C3D2E":"transparent",boxShadow:e===s.value?"inset 0 1px 0 0 #6B4C3B, inset 0 -1px 0 0 #3D2B1F":"none"},onClick:()=>t(s.value),children:s.label},s.value))})}function um({event:e}){const[t,n]=f.useState(!1),s=e.meta&&e.meta.length>0||e.detail&&e.detail.length>=50,o=e.detail&&e.detail.length>0&&e.detail.length<50&&!s;return r.jsxs("div",{style:te,children:[s?r.jsxs("button",{type:"button",onClick:()=>n(a=>!a),className:"w-full text-left flex gap-2 px-2 py-1.5 font-mono transition-colors",onMouseEnter:a=>{a.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:a=>{a.currentTarget.style.backgroundColor=""},"aria-expanded":t,children:[r.jsx("span",{className:"flex items-center justify-center shrink-0 mt-0.5",style:{color:e.iconColor},"aria-hidden":"true",children:e.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx("p",{className:"text-[11px] leading-snug flex-1",style:{color:g.text},children:e.description}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0 mt-0.5",children:[r.jsx("span",{className:"text-[9px] tabular-nums",style:{color:g.textDim},children:Vo(e.timestamp)}),r.jsx(st,{className:"h-2.5 w-2.5 transition-transform",style:{color:g.accent,transform:t?"rotate(0deg)":"rotate(-90deg)"}})]})]}),e.detail&&!t&&r.jsx("p",{className:"text-[9px] mt-0.5 leading-snug truncate",style:{color:g.textDim},children:e.detail})]})]}):r.jsxs("div",{className:"flex gap-2 px-2 py-1.5 font-mono",children:[r.jsx("span",{className:"flex items-center justify-center shrink-0 mt-0.5",style:{color:e.iconColor},"aria-hidden":"true",children:e.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx("p",{className:"text-[11px] leading-snug flex-1",style:{color:g.text},children:e.description}),r.jsx("span",{className:"text-[9px] tabular-nums shrink-0 mt-0.5",style:{color:g.textDim},children:Vo(e.timestamp)})]}),o&&r.jsx("p",{className:"text-[10px] mt-0.5 leading-snug",style:{color:g.textDim},children:e.detail})]})]}),t&&r.jsxs("div",{className:"px-2 pb-2 font-mono",style:{borderTop:`1px solid ${g.border}30`},children:[e.detail&&r.jsx("p",{className:"text-[10px] mt-1.5 leading-snug",style:{color:g.textDim},children:e.detail}),e.meta&&e.meta.length>0&&r.jsx("div",{className:"mt-1.5 space-y-0.5",children:e.meta.map((a,l)=>r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[9px] font-bold shrink-0 w-[60px] text-right",style:{color:g.accent},children:a.label}),r.jsx("span",{className:"text-[9px] flex-1 break-words",style:{color:g.textDim},children:a.value})]},l))})]})]})}const fm=3e3,mt=50;function mm(){const e=J(P=>P.events),t=J(P=>P.sessions),n=J(P=>P.directiveState),s=J(P=>P.activeDirectives),o=J(P=>P.directiveHistory),a=J(P=>P.sessionActivities),l=J(P=>P.connected),i=J(P=>P.teams),c=J(P=>P.tasksBySession),[d,u]=f.useState("important"),m=f.useRef({}),h=f.useRef([]),p=f.useRef({}),x=f.useRef(new Set),b=f.useRef(null),w=f.useRef([]),y=f.useRef(new Set),S=f.useRef({}),N=f.useRef([]),v=f.useRef({}),k=f.useRef([]);f.useEffect(()=>{const P=m.current,q=Date.now();for(const[K,Q]of Object.entries(a)){const oe=P[K];if(!(!oe||oe.tool!==Q.tool||oe.detail!==Q.detail||oe.thinking!==Q.thinking))continue;const ne=p.current[K]??0;if(q-ne<fm)continue;const V=am(K,Q.tool,Q.detail);if(x.current.has(V))continue;x.current.add(V);const C=t.find(F=>F.id===K);let D=`${C?.agentName??C?.slug??K.slice(0,8)}`;Q.thinking?D+=" is thinking":Q.tool?D+=` using ${Q.tool}`:D+=" activity changed";const z=[];Q.tool&&z.push({label:"Tool",value:Q.tool}),Q.detail&&z.push({label:"Detail",value:Q.detail});const M=Mt(Q.model);M&&z.push({label:"Model",value:M}),C?.feature&&z.push({label:"Feature",value:C.feature}),h.current.push({id:`act-${K}-${q}`,timestamp:Q.lastSeen||new Date().toISOString(),icon:r.jsx(yt,{className:"h-3 w-3"}),iconColor:"#3B82F6",description:D,detail:Q.detail??void 0,priority:"low",source:"activity",meta:z.length>0?z:void 0}),p.current[K]=q}h.current.length>mt&&(h.current=h.current.slice(-mt)),m.current={...a}},[a,t]),f.useEffect(()=>{if(b.current===null){b.current=l;return}b.current!==l&&(w.current.push({id:`conn-${Date.now()}`,timestamp:new Date().toISOString(),icon:l?r.jsx(Cr,{className:"h-3 w-3"}):r.jsx(vr,{className:"h-3 w-3"}),iconColor:l?"#22C55E":"#EF4444",description:l?"Connected to server":"Disconnected from server",priority:"high",source:"connection"}),b.current=l)},[l]);const E=f.useRef(!1);f.useEffect(()=>{if(!E.current&&t.length!==0){E.current=!0;for(const P of t)if(P.subagentIds)for(const q of P.subagentIds){y.current.add(q);const K=t.find(Q=>Q.id===q);K&&(S.current[q]=K.status)}}},[t]),f.useEffect(()=>{if(!E.current)return;const P=im(t,y,S);P.length>0&&(N.current.push(...P),N.current.length>mt&&(N.current=N.current.slice(-mt)))},[t]);const A=f.useRef(!1);f.useEffect(()=>{if(!A.current&&Object.keys(c).length!==0){A.current=!0;for(const[P,q]of Object.entries(c))for(const K of q)v.current[`${P}:${K.id}`]=K.status}},[c]),f.useEffect(()=>{if(!A.current)return;const P=v.current,q={};for(const[K,Q]of Object.entries(c)){const oe=t.find(ne=>ne.id===K),ue=oe?.agentName??oe?.slug??K.slice(0,8);for(const ne of Q){const V=`${K}:${ne.id}`;q[V]=ne.status;const C=P[V];if(C&&C!==ne.status){const X=[{label:"Task",value:ne.subject},{label:"Owner",value:ne.owner||ue},{label:"Status",value:`${C} → ${ne.status}`}];ne.description&&X.push({label:"Description",value:ne.description}),ne.status==="in_progress"?k.current.push({id:`task-prog-${ne.id}-${Date.now()}`,timestamp:new Date().toISOString(),icon:r.jsx(Zi,{className:"h-3 w-3"}),iconColor:"#3B82F6",description:`Task started: ${ne.subject}`,detail:`Owner: ${ne.owner||ue}`,priority:"medium",source:"task",meta:X}):ne.status==="completed"&&k.current.push({id:`task-done-${ne.id}-${Date.now()}`,timestamp:new Date().toISOString(),icon:r.jsx(Ee,{className:"h-3 w-3"}),iconColor:"#22C55E",description:`Task completed: ${ne.subject}`,detail:`Owner: ${ne.owner||ue}`,priority:"high",source:"task",meta:X})}}}k.current.length>mt&&(k.current=k.current.slice(-mt)),v.current=q},[c,t]);const j=f.useMemo(()=>{const P=nm(e),q=sm(t),K=om(s,o),Q=rm(n),oe=lm(i),ue=h.current,ne=w.current,V=N.current,C=k.current;return[...P,...q,...K,...Q,...oe,...ue,...ne,...V,...C].sort((X,D)=>new Date(D.timestamp).getTime()-new Date(X.timestamp).getTime())},[e,t,n,s,o,i,a,l,c]),T=f.useMemo(()=>{if(d==="all")return j;if(d==="activity"){const P=new Set(["session","activity","subagent","task"]);return j.filter(q=>P.has(q.source))}return j.filter(P=>P.priority==="high"||P.priority==="medium")},[j,d]),G=f.useMemo(()=>{const P=[];let q="";for(const K of T){const Q=cm(K.timestamp);Q!==q&&(q=Q,P.push({label:Q,events:[]})),P[P.length-1].events.push(K)}return P},[T]);if(j.length===0)return r.jsxs("div",{className:"text-center py-8 font-mono",style:te,children:[r.jsx(rs,{className:"h-6 w-6 mx-auto mb-2",style:{color:g.textDim,opacity:.4},"aria-hidden":"true"}),r.jsx("p",{className:"text-xs font-bold",style:{color:g.text},children:"No events yet"}),r.jsx("p",{className:"text-[10px] mt-0.5",style:{color:g.textDim},children:"Activity will appear here as agents work"})]});const W=T.length===0&&j.length>0;return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Re,{icon:r.jsx(rs,{className:"h-3 w-3"}),count:T.length,children:"Activity"}),r.jsx(dm,{mode:d,onChange:u})]}),W&&r.jsxs("div",{className:"text-center py-6 font-mono",style:te,children:[r.jsx("p",{className:"text-xs font-bold",style:{color:g.text},children:d==="important"?"No important events":"No agent activity"}),r.jsxs("p",{className:"text-[10px] mt-0.5",style:{color:g.textDim},children:['Switch to "All" to see ',j.length," event",j.length!==1?"s":""]})]}),G.map((P,q)=>r.jsxs("div",{className:"space-y-1.5",children:[q>0&&r.jsx(Me,{ornament:!0}),r.jsx("div",{className:"text-[10px] font-bold font-mono uppercase tracking-widest text-center py-0.5",style:{color:g.accent},children:P.label}),P.events.map(K=>r.jsx(um,{event:K},K.id))]},P.label))]})}const pm=Kr("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ft({className:e,variant:t,...n}){return r.jsx("div",{className:de(pm({variant:t}),e),...n})}function hm(e){const{tool:t,detail:n,thinking:s}=e;if(s)return{icon:r.jsx(Gi,{className:"h-3 w-3 shrink-0"}),label:"Thinking..."};if(!t)return null;const o=t.toLowerCase();return o==="edit"||o==="write"?{icon:r.jsx(Cl,{className:"h-3 w-3 shrink-0"}),label:`Editing ${n??""}`.trim()}:o==="read"?{icon:r.jsx(Pt,{className:"h-3 w-3 shrink-0"}),label:`Reading ${n??""}`.trim()}:o==="bash"?{icon:r.jsx(wr,{className:"h-3 w-3 shrink-0"}),label:`Running: ${n??""}`.trim()}:o==="grep"?{icon:r.jsx(Al,{className:"h-3 w-3 shrink-0"}),label:`Searching: ${n??""}`.trim()}:o==="task"?{icon:r.jsx(os,{className:"h-3 w-3 shrink-0"}),label:"Spawned agent"}:null}function gm({activity:e}){if(!e||!e.active)return null;const t=hm(e);return t?r.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-xs text-muted-foreground min-w-0 overflow-hidden",children:[r.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}),t.icon,r.jsx("span",{className:"truncate min-w-0",children:t.label}),e.model&&r.jsx(Ft,{variant:"secondary",className:"text-[10px] px-1 py-0 shrink-0",children:e.model.replace("claude-","").replace("-4-6","")})]}):null}const Ia=f.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:de("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));Ia.displayName="Input";var xm=vs[" useId ".trim().toString()]||(()=>{}),bm=0;function Kn(e){const[t,n]=f.useState(xm());return vt(()=>{n(s=>s??String(bm++))},[e]),e||(t?`radix-${t}`:"")}var ym=vs[" useInsertionEffect ".trim().toString()]||vt;function wm({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,l]=vm({defaultProp:t,onChange:n}),i=e!==void 0,c=i?e:o;{const u=f.useRef(e!==void 0);f.useEffect(()=>{const m=u.current;m!==i&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=i},[i,s])}const d=f.useCallback(u=>{if(i){const m=Cm(u)?u(e):u;m!==e&&l.current?.(m)}else a(u)},[i,e,a,l]);return[c,d]}function vm({defaultProp:e,onChange:t}){const[n,s]=f.useState(e),o=f.useRef(n),a=f.useRef(t);return ym(()=>{a.current=t},[t]),f.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,s,a]}function Cm(e){return typeof e=="function"}function km(e,t=globalThis?.document){const n=Xe(e);f.useEffect(()=>{const s=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var Nm="DismissableLayer",ys="dismissableLayer.update",Sm="dismissableLayer.pointerDownOutside",Em="dismissableLayer.focusOutside",Ko,Pa=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_a=f.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:i,...c}=e,d=f.useContext(Pa),[u,m]=f.useState(null),h=u?.ownerDocument??globalThis?.document,[,p]=f.useState({}),x=je(t,A=>m(A)),b=Array.from(d.layers),[w]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=b.indexOf(w),S=u?b.indexOf(u):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,v=S>=y,k=Tm(A=>{const j=A.target,T=[...d.branches].some(G=>G.contains(j));!v||T||(o?.(A),l?.(A),A.defaultPrevented||i?.())},h),E=Xm(A=>{const j=A.target;[...d.branches].some(G=>G.contains(j))||(a?.(A),l?.(A),A.defaultPrevented||i?.())},h);return km(A=>{S===d.layers.size-1&&(s?.(A),!A.defaultPrevented&&i&&(A.preventDefault(),i()))},h),f.useEffect(()=>{if(u)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Ko=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),Zo(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ko)}},[u,h,n,d]),f.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),Zo())},[u,d]),f.useEffect(()=>{const A=()=>p({});return document.addEventListener(ys,A),()=>document.removeEventListener(ys,A)},[]),r.jsx(ve.div,{...c,ref:x,style:{pointerEvents:N?v?"auto":"none":void 0,...e.style},onFocusCapture:ye(e.onFocusCapture,E.onFocusCapture),onBlurCapture:ye(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:ye(e.onPointerDownCapture,k.onPointerDownCapture)})});_a.displayName=Nm;var jm="DismissableLayerBranch",Am=f.forwardRef((e,t)=>{const n=f.useContext(Pa),s=f.useRef(null),o=je(t,s);return f.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(ve.div,{...e,ref:o})});Am.displayName=jm;function Tm(e,t=globalThis?.document){const n=Xe(e),s=f.useRef(!1),o=f.useRef(()=>{});return f.useEffect(()=>{const a=i=>{if(i.target&&!s.current){let c=function(){Ma(Sm,n,d,{discrete:!0})};const d={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);s.current=!1},l=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(l),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function Xm(e,t=globalThis?.document){const n=Xe(e),s=f.useRef(!1);return f.useEffect(()=>{const o=a=>{a.target&&!s.current&&Ma(Em,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Zo(){const e=new CustomEvent(ys);document.dispatchEvent(e)}function Ma(e,t,n,{discrete:s}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?Vu(o,a):o.dispatchEvent(a)}var Zn="focusScope.autoFocusOnMount",qn="focusScope.autoFocusOnUnmount",qo={bubbles:!1,cancelable:!0},Rm="FocusScope",Fa=f.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[i,c]=f.useState(null),d=Xe(o),u=Xe(a),m=f.useRef(null),h=je(t,b=>c(b)),p=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(s){let b=function(N){if(p.paused||!i)return;const v=N.target;i.contains(v)?m.current=v:Je(m.current,{select:!0})},w=function(N){if(p.paused||!i)return;const v=N.relatedTarget;v!==null&&(i.contains(v)||Je(m.current,{select:!0}))},y=function(N){if(document.activeElement===document.body)for(const k of N)k.removedNodes.length>0&&Je(i)};document.addEventListener("focusin",b),document.addEventListener("focusout",w);const S=new MutationObserver(y);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",w),S.disconnect()}}},[s,i,p.paused]),f.useEffect(()=>{if(i){Jo.add(p);const b=document.activeElement;if(!i.contains(b)){const y=new CustomEvent(Zn,qo);i.addEventListener(Zn,d),i.dispatchEvent(y),y.defaultPrevented||(Dm(Fm(Oa(i)),{select:!0}),document.activeElement===b&&Je(i))}return()=>{i.removeEventListener(Zn,d),setTimeout(()=>{const y=new CustomEvent(qn,qo);i.addEventListener(qn,u),i.dispatchEvent(y),y.defaultPrevented||Je(b??document.body,{select:!0}),i.removeEventListener(qn,u),Jo.remove(p)},0)}}},[i,d,u,p]);const x=f.useCallback(b=>{if(!n&&!s||p.paused)return;const w=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,y=document.activeElement;if(w&&y){const S=b.currentTarget,[N,v]=Im(S);N&&v?!b.shiftKey&&y===v?(b.preventDefault(),n&&Je(N,{select:!0})):b.shiftKey&&y===N&&(b.preventDefault(),n&&Je(v,{select:!0})):y===S&&b.preventDefault()}},[n,s,p.paused]);return r.jsx(ve.div,{tabIndex:-1,...l,ref:h,onKeyDown:x})});Fa.displayName=Rm;function Dm(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Je(s,{select:t}),document.activeElement!==n)return}function Im(e){const t=Oa(e),n=Qo(t,e),s=Qo(t.reverse(),e);return[n,s]}function Oa(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Qo(e,t){for(const n of e)if(!Pm(n,{upTo:t}))return n}function Pm(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function _m(e){return e instanceof HTMLInputElement&&"select"in e}function Je(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&_m(e)&&t&&e.select()}}var Jo=Mm();function Mm(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=er(e,t),e.unshift(t)},remove(t){e=er(e,t),e[0]?.resume()}}}function er(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Fm(e){return e.filter(t=>t.tagName!=="A")}var Om="Portal",La=f.forwardRef((e,t)=>{const{container:n,...s}=e,[o,a]=f.useState(!1);vt(()=>a(!0),[]);const l=n||o&&globalThis?.document?.body;return l?Ei.createPortal(r.jsx(ve.div,{...s,ref:t}),l):null});La.displayName=Om;var Qn=0;function Lm(){f.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??tr()),document.body.insertAdjacentElement("beforeend",e[1]??tr()),Qn++,()=>{Qn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Qn--}},[])}function tr(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Le=function(){return Le=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Le.apply(this,arguments)};function Ba(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function Bm(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var rn="right-scroll-bar-position",an="width-before-scroll-bar",$m="with-scroll-bars-hidden",Gm="--removed-body-scroll-bar-size";function Jn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Wm(e,t){var n=f.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var Hm=typeof window<"u"?f.useLayoutEffect:f.useEffect,nr=new WeakMap;function Um(e,t){var n=Wm(null,function(s){return e.forEach(function(o){return Jn(o,s)})});return Hm(function(){var s=nr.get(n);if(s){var o=new Set(s),a=new Set(e),l=n.current;o.forEach(function(i){a.has(i)||Jn(i,null)}),a.forEach(function(i){o.has(i)||Jn(i,l)})}nr.set(n,e)},[e]),n}function Ym(e){return e}function zm(e,t){t===void 0&&(t=Ym);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var l=t(a,s);return n.push(l),function(){n=n.filter(function(i){return i!==l})}},assignSyncMedium:function(a){for(s=!0;n.length;){var l=n;n=[],l.forEach(a)}n={push:function(i){return a(i)},filter:function(){return n}}},assignMedium:function(a){s=!0;var l=[];if(n.length){var i=n;n=[],i.forEach(a),l=n}var c=function(){var u=l;l=[],u.forEach(a)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(u){l.push(u),d()},filter:function(u){return l=l.filter(u),n}}}};return o}function Vm(e){e===void 0&&(e={});var t=zm(null);return t.options=Le({async:!0,ssr:!1},e),t}var $a=function(e){var t=e.sideCar,n=Ba(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return f.createElement(s,Le({},n))};$a.isSideCarExport=!0;function Km(e,t){return e.useMedium(t),$a}var Ga=Vm(),es=function(){},Sn=f.forwardRef(function(e,t){var n=f.useRef(null),s=f.useState({onScrollCapture:es,onWheelCapture:es,onTouchMoveCapture:es}),o=s[0],a=s[1],l=e.forwardProps,i=e.children,c=e.className,d=e.removeScrollBar,u=e.enabled,m=e.shards,h=e.sideCar,p=e.noRelative,x=e.noIsolation,b=e.inert,w=e.allowPinchZoom,y=e.as,S=y===void 0?"div":y,N=e.gapMode,v=Ba(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,E=Um([n,t]),A=Le(Le({},v),o);return f.createElement(f.Fragment,null,u&&f.createElement(k,{sideCar:Ga,removeScrollBar:d,shards:m,noRelative:p,noIsolation:x,inert:b,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:N}),l?f.cloneElement(f.Children.only(i),Le(Le({},A),{ref:E})):f.createElement(S,Le({},A,{className:c,ref:E}),i))});Sn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Sn.classNames={fullWidth:an,zeroRight:rn};var Zm=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qm(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Zm();return t&&e.setAttribute("nonce",t),e}function Qm(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Jm(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ep=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qm())&&(Qm(t,n),Jm(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tp=function(){var e=ep();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wa=function(){var e=tp(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},np={left:0,top:0,right:0,gap:0},ts=function(e){return parseInt(e||"",10)||0},sp=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ts(n),ts(s),ts(o)]},op=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return np;var t=sp(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},rp=Wa(),xt="data-scroll-locked",ap=function(e,t,n,s){var o=e.left,a=e.top,l=e.right,i=e.gap;return n===void 0&&(n="margin"),`
4
+ .`.concat($m,` {
5
+ overflow: hidden `).concat(s,`;
6
+ padding-right: `).concat(i,"px ").concat(s,`;
7
+ }
8
+ body[`).concat(xt,`] {
9
+ overflow: hidden `).concat(s,`;
10
+ overscroll-behavior: contain;
11
+ `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
12
+ padding-left: `.concat(o,`px;
13
+ padding-top: `).concat(a,`px;
14
+ padding-right: `).concat(l,`px;
15
+ margin-left:0;
16
+ margin-top:0;
17
+ margin-right: `).concat(i,"px ").concat(s,`;
18
+ `),n==="padding"&&"padding-right: ".concat(i,"px ").concat(s,";")].filter(Boolean).join(""),`
19
+ }
20
+
21
+ .`).concat(rn,` {
22
+ right: `).concat(i,"px ").concat(s,`;
23
+ }
24
+
25
+ .`).concat(an,` {
26
+ margin-right: `).concat(i,"px ").concat(s,`;
27
+ }
28
+
29
+ .`).concat(rn," .").concat(rn,` {
30
+ right: 0 `).concat(s,`;
31
+ }
32
+
33
+ .`).concat(an," .").concat(an,` {
34
+ margin-right: 0 `).concat(s,`;
35
+ }
36
+
37
+ body[`).concat(xt,`] {
38
+ `).concat(Gm,": ").concat(i,`px;
39
+ }
40
+ `)},sr=function(){var e=parseInt(document.body.getAttribute(xt)||"0",10);return isFinite(e)?e:0},ip=function(){f.useEffect(function(){return document.body.setAttribute(xt,(sr()+1).toString()),function(){var e=sr()-1;e<=0?document.body.removeAttribute(xt):document.body.setAttribute(xt,e.toString())}},[])},lp=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;ip();var a=f.useMemo(function(){return op(o)},[o]);return f.createElement(rp,{styles:ap(a,!t,o,n?"":"!important")})},ws=!1;if(typeof window<"u")try{var Qt=Object.defineProperty({},"passive",{get:function(){return ws=!0,!0}});window.addEventListener("test",Qt,Qt),window.removeEventListener("test",Qt,Qt)}catch{ws=!1}var pt=ws?{passive:!1}:!1,cp=function(e){return e.tagName==="TEXTAREA"},Ha=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!cp(e)&&n[t]==="visible")},dp=function(e){return Ha(e,"overflowY")},up=function(e){return Ha(e,"overflowX")},or=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Ua(e,s);if(o){var a=Ya(e,s),l=a[1],i=a[2];if(l>i)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},fp=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},mp=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Ua=function(e,t){return e==="v"?dp(t):up(t)},Ya=function(e,t){return e==="v"?fp(t):mp(t)},pp=function(e,t){return e==="h"&&t==="rtl"?-1:1},hp=function(e,t,n,s,o){var a=pp(e,window.getComputedStyle(t).direction),l=a*s,i=n.target,c=t.contains(i),d=!1,u=l>0,m=0,h=0;do{if(!i)break;var p=Ya(e,i),x=p[0],b=p[1],w=p[2],y=b-w-a*x;(x||y)&&Ua(e,i)&&(m+=y,h+=x);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&i!==document.body||c&&(t.contains(i)||t===i));return(u&&Math.abs(m)<1||!u&&Math.abs(h)<1)&&(d=!0),d},Jt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},rr=function(e){return[e.deltaX,e.deltaY]},ar=function(e){return e&&"current"in e?e.current:e},gp=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xp=function(e){return`
41
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
42
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
43
+ `)},bp=0,ht=[];function yp(e){var t=f.useRef([]),n=f.useRef([0,0]),s=f.useRef(),o=f.useState(bp++)[0],a=f.useState(Wa)[0],l=f.useRef(e);f.useEffect(function(){l.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var b=Bm([e.lockRef.current],(e.shards||[]).map(ar),!0).filter(Boolean);return b.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),b.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=f.useCallback(function(b,w){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!l.current.allowPinchZoom;var y=Jt(b),S=n.current,N="deltaX"in b?b.deltaX:S[0]-y[0],v="deltaY"in b?b.deltaY:S[1]-y[1],k,E=b.target,A=Math.abs(N)>Math.abs(v)?"h":"v";if("touches"in b&&A==="h"&&E.type==="range")return!1;var j=window.getSelection(),T=j&&j.anchorNode,G=T?T===E||T.contains(E):!1;if(G)return!1;var W=or(A,E);if(!W)return!0;if(W?k=A:(k=A==="v"?"h":"v",W=or(A,E)),!W)return!1;if(!s.current&&"changedTouches"in b&&(N||v)&&(s.current=k),!k)return!0;var P=s.current||k;return hp(P,w,b,P==="h"?N:v)},[]),c=f.useCallback(function(b){var w=b;if(!(!ht.length||ht[ht.length-1]!==a)){var y="deltaY"in w?rr(w):Jt(w),S=t.current.filter(function(k){return k.name===w.type&&(k.target===w.target||w.target===k.shadowParent)&&gp(k.delta,y)})[0];if(S&&S.should){w.cancelable&&w.preventDefault();return}if(!S){var N=(l.current.shards||[]).map(ar).filter(Boolean).filter(function(k){return k.contains(w.target)}),v=N.length>0?i(w,N[0]):!l.current.noIsolation;v&&w.cancelable&&w.preventDefault()}}},[]),d=f.useCallback(function(b,w,y,S){var N={name:b,delta:w,target:y,should:S,shadowParent:wp(y)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(v){return v!==N})},1)},[]),u=f.useCallback(function(b){n.current=Jt(b),s.current=void 0},[]),m=f.useCallback(function(b){d(b.type,rr(b),b.target,i(b,e.lockRef.current))},[]),h=f.useCallback(function(b){d(b.type,Jt(b),b.target,i(b,e.lockRef.current))},[]);f.useEffect(function(){return ht.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",c,pt),document.addEventListener("touchmove",c,pt),document.addEventListener("touchstart",u,pt),function(){ht=ht.filter(function(b){return b!==a}),document.removeEventListener("wheel",c,pt),document.removeEventListener("touchmove",c,pt),document.removeEventListener("touchstart",u,pt)}},[]);var p=e.removeScrollBar,x=e.inert;return f.createElement(f.Fragment,null,x?f.createElement(a,{styles:xp(o)}):null,p?f.createElement(lp,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function wp(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vp=Km(Ga,yp);var za=f.forwardRef(function(e,t){return f.createElement(Sn,Le({},e,{ref:t,sideCar:vp}))});za.classNames=Sn.classNames;var Cp=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gt=new WeakMap,en=new WeakMap,tn={},ns=0,Va=function(e){return e&&(e.host||Va(e.parentNode))},kp=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Va(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Np=function(e,t,n,s){var o=kp(t,Array.isArray(e)?e:[e]);tn[n]||(tn[n]=new WeakMap);var a=tn[n],l=[],i=new Set,c=new Set(o),d=function(m){!m||i.has(m)||(i.add(m),d(m.parentNode))};o.forEach(d);var u=function(m){!m||c.has(m)||Array.prototype.forEach.call(m.children,function(h){if(i.has(h))u(h);else try{var p=h.getAttribute(s),x=p!==null&&p!=="false",b=(gt.get(h)||0)+1,w=(a.get(h)||0)+1;gt.set(h,b),a.set(h,w),l.push(h),b===1&&x&&en.set(h,!0),w===1&&h.setAttribute(n,"true"),x||h.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return u(t),i.clear(),ns++,function(){l.forEach(function(m){var h=gt.get(m)-1,p=a.get(m)-1;gt.set(m,h),a.set(m,p),h||(en.has(m)||m.removeAttribute(s),en.delete(m)),p||m.removeAttribute(n)}),ns--,ns||(gt=new WeakMap,gt=new WeakMap,en=new WeakMap,tn={})}},Sp=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Cp(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),Np(s,o,n,"aria-hidden")):function(){return null}};function Ep(e){const t=jp(e),n=f.forwardRef((s,o)=>{const{children:a,...l}=s,i=f.Children.toArray(a),c=i.find(Tp);if(c){const d=c.props.children,u=i.map(m=>m===c?f.Children.count(d)>1?f.Children.only(null):f.isValidElement(d)?d.props.children:null:m);return r.jsx(t,{...l,ref:o,children:f.isValidElement(d)?f.cloneElement(d,void 0,u):null})}return r.jsx(t,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function jp(e){const t=f.forwardRef((n,s)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const l=Rp(o),i=Xp(a,o.props);return o.type!==f.Fragment&&(i.ref=s?Cn(s,l):l),f.cloneElement(o,i)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ap=Symbol("radix.slottable");function Tp(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ap}function Xp(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...i)=>{const c=a(...i);return o(...i),c}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Rp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var En="Dialog",[Ka]=da(En),[Dp,Fe]=Ka(En),Za=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,i=f.useRef(null),c=f.useRef(null),[d,u]=wm({prop:s,defaultProp:o??!1,onChange:a,caller:En});return r.jsx(Dp,{scope:t,triggerRef:i,contentRef:c,contentId:Kn(),titleId:Kn(),descriptionId:Kn(),open:d,onOpenChange:u,onOpenToggle:f.useCallback(()=>u(m=>!m),[u]),modal:l,children:n})};Za.displayName=En;var qa="DialogTrigger",Ip=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Fe(qa,n),a=je(t,o.triggerRef);return r.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Os(o.open),...s,ref:a,onClick:ye(e.onClick,o.onOpenToggle)})});Ip.displayName=qa;var Ms="DialogPortal",[Pp,Qa]=Ka(Ms,{forceMount:void 0}),Ja=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=Fe(Ms,t);return r.jsx(Pp,{scope:t,forceMount:n,children:f.Children.map(s,l=>r.jsx(rt,{present:n||a.open,children:r.jsx(La,{asChild:!0,container:o,children:l})}))})};Ja.displayName=Ms;var gn="DialogOverlay",ei=f.forwardRef((e,t)=>{const n=Qa(gn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Fe(gn,e.__scopeDialog);return a.modal?r.jsx(rt,{present:s||a.open,children:r.jsx(Mp,{...o,ref:t})}):null});ei.displayName=gn;var _p=Ep("DialogOverlay.RemoveScroll"),Mp=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Fe(gn,n);return r.jsx(za,{as:_p,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(ve.div,{"data-state":Os(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),ct="DialogContent",ti=f.forwardRef((e,t)=>{const n=Qa(ct,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Fe(ct,e.__scopeDialog);return r.jsx(rt,{present:s||a.open,children:a.modal?r.jsx(Fp,{...o,ref:t}):r.jsx(Op,{...o,ref:t})})});ti.displayName=ct;var Fp=f.forwardRef((e,t)=>{const n=Fe(ct,e.__scopeDialog),s=f.useRef(null),o=je(t,n.contentRef,s);return f.useEffect(()=>{const a=s.current;if(a)return Sp(a)},[]),r.jsx(ni,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ye(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ye(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&a.preventDefault()}),onFocusOutside:ye(e.onFocusOutside,a=>a.preventDefault())})}),Op=f.forwardRef((e,t)=>{const n=Fe(ct,e.__scopeDialog),s=f.useRef(!1),o=f.useRef(!1);return r.jsx(ni,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||n.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=a.target;n.triggerRef.current?.contains(l)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ni=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,i=Fe(ct,n),c=f.useRef(null),d=je(t,c);return Lm(),r.jsxs(r.Fragment,{children:[r.jsx(Fa,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(_a,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Os(i.open),...l,ref:d,onDismiss:()=>i.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(Lp,{titleId:i.titleId}),r.jsx($p,{contentRef:c,descriptionId:i.descriptionId})]})]})}),Fs="DialogTitle",si=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Fe(Fs,n);return r.jsx(ve.h2,{id:o.titleId,...s,ref:t})});si.displayName=Fs;var oi="DialogDescription",ri=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Fe(oi,n);return r.jsx(ve.p,{id:o.descriptionId,...s,ref:t})});ri.displayName=oi;var ai="DialogClose",ii=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Fe(ai,n);return r.jsx(ve.button,{type:"button",...s,ref:t,onClick:ye(e.onClick,()=>o.onOpenChange(!1))})});ii.displayName=ai;function Os(e){return e?"open":"closed"}var li="DialogTitleWarning",[ph,ci]=Qu(li,{contentName:ct,titleName:Fs,docsSlug:"dialog"}),Lp=({titleId:e})=>{const t=ci(li),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
44
+
45
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
46
+
47
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Bp="DialogDescriptionWarning",$p=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ci(Bp).contentName}}.`;return f.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Gp=Za,Wp=Ja,di=ei,ui=ti,fi=si,mi=ri,Hp=ii;const Up=Gp,Yp=Wp,pi=f.forwardRef(({className:e,...t},n)=>r.jsx(di,{ref:n,className:de("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));pi.displayName=di.displayName;const hi=f.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Yp,{children:[r.jsx(pi,{}),r.jsxs(ui,{ref:s,className:de("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",e),...n,children:[t,r.jsxs(Hp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[r.jsx(cn,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hi.displayName=ui.displayName;const gi=({className:e,...t})=>r.jsx("div",{className:de("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});gi.displayName="DialogHeader";const xi=({className:e,...t})=>r.jsx("div",{className:de("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xi.displayName="DialogFooter";const bi=f.forwardRef(({className:e,...t},n)=>r.jsx(fi,{ref:n,className:de("text-lg font-semibold leading-none tracking-tight",e),...t}));bi.displayName=fi.displayName;const yi=f.forwardRef(({className:e,...t},n)=>r.jsx(mi,{ref:n,className:de("text-sm text-muted-foreground",e),...t}));yi.displayName=mi.displayName;const ss=500;function zp({paneId:e,terminalApp:t}){if(!(t==="tmux"||t==="iterm2"))return null;const[s,o]=f.useState(!1),[a,l]=f.useState(""),[i,c]=f.useState(!1),[d,u]=f.useState(!1);async function m(){if(!(!a.trim()||d)){u(!0);try{(await fetch(`${bt}/api/actions/send-input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paneId:e,type:"text",input:a})})).ok&&(l(""),c(!1),o(!1))}catch{}finally{u(!1)}}}return r.jsxs("div",{className:"mt-2",children:[r.jsxs("button",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>o(h=>!h),children:[s?r.jsx(st,{className:"h-3 w-3"}):r.jsx(Be,{className:"h-3 w-3"}),"Send input"]}),s&&r.jsxs("div",{className:"mt-2 space-y-2",children:[r.jsxs("div",{className:"relative",children:[r.jsx(Ia,{value:a,onChange:h=>l(h.target.value.slice(0,ss)),maxLength:ss,placeholder:"Type input to send to agent terminal…",className:"h-8 text-xs pr-14",onKeyDown:h=>{h.key==="Enter"&&a.trim()&&c(!0)}}),r.jsxs("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground pointer-events-none",children:[a.length,"/",ss]})]}),r.jsx(_e,{size:"sm",className:"h-7 px-3 text-xs",onClick:()=>{a.trim()&&c(!0)},disabled:!a.trim(),children:"Send"})]}),r.jsx(Up,{open:i,onOpenChange:c,children:r.jsxs(hi,{className:"sm:max-w-md",children:[r.jsxs(gi,{children:[r.jsx(bi,{children:"Send input to terminal"}),r.jsx(yi,{children:"This will type the following into the agent's terminal:"})]}),r.jsx("pre",{className:"mt-2 rounded-md bg-secondary/50 p-3 text-xs font-mono overflow-x-auto whitespace-pre-wrap break-all border border-border",children:r.jsx("code",{children:a})}),r.jsxs(xi,{className:"mt-2 gap-2",children:[r.jsx(_e,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:d,children:"Cancel"}),r.jsxs(_e,{size:"sm",onClick:m,disabled:d,children:[d&&r.jsx(Pe,{className:"h-3 w-3 animate-spin mr-1"}),"Send"]})]})]})})]})}function ir(e){if(e.feature)return e.feature;if(e.gitBranch&&e.gitBranch!=="main"&&e.gitBranch!=="game")return e.gitBranch;const t=e.initialPrompt||e.latestPrompt;return t?Vp(t):e.slug?e.slug:e.id.slice(0,8)}function Vp(e){let t=e;t=t.replace(/^MODE:\s*/,"");const n=t.match(/^You are [A-Z][a-z]+ [A-Z][a-z]+[,.]?\s*[A-Z][A-Za-z/ ]*[.,]\s*/);return n&&(t=t.slice(n[0].length)),n||(t=t.replace(/^You are (performing|reviewing|decomposing|running|executing|building|creating|writing|doing)\s+/i,"$1 ")),t=t.replace(/^You (proposed|completed|finished|started|created|built|reviewed|performed)\s+/i,"$1 "),t.length>0&&(t=t[0].toUpperCase()+t.slice(1)),t.slice(0,60)}function lr({agentName:e,agentStatuses:t}){const n=J(p=>p.sessions),s=J(p=>p.sessionActivities),o=pe.find(p=>p.agentName===e),a=t[e]??"offline",l=f.useMemo(()=>n.filter(p=>p.agentName===e).map(p=>p.id),[n,e]),i=ja(l,s),{activeSessions:c,recentIdle:d}=f.useMemo(()=>{const p=n.filter(v=>v.agentName===e&&!v.isSubagent),x=n.filter(v=>v.agentName===e&&v.isSubagent),b=v=>v.status==="working"||v.status==="waiting-approval"||v.status==="waiting-input"||v.status==="error"||v.status==="paused";let w=p.filter(b),y=w.length>0?w:x.filter(b).slice(0,3);y=y.sort((v,k)=>Wo(v.status)-Wo(k.status));const S=new Set(y.map(v=>v.id)),N=[...p,...x].filter(v=>!S.has(v.id)&&(v.feature||v.initialPrompt||v.latestPrompt)).sort((v,k)=>new Date(k.lastActivity).getTime()-new Date(v.lastActivity).getTime()).slice(0,8);return{activeSessions:y,recentIdle:N}},[n,e]),[u,m]=f.useState(null),h=f.useCallback(async p=>{m(p);try{await fetch(`${bt}/api/actions/focus-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paneId:p})})}catch{}finally{m(null)}},[]);return o?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"relative overflow-hidden",style:tt,children:[r.jsx("div",{className:"h-2",style:{backgroundColor:o.color,boxShadow:`inset 0 -1px 0 0 ${o.color}80`}}),r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"h-4 w-4 rounded-sm shrink-0",style:{backgroundColor:o.color,boxShadow:[`0 0 0 1px ${o.color}`,"inset 1px 1px 0 0 #ffffff40","inset -1px -1px 0 0 #00000040"].join(", ")}}),r.jsx("span",{className:"font-bold text-sm font-mono",style:{color:g.text},children:o.agentName}),r.jsx(hn,{status:a==="working"?"working":a==="waiting"?"waiting-approval":"idle"})]}),r.jsx("div",{className:"text-xs font-mono",style:{color:g.textDim},children:o.agentRole})]})]}),c.length>0?c.map(p=>{const x=s[p.id],b=ir(p),w=p.latestPrompt??p.initialPrompt,y=n.filter(v=>v.parentSessionId===p.id&&v.isSubagent),S=p.status==="waiting-approval"||p.status==="waiting-input",N=Mt(p.model);return r.jsx("div",{className:"relative overflow-hidden",style:{...tt,borderLeft:`3px solid ${o.color}`},children:r.jsxs("div",{className:"px-2 py-2 space-y-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-mono",children:[r.jsx(hn,{status:p.status,animated:p.status==="working"}),r.jsx("span",{className:"font-semibold truncate",style:{color:g.text},children:b}),N&&r.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded-sm shrink-0 ml-auto",style:{backgroundColor:"#C4A26520",color:g.textDim,border:`1px solid ${g.border}40`},children:N})]}),p.status==="working"&&r.jsx(gm,{activity:x}),r.jsx(Aa,{entries:i.current.get(p.id)??[]}),p.gitBranch&&r.jsxs("div",{className:"flex items-center gap-1 text-[11px] font-mono",style:{color:g.textDim},children:[r.jsx(os,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate",children:p.gitBranch})]}),w&&r.jsx("p",{className:"text-[11px] line-clamp-2 leading-tight font-mono",style:{color:g.textDim},children:w}),y.length>0&&r.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[y.slice(0,4).map(v=>r.jsx("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded-sm",style:{backgroundColor:"#5B8C3E20",color:"#3D6B26",border:"1px solid #5B8C3E30"},children:v.agentName??v.id.slice(0,6)},v.id)),y.length>4&&r.jsxs("span",{className:"text-[9px] font-mono",style:{color:g.textDim},children:["+",y.length-4]})]}),S&&p.paneId&&r.jsx(Ps,{paneId:p.paneId,sessionStatus:p.status,terminalApp:p.terminalApp}),p.paneId&&r.jsx(zp,{paneId:p.paneId,terminalApp:p.terminalApp}),p.paneId&&r.jsxs(_e,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[11px] w-full justify-start gap-1.5 font-mono",style:{color:g.text},onClick:()=>h(p.paneId),disabled:u===p.paneId,children:[u===p.paneId?r.jsx(Pe,{className:"h-3 w-3 animate-spin"}):r.jsx(ks,{className:"h-3 w-3"}),"Focus terminal"]})]})},p.id)}):r.jsx("div",{className:"text-center py-4 font-mono",style:te,children:r.jsx("p",{className:"text-xs",style:{color:g.textDim},children:"No active sessions"})}),d.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Me,{ornament:!0}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Re,{children:"History"}),d.map(p=>{const x=ir(p),b=p.initialPrompt||p.latestPrompt,w=p.status==="done"?"#5B8C3E":p.status==="error"?"#B44":"#9CA3AF";return r.jsxs("div",{className:"px-2 py-1.5 font-mono rounded-sm space-y-0.5",style:te,children:[r.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0 mt-1",style:{backgroundColor:w}}),r.jsx("span",{className:"truncate font-medium",style:{color:g.text},children:x}),r.jsx("span",{className:"ml-auto shrink-0 text-[10px]",style:{color:g.textDim,opacity:.6},children:et(p.lastActivity)})]}),b&&p.feature&&r.jsx("p",{className:"text-[10px] line-clamp-1 leading-tight pl-3",style:{color:g.textDim,opacity:.7},children:b.slice(0,80)}),r.jsxs("div",{className:"flex items-center gap-2 pl-3 text-[10px]",style:{color:g.textDim,opacity:.6},children:[p.gitBranch&&r.jsxs("span",{className:"flex items-center gap-0.5 truncate",children:[r.jsx(os,{className:"h-2.5 w-2.5 shrink-0"}),p.gitBranch]}),p.model&&r.jsx("span",{className:"shrink-0",children:Mt(p.model)}),r.jsx("span",{className:"shrink-0",style:{color:w},children:Lu(p.status)})]})]},p.id)})]})]})]}):r.jsx("p",{className:"text-sm font-mono",style:{color:g.text},children:"Unknown agent"})}const Kp=[{id:"orchestration",title:"Orchestration Patterns",filePath:".context/lessons/orchestration.md",contentSummary:"Pipeline design, agent casting, wave execution"},{id:"agent-behavior",title:"Agent Behavior",filePath:".context/lessons/agent-behavior.md",contentSummary:"How agents work, common pitfalls, delegation rules"},{id:"review-quality",title:"Review Quality",filePath:".context/lessons/review-quality.md",contentSummary:"Code review standards, DOD verification, review failures"},{id:"skill-design",title:"Skill Design",filePath:".context/lessons/skill-design.md",contentSummary:"Skill structure, prompt design, routing rules"},{id:"state-management",title:"State Management",filePath:".context/lessons/state-management.md",contentSummary:"Dashboard state, directive JSON, context tree"},{id:"scenarios",title:"Scenarios",filePath:".context/lessons/scenarios.md",contentSummary:"Walkthrough scenarios and real-world failure cases"}];function Zp(){const e=J(h=>h.workState?.conductor?.lessons),t=e&&e.length>0?e:[...Kp],[n,s]=f.useState(null),[o,a]=f.useState(null),[l,i]=f.useState(!1),[c,d]=f.useState(!1),u=f.useCallback(h=>{i(!0),a(null),d(!1),fetch(`${bt}/api/state/artifact-content?path=${encodeURIComponent(h.filePath)}`).then(p=>p.ok?p.text():Promise.reject(new Error("Failed to load"))).then(p=>a(p)).catch(()=>{a(null),d(!0)}).finally(()=>i(!1))},[]);f.useEffect(()=>{if(!n){a(null),d(!1);return}u(n)},[n,u]);const m=f.useCallback(()=>{s(null)},[]);return t.length===0?r.jsxs("div",{className:"text-center py-8 font-mono",style:te,children:[r.jsx(Pt,{className:"h-6 w-6 mx-auto mb-2",style:{color:g.textDim,opacity:.4},"aria-hidden":"true"}),r.jsx("p",{className:"text-xs font-bold",style:{color:g.text},children:"No knowledge captured yet"}),r.jsx("p",{className:"text-[10px] mt-0.5",style:{color:g.textDim},children:"Lessons will appear here as the team learns"})]}):n?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("button",{onClick:m,className:`flex items-center gap-1 text-[11px] font-mono font-bold cursor-pointer
48
+ px-1.5 py-0.5 rounded-sm transition-colors`,style:{color:g.text,backgroundColor:"transparent",border:"none"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor=g.card},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent"},children:[r.jsx(hr,{className:"h-3 w-3"}),"Back to topics"]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Pt,{className:"h-3 w-3 shrink-0",style:{color:g.text}}),r.jsx("span",{className:"text-xs font-bold font-mono truncate",style:{color:g.text},children:n.title})]}),r.jsx(Me,{}),l&&r.jsxs("div",{className:"flex items-center gap-2 text-xs py-4 font-mono justify-center",style:{color:g.textDim},children:[r.jsx(Pe,{className:"h-3 w-3 animate-spin"}),"Loading lesson..."]}),!l&&o&&r.jsx("div",{className:"max-h-[500px] overflow-y-auto p-2",style:te,children:Sa(o,500)}),!l&&c&&r.jsxs("div",{className:"text-center py-4 font-mono",style:te,children:[r.jsx("p",{className:"text-xs",style:{color:g.textDim},children:"Could not load lesson content."}),r.jsxs("button",{onClick:()=>n&&u(n),className:"flex items-center gap-1 mx-auto mt-2 text-[10px] font-bold font-mono px-2 py-1 cursor-pointer transition-colors",style:{color:g.text,backgroundColor:g.card,borderRadius:"2px",border:`1px solid ${g.border}`},onMouseEnter:h=>{h.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:h=>{h.currentTarget.style.backgroundColor=g.card},children:[r.jsx(Sl,{className:"h-2.5 w-2.5"}),"Retry"]})]})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsx(Re,{icon:r.jsx(Pt,{className:"h-3 w-3"}),count:t.length,children:"Knowledge Base"}),r.jsx("div",{className:"space-y-1",children:t.map(h=>r.jsxs("button",{onClick:()=>s(h),className:`flex items-center gap-2 w-full text-left px-2 py-1.5
49
+ cursor-pointer font-mono rounded-sm`,style:{...te,color:g.text},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=g.cardHover},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=g.card},children:[r.jsx(Pt,{className:"h-3 w-3 shrink-0",style:{color:g.accent},"aria-hidden":"true"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-xs font-medium truncate block",children:h.title}),h.contentSummary&&r.jsx("span",{className:"text-[10px] truncate block mt-0.5",style:{color:g.textDim},children:h.contentSummary})]})]},h.id))})]})}function qp(){const e=J(o=>o.directiveState),t=J(o=>o.sessions),n=t.filter(o=>o.status==="waiting-approval").length,s=t.filter(o=>!o.isSubagent&&o.status==="error").length;return r.jsxs("div",{className:"space-y-3 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(tl,{className:"h-4 w-4 text-yellow-600","aria-hidden":"true"}),r.jsx("span",{className:"font-bold text-sm",style:{color:g.text},children:"CEO Desk"})]}),r.jsxs("div",{className:"space-y-1.5",style:te,children:[r.jsxs("div",{className:"flex justify-between items-center px-2 py-1.5",children:[r.jsx("span",{className:"text-xs",style:{color:g.textDim},children:"Pending approvals"}),r.jsx(Ft,{variant:n>0?"destructive":"secondary",className:"text-[10px] px-1.5 py-0",children:n})]}),s>0&&r.jsxs("div",{className:"flex justify-between items-center px-2 py-1.5 border-t",style:{borderColor:`${g.border}40`},children:[r.jsx("span",{className:"text-xs",style:{color:g.textDim},children:"Errors"}),r.jsx(Ft,{variant:"destructive",className:"text-[10px] px-1.5 py-0",children:s})]})]}),e?r.jsxs("div",{className:"space-y-1.5 p-2",style:tt,children:[r.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:g.textDim},children:"Active Directive"}),r.jsx("p",{className:"text-xs font-semibold",style:{color:g.text},children:e.directiveName}),r.jsxs("div",{className:"flex justify-between text-[11px]",children:[r.jsx("span",{style:{color:g.textDim},children:"Phase"}),r.jsx("span",{className:"font-medium",style:{color:g.text},children:e.currentPhase})]}),r.jsx(nt,{value:e.currentProject,max:e.totalProjects,color:"#C4A265",showLabel:!0})]}):r.jsx("div",{className:"text-center py-4",style:te,children:r.jsx("p",{className:"text-xs",style:{color:g.textDim},children:"No active directive"})})]})}function Qp(){const t=J(n=>n.workState)?.conductor?.directives??[];return r.jsxs("div",{className:"space-y-3 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ol,{className:"h-4 w-4",style:{color:g.text},"aria-hidden":"true"}),r.jsx("span",{className:"font-bold text-sm",style:{color:g.text},children:"Directives"})]}),t.length>0?r.jsx("div",{className:"space-y-1.5",children:t.map(n=>r.jsxs("div",{className:"flex items-center justify-between text-xs px-2 py-1.5",style:te,children:[r.jsx("span",{className:"truncate mr-2 font-medium",style:{color:g.text},children:n.title}),r.jsx(Ft,{variant:"secondary",className:"text-[9px] shrink-0 px-1 py-0",children:n.status})]},n.id))}):r.jsx("div",{className:"text-center py-4",style:te,children:r.jsx("p",{className:"text-xs",style:{color:g.textDim},children:"No active directives"})})]})}function Jp(){const t=J(n=>n.workState)?.conductor?.reports??[];return r.jsxs("div",{className:"space-y-3 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ml,{className:"h-4 w-4",style:{color:g.text},"aria-hidden":"true"}),r.jsx("span",{className:"font-bold text-sm",style:{color:g.text},children:"Reports"})]}),t.length>0?r.jsx("div",{className:"space-y-1.5",children:t.map(n=>r.jsxs("div",{className:"px-2 py-1.5",style:te,children:[r.jsx("span",{className:"block text-xs truncate font-medium",style:{color:g.text},children:n.title}),r.jsx("span",{className:"text-[10px]",style:{color:g.textDim},children:et(n.updatedAt)})]},n.id))}):r.jsx("div",{className:"text-center py-4",style:te,children:r.jsx("p",{className:"text-xs",style:{color:g.textDim},children:"No reports available"})})]})}function eh(){const e=J(t=>t.directiveState);return r.jsxs("div",{className:"space-y-3 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(St,{className:"h-4 w-4",style:{color:g.text},"aria-hidden":"true"}),r.jsx("span",{className:"font-bold text-sm",style:{color:g.text},children:"Conference Room"})]}),e?r.jsxs("div",{className:"space-y-2 p-2",style:tt,children:[r.jsx("p",{className:"text-xs font-semibold",style:{color:g.text},children:e.directiveName}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex justify-between text-[11px]",children:[r.jsx("span",{style:{color:g.textDim},children:"Phase"}),r.jsx("span",{className:"font-medium",style:{color:g.text},children:e.currentPhase})]}),r.jsxs("div",{className:"flex justify-between text-[11px]",children:[r.jsx("span",{style:{color:g.textDim},children:"Status"}),r.jsx(Ft,{variant:"secondary",className:"text-[9px] px-1 py-0",children:e.status})]})]}),r.jsx(nt,{value:e.currentProject,max:e.totalProjects,color:"#5B8C3E",showLabel:!0})]}):r.jsx("div",{className:"text-center py-4",style:te,children:r.jsx("p",{className:"text-xs",style:{color:g.textDim},children:"No directive in progress"})})]})}function th(){return r.jsxs("div",{className:"space-y-3 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Li,{className:"h-4 w-4 text-yellow-600","aria-hidden":"true"}),r.jsx("span",{className:"font-bold text-sm",style:{color:g.text},children:"Scout Bell"})]}),r.jsxs("div",{className:"text-center py-6",style:te,children:[r.jsx("div",{className:"text-2xl mb-2",style:{opacity:.25},children:"🔔"}),r.jsxs("p",{className:"text-xs font-medium",style:{color:g.text},children:["Ring the bell to start ",r.jsx("span",{className:"font-mono",children:"/scout"})]}),r.jsx("p",{className:"text-[10px] mt-1",style:{color:g.textDim},children:"Coming in Phase 4 — action layer"})]})]})}function nh(){const e=J(s=>s.sessions),t=e.filter(s=>s.status==="working").length,n=e.filter(s=>!s.isSubagent).length;return r.jsxs("div",{className:"space-y-3 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xl,{className:"h-4 w-4 text-emerald-500","aria-hidden":"true"}),r.jsx("span",{className:"font-bold text-sm",style:{color:g.text},children:"Server Room"})]}),r.jsxs("div",{className:"space-y-2 p-2",style:te,children:[r.jsxs("div",{className:"flex justify-between text-xs",children:[r.jsx("span",{style:{color:g.textDim},children:"Active sessions"}),r.jsx("span",{className:"font-bold",style:{color:t>0?"#22C55E":g.text},children:t})]}),r.jsxs("div",{className:"flex justify-between text-xs",children:[r.jsx("span",{style:{color:g.textDim},children:"Total sessions"}),r.jsx("span",{className:"font-medium",style:{color:g.text},children:n})]}),t>0&&r.jsx(nt,{value:t,max:n,color:"#22C55E",showLabel:!0})]})]})}const cr=new Set(["hud-team","hud-tasks","hud-status","hud-log"]),sh=[{id:"team",label:"Team"},{id:"tasks",label:"Tasks"},{id:"status",label:"Status"},{id:"log",label:"Log"}];function oh(e){switch(e){case"hud-team":return"team";case"hud-tasks":return"tasks";case"hud-action":return"tasks";case"hud-directive":return"tasks";case"hud-status":return"status";case"hud-log":return"log";default:return null}}function rh(e,t){if(t)return sh.find(s=>s.id===t)?.label??"Office";if(!e)return"Office Overview";switch(e.type){case"desk":return e.agentName??"Agent Desk";case"ceo-desk":return"CEO Desk";case"conference":return"Conference Room";case"whiteboard":return"Whiteboard";case"mailbox":return"Mailbox";case"bell":return"Scout Bell";case"server-room":return"Server Room";case"bookshelf":return"Knowledge Base";case"door":return"Entrance";default:return"Office"}}function dr({selected:e,agentStatuses:t,activeTab:n,agentOverride:s,onSelectAgent:o}){if(s)return r.jsx(lr,{agentName:s,agentStatuses:t});if(n)switch(n){case"team":return r.jsx(zn,{agentStatuses:t,onSelectAgent:o});case"tasks":return r.jsx(Of,{});case"status":return r.jsx(Qf,{});case"log":return r.jsx(mm,{})}if(!e)return r.jsx(zn,{agentStatuses:t,onSelectAgent:o});switch(e.type){case"desk":return e.agentName?r.jsx(lr,{agentName:e.agentName,agentStatuses:t}):r.jsx("p",{className:"text-sm font-mono",style:{color:g.text},children:"Empty desk"});case"ceo-desk":return r.jsx(qp,{});case"whiteboard":return r.jsx(Qp,{});case"mailbox":return r.jsx(Jp,{});case"conference":return r.jsx(eh,{});case"bell":return r.jsx(th,{});case"server-room":return r.jsx(nh,{});case"bookshelf":return r.jsx(Zp,{});case"door":return r.jsx("p",{className:"text-sm font-mono",style:{color:g.text},children:"The office entrance."});default:return r.jsx(zn,{agentStatuses:t,onSelectAgent:o})}}function ur({selected:e,agentStatuses:t,onClose:n,variant:s="side"}){kr();const o=e?cr.has(e.type):!1,[a,l]=f.useState(null),[i,c]=f.useState(null);f.useEffect(()=>{if(e&&cr.has(e.type)){const b=oh(e.type);l(b),c(null)}else l(null),c(null)},[e]),f.useCallback(b=>{l(b),c(null)},[]);const d=f.useCallback(b=>{c(b)},[]),u=f.useCallback(()=>{c(null)},[]),m=f.useCallback(b=>{b.key==="Escape"&&n()},[n]);f.useEffect(()=>{if(s==="bottom")return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[s,m]);const h=i||rh(e,a),p={backgroundColor:g.bg,color:g.text},x={backgroundColor:"#5C3D2E",color:"#F5ECD7",borderBottom:"2px solid #3D2B1F",boxShadow:"inset 0 1px 0 0 #6B4C3B"};return s==="side"?r.jsxs("aside",{className:"w-80 xl:w-96 flex flex-col shrink-0",style:{...p,borderLeft:"2px solid #3D2B1F"},children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:x,children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i&&r.jsx("button",{type:"button",className:"h-6 px-1.5 text-[11px] font-mono shrink-0 rounded transition-colors",style:{color:"#C4A265"},onClick:u,"aria-label":"Back to tab",children:"◀ Back"}),r.jsx("h2",{className:"text-sm font-bold font-mono truncate",style:{color:"#C4A265",textShadow:"0 1px 2px #3D2B1F"},children:h})]}),e&&r.jsx("button",{type:"button",className:"h-6 w-6 shrink-0 flex items-center justify-center rounded transition-colors hover:bg-white/10",onClick:n,"aria-label":"Close panel",children:r.jsx(cn,{className:"h-3.5 w-3.5",style:{color:"#C4A265"}})})]}),r.jsx(gs,{className:"flex-1",children:r.jsx("div",{className:"p-3",style:{margin:"6px",borderRadius:"2px",boxShadow:"inset 1px 1px 0 0 #C4A26540, inset -1px -1px 0 0 #F5ECD740",backgroundColor:"#F0E4C8"},children:r.jsx(dr,{selected:e,agentStatuses:t,activeTab:o?a:null,agentOverride:i,onSelectAgent:d})})})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 bg-black/40 z-40",onClick:n,"aria-hidden":"true"}),r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"sheet-title",className:"fixed bottom-0 left-0 right-0 z-50 rounded-t-2xl max-h-[55vh] flex flex-col animate-[slideUp_200ms_ease-out]",style:{...p,borderTop:`2px solid ${g.border}`,paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:[r.jsx("div",{className:"flex justify-center pt-2 pb-1",style:{backgroundColor:"#5C3D2E"},children:r.jsx("div",{className:"w-10 h-1 rounded-full",style:{backgroundColor:"#C4A265"}})}),r.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:x,children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i&&r.jsx("button",{type:"button",className:"h-6 px-1.5 text-[11px] font-mono shrink-0 rounded",style:{color:"#C4A265"},onClick:u,"aria-label":"Back to tab",children:"◀ Back"}),r.jsx("h2",{id:"sheet-title",className:"text-sm font-bold font-mono truncate",style:{color:"#C4A265",textShadow:"0 1px 2px #3D2B1F"},children:h})]}),r.jsx("button",{type:"button",className:"h-6 w-6 shrink-0 flex items-center justify-center rounded hover:bg-white/10",onClick:n,"aria-label":"Close panel",children:r.jsx(cn,{className:"h-3.5 w-3.5",style:{color:"#C4A265"}})})]}),r.jsx(gs,{className:"flex-1 min-h-0",children:r.jsx("div",{className:"p-3",style:{margin:"6px",borderRadius:"2px",boxShadow:"inset 1px 1px 0 0 #C4A26540, inset -1px -1px 0 0 #F5ECD740",backgroundColor:"#F0E4C8"},children:r.jsx(dr,{selected:e,agentStatuses:t,activeTab:o?a:null,agentOverride:i,onSelectAgent:d})})})]})]})}const It={bg:"#3D2B1F",text:"#F5ECD7",textDim:"#C4A265",border:"#5C3D2E"},ah=new Map(pe.map(e=>[e.agentName,e.color]));function ih({agentStatuses:e,agentSessionInfos:t}){const n=f.useMemo(()=>{const l=[];for(const[i,c]of Object.entries(e)){if(c!=="working"&&c!=="waiting")continue;const d=t[i];let u;c==="paused"?u="Paused":c==="done"?u="Task complete":u=d?.taskName??(c==="waiting"?"Waiting for input":"Working..."),l.push({agentName:i,color:ah.get(i)??"#888",label:u})}return l},[e,t]),[s,o]=f.useState(0);if(f.useEffect(()=>{if(n.length<=1){o(0);return}const l=setInterval(()=>{o(i=>(i+1)%n.length)},3e3);return()=>clearInterval(l)},[n.length]),n.length===0)return null;const a=n[s%n.length];return a?r.jsx("div",{className:"absolute top-16 right-2 z-10 font-mono text-[10px] px-2 py-1 select-none pointer-events-none",style:{backgroundColor:It.bg,color:It.text,borderRadius:"2px",boxShadow:`0 0 0 1px ${It.border}, inset 1px 1px 0 0 #4A2F20`,maxWidth:"320px"},children:r.jsxs("div",{className:"flex items-center gap-1.5 truncate",style:{animation:"tickerFadeIn 0.3s ease-out"},children:[r.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:a.color}}),r.jsx("span",{className:"font-semibold shrink-0",style:{color:It.textDim},children:a.agentName}),r.jsx("span",{className:"truncate",children:a.label}),n.length>1&&r.jsxs("span",{className:"shrink-0 ml-auto",style:{color:It.textDim,opacity:.5},children:[s%n.length+1,"/",n.length]})]},a.agentName)}):null}const Ye=new Set(pe.map(e=>e.agentName));function lh(e){if(!e)return;let t=e;const n=t.match(/^MODE:\s*([^\n]+)/);if(n)return n[1].trim().slice(0,60);if(t=t.replace(/^You are [A-Z][^\n.]*\.\s*/,""),t=t.replace(/^You are the [A-Za-z/\- ]+\.\s*/,""),t=t.replace(/^You are operating in [A-Z_ ]+\.\s*/,""),t=t.replace(/^You are (decomposing|reviewing|executing|performing)\s+/,"$1 "),t=t.replace(/^You (proposed|completed|finished|started)\s+/,"$1 "),t=t.trim(),t.length===0)return;const s=t.match(/^[^.!?\n]+/)?.[0]?.trim();if(!s||s.length<5)return;const o=s[0].toUpperCase()+s.slice(1);return o.length>60?o.slice(0,57)+"...":o}const ch={"ceo-desk":"tasks",whiteboard:"tasks",conference:"status","server-room":"team"},fr=768;function dh(){const[e,t]=f.useState(()=>typeof window<"u"&&window.innerWidth<fr);return f.useEffect(()=>{const n=window.matchMedia(`(max-width: ${fr-1}px)`),s=o=>t(o.matches);return n.addEventListener("change",s),t(n.matches),()=>n.removeEventListener("change",s)},[]),e}function mr(e){switch(e){case"working":return"working";case"waiting-approval":case"waiting-input":return"waiting";case"paused":return"paused";case"done":return"done";case"idle":return"idle";case"error":return"error";default:return"offline"}}function uh({agentStatuses:e}){const t=J(l=>l.directiveState),n=pe.filter(l=>!l.isPlayer).length,s=Object.values(e).filter(l=>l==="working").length,o=t?.currentProject??0,a=t?.totalProjects??0;return r.jsx("div",{className:"absolute top-2 right-2 z-10 font-mono text-[10px] leading-snug px-2.5 py-2 pointer-events-none select-none",style:{backgroundColor:"#5C3D2E",color:"#F5ECD7",borderRadius:"2px",boxShadow:["0 0 0 1px #3D2B1F","0 2px 4px rgba(0,0,0,0.3)","inset 1px 1px 0 0 #6B4C3B","inset -1px -1px 0 0 #3D2B1F"].join(", ")},children:r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("span",{children:[r.jsx("span",{style:{color:"#C4A265"},children:"Staff:"})," ",n]}),r.jsxs("span",{children:[r.jsx("span",{style:{color:"#C4A265"},children:"Working:"})," ",r.jsx("span",{style:{color:s>0?"#22C55E":"#F5ECD7"},children:s})]}),a>0&&r.jsxs("span",{children:[r.jsx("span",{style:{color:"#C4A265"},children:"In Progress:"})," ",o,"/",a]})]})})}function fh(){return r.jsx("div",{className:"absolute bottom-2 right-2 z-10 font-mono text-[10px] px-2 py-1 pointer-events-none select-none",style:{backgroundColor:"#3D2B1F",color:"#C4A265",borderRadius:"2px",boxShadow:"0 0 0 1px #5C3D2E, inset 1px 1px 0 0 #4A2F20"},children:"WASD / Arrows: Move  |  Click: Interact"})}function hh(){const e=J(N=>N.sessions),t=J(N=>N.sessionActivities),[n,s]=f.useState(null),o=dh(),[a,l]=f.useState(!1),i=f.useMemo(()=>{const N={};for(const k of Ye)N[k]="offline";const v={working:3,waiting:2,paused:1.5,done:1,idle:1,error:1,offline:0};for(const k of e)if(k.agentName&&Ye.has(k.agentName)){const E=mr(k.status);v[E]>v[N[k.agentName]??"offline"]&&(N[k.agentName]=E)}return N},[e]),c=f.useMemo(()=>{const N={},v={},k={working:3,"waiting-approval":2,"waiting-input":2,idle:1,paused:1,done:0,error:0};for(const E of e)if(E.agentName&&Ye.has(E.agentName)){const A=k[E.status]??0;if(A>=(v[E.agentName]??-1)){v[E.agentName]=A;const j=t[E.id];N[E.agentName]={taskName:E.feature??lh(E.initialPrompt)??void 0,toolName:j?.tool??void 0,detail:j?.detail??void 0}}}return N},[e,t]),d=f.useMemo(()=>{const N={};for(const k of e)if(k.agentName&&Ye.has(k.agentName)){const E=mr(k.status);(E==="working"||E==="waiting")&&(N[k.agentName]=(N[k.agentName]??0)+1)}const v={};for(const k of Ye)v[k]=(N[k]??0)>1;return v},[e]),{agentInteractions:u,subagentsByParent:m}=f.useMemo(()=>{const N=new Map;for(const T of e)T.agentName&&Ye.has(T.agentName)&&N.set(T.id,T.agentName);const v=[],k=new Set,E=new Map,A=new Map;for(const T of e)if(T.isSubagent&&T.parentSessionId&&T.agentName&&Ye.has(T.agentName)){const G=N.get(T.parentSessionId);if(G&&G!==T.agentName){const W=[G,T.agentName].sort().join(":");k.has(W)||(k.add(W),v.push([G,T.agentName]));const P=E.get(G)??[];P.includes(T.agentName)||(P.push(T.agentName),E.set(G,P))}if(T.status==="working"||T.status==="waiting-approval"||T.status==="waiting-input"){const W=A.get(T.parentSessionId)??[];W.includes(T.agentName)||(W.push(T.agentName),A.set(T.parentSessionId,W))}}const j=new Set;for(const[T,G]of E){j.add(T);for(const W of G)j.add(W)}for(const[,T]of A)if(T.length>=3){if(T.filter(q=>!j.has(q)).length<T.length)continue;const W=T[0],P=E.get(W)??[];for(const q of T.slice(1))P.includes(q)||P.push(q);E.set(W,P)}return{agentInteractions:v,subagentsByParent:E}},[e]),h=f.useMemo(()=>{const N=new Map,v=new Map;for(const k of e)k.agentName&&Ye.has(k.agentName)&&v.set(k.id,k.agentName);for(const k of e)if(k.isSubagent&&k.parentSessionId&&k.agentName&&Ye.has(k.agentName)&&k.feature&&/review|audit/i.test(k.feature)){const E=v.get(k.parentSessionId);E&&E!==k.agentName&&N.set(k.agentName,E)}return N},[e]),p=f.useCallback(N=>{if(!N){s(null),l(!1);return}if(n?.agentName===N){s(null),l(!1);return}const v=pe.find(k=>k.agentName===N);v&&(s({type:"desk",agentName:v.agentName,position:v.position}),l(!0))},[n]),x=f.useCallback(()=>{s(null),l(!1)},[]),b=f.useCallback(N=>{const v={team:"hud-team",tasks:"hud-tasks",status:"hud-status",log:"hud-log"};if(n?.type===v[N]){s(null),l(!1);return}s({type:v[N],position:{row:0,col:0}}),l(!0)},[n]),w=f.useCallback(N=>{if(!N){s(null),l(!1);return}let k={desk:"desk",furniture:"desk",server:"server-room",conference:"conference",wall:"wall",whiteboard:"whiteboard",bookshelf:"bookshelf"}[N.type];if(N.type==="furniture"){const A=Rr(N.col,N.row);A==="ceo-office"?k="ceo-desk":A==="meeting"?k="conference":A==="server-room"&&(k="server-room")}const E=ch[k];if(E){b(E);return}s({type:k,agentName:N.agentName,position:{row:N.row,col:N.col}}),l(!0)},[b]),y=f.useMemo(()=>{if(!n)return null;switch(n.type){case"hud-team":return"team";case"hud-tasks":return"tasks";case"hud-action":return"tasks";case"hud-directive":return"tasks";case"hud-status":return"status";case"hud-log":return"log";default:return null}},[n]),S=f.useRef(null);return r.jsxs("div",{ref:S,className:"flex flex-col h-full",children:[r.jsx(Vl,{onPanelRequest:b,gameContainerRef:S,activePanel:y}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"flex-1 min-h-0 overflow-auto bg-stone-200 dark:bg-stone-950 relative",children:[r.jsx(Bd,{onAgentClick:p,onItemClick:w,agentStatuses:i,agentSessionInfos:c,agentBusyMap:d,agentInteractions:u,subagentsByParent:m,reviewInteractions:h,selectedAgentName:n?.agentName??null}),r.jsx(uh,{agentStatuses:i}),r.jsx(ih,{agentStatuses:i,agentSessionInfos:c}),r.jsx(fh,{})]}),!o&&n&&r.jsx(ur,{selected:n,agentStatuses:i,onClose:x,variant:"side"})]}),o&&a&&n&&r.jsx(ur,{selected:n,agentStatuses:i,onClose:x,variant:"bottom"}),r.jsxs("div",{style:{textAlign:"center",padding:"4px 0",fontSize:"11px",color:"#666",opacity:.7},children:["Tileset by ",r.jsx("a",{href:"https://limezu.itch.io/modernoffice",target:"_blank",rel:"noopener",style:{color:"#888"},children:"LimeZu"})," | ","Characters by ",r.jsx("a",{href:"https://jik-a-4.itch.io/metrocity-free-topdown-character-pack",target:"_blank",rel:"noopener",style:{color:"#888"},children:"JIK-A-4"})," (CC0)"]})]})}export{hh as default};