@hotmeshio/long-tail 0.26.0 → 0.28.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 (392) hide show
  1. package/README.md +9 -2
  2. package/build/api/settings.d.ts +4 -1
  3. package/build/api/settings.js +7 -1
  4. package/build/index.d.ts +4 -0
  5. package/build/index.js +35 -8
  6. package/build/lib/db/config-lock.d.ts +10 -0
  7. package/build/lib/db/config-lock.js +28 -0
  8. package/build/lib/db/schemas/041_machine_lines.sql +26 -0
  9. package/build/lib/events/browser-view.js +8 -2
  10. package/build/lib/events/nats.d.ts +11 -0
  11. package/build/lib/events/nats.js +33 -2
  12. package/build/lib/events/publish.d.ts +33 -0
  13. package/build/lib/events/publish.js +52 -1
  14. package/build/lib/machines/index.d.ts +1 -0
  15. package/build/lib/machines/index.js +1 -0
  16. package/build/lib/machines/line.d.ts +4 -1
  17. package/build/lib/machines/line.js +18 -1
  18. package/build/lib/machines/protocol/codec.d.ts +24 -0
  19. package/build/lib/machines/protocol/codec.js +10 -0
  20. package/build/lib/machines/protocol/constants.d.ts +1 -1
  21. package/build/lib/machines/protocol/constants.js +1 -1
  22. package/build/lib/machines/protocol/contract.js +12 -3
  23. package/build/lib/machines/site/edge-account.d.ts +11 -0
  24. package/build/lib/machines/site/edge-account.js +24 -0
  25. package/build/lib/machines/site/mosquitto-conf.d.ts +5 -4
  26. package/build/lib/machines/site/mosquitto-conf.js +31 -16
  27. package/build/lib/machines/site/site-conf.d.ts +16 -6
  28. package/build/lib/machines/site/site-conf.js +39 -13
  29. package/build/lib/machines/transport/callback-feed.d.ts +1 -0
  30. package/build/lib/machines/transport/callback-feed.js +4 -1
  31. package/build/lib/machines/transport/delivery.d.ts +3 -4
  32. package/build/lib/machines/transport/delivery.js +3 -8
  33. package/build/lib/machines/transport/index.d.ts +2 -0
  34. package/build/lib/machines/transport/index.js +2 -0
  35. package/build/lib/machines/transport/memory.d.ts +2 -0
  36. package/build/lib/machines/transport/memory.js +6 -0
  37. package/build/lib/machines/transport/mqtt-bus.d.ts +2 -0
  38. package/build/lib/machines/transport/mqtt-bus.js +4 -0
  39. package/build/lib/machines/transport/nats-bus.d.ts +8 -13
  40. package/build/lib/machines/transport/nats-bus.js +26 -43
  41. package/build/lib/machines/transport/nats-feed.d.ts +1 -0
  42. package/build/lib/machines/transport/nats-feed.js +6 -3
  43. package/build/lib/machines/transport/pubsub-feed.d.ts +18 -0
  44. package/build/lib/machines/transport/pubsub-feed.js +42 -0
  45. package/build/lib/machines/transport/stream-bus.d.ts +42 -0
  46. package/build/lib/machines/transport/stream-bus.js +61 -0
  47. package/build/lib/machines/transport/streams.d.ts +10 -14
  48. package/build/lib/machines/transport/streams.js +18 -61
  49. package/build/lib/messaging/config.d.ts +25 -0
  50. package/build/lib/messaging/config.js +55 -0
  51. package/build/lib/messaging/constants.d.ts +26 -0
  52. package/build/lib/messaging/constants.js +26 -0
  53. package/build/lib/messaging/index.d.ts +24 -0
  54. package/build/lib/messaging/index.js +65 -0
  55. package/build/lib/messaging/memory.d.ts +16 -0
  56. package/build/lib/messaging/memory.js +147 -0
  57. package/build/lib/messaging/nats/permissions.d.ts +13 -0
  58. package/build/lib/messaging/nats/permissions.js +22 -0
  59. package/build/lib/messaging/nats/provider.d.ts +30 -0
  60. package/build/lib/messaging/nats/provider.js +77 -0
  61. package/build/lib/messaging/nats/render-conf.d.ts +68 -0
  62. package/build/lib/messaging/nats/render-conf.js +58 -0
  63. package/build/lib/messaging/nats/streams.d.ts +26 -0
  64. package/build/lib/messaging/nats/streams.js +97 -0
  65. package/build/lib/messaging/subjects.d.ts +8 -0
  66. package/build/lib/messaging/subjects.js +25 -0
  67. package/build/modules/machines.d.ts +8 -0
  68. package/build/modules/machines.js +16 -0
  69. package/build/routes/index.js +2 -0
  70. package/build/routes/machines.d.ts +2 -0
  71. package/build/routes/machines.js +220 -0
  72. package/build/scripts/bambu-boat.d.ts +17 -0
  73. package/build/scripts/bambu-boat.js +134 -0
  74. package/build/scripts/bambu-print.d.ts +18 -0
  75. package/build/scripts/bambu-print.js +114 -0
  76. package/build/services/machines/commands.d.ts +5 -5
  77. package/build/services/machines/commands.js +3 -2
  78. package/build/services/machines/config.d.ts +8 -1
  79. package/build/services/machines/config.js +17 -7
  80. package/build/services/machines/contracts.d.ts +29 -2
  81. package/build/services/machines/contracts.js +12 -3
  82. package/build/services/machines/gateway/actions.d.ts +2 -1
  83. package/build/services/machines/gateway/admission.d.ts +15 -3
  84. package/build/services/machines/gateway/admission.js +29 -14
  85. package/build/services/machines/gateway/dispatcher.d.ts +19 -3
  86. package/build/services/machines/gateway/dispatcher.js +61 -13
  87. package/build/services/machines/gateway/executor.d.ts +18 -4
  88. package/build/services/machines/gateway/executor.js +99 -34
  89. package/build/services/machines/gateway/gateway.d.ts +22 -1
  90. package/build/services/machines/gateway/gateway.js +83 -28
  91. package/build/services/machines/gateway/index.d.ts +3 -0
  92. package/build/services/machines/gateway/index.js +3 -0
  93. package/build/services/machines/gateway/inspect.d.ts +17 -0
  94. package/build/services/machines/gateway/inspect.js +68 -0
  95. package/build/services/machines/gateway/lifecycle.d.ts +21 -0
  96. package/build/services/machines/gateway/lifecycle.js +89 -0
  97. package/build/services/machines/gateway/log.d.ts +8 -0
  98. package/build/services/machines/gateway/log.js +18 -0
  99. package/build/services/machines/gateway/pacing.d.ts +14 -0
  100. package/build/services/machines/gateway/pacing.js +27 -2
  101. package/build/services/machines/gateway/plan-escalation.js +21 -7
  102. package/build/services/machines/gateway/plan-machine.d.ts +5 -4
  103. package/build/services/machines/gateway/plan-machine.js +70 -19
  104. package/build/services/machines/gateway/project.d.ts +9 -0
  105. package/build/services/machines/gateway/project.js +55 -0
  106. package/build/services/machines/gateway/receipts.d.ts +3 -0
  107. package/build/services/machines/gateway/receipts.js +3 -1
  108. package/build/services/machines/gateway/reconcile.d.ts +2 -0
  109. package/build/services/machines/gateway/reconcile.js +16 -3
  110. package/build/services/machines/gateway/registration.js +1 -1
  111. package/build/services/machines/gateway/reply-waiter.d.ts +6 -3
  112. package/build/services/machines/gateway/reply-waiter.js +37 -16
  113. package/build/services/machines/gateway/state.d.ts +50 -4
  114. package/build/services/machines/gateway/state.js +77 -10
  115. package/build/services/machines/gateway/wire.d.ts +58 -0
  116. package/build/services/machines/gateway/wire.js +171 -0
  117. package/build/services/machines/index.d.ts +3 -0
  118. package/build/services/machines/index.js +2 -0
  119. package/build/services/machines/leadership.d.ts +17 -4
  120. package/build/services/machines/leadership.js +43 -18
  121. package/build/services/machines/line-index.d.ts +16 -0
  122. package/build/services/machines/line-index.js +39 -0
  123. package/build/services/machines/registry-sql.d.ts +31 -0
  124. package/build/services/machines/registry-sql.js +110 -0
  125. package/build/services/machines/registry-sync.d.ts +31 -0
  126. package/build/services/machines/registry-sync.js +81 -0
  127. package/build/services/machines/registry.d.ts +77 -0
  128. package/build/services/machines/registry.js +158 -0
  129. package/build/services/machines/rows.js +26 -2
  130. package/build/services/machines/select.d.ts +9 -2
  131. package/build/services/machines/select.js +20 -7
  132. package/build/services/machines/surface.d.ts +45 -5
  133. package/build/services/machines/surface.js +102 -16
  134. package/build/services/machines/testing/fake-long-tail.d.ts +1 -0
  135. package/build/services/machines/testing/fake-long-tail.js +6 -3
  136. package/build/start/adapters.js +11 -2
  137. package/build/start/apply-report.d.ts +1 -1
  138. package/build/start/apply-report.js +3 -25
  139. package/build/start/index.js +23 -5
  140. package/build/system/index.js +13 -0
  141. package/build/system/mcp-servers/admin/schemas.d.ts +22 -22
  142. package/build/system/mcp-servers/human-queue-schemas.d.ts +7 -7
  143. package/build/system/mcp-servers/machines-schemas.d.ts +35 -0
  144. package/build/system/mcp-servers/machines-schemas.js +35 -0
  145. package/build/system/mcp-servers/machines.d.ts +20 -0
  146. package/build/system/mcp-servers/machines.js +154 -0
  147. package/build/system/seed/tool-manifests-machines.d.ts +2 -0
  148. package/build/system/seed/tool-manifests-machines.js +88 -0
  149. package/build/tsconfig.tsbuildinfo +1 -1
  150. package/build/types/events.d.ts +6 -1
  151. package/build/types/index.d.ts +2 -0
  152. package/build/types/machines-view.d.ts +159 -0
  153. package/build/types/machines-view.js +7 -0
  154. package/build/types/machines.d.ts +6 -1
  155. package/build/types/messaging.d.ts +72 -0
  156. package/build/types/messaging.js +11 -0
  157. package/build/types/startup.d.ts +26 -1
  158. package/dashboard/dist/assets/{AdminDashboard-DlItqxFS.js → AdminDashboard-Bm7VG65H.js} +2 -2
  159. package/dashboard/dist/assets/{AdminDashboard-DlItqxFS.js.map → AdminDashboard-Bm7VG65H.js.map} +1 -1
  160. package/dashboard/dist/assets/{AgentConfigPage-BUmT4a7n.js → AgentConfigPage-aJF7Sdbc.js} +6 -6
  161. package/dashboard/dist/assets/{AgentConfigPage-BUmT4a7n.js.map → AgentConfigPage-aJF7Sdbc.js.map} +1 -1
  162. package/dashboard/dist/assets/{AgentDetailPage-Cww8rlBi.js → AgentDetailPage-GwwghhxT.js} +3 -3
  163. package/dashboard/dist/assets/{AgentDetailPage-Cww8rlBi.js.map → AgentDetailPage-GwwghhxT.js.map} +1 -1
  164. package/dashboard/dist/assets/AgentsPage-DVvCzZyg.js +2 -0
  165. package/dashboard/dist/assets/{AgentsPage-C9UuUKhr.js.map → AgentsPage-DVvCzZyg.js.map} +1 -1
  166. package/dashboard/dist/assets/AvailableEscalationsPage-Cxmcji_K.js +2 -0
  167. package/dashboard/dist/assets/{AvailableEscalationsPage-DrvfXz70.js.map → AvailableEscalationsPage-Cxmcji_K.js.map} +1 -1
  168. package/dashboard/dist/assets/{BotPicker-CDq9XRMp.js → BotPicker-CofRxk4L.js} +2 -2
  169. package/dashboard/dist/assets/{BotPicker-CDq9XRMp.js.map → BotPicker-CofRxk4L.js.map} +1 -1
  170. package/dashboard/dist/assets/{BulkAssignModal-jsvqtrEA.js → BulkAssignModal-BARWuz4L.js} +2 -2
  171. package/dashboard/dist/assets/{BulkAssignModal-jsvqtrEA.js.map → BulkAssignModal-BARWuz4L.js.map} +1 -1
  172. package/dashboard/dist/assets/{CapabilitiesPage-CSCrI6B1.js → CapabilitiesPage-BJAWVNEx.js} +2 -2
  173. package/dashboard/dist/assets/{CapabilitiesPage-CSCrI6B1.js.map → CapabilitiesPage-BJAWVNEx.js.map} +1 -1
  174. package/dashboard/dist/assets/{CollapsibleSection-uD9mn-CQ.js → CollapsibleSection-CtgoaG75.js} +2 -2
  175. package/dashboard/dist/assets/{CollapsibleSection-uD9mn-CQ.js.map → CollapsibleSection-CtgoaG75.js.map} +1 -1
  176. package/dashboard/dist/assets/{ConfirmDeleteModal-BRmx2hA4.js → ConfirmDeleteModal-BYXXBWs6.js} +2 -2
  177. package/dashboard/dist/assets/{ConfirmDeleteModal-BRmx2hA4.js.map → ConfirmDeleteModal-BYXXBWs6.js.map} +1 -1
  178. package/dashboard/dist/assets/{ConnectedAppsPage-DlMzE5a-.js → ConnectedAppsPage-D0JkzWa7.js} +2 -2
  179. package/dashboard/dist/assets/{ConnectedAppsPage-DlMzE5a-.js.map → ConnectedAppsPage-D0JkzWa7.js.map} +1 -1
  180. package/dashboard/dist/assets/{CountdownTimer-sRuM4eM5.js → CountdownTimer-BcFxdZYN.js} +2 -2
  181. package/dashboard/dist/assets/{CountdownTimer-sRuM4eM5.js.map → CountdownTimer-BcFxdZYN.js.map} +1 -1
  182. package/dashboard/dist/assets/{CredentialsPage-bLYydwqa.js → CredentialsPage-DPSY20rV.js} +2 -2
  183. package/dashboard/dist/assets/{CredentialsPage-bLYydwqa.js.map → CredentialsPage-DPSY20rV.js.map} +1 -1
  184. package/dashboard/dist/assets/{CronLabel-D_ATDL2N.js → CronLabel-Dg_Oew_Y.js} +2 -2
  185. package/dashboard/dist/assets/{CronLabel-D_ATDL2N.js.map → CronLabel-Dg_Oew_Y.js.map} +1 -1
  186. package/dashboard/dist/assets/{DropZone-u1JGfR9G.js → DropZone-Cl_Flb16.js} +2 -2
  187. package/dashboard/dist/assets/{DropZone-u1JGfR9G.js.map → DropZone-Cl_Flb16.js.map} +1 -1
  188. package/dashboard/dist/assets/{ElapsedCell-groSMfqB.js → ElapsedCell-Dm3G5fK2.js} +2 -2
  189. package/dashboard/dist/assets/{ElapsedCell-groSMfqB.js.map → ElapsedCell-Dm3G5fK2.js.map} +1 -1
  190. package/dashboard/dist/assets/{EntityTimelinePanel-D-F3_A9m.js → EntityTimelinePanel-CrEEP04e.js} +2 -2
  191. package/dashboard/dist/assets/{EntityTimelinePanel-D-F3_A9m.js.map → EntityTimelinePanel-CrEEP04e.js.map} +1 -1
  192. package/dashboard/dist/assets/{EscalationListSchemaPage-Bad6Jrmr.js → EscalationListSchemaPage-wOInXcjs.js} +3 -3
  193. package/dashboard/dist/assets/{EscalationListSchemaPage-Bad6Jrmr.js.map → EscalationListSchemaPage-wOInXcjs.js.map} +1 -1
  194. package/dashboard/dist/assets/{EscalationSchemaPage-BKi_npI9.js → EscalationSchemaPage-CrIj_g9d.js} +3 -3
  195. package/dashboard/dist/assets/{EscalationSchemaPage-BKi_npI9.js.map → EscalationSchemaPage-CrIj_g9d.js.map} +1 -1
  196. package/dashboard/dist/assets/{EscalationTimeline-DQUUm3b1.js → EscalationTimeline-CeAsl5IT.js} +2 -2
  197. package/dashboard/dist/assets/{EscalationTimeline-DQUUm3b1.js.map → EscalationTimeline-CeAsl5IT.js.map} +1 -1
  198. package/dashboard/dist/assets/{EscalationTitleSelect-3mhXh77a.js → EscalationTitleSelect-D8qpCYiy.js} +2 -2
  199. package/dashboard/dist/assets/{EscalationTitleSelect-3mhXh77a.js.map → EscalationTitleSelect-D8qpCYiy.js.map} +1 -1
  200. package/dashboard/dist/assets/{EscalationsOverview-Qaov-uML.js → EscalationsOverview-CvaqVPsr.js} +2 -2
  201. package/dashboard/dist/assets/{EscalationsOverview-Qaov-uML.js.map → EscalationsOverview-CvaqVPsr.js.map} +1 -1
  202. package/dashboard/dist/assets/{EventTable-V4RF_n58.js → EventTable-Be0JuEl6.js} +2 -2
  203. package/dashboard/dist/assets/{EventTable-V4RF_n58.js.map → EventTable-Be0JuEl6.js.map} +1 -1
  204. package/dashboard/dist/assets/FilterBar-BVyAjIgv.js +2 -0
  205. package/dashboard/dist/assets/FilterBar-BVyAjIgv.js.map +1 -0
  206. package/dashboard/dist/assets/{GraphInvokePage-Djslhf96.js → GraphInvokePage-D_QigJeD.js} +2 -2
  207. package/dashboard/dist/assets/{GraphInvokePage-Djslhf96.js.map → GraphInvokePage-D_QigJeD.js.map} +1 -1
  208. package/dashboard/dist/assets/{HomePage-EjcNxlKx.js → HomePage-C1haeuNy.js} +2 -2
  209. package/dashboard/dist/assets/{HomePage-EjcNxlKx.js.map → HomePage-C1haeuNy.js.map} +1 -1
  210. package/dashboard/dist/assets/LinePage-CWD5pv1g.js +5 -0
  211. package/dashboard/dist/assets/LinePage-CWD5pv1g.js.map +1 -0
  212. package/dashboard/dist/assets/LinesPage-NqChsKcO.js +3 -0
  213. package/dashboard/dist/assets/LinesPage-NqChsKcO.js.map +1 -0
  214. package/dashboard/dist/assets/{ListToolbar-RrEAePOX.js → ListToolbar-BZCNrTh6.js} +2 -2
  215. package/dashboard/dist/assets/{ListToolbar-RrEAePOX.js.map → ListToolbar-BZCNrTh6.js.map} +1 -1
  216. package/dashboard/dist/assets/{McpOverview-8gqiL3Vj.js → McpOverview-yJTYnh1z.js} +2 -2
  217. package/dashboard/dist/assets/{McpOverview-8gqiL3Vj.js.map → McpOverview-yJTYnh1z.js.map} +1 -1
  218. package/dashboard/dist/assets/{McpQueryDetailPage-COyn6Ak5.js → McpQueryDetailPage-ChuLpJ4u.js} +3 -3
  219. package/dashboard/dist/assets/{McpQueryDetailPage-COyn6Ak5.js.map → McpQueryDetailPage-ChuLpJ4u.js.map} +1 -1
  220. package/dashboard/dist/assets/{McpQueryPage-Dj6Qj72w.js → McpQueryPage-9S-v9soF.js} +2 -2
  221. package/dashboard/dist/assets/{McpQueryPage-Dj6Qj72w.js.map → McpQueryPage-9S-v9soF.js.map} +1 -1
  222. package/dashboard/dist/assets/McpRunDetailPage-BhrcfxD5.js +2 -0
  223. package/dashboard/dist/assets/{McpRunDetailPage-80fQn9iX.js.map → McpRunDetailPage-BhrcfxD5.js.map} +1 -1
  224. package/dashboard/dist/assets/{McpRunsPage-DaSsI-EM.js → McpRunsPage-C5_i8_Zx.js} +2 -2
  225. package/dashboard/dist/assets/{McpRunsPage-DaSsI-EM.js.map → McpRunsPage-C5_i8_Zx.js.map} +1 -1
  226. package/dashboard/dist/assets/{NamespacePill-C5epAgq6.js → NamespacePill-OTZD2hzt.js} +2 -2
  227. package/dashboard/dist/assets/{NamespacePill-C5epAgq6.js.map → NamespacePill-OTZD2hzt.js.map} +1 -1
  228. package/dashboard/dist/assets/{OperationsPage-BSu1o2gB.js → OperationsPage-C03CeU5P.js} +2 -2
  229. package/dashboard/dist/assets/{OperationsPage-BSu1o2gB.js.map → OperationsPage-C03CeU5P.js.map} +1 -1
  230. package/dashboard/dist/assets/{OperatorDashboard-HFI4WGIV.js → OperatorDashboard-BzC134Jt.js} +2 -2
  231. package/dashboard/dist/assets/{OperatorDashboard-HFI4WGIV.js.map → OperatorDashboard-BzC134Jt.js.map} +1 -1
  232. package/dashboard/dist/assets/{PageHeader-BSWIspNB.js → PageHeader-Hx8APPwE.js} +2 -2
  233. package/dashboard/dist/assets/{PageHeader-BSWIspNB.js.map → PageHeader-Hx8APPwE.js.map} +1 -1
  234. package/dashboard/dist/assets/{PageHeaderWithStats-DDjopQ-k.js → PageHeaderWithStats-BEQYYBJv.js} +2 -2
  235. package/dashboard/dist/assets/{PageHeaderWithStats-DDjopQ-k.js.map → PageHeaderWithStats-BEQYYBJv.js.map} +1 -1
  236. package/dashboard/dist/assets/{PersonaDetailPage-D0qlBuGi.js → PersonaDetailPage-D0mY9L6j.js} +2 -2
  237. package/dashboard/dist/assets/{PersonaDetailPage-D0qlBuGi.js.map → PersonaDetailPage-D0mY9L6j.js.map} +1 -1
  238. package/dashboard/dist/assets/{PersonasPage-BJClu-5H.js → PersonasPage-FFlm5Eug.js} +2 -2
  239. package/dashboard/dist/assets/{PersonasPage-BJClu-5H.js.map → PersonasPage-FFlm5Eug.js.map} +1 -1
  240. package/dashboard/dist/assets/{PortalPage-CucNZn_w.js → PortalPage-Cpc25uO-.js} +2 -2
  241. package/dashboard/dist/assets/{PortalPage-CucNZn_w.js.map → PortalPage-Cpc25uO-.js.map} +1 -1
  242. package/dashboard/dist/assets/{ProcessDetailPage-B9wMw0RV.js → ProcessDetailPage-Di2J7KwY.js} +2 -2
  243. package/dashboard/dist/assets/{ProcessDetailPage-B9wMw0RV.js.map → ProcessDetailPage-Di2J7KwY.js.map} +1 -1
  244. package/dashboard/dist/assets/{ProcessesListPage-B6k4RpmR.js → ProcessesListPage-BEXwU3Z0.js} +2 -2
  245. package/dashboard/dist/assets/{ProcessesListPage-B6k4RpmR.js.map → ProcessesListPage-BEXwU3Z0.js.map} +1 -1
  246. package/dashboard/dist/assets/{ResolverForm-ZVufJ4G-.js → ResolverForm-2ks-3jXC.js} +6 -6
  247. package/dashboard/dist/assets/{ResolverForm-ZVufJ4G-.js.map → ResolverForm-2ks-3jXC.js.map} +1 -1
  248. package/dashboard/dist/assets/{RoleDetailPage-CTbq0mz4.js → RoleDetailPage-DqoOk0xc.js} +3 -3
  249. package/dashboard/dist/assets/{RoleDetailPage-CTbq0mz4.js.map → RoleDetailPage-DqoOk0xc.js.map} +1 -1
  250. package/dashboard/dist/assets/{RolePill-CoETDpjF.js → RolePill-R5_ctGFy.js} +2 -2
  251. package/dashboard/dist/assets/{RolePill-CoETDpjF.js.map → RolePill-R5_ctGFy.js.map} +1 -1
  252. package/dashboard/dist/assets/{RolesPage-DBKxeam4.js → RolesPage-CPmo8Srr.js} +2 -2
  253. package/dashboard/dist/assets/{RolesPage-DBKxeam4.js.map → RolesPage-CPmo8Srr.js.map} +1 -1
  254. package/dashboard/dist/assets/{RosterWidget-BkLAwEYB.js → RosterWidget-D2yovCKw.js} +2 -2
  255. package/dashboard/dist/assets/{RosterWidget-BkLAwEYB.js.map → RosterWidget-D2yovCKw.js.map} +1 -1
  256. package/dashboard/dist/assets/{RunAsSelector-D2DC4iDf.js → RunAsSelector-CMv96On6.js} +2 -2
  257. package/dashboard/dist/assets/{RunAsSelector-D2DC4iDf.js.map → RunAsSelector-CMv96On6.js.map} +1 -1
  258. package/dashboard/dist/assets/{ScanCodesPage-BlKleaT0.js → ScanCodesPage-CA6cTT-M.js} +2 -2
  259. package/dashboard/dist/assets/{ScanCodesPage-BlKleaT0.js.map → ScanCodesPage-CA6cTT-M.js.map} +1 -1
  260. package/dashboard/dist/assets/{ScanSchemeDetailPage-CTW6gofi.js → ScanSchemeDetailPage-DnctN5-H.js} +2 -2
  261. package/dashboard/dist/assets/{ScanSchemeDetailPage-CTW6gofi.js.map → ScanSchemeDetailPage-DnctN5-H.js.map} +1 -1
  262. package/dashboard/dist/assets/{ScanStationPage-DPRjSPyT.js → ScanStationPage-Bk8RwkKL.js} +2 -2
  263. package/dashboard/dist/assets/{ScanStationPage-DPRjSPyT.js.map → ScanStationPage-Bk8RwkKL.js.map} +1 -1
  264. package/dashboard/dist/assets/{ScopeBadge-CGsTtqFr.js → ScopeBadge-BXZ084nD.js} +2 -2
  265. package/dashboard/dist/assets/{ScopeBadge-CGsTtqFr.js.map → ScopeBadge-BXZ084nD.js.map} +1 -1
  266. package/dashboard/dist/assets/{StickyPagination-CkmX3-Gu.js → StickyPagination-B0FSuUgs.js} +2 -2
  267. package/dashboard/dist/assets/{StickyPagination-CkmX3-Gu.js.map → StickyPagination-B0FSuUgs.js.map} +1 -1
  268. package/dashboard/dist/assets/{StreamMessageDetail-Xm_n510s.js → StreamMessageDetail-BwZEvMpP.js} +2 -2
  269. package/dashboard/dist/assets/{StreamMessageDetail-Xm_n510s.js.map → StreamMessageDetail-BwZEvMpP.js.map} +1 -1
  270. package/dashboard/dist/assets/{SwimlaneTimeline-De48aJan.js → SwimlaneTimeline-BDVQEaMw.js} +2 -2
  271. package/dashboard/dist/assets/{SwimlaneTimeline-De48aJan.js.map → SwimlaneTimeline-BDVQEaMw.js.map} +1 -1
  272. package/dashboard/dist/assets/{TagInput-S7UuVT_M.js → TagInput-DjPUDp2M.js} +2 -2
  273. package/dashboard/dist/assets/{TagInput-S7UuVT_M.js.map → TagInput-DjPUDp2M.js.map} +1 -1
  274. package/dashboard/dist/assets/{TaskDetailPage-HycMx3O9.js → TaskDetailPage-BOlv3iGB.js} +2 -2
  275. package/dashboard/dist/assets/{TaskDetailPage-HycMx3O9.js.map → TaskDetailPage-BOlv3iGB.js.map} +1 -1
  276. package/dashboard/dist/assets/{TaskQueuePill-BlHNpYiZ.js → TaskQueuePill-D-4Ynf3K.js} +2 -2
  277. package/dashboard/dist/assets/{TaskQueuePill-BlHNpYiZ.js.map → TaskQueuePill-D-4Ynf3K.js.map} +1 -1
  278. package/dashboard/dist/assets/{TasksListPage-OIcFFp1C.js → TasksListPage-e2teY0bD.js} +2 -2
  279. package/dashboard/dist/assets/{TasksListPage-OIcFFp1C.js.map → TasksListPage-e2teY0bD.js.map} +1 -1
  280. package/dashboard/dist/assets/{TimeAgo-OTC_55oZ.js → TimeAgo-Cvkpf_b3.js} +2 -2
  281. package/dashboard/dist/assets/{TimeAgo-OTC_55oZ.js.map → TimeAgo-Cvkpf_b3.js.map} +1 -1
  282. package/dashboard/dist/assets/{TimestampCell-CAwIj_AI.js → TimestampCell-B3btAV0N.js} +2 -2
  283. package/dashboard/dist/assets/{TimestampCell-CAwIj_AI.js.map → TimestampCell-B3btAV0N.js.map} +1 -1
  284. package/dashboard/dist/assets/{ToolPill-D40uLM_v.js → ToolPill-GsKQ80CO.js} +2 -2
  285. package/dashboard/dist/assets/{ToolPill-D40uLM_v.js.map → ToolPill-GsKQ80CO.js.map} +1 -1
  286. package/dashboard/dist/assets/{ToolTestPanel-8Vf6pfw4.js → ToolTestPanel-B03nebR7.js} +2 -2
  287. package/dashboard/dist/assets/{ToolTestPanel-8Vf6pfw4.js.map → ToolTestPanel-B03nebR7.js.map} +1 -1
  288. package/dashboard/dist/assets/{TopicDetailPage-iZW8rK9L.js → TopicDetailPage-DBRWne3O.js} +3 -3
  289. package/dashboard/dist/assets/{TopicDetailPage-iZW8rK9L.js.map → TopicDetailPage-DBRWne3O.js.map} +1 -1
  290. package/dashboard/dist/assets/{TopicsPage-CqiEcj-W.js → TopicsPage-CVe2M9HD.js} +2 -2
  291. package/dashboard/dist/assets/{TopicsPage-CqiEcj-W.js.map → TopicsPage-CVe2M9HD.js.map} +1 -1
  292. package/dashboard/dist/assets/{UserName-DQFjuoib.js → UserName-B_q_qp6V.js} +2 -2
  293. package/dashboard/dist/assets/{UserName-DQFjuoib.js.map → UserName-B_q_qp6V.js.map} +1 -1
  294. package/dashboard/dist/assets/WorkflowExecutionPage-Bh_dr9tM.js +2 -0
  295. package/dashboard/dist/assets/{WorkflowExecutionPage-Di08wCbs.js.map → WorkflowExecutionPage-Bh_dr9tM.js.map} +1 -1
  296. package/dashboard/dist/assets/{WorkflowPill-DJLcK_CM.js → WorkflowPill-D7244fKp.js} +2 -2
  297. package/dashboard/dist/assets/{WorkflowPill-DJLcK_CM.js.map → WorkflowPill-D7244fKp.js.map} +1 -1
  298. package/dashboard/dist/assets/{WorkflowsDashboard-Bb8HlrTJ.js → WorkflowsDashboard-DA6Mj7qH.js} +2 -2
  299. package/dashboard/dist/assets/{WorkflowsDashboard-Bb8HlrTJ.js.map → WorkflowsDashboard-DA6Mj7qH.js.map} +1 -1
  300. package/dashboard/dist/assets/{WorkflowsOverview-Dta1kurk.js → WorkflowsOverview-B1kBLj-a.js} +2 -2
  301. package/dashboard/dist/assets/{WorkflowsOverview-Dta1kurk.js.map → WorkflowsOverview-B1kBLj-a.js.map} +1 -1
  302. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CfAajg68.js → YamlWorkflowDetailPage-6GJM8QIX.js} +8 -8
  303. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CfAajg68.js.map → YamlWorkflowDetailPage-6GJM8QIX.js.map} +1 -1
  304. package/dashboard/dist/assets/{YamlWorkflowsPage-CQFUzT4t.js → YamlWorkflowsPage-Bu811C7f.js} +2 -2
  305. package/dashboard/dist/assets/{YamlWorkflowsPage-CQFUzT4t.js.map → YamlWorkflowsPage-Bu811C7f.js.map} +1 -1
  306. package/dashboard/dist/assets/{agents-PuftRTB2.js → agents-MPk_GnYz.js} +2 -2
  307. package/dashboard/dist/assets/{agents-PuftRTB2.js.map → agents-MPk_GnYz.js.map} +1 -1
  308. package/dashboard/dist/assets/{bots-BmEiPAWY.js → bots-2RihE2Tc.js} +2 -2
  309. package/dashboard/dist/assets/{bots-BmEiPAWY.js.map → bots-2RihE2Tc.js.map} +1 -1
  310. package/dashboard/dist/assets/{capabilities-CRii4Soa.js → capabilities-CC4iwJ1P.js} +2 -2
  311. package/dashboard/dist/assets/{capabilities-CRii4Soa.js.map → capabilities-CC4iwJ1P.js.map} +1 -1
  312. package/dashboard/dist/assets/{controlplane-DO_czaYo.js → controlplane-Bmkic8BH.js} +2 -2
  313. package/dashboard/dist/assets/{controlplane-DO_czaYo.js.map → controlplane-Bmkic8BH.js.map} +1 -1
  314. package/dashboard/dist/assets/{escalation-columns-CzCquCPh.js → escalation-columns-B0lhUUrQ.js} +2 -2
  315. package/dashboard/dist/assets/{escalation-columns-CzCquCPh.js.map → escalation-columns-B0lhUUrQ.js.map} +1 -1
  316. package/dashboard/dist/assets/{escalation-items-Cy0ZgJqV.js → escalation-items-7WFpPo46.js} +2 -2
  317. package/dashboard/dist/assets/{escalation-items-Cy0ZgJqV.js.map → escalation-items-7WFpPo46.js.map} +1 -1
  318. package/dashboard/dist/assets/index-B9uv-euR.css +1 -0
  319. package/dashboard/dist/assets/{index-DhSCCpqM.js → index-B_XV1rwu.js} +2 -2
  320. package/dashboard/dist/assets/{index-DhSCCpqM.js.map → index-B_XV1rwu.js.map} +1 -1
  321. package/dashboard/dist/assets/{index-Cx8xb-oU.js → index-C2CLfGwL.js} +2 -2
  322. package/dashboard/dist/assets/{index-Cx8xb-oU.js.map → index-C2CLfGwL.js.map} +1 -1
  323. package/dashboard/dist/assets/{index-Cga5IW3D.js → index-C3AeFihz.js} +2 -2
  324. package/dashboard/dist/assets/{index-Cga5IW3D.js.map → index-C3AeFihz.js.map} +1 -1
  325. package/dashboard/dist/assets/{index-DiaRlFYI.js → index-CBri8fYM.js} +2 -2
  326. package/dashboard/dist/assets/{index-DiaRlFYI.js.map → index-CBri8fYM.js.map} +1 -1
  327. package/dashboard/dist/assets/{index-CL_1VpGb.js → index-CRWsB7ZC.js} +2 -2
  328. package/dashboard/dist/assets/{index-CL_1VpGb.js.map → index-CRWsB7ZC.js.map} +1 -1
  329. package/dashboard/dist/assets/{index-XntldBd0.js → index-CTOv3G7a.js} +2 -2
  330. package/dashboard/dist/assets/{index-XntldBd0.js.map → index-CTOv3G7a.js.map} +1 -1
  331. package/dashboard/dist/assets/{index-CfP2nKRc.js → index-CcArGkzI.js} +3 -3
  332. package/dashboard/dist/assets/{index-CfP2nKRc.js.map → index-CcArGkzI.js.map} +1 -1
  333. package/dashboard/dist/assets/{index-Dz6R8-Dw.js → index-CkMHS-hG.js} +25 -25
  334. package/dashboard/dist/assets/index-CkMHS-hG.js.map +1 -0
  335. package/dashboard/dist/assets/index-CmsmwCyv.js +2 -0
  336. package/dashboard/dist/assets/{index-4YaDUcKd.js.map → index-CmsmwCyv.js.map} +1 -1
  337. package/dashboard/dist/assets/{index-2SM2_onB.js → index-CvJsvqIc.js} +2 -2
  338. package/dashboard/dist/assets/{index-2SM2_onB.js.map → index-CvJsvqIc.js.map} +1 -1
  339. package/dashboard/dist/assets/{index-Rwqrflm-.js → index-D-ilRyfy.js} +2 -2
  340. package/dashboard/dist/assets/{index-Rwqrflm-.js.map → index-D-ilRyfy.js.map} +1 -1
  341. package/dashboard/dist/assets/{index-CZ7A3AcD.js → index-DSUtfDXx.js} +2 -2
  342. package/dashboard/dist/assets/{index-CZ7A3AcD.js.map → index-DSUtfDXx.js.map} +1 -1
  343. package/dashboard/dist/assets/{index-jL2K6us4.js → index-Da6ycKyf.js} +2 -2
  344. package/dashboard/dist/assets/{index-jL2K6us4.js.map → index-Da6ycKyf.js.map} +1 -1
  345. package/dashboard/dist/assets/{knowledge-CeUqGPuo.js → knowledge-Bpbg20DC.js} +2 -2
  346. package/dashboard/dist/assets/{knowledge-CeUqGPuo.js.map → knowledge-Bpbg20DC.js.map} +1 -1
  347. package/dashboard/dist/assets/machines-BqOZZU-3.js +2 -0
  348. package/dashboard/dist/assets/machines-BqOZZU-3.js.map +1 -0
  349. package/dashboard/dist/assets/{mcp-Cx96NTeD.js → mcp-CmcUXYce.js} +2 -2
  350. package/dashboard/dist/assets/{mcp-Cx96NTeD.js.map → mcp-CmcUXYce.js.map} +1 -1
  351. package/dashboard/dist/assets/{mcp-query-XAzWl0gm.js → mcp-query-C8buQxN9.js} +2 -2
  352. package/dashboard/dist/assets/{mcp-query-XAzWl0gm.js.map → mcp-query-C8buQxN9.js.map} +1 -1
  353. package/dashboard/dist/assets/{personas--4kjwyOw.js → personas-C2n5oDmY.js} +2 -2
  354. package/dashboard/dist/assets/{personas--4kjwyOw.js.map → personas-C2n5oDmY.js.map} +1 -1
  355. package/dashboard/dist/assets/{pipelines-PgkwvG7f.js → pipelines-RKpSkFz7.js} +2 -2
  356. package/dashboard/dist/assets/{pipelines-PgkwvG7f.js.map → pipelines-RKpSkFz7.js.map} +1 -1
  357. package/dashboard/dist/assets/{tasks-CcYxdBa3.js → tasks-Dab4hExW.js} +2 -2
  358. package/dashboard/dist/assets/{tasks-CcYxdBa3.js.map → tasks-Dab4hExW.js.map} +1 -1
  359. package/dashboard/dist/assets/{topics-_lik7cNY.js → topics-FTMNP7r3.js} +2 -2
  360. package/dashboard/dist/assets/{topics-_lik7cNY.js.map → topics-FTMNP7r3.js.map} +1 -1
  361. package/dashboard/dist/assets/{useDebouncedValue-Bm_AoxVx.js → useDebouncedValue-B_1u1YIk.js} +2 -2
  362. package/dashboard/dist/assets/{useDebouncedValue-Bm_AoxVx.js.map → useDebouncedValue-B_1u1YIk.js.map} +1 -1
  363. package/dashboard/dist/assets/{useNamespace-DgXXKdx5.js → useNamespace-HUeAI7Qb.js} +2 -2
  364. package/dashboard/dist/assets/{useNamespace-DgXXKdx5.js.map → useNamespace-HUeAI7Qb.js.map} +1 -1
  365. package/dashboard/dist/assets/{useYamlActivityEvents-Dj2qtGSd.js → useYamlActivityEvents-Cax54qHH.js} +2 -2
  366. package/dashboard/dist/assets/{useYamlActivityEvents-Dj2qtGSd.js.map → useYamlActivityEvents-Cax54qHH.js.map} +1 -1
  367. package/dashboard/dist/assets/{validate-FlXCBBT6.js → validate-DxOaV7QS.js} +2 -2
  368. package/dashboard/dist/assets/{validate-FlXCBBT6.js.map → validate-DxOaV7QS.js.map} +1 -1
  369. package/dashboard/dist/assets/{vendor-icons-DUYcKTjP.js → vendor-icons-fxBvvHBi.js} +187 -182
  370. package/dashboard/dist/assets/vendor-icons-fxBvvHBi.js.map +1 -0
  371. package/dashboard/dist/assets/{yaml-workflows-B0_JxRYQ.js → yaml-workflows-BgY1XHJx.js} +2 -2
  372. package/dashboard/dist/assets/{yaml-workflows-B0_JxRYQ.js.map → yaml-workflows-BgY1XHJx.js.map} +1 -1
  373. package/dashboard/dist/index.html +3 -3
  374. package/docs/architecture.md +1 -0
  375. package/docs/code-owned-configuration.md +6 -0
  376. package/docs/dashboard.md +1 -0
  377. package/docs/events.md +83 -4
  378. package/docs/machines.md +129 -23
  379. package/docs/mcp.md +19 -0
  380. package/package.json +3 -1
  381. package/build/lib/machines/transport/nats-durable.d.ts +0 -11
  382. package/build/lib/machines/transport/nats-durable.js +0 -28
  383. package/dashboard/dist/assets/AgentsPage-C9UuUKhr.js +0 -2
  384. package/dashboard/dist/assets/AvailableEscalationsPage-DrvfXz70.js +0 -2
  385. package/dashboard/dist/assets/FilterBar-BygWrnB1.js +0 -2
  386. package/dashboard/dist/assets/FilterBar-BygWrnB1.js.map +0 -1
  387. package/dashboard/dist/assets/McpRunDetailPage-80fQn9iX.js +0 -2
  388. package/dashboard/dist/assets/WorkflowExecutionPage-Di08wCbs.js +0 -2
  389. package/dashboard/dist/assets/index-4YaDUcKd.js +0 -2
  390. package/dashboard/dist/assets/index-CnU7Jjz3.css +0 -1
  391. package/dashboard/dist/assets/index-Dz6R8-Dw.js.map +0 -1
  392. package/dashboard/dist/assets/vendor-icons-DUYcKTjP.js.map +0 -1
@@ -1,3 +1,3 @@
1
- import{a as f,j as e}from"./vendor-query-DvWWuNIB.js";import{a4 as he,ai as Ct,a_ as rt,a0 as Se,E as _t,e as Rt,bI as ot,bJ as Pt,bh as Lt,Z as Et,w as Bt,bK as Ot,aU as Ft,O as At}from"./index-Dz6R8-Dw.js";import{s as Ee,a as pe,u as F,b as He,E as De,c as lt,i as Be,d as ct}from"./EntityTimelinePanel-D-F3_A9m.js";import{ay as It,bL as Tt,aC as it,d as Wt,C as dt,ao as xt,bJ as Dt,e as Ut,X as Gt,aB as Ht,E as ut,an as zt,bM as Vt,a4 as Yt}from"./vendor-icons-DUYcKTjP.js";import{u as mt,f as pt,L as le,a as Qt}from"./vendor-react-_9U4mKFr.js";import{P as Zt}from"./PageHeader-BSWIspNB.js";import{a as Xt}from"./useContainerWidth-DSLp1gEm.js";function Jt({groups:t,colors:s}){const l=f.useMemo(()=>{const o=(t??[]).filter(n=>(n.dwellSeconds??0)>0),d=o.reduce((n,r)=>n+(r.dwellSeconds??0),0);return d?o.map(n=>({key:pe(n.subtype),label:Ee(n.subtype),seconds:n.dwellSeconds??0,pct:(n.dwellSeconds??0)/d})).sort((n,r)=>r.seconds-n.seconds):null},[t]);if(!l)return e.jsx("span",{className:"text-2xs text-text-quaternary",children:"—"});const i=l.map(o=>`${o.label} ${he(o.seconds*1e3)} · ${Math.round(o.pct*100)}%`).join(`
1
+ import{a as f,j as e}from"./vendor-query-DvWWuNIB.js";import{a4 as he,ai as Ct,a_ as rt,a0 as Se,E as _t,e as Rt,bI as ot,bJ as Pt,bh as Lt,Z as Et,w as Bt,bK as Ot,aU as Ft,O as At}from"./index-CkMHS-hG.js";import{s as Ee,a as pe,u as F,b as He,E as De,c as lt,i as Be,d as ct}from"./EntityTimelinePanel-CrEEP04e.js";import{az as It,bL as Tt,aD as it,d as Wt,C as dt,ap as xt,bJ as Dt,e as Ut,X as Gt,aC as Ht,E as ut,ao as zt,bM as Vt,a5 as Yt}from"./vendor-icons-fxBvvHBi.js";import{u as mt,f as pt,L as le,a as Qt}from"./vendor-react-_9U4mKFr.js";import{P as Zt}from"./PageHeader-Hx8APPwE.js";import{a as Xt}from"./useContainerWidth-DSLp1gEm.js";function Jt({groups:t,colors:s}){const l=f.useMemo(()=>{const o=(t??[]).filter(n=>(n.dwellSeconds??0)>0),d=o.reduce((n,r)=>n+(r.dwellSeconds??0),0);return d?o.map(n=>({key:pe(n.subtype),label:Ee(n.subtype),seconds:n.dwellSeconds??0,pct:(n.dwellSeconds??0)/d})).sort((n,r)=>r.seconds-n.seconds):null},[t]);if(!l)return e.jsx("span",{className:"text-2xs text-text-quaternary",children:"—"});const i=l.map(o=>`${o.label} ${he(o.seconds*1e3)} · ${Math.round(o.pct*100)}%`).join(`
2
2
  `);return e.jsxs("div",{className:"flex items-center gap-1.5",title:i,children:[e.jsx("div",{className:"w-16 h-1.5 bg-surface-sunken rounded-full overflow-hidden flex shrink-0",children:l.map(o=>e.jsx("div",{style:{width:`${o.pct*100}%`,backgroundColor:s.get(o.key)}},o.key))}),e.jsxs("span",{className:"text-2xs font-mono text-text-quaternary tabular-nums",children:[Math.round(l[0].pct*100),"%"]})]})}function Fe(t){return t.reduce((s,l)=>s+(l.dwellSeconds??0),0)||1}function ht(t,s){const l=[];for(const i of t){const o=i.facets[s];o==null||(i.dwellSeconds??0)<=0||l.push(o)}return l}function ft(t,s,l,i){const o=new Map;for(const r of s){const h=r.facets[i];if(h==null||(r.dwellSeconds??0)<=0)continue;const u=o.get(h)??[];u.push(r),o.set(h,u)}const d=new Map;for(const r of l){const h=r.facets[i];h==null||(r.count??0)<=0||r.state==null||d.has(h)||d.set(h,r.state)}const n=[];for(const r of t){const h=r.facets[i];if(h==null||(r.dwellSeconds??0)<=0)continue;const u=[...o.get(h)??[]].sort((m,g)=>(g.dwellSeconds??0)-(m.dwellSeconds??0));n.push({value:h,groups:u,total:r.dwellSeconds??0,nowState:d.get(h)??null})}return n}function Kt(t,s,l=12){const i=new Map;for(const o of t){if((o.dwellSeconds??0)<=0)continue;const d=o.facets[s]??"no value",n=i.get(d)??[];n.push(o),i.set(d,n)}return[...i.entries()].map(([o,d])=>({value:o,groups:[...d].sort((n,r)=>(r.dwellSeconds??0)-(n.dwellSeconds??0)),total:Fe(d)})).sort((o,d)=>d.total-o.total).slice(0,l)}function ze({groups:t,colors:s,height:l,rounded:i="rounded-sm",className:o=""}){const d=Fe(t),n=new Map([...s.keys()].map((h,u)=>[h,u])),r=[...t].sort((h,u)=>(n.get(h.state??"—")??1/0)-(n.get(u.state??"—")??1/0));return e.jsx("div",{className:`${l} flex ${i} overflow-hidden bg-surface-sunken ${o}`,children:r.map(h=>{const u=d>0?Math.round((h.dwellSeconds??0)/d*100):0;return e.jsx("div",{title:`${h.state??"—"} · ${u}%`,style:{width:`${(h.dwellSeconds??0)/d*100}%`,backgroundColor:s.get(h.state??"—")}},h.state??"—")})})}const es=10;function ts(t){return t<1?`${Math.round(t*60)}m`:t<=24?`${Math.round(t)}h`:`${Math.round(t/24)}d`}function ss({groups:t,colors:s,stateLabel:l,nowByState:i,periodHours:o,tracked:d,entityKey:n}){var N;const r=Fe(t),h=[...t].filter(y=>(y.dwellSeconds??0)>0).sort((y,b)=>(b.dwellSeconds??0)-(y.dwellSeconds??0)).map(y=>({state:y.state??"—",label:l(y.state),pct:r>0?Math.round((y.dwellSeconds??0)/r*100):0,color:s.get(y.state??"—"),now:i.get(y.state??"—")??0})),u=((N=h[0])==null?void 0:N.pct)||1,m=h.slice(0,es),g=h.length-m.length,j=h[0];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:["Where the time went · ",e.jsx("span",{className:"normal-case font-mono",children:n})," system"]}),e.jsxs("div",{className:"space-y-px max-h-40 overflow-hidden",children:[m.map(y=>e.jsx("div",{className:"relative h-3 rounded-sm bg-surface-sunken overflow-hidden",title:`${y.label} · ${y.pct}%${y.now>0?` · ${y.now} now`:""}`,children:e.jsxs("div",{className:"absolute inset-y-0 left-0 flex items-center justify-end gap-1 pr-1.5 rounded-sm",style:{width:`${Math.max(y.pct/u*100,0)}%`,minWidth:"4.25rem",backgroundColor:y.color},children:[e.jsx("span",{className:"text-[10px] leading-none font-mono font-medium text-white/95 truncate",children:y.label}),e.jsxs("span",{className:"text-[10px] leading-none font-mono tabular-nums text-white/75 shrink-0",children:[y.pct,"%"]})]})},y.state)),g>0&&e.jsxs("p",{className:"text-[10px] text-text-quaternary pl-1 pt-0.5",children:["+",g," more stages"]})]})]}),e.jsxs("div",{className:"shrink-0 w-52 pl-6 border-l border-surface-border/40 flex flex-col justify-center",children:[e.jsxs("p",{className:"text-2xs uppercase tracking-widest text-text-tertiary",children:["Last ",ts(o)]}),e.jsxs("p",{className:"mt-1 flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-xl font-light text-text-primary tabular-nums leading-none",children:[(j==null?void 0:j.pct)??0,"%"]}),e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:j==null?void 0:j.color}})]}),e.jsxs("p",{className:"text-xs text-text-secondary mt-1",children:[e.jsx("span",{className:"font-mono font-medium text-text-primary",children:j==null?void 0:j.label})," is the biggest time sink"]}),e.jsxs("p",{className:"text-2xs text-text-tertiary mt-1",children:["across ",h.length," stages",d!=null&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"font-mono font-semibold text-text-primary tabular-nums",children:d})," ",e.jsx("span",{className:"font-mono",children:n})," in queue now"]})]})]})]})}function gt({text:t,tail:s=6,className:l=""}){if(t.length<=s+1)return e.jsx("span",{className:`truncate ${l}`,title:t,children:t});const i=t.slice(0,t.length-s),o=t.slice(t.length-s);return e.jsxs("span",{className:`flex items-baseline min-w-0 ${l}`,title:t,children:[e.jsx("span",{className:"truncate min-w-0",children:i}),e.jsx("span",{className:"shrink-0",children:o})]})}const Qe=15,yt="grid grid-cols-[0.6rem_7rem_minmax(2rem,1fr)_1rem] items-center gap-2.5",ns=[25,50,100],as=50;function rs({facetKey:t,row:s,colors:l,stateLabel:i,onOpen:o}){const d=mt(),n=r=>{if(r.metaKey||r.ctrlKey){d(Ct(t,s.value));return}o(s.value)};return e.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:r=>{r.key==="Enter"&&n(r)},className:`${yt} text-2xs cursor-pointer group`,children:[e.jsx("span",{className:"w-2 h-2 rounded-full justify-self-center",style:{backgroundColor:s.nowState?l.get(s.nowState):"transparent"},title:s.nowState?i(s.nowState):"no current state"}),e.jsx(gt,{text:s.value,className:"font-mono text-text-secondary group-hover:text-accent transition-colors"}),e.jsx(ze,{groups:s.groups,colors:l,height:"h-4",className:"min-w-[2rem]"}),e.jsx("button",{className:"icon-link justify-self-center",title:`${he(s.total*1e3)} tracked · open timeline · ⌘-click row searches every queue`,onClick:r=>{r.stopPropagation(),o(s.value)},children:e.jsx(it,{className:"w-3 h-3"})})]})}function bt({facetKey:t,sliced:s,header:l,rows:i,colors:o,stateLabel:d,onOpen:n,onTarget:r,hasMore:h,emptyText:u}){return e.jsxs("div",{className:s?"w-72 shrink-0":"flex-1",children:[l&&e.jsxs("button",{type:"button",onClick:()=>r==null?void 0:r(l.value),className:`${yt} w-full text-left mb-2 group`,children:[e.jsx("span",{"aria-hidden":!0}),e.jsx(gt,{text:l.value,className:"font-mono text-xs font-medium text-text-primary group-hover:text-accent transition-colors"}),e.jsx(ze,{groups:l.groups,colors:o,height:"h-2.5",className:"min-w-[2rem]"}),e.jsx("span",{className:"icon-link justify-self-center",title:`${he(l.total*1e3)} total in ${l.value} — the band shows the state split`,children:e.jsx(It,{className:"w-3 h-3"})})]}),i.length===0?e.jsx("p",{className:"text-2xs text-text-quaternary",children:u??"No entities on this page."}):e.jsx("div",{className:"space-y-px",children:i.map(m=>e.jsx(rs,{facetKey:t,row:m,colors:o,stateLabel:d,onOpen:n},m.value))}),h&&l&&r&&e.jsxs("button",{type:"button",onClick:()=>r(l.value),className:"mt-2 inline-flex items-center gap-1 text-2xs text-accent hover:text-accent-hover transition-colors",children:["More ",e.jsx(Tt,{className:"w-3 h-3"})]})]})}function os({entityKey:t,sliceKey:s,value:l,headerGroups:i,headerTotal:o,window:d,find:n,colors:r,stateLabel:h,onOpen:u,onTarget:m}){var M;const g={entity:t,equals:{[s]:l}},j=F({query:{...g,...n?{prefix:{[t]:n}}:{}},groupBy:{facets:[t]},measure:{kind:"dwell",window:d},orderBy:[{field:"dwellSeconds",direction:"desc"}],limit:Qe}),N=f.useMemo(()=>{var C;return ht(((C=j.data)==null?void 0:C.groups)??[],t)},[j.data,t]),y=N.map(C=>({[t]:C})),b=F(N.length?{query:{entity:t,anyOf:y},groupBy:{state:!0,facets:[t]},measure:{kind:"dwell",window:d},limit:Qe*4}:null),q=F(N.length?{query:{entity:t,anyOf:y},groupBy:{state:!0,facets:[t]},measure:{kind:"membership"}}:null),R=f.useMemo(()=>{var C,S,P;return ft(((C=j.data)==null?void 0:C.groups)??[],((S=b.data)==null?void 0:S.groups)??[],((P=q.data)==null?void 0:P.groups)??[],t)},[j.data,b.data,q.data,t]);return e.jsx(bt,{facetKey:t,sliced:!0,header:{value:l,groups:i,total:o},rows:R,colors:r,stateLabel:h,onOpen:u,onTarget:m,hasMore:((M=j.data)==null?void 0:M.overflow)??!1})}function ls({facetKey:t,rows:s,colors:l,stateLabel:i,onOpen:o,emptyText:d}){return e.jsx(bt,{facetKey:t,sliced:!1,rows:s,colors:l,stateLabel:i,onOpen:o,emptyText:d})}const Ce="entity-timeline",cs=Rt,We=12;function is({entityKey:t,periodHours:s,roles:l,scopeFacets:i,find:o,onFindChange:d,entityValue:n,onEntityChange:r,sliceKey:h=null,onSliceKeyChange:u,sliceValue:m=null,onSliceValueChange:g}){var ve,Me,qe,ke,x;const j=He(s),N=rt(),y=a=>i?{...a,facets:{...a.facets??{},...i}}:a,b=h??"",q=!!b,R=q&&!!m,M=q&&!m,[C,S]=f.useState(0),[P,v]=f.useState(as);f.useEffect(()=>{S(0)},[o,j.from,j.to,t,b,m,P]);const[te,A]=f.useState(o??""),w=f.useRef(void 0);f.useEffect(()=>()=>clearTimeout(w.current),[]),f.useEffect(()=>{A(o??"")},[o]);const $=a=>{A(a),clearTimeout(w.current),w.current=setTimeout(()=>{const p=a.trim();d(p||null)},cs)},G=f.useMemo(()=>{const a=new Map;for(const p of l)a.set(p.role,Se(p));return a},[l]),O=a=>a==null?"—":G.get(a)??a,fe=F({query:y({entity:t}),groupBy:{state:!0},measure:{kind:"dwell",window:j},orderBy:[{field:"dwellSeconds",direction:"desc"}]}),D=F({query:y({entity:t}),groupBy:{state:!0},measure:{kind:"membership"}}),V=F({query:y({entity:t}),groupBy:{},measure:{kind:"membership"},distinctBy:t}),E=F(q?{query:y({entity:t}),groupBy:{state:!0,facets:[b]},measure:{kind:"dwell",window:j},limit:200}:null),_=F(!M?{query:y({entity:t,...R?{equals:{[b]:m}}:{},...o?{prefix:{[t]:o}}:{}}),groupBy:{facets:[t]},measure:{kind:"dwell",window:j},orderBy:[{field:"dwellSeconds",direction:"desc"}],limit:P,offset:C*P}:null),z=f.useMemo(()=>{var a;return ht(((a=_==null?void 0:_.data)==null?void 0:a.groups)??[],t)},[_==null?void 0:_.data,t]),I=z.length?{entity:t,anyOf:z.map(a=>({[t]:a}))}:null,Y=F(I?{query:y(I),groupBy:{state:!0,facets:[t]},measure:{kind:"dwell",window:j},limit:P*10}:null),ne=F(I?{query:y(I),groupBy:{state:!0,facets:[t]},measure:{kind:"membership"}}:null),ge=f.useMemo(()=>{var a,p,U;return ft(((a=_==null?void 0:_.data)==null?void 0:a.groups)??[],((p=Y.data)==null?void 0:p.groups)??[],((U=ne.data)==null?void 0:U.groups)??[],t)},[_==null?void 0:_.data,Y.data,ne.data,t]),de=f.useRef(()=>{}),Ne=f.useRef(a=>de.current(a)).current,xe=f.useRef(null),ae=f.useRef(!1);f.useEffect(()=>{N&&n!==xe.current&&(xe.current=n,n?N.setPanel(e.jsx(De,{facetKey:t,value:n,entity:t,intervalColor:Ne}),{key:Ce,width:420}):(ae.current=!1,N.closePanel(Ce)))},[n,t,N]),f.useEffect(()=>{if(!(!N||!n)){if(N.open&&N.ownerKey===Ce){ae.current=!0;return}ae.current&&(ae.current=!1,r(null))}},[N,n,r]);const c=f.useRef(N);c.current=N,f.useEffect(()=>()=>{var a;xe.current&&((a=c.current)==null||a.closePanel(Ce))},[]);const{data:k}=_t(),L=f.useMemo(()=>((k==null?void 0:k.keys)??[]).filter(a=>a!==t),[k,t]),T=(((ve=fe.data)==null?void 0:ve.groups)??[]).filter(a=>(a.dwellSeconds??0)>0),B=f.useMemo(()=>{var a;return lt([...T,...((a=D.data)==null?void 0:a.groups)??[]].map(p=>({label:p.state??"—",weight:p.dwellSeconds??p.count??0})))},[T,D.data]),Q=new Map((((Me=D.data)==null?void 0:Me.groups)??[]).map(a=>[a.state??"—",a.count??0])),Z=((ke=(qe=V.data)==null?void 0:qe.groups[0])==null?void 0:ke.count)??null,X=f.useMemo(()=>new Set(l.filter(a=>a.entity_state_source==="subtype").map(a=>a.role)),[l]);de.current=a=>{const p=X.has(a.role)?a.subtype??a.role:a.role;return B.get(p)};const J=f.useMemo(()=>{var a;return q?Kt(((a=E.data)==null?void 0:a.groups)??[],b,We):[]},[q,E.data,b]),ue=f.useMemo(()=>{var p;const a=new Set;for(const U of((p=E.data)==null?void 0:p.groups)??[])(U.dwellSeconds??0)>0&&U.facets[b]!=null&&a.add(U.facets[b]);return a.size},[E.data,b]),me=f.useMemo(()=>{var p;if(!R)return{groups:[],total:0};const a=(((p=E.data)==null?void 0:p.groups)??[]).filter(U=>U.facets[b]===m);return{groups:a,total:Fe(a)}},[R,E.data,b,m]),ye=((x=_==null?void 0:_.data)==null?void 0:x.overflow)??!1,K=Be(_==null?void 0:_.error),Te=q&&Be(E.error);return e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-2 pt-4 pb-4 flex items-stretch gap-6 border-b border-surface-border/40",children:[T.length>0?e.jsx(ss,{groups:T,colors:B,stateLabel:O,nowByState:Q,periodHours:s,tracked:Z,entityKey:t}):e.jsx("p",{className:"flex-1 text-2xs text-text-quaternary self-center",children:"No tracked time in this window."}),e.jsxs("div",{className:"shrink-0 w-56 space-y-2.5 self-center",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Slice by"}),e.jsxs("select",{value:b,onChange:a=>u==null?void 0:u(a.target.value||null),className:"select text-xs font-mono w-full",children:[e.jsx("option",{value:"",children:"— none —"}),L.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),e.jsx("input",{type:"text",value:te,onChange:a=>$(a.target.value),placeholder:`Find by ${t}…`,"aria-label":`Find by ${t}`,className:"w-full bg-transparent border-b border-surface-border/60 focus:border-accent focus:outline-none text-xs font-mono text-text-primary placeholder:text-text-quaternary pb-0.5 transition-colors"})]})]}),R&&e.jsxs("div",{className:"shrink-0 px-2 pt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>g==null?void 0:g(null),className:"inline-flex items-center gap-1 text-2xs text-accent hover:text-accent-hover transition-colors shrink-0",children:[e.jsx(Wt,{className:"w-3 h-3"})," all ",b]}),e.jsx("span",{className:"font-mono text-xs text-text-primary shrink-0",children:m}),e.jsx(ze,{groups:me.groups,colors:B,height:"h-2",className:"flex-1 max-w-md"}),e.jsx("span",{className:"font-mono tabular-nums text-2xs text-text-tertiary shrink-0",children:he(me.total*1e3)})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto px-2 py-4",children:M?Te?e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Slicing requires full read access to the system's queues."}):J.length===0?e.jsx("p",{className:"text-2xs text-text-quaternary",children:"No tracked time for this slice in the window."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-6 min-w-max",children:J.map(a=>e.jsx(os,{entityKey:t,sliceKey:b,value:a.value,headerGroups:a.groups,headerTotal:a.total,window:j,find:o,colors:B,stateLabel:O,onOpen:r,onTarget:p=>g==null?void 0:g(p)},a.value))}),ue>We&&e.jsxs("p",{className:"text-2xs text-text-quaternary pt-4",children:["Showing the top ",We," of ",ue," ",e.jsx("span",{className:"font-mono",children:b})," values — a facet this wide isn't a good slice dimension."]})]}):K?e.jsx("p",{className:"text-2xs text-text-quaternary",children:"The per-entity view requires full read access to the system's queues."}):e.jsx(ls,{facetKey:t,rows:ge,colors:B,stateLabel:O,onOpen:r,emptyText:o?`No ${t} starts with “${o}” in this window.`:"No entities tracked in this window."})}),!M&&e.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface/95 px-2 pt-2 pb-3 flex items-center gap-3 text-2xs",children:[e.jsx("button",{disabled:C===0,onClick:()=>S(C-1),className:"text-text-tertiary hover:text-accent transition-colors disabled:opacity-40 disabled:hover:text-text-tertiary",children:"Prev"}),e.jsxs("span",{className:"font-mono tabular-nums text-text-quaternary",children:["page ",C+1]}),e.jsx("button",{disabled:!ye,onClick:()=>S(C+1),className:"text-text-tertiary hover:text-accent transition-colors disabled:opacity-40 disabled:hover:text-text-tertiary",children:"Next"}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 text-text-quaternary",children:[e.jsx("span",{children:"per page"}),e.jsx("select",{value:P,onChange:a=>v(Number(a.target.value)),"aria-label":"Results per page",className:"select text-2xs font-mono py-0.5",children:ns.map(a=>e.jsx("option",{value:a,children:a},a))})]})]})]})}function ds({fragments:t,activeFragment:s,lenses:l,activeLens:i,onSelectFragment:o,onSelectLens:d}){const[n,r]=f.useState(!1),h=f.useRef(null);f.useEffect(()=>{if(!n)return;const g=N=>{h.current&&!h.current.contains(N.target)&&r(!1)},j=N=>{N.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",j)}},[n]);const u=t.find(g=>g.origin===s)??t[0],m=i?null:(u==null?void 0:u.origin)??null;return e.jsxs("div",{ref:h,className:"relative",title:"Board: pace a segment of roles, or read a metadata facet's trend",children:[e.jsxs("button",{type:"button",onClick:()=>r(g=>!g),className:"group flex items-baseline gap-1.5","aria-expanded":n,"aria-haspopup":"listbox","aria-label":"Board view",children:[e.jsx("span",{className:"text-2xs uppercase tracking-widest text-text-quaternary",children:"View"}),e.jsx("span",{className:"text-xs font-medium text-accent",children:i?e.jsxs(e.Fragment,{children:["by ",e.jsx("span",{className:"font-mono",children:i})]}):(u==null?void 0:u.title)??"Pace Board"}),e.jsx(dt,{className:`w-3 h-3 self-center shrink-0 text-text-tertiary group-hover:text-accent transition-transform ${n?"rotate-180":""}`,strokeWidth:1.5})]}),n&&e.jsxs("div",{role:"listbox",className:"absolute z-[100] top-full right-0 mt-1.5 min-w-[19rem] max-h-96 overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[e.jsx(Ze,{children:"Pace Board"}),t.map(g=>e.jsx(jt,{label:g.title,note:`${g.roleCount} role${g.roleCount===1?"":"s"} · ${g.pending} pending`,jeopardy:g.jeopardy,active:g.origin===m,onClick:()=>{o(g.origin),r(!1)}},g.origin)),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{children:"Trend Board"}),l.map(g=>e.jsx(xs,{lens:g,active:i===g,fetchCount:n,onClick:()=>{d(g),r(!1)}},g))]})]})]})}function Ze({children:t}){return e.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:t})}function jt({label:t,note:s,jeopardy:l=0,active:i,mono:o,onClick:d}){return e.jsxs("button",{type:"button",role:"option","aria-selected":i,onClick:d,className:`w-full text-left pl-3 pr-2.5 py-1.5 flex items-baseline gap-2.5 border-l-2 transition-colors ${i?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[e.jsx("span",{className:`text-xs font-medium truncate ${o?"font-mono":""}`,children:t}),s&&e.jsx("span",{className:`ml-auto text-2xs font-mono tabular-nums shrink-0 ${i?"text-accent/70":"text-text-quaternary"}`,children:s}),e.jsx("span",{className:"w-9 shrink-0 flex items-center justify-end gap-0.5 text-2xs font-mono tabular-nums text-status-warning",title:l>0?`${l} in jeopardy`:void 0,children:l>0&&e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"w-3 h-3 shrink-0",strokeWidth:2}),l]})})]})}function xs({lens:t,active:s,fetchCount:l,onClick:i}){var n,r;const d=(r=(n=F({query:{entity:t},groupBy:{},measure:{kind:"membership"},distinctBy:t},{enabled:l}).data)==null?void 0:n.groups[0])==null?void 0:r.count;return e.jsx(jt,{label:`by ${t}`,mono:!0,note:d!=null?`${d} in queue`:null,active:s,onClick:i})}const Xe=800,Ve=270,re=28,us=60,Oe=24,ms=72,Ue=Ve-Oe-ms,H=Oe+Ue;function ps(t,s){return!s||!t||t.height<=0||t.width<=0?Xe:Math.max(Xe,Math.round(Ve*t.width/t.height))}const W="0.5s cubic-bezier(0.4, 0, 0.2, 1)",Je=9;function hs(t){return`M ${(t.x-Je).toFixed(1)} ${t.y.toFixed(1)} L ${(t.x+Je).toFixed(1)} ${t.y.toFixed(1)}`}function je(t){if(t.length===0)return"";if(t.length===1)return hs(t[0]);const s=[];for(let l=0;l<t.length-1;l++){const i=t[Math.max(0,l-1)],o=t[l],d=t[l+1],n=t[Math.min(t.length-1,l+2)],r=(o.x+(d.x-i.x)/6).toFixed(1),h=(o.y+(d.y-i.y)/6).toFixed(1),u=(d.x-(n.x-o.x)/6).toFixed(1),m=(d.y-(n.y-o.y)/6).toFixed(1);l===0&&s.push(`M ${o.x.toFixed(1)} ${o.y.toFixed(1)}`),s.push(`C ${r} ${h}, ${u} ${m}, ${d.x.toFixed(1)} ${d.y.toFixed(1)}`)}return s.join(" ")}function fs(t,s){if(t.length<2||s.length<2)return"";const l=je(t),i=[...s].reverse(),o=je(i),d=o.slice(o.indexOf("C"));return`${l} L ${i[0].x.toFixed(1)} ${i[0].y.toFixed(1)} ${d} Z`}function Ke(t){return t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function _e(t){return t.length>0?t[t.length-1]:void 0}function gs(t){return[1,2,5,10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4].filter(l=>l>0&&l<t*.98)}function ys(t){return[.25,.5,.75].map(l=>Math.round(l*t)).filter(l=>l>0)}const ce="rgb(var(--lt-status-claimed-graphic))",we="rgb(var(--lt-status-queued-graphic))",ee="rgb(var(--lt-status-success-graphic))",ie="rgb(var(--lt-text-quaternary))",$e="rgb(var(--lt-status-error))";function Ae(t,s){return t.replace(/\)$/,` / ${s})`)}const bs=13;function js(t,s){const l=[...t].sort((n,r)=>n.y-r.y);let i=-1/0;const o=l.map(n=>{const r=Math.max(n.y+3,i+bs);return i=r,{...n,labelY:r}}),d=o.length>0?o[o.length-1].labelY-s:0;if(d>0)for(const n of o)n.labelY-=d;return o}function ws({stations:t,selectedRole:s,onSelect:l,onUpstreamSelect:i,onCmdClick:o,periodHours:d,logScale:n=!1,fill:r=!1}){const[h,u]=f.useState(null),[m,g]=Xt(),j=t.length;if(j===0)return null;const N=ps(g,r),y=N-re-us,b=re+y,q=c=>j===1?re+y/2:re+c/(j-1)*y,R=new Map(t.map((c,k)=>[c.role,q(k)])),M=t.map((c,k)=>{var B,Q,Z,X;const L=c.target_per_hour??null,T=L!=null?L*d:null;return{idx:k,x:q(k),expected:T,actual:((B=c.metric)==null?void 0:B.resolved)??0,active:((Q=c.metric)==null?void 0:Q.claimed)??0,pending:((Z=c.metric)==null?void 0:Z.pending)??0,priorityCount:((X=c.metric)==null?void 0:X.priority_count)??0}}),C=M.some(c=>c.expected!=null),P=Math.max(1,...M.map(c=>c.expected??0),...M.map(c=>c.actual),...M.map(c=>c.expected!=null?c.pending:0))*1.15,v=n?c=>{const k=Math.log(1+P);return Oe+Ue*(1-Math.log(1+Math.max(0,c))/k)}:c=>Oe+Ue*(1-Math.max(0,Math.min(c,P))/P),te=n?gs(P):ys(P),A=M.filter(c=>c.expected!=null),w=A.map(c=>({...c,y:v(c.expected)})),$=A.map(c=>({...c,y:v(c.actual)})),G=A.map(c=>({...c,y:v(c.active)})),O=A.map(c=>({...c,y:v(c.pending)})),fe=je(w),D=je($),V=je(G),E=je(O),se=_e($),_=_e(w),z=_e(G),I=_e(O),Y=$.length>=2&&se?`${D} L ${se.x.toFixed(1)} ${H} L ${$[0].x.toFixed(1)} ${H} Z`:"",ne=A.some(c=>c.pending>0||c.active>0),ge=ne&&G.length>=2&&z?`${V} L ${z.x.toFixed(1)} ${H} L ${G[0].x.toFixed(1)} ${H} Z`:"",de=ne?fs(O,G):"",Ne=A.some(c=>c.active>0),xe=A.some(c=>c.pending>c.active),ae=js([_?{key:"target",text:"Target",color:ie,y:_.y}:null,se?{key:"actual",text:"Resolved",color:ee,y:se.y}:null,Ne&&z?{key:"active",text:"Claimed",color:ce,y:z.y}:null,xe&&I?{key:"queued",text:"Pending",color:we,y:I.y}:null].filter(Boolean),H+4);return e.jsx("div",{ref:m,className:r?"w-full h-full min-h-0":"w-full",children:e.jsxs("svg",{viewBox:`0 0 ${N} ${Ve}`,className:r?"w-full h-full":"w-full",preserveAspectRatio:"xMidYMid meet",style:{display:"block",...r?{}:{height:"auto"}},children:[te.map(c=>{const k=v(c);return e.jsxs("g",{children:[e.jsx("line",{x1:re,y1:k,x2:b,y2:k,className:"stroke-surface-border",strokeWidth:.5,opacity:n?.45:.3,strokeDasharray:n?"2 5":void 0,style:{transition:`y1 ${W}, y2 ${W}`}}),e.jsx("text",{x:re-4,y:k+2.5,textAnchor:"end",fontSize:6,fontFamily:"ui-monospace, monospace",opacity:.35,className:"fill-text-quaternary",children:Ke(c)})]},`grid-${c}`)}),t.map(c=>{if(!c.parent_role)return null;const k=R.get(c.parent_role);if(k==null)return null;const L=q(t.findIndex(T=>T.role===c.role));return e.jsx("line",{x1:k,y1:H,x2:L,y2:H,className:"stroke-surface-border",strokeWidth:.75},`dep-${c.role}`)}),Y&&e.jsx("path",{d:Y,opacity:.05,style:{fill:ee,transition:`d ${W}`}}),ge&&e.jsx("path",{d:ge,opacity:.12,style:{fill:ce,transition:`d ${W}`}}),de&&e.jsx("path",{d:de,opacity:.12,style:{fill:we,transition:`d ${W}`}}),fe&&e.jsx("path",{d:fe,fill:"none",strokeWidth:.75,strokeDasharray:"2 3",strokeLinecap:"round",opacity:.7,style:{stroke:ie,transition:`d ${W}`}}),w.map(c=>e.jsxs("g",{transform:`translate(${c.x} ${c.y})`,style:{transition:`transform ${W}`},children:[e.jsx("circle",{r:2,opacity:.8,style:{fill:ie}}),e.jsx("text",{y:-5,textAnchor:"middle",fontSize:6.5,fontFamily:"ui-monospace, monospace",fontWeight:"500",opacity:.7,style:{fill:ie},children:Math.round(c.expected)})]},`tval-${c.idx}`)),ne&&E&&e.jsx("path",{d:E,fill:"none",strokeWidth:.75,strokeDasharray:"2 3",strokeLinecap:"round",opacity:.55,style:{stroke:we,transition:`d ${W}`}}),V&&e.jsx("path",{d:V,fill:"none",strokeWidth:.75,strokeDasharray:"2 3",strokeLinecap:"round",opacity:.5,style:{stroke:ce,transition:`d ${W}`}}),D&&e.jsx("path",{d:D,fill:"none",strokeWidth:.6,strokeLinejoin:"round",strokeLinecap:"round",opacity:.65,style:{stroke:ee,transition:`d ${W}`}}),G.map((c,k)=>{if(c.pending<=0&&c.active<=0)return null;const L=Math.max(2.5,Math.min(5,2.5+c.active/10)),T=c.pending>c.active,B=Math.min(O[k].y-4,c.y-L-4);return e.jsxs("g",{children:[c.pending>0&&e.jsx("text",{x:c.x,y:B,textAnchor:"middle",fontSize:7.5,fontFamily:"ui-monospace, monospace",fontWeight:"600",style:{fill:T?we:"rgb(var(--lt-text-tertiary))",transition:`y ${W}`},children:c.pending}),e.jsxs("g",{transform:`translate(${c.x} ${c.y})`,style:{transition:`transform ${W}`},children:[e.jsx("circle",{r:L,opacity:.85,style:{fill:ce}}),c.active>0&&e.jsx("text",{y:L+9,textAnchor:"middle",fontSize:7.5,fontFamily:"ui-monospace, monospace",fontWeight:"600",style:{fill:ce},children:c.active})]})]},`active-${c.idx}`)}),M.map(c=>{var ye;const k=t[c.idx],L=c.x,T=c.expected!=null?v(c.actual):H,B=Math.max(2.25,Math.min(4,2.25+c.actual/160)),Q=k.role===s,Z=h===c.idx,X=c.expected==null?"idle · set a target rate to plot pace":`${c.actual} resolved · target ${Math.round(c.expected)}`+(c.pending>c.active?` · ${c.pending-c.active} pending`:"")+(c.active>0?` · ${c.active} claimed`:"")+(c.priorityCount>0?` · ${c.priorityCount} in jeopardy`:""),J=X.length*5.5+20,ue=Math.max(re+J/2+4,Math.min(b-J/2-4,L)),me=T-B-10;return e.jsxs("g",{onClick:K=>{K.metaKey||K.ctrlKey?(K.stopPropagation(),o==null||o(k.role)):l(k.role)},onMouseEnter:()=>u(c.idx),onMouseLeave:()=>u(null),style:{cursor:"pointer"},children:[e.jsxs("g",{transform:`translate(${L} ${T})`,style:{transition:`transform ${W}`},children:[e.jsx("circle",{r:22,fill:"transparent"}),e.jsx("circle",{r:B,opacity:.9,style:{fill:ee,transition:`r ${W}`}}),c.expected!=null&&e.jsx("text",{y:-B-5,textAnchor:"middle",fontSize:9.5,fontFamily:"ui-monospace, monospace",fontWeight:"500",style:{fill:ee},children:Ke(c.actual)}),Z&&!Q&&e.jsx("circle",{r:B+3,fill:"none",strokeWidth:1,opacity:.4,style:{stroke:ee}}),Q&&e.jsx("circle",{r:B+4,fill:"none",className:"stroke-accent",strokeWidth:2})]}),(((ye=k.upstream_roles)==null?void 0:ye.length)??0)>0&&e.jsxs("g",{transform:`translate(${L-20} ${H})`,onClick:K=>{K.stopPropagation(),i==null||i(k.upstream_roles[0])},style:{cursor:"pointer"},children:[e.jsx("title",{children:`Fed by ${k.upstream_roles.join(", ")} — click to view that sequence`}),e.jsx("circle",{r:9,cy:-6,fill:"transparent"}),e.jsx("path",{d:"M -7 -14 C -3 -14 -1 -9 0 -2",fill:"none",className:"stroke-text-quaternary",strokeWidth:1,strokeDasharray:"2 2",strokeLinecap:"round"}),e.jsx("path",{d:"M 0 -2 L 8 -2",className:"stroke-text-quaternary",strokeWidth:1,strokeLinecap:"round"}),e.jsx("path",{d:"M 8 -2 l -3.5 -2 v 4 z",className:"fill-text-quaternary"})]}),e.jsx("text",{x:L,y:H+(c.idx%2===0?14:27),textAnchor:"middle",fontSize:9.5,className:"fill-text-tertiary",fontFamily:"ui-sans-serif, sans-serif",fontWeight:"500",children:Se(k)}),Z&&e.jsxs("g",{children:[e.jsx("rect",{x:ue-J/2,y:me-16,width:J,height:19,rx:3,className:"fill-text-primary",opacity:.88}),e.jsx("text",{x:ue,y:me-3,textAnchor:"middle",fontSize:8.5,className:"fill-surface",fontFamily:"ui-monospace, monospace",children:X})]})]},k.role)}),!C&&e.jsx("text",{x:re+y/2,y:H+48,textAnchor:"middle",fontSize:8.5,className:"fill-text-quaternary",fontFamily:"ui-sans-serif, sans-serif",children:"Set target_per_hour on each role in Admin → Roles to enable the pace chart"}),ae.map(c=>e.jsx("text",{x:b+6,y:c.labelY,fontSize:8,fontFamily:"ui-sans-serif, sans-serif",fontWeight:c.key==="actual"?700:500,opacity:c.key==="active"?.85:1,style:{fill:c.color,transition:`y ${W}`},children:c.text},c.key))]})})}function wt(t){const s=t.priority_facet?`metadata.${t.priority_facet}`:"created_at",l=JSON.stringify([{field:s,direction:"asc"}]);return`/escalations/available?role=${encodeURIComponent(t.role)}&jeopardy=1&view=table&orderBy=${encodeURIComponent(l)}`}function Ns({role:t,periodHours:s,onOpenEntity:l}){var M,C,S,P,v,te,A;const i=He(s),o=t.entity_facet,[d,n]=f.useState(!1),[,r]=pt(),h=()=>{o&&r(w=>{const $=new URLSearchParams(w);return $.set("lens",o),$})},u=F({query:{roles:[t.role]},groupBy:{columns:["subtype"]},measure:{kind:"dwell",window:i},orderBy:[{field:"dwellSeconds",direction:"desc"}]}),m=F({query:{roles:[t.role]},groupBy:{columns:["subtype"]},measure:{kind:"membership"},orderBy:[{field:"count",direction:"desc"}]}),g=F(o?{query:{roles:[t.role]},groupBy:{},measure:{kind:"membership"},distinctBy:o}:null),j=F(o&&d?{query:{roles:[t.role],exists:[o]},groupBy:{facets:[o]},measure:{kind:"dwell",window:i},orderBy:[{field:"dwellSeconds",direction:"desc"}],limit:8}:null),N=f.useMemo(()=>{var w,$;return ct([...((w=u.data)==null?void 0:w.groups)??[],...(($=m.data)==null?void 0:$.groups)??[]])},[u.data,m.data]);if(Be(u.error))return e.jsx("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Analytics require full read access to this station's queue."})});const y=(((M=u.data)==null?void 0:M.groups)??[]).filter(w=>(w.dwellSeconds??0)>0),b=y.reduce((w,$)=>w+($.dwellSeconds??0),0),q=(((C=m.data)==null?void 0:C.groups)??[]).filter(w=>(w.count??0)>0),R=((P=(S=g.data)==null?void 0:S.groups[0])==null?void 0:P.count)??null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2.5",children:"Where the time went"}),b>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 flex rounded-full overflow-hidden bg-surface-sunken mb-2.5",children:y.map(w=>e.jsx("div",{style:{width:`${(w.dwellSeconds??0)/b*100}%`,backgroundColor:N.get(pe(w.subtype))}},pe(w.subtype)))}),e.jsx("div",{className:"space-y-1",children:y.map(w=>e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:N.get(pe(w.subtype))}}),e.jsx("span",{className:`font-mono truncate flex-1 ${w.subtype?"text-text-secondary":"text-text-tertiary"}`,children:Ee(w.subtype)}),e.jsx("span",{className:"font-mono tabular-nums text-text-secondary shrink-0",children:he((w.dwellSeconds??0)*1e3)}),e.jsxs("span",{className:"font-mono tabular-nums text-text-quaternary w-8 text-right shrink-0",children:[Math.round((w.dwellSeconds??0)/b*100),"%"]})]},pe(w.subtype)))}),((v=u.data)==null?void 0:v.overflow)&&e.jsx("p",{className:"text-2xs text-text-quaternary mt-1.5",children:"more groups exist — narrow the window"})]}):e.jsx("p",{className:"text-2xs text-text-quaternary",children:"No tracked time in this window."})]}),e.jsxs("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2.5",children:"In queue now"}),o&&R!=null&&e.jsxs("button",{onClick:h,className:"group flex items-center gap-1 text-2xs mb-2 text-left",title:`Open the ${o} lens — the whole system, entity-first`,children:[e.jsx("span",{className:"text-xs font-mono font-semibold text-text-primary tabular-nums",children:R})," ",e.jsx("span",{className:"font-mono text-text-tertiary group-hover:text-accent transition-colors",children:o}),e.jsx("span",{className:"text-text-quaternary",children:" in queue"}),e.jsx(Dt,{className:"w-3 h-3 text-text-quaternary group-hover:text-accent transition-colors"})]}),q.length>0?e.jsx("div",{className:"space-y-1",children:q.map(w=>e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:N.get(pe(w.subtype))}}),e.jsx("span",{className:`font-mono truncate flex-1 ${w.subtype?"text-text-secondary":"text-text-tertiary"}`,children:Ee(w.subtype)}),e.jsx("span",{className:"font-mono tabular-nums text-text-primary shrink-0",children:w.count})]},pe(w.subtype)))}):e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Queue clear."}),o&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{onClick:()=>n(w=>!w),className:"flex items-center gap-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:[d?e.jsx(dt,{className:"w-3 h-3"}):e.jsx(Ut,{className:"w-3 h-3"}),"By entity"]}),d&&(Be(j.error)?e.jsx("p",{className:"text-2xs text-text-quaternary mt-1.5",children:"Requires full read access to this station's queue."}):e.jsxs("div",{className:"space-y-1 mt-1.5",children:[(((te=j.data)==null?void 0:te.groups)??[]).map(w=>{const $=w.facets[o];return $==null?null:e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"font-mono truncate flex-1 text-text-secondary",title:$,children:$}),e.jsx("span",{className:"font-mono tabular-nums text-text-secondary shrink-0",children:he((w.dwellSeconds??0)*1e3)}),e.jsx("button",{className:"icon-link shrink-0",title:"Open timeline",onClick:()=>l(o,$),children:e.jsx(it,{className:"w-3 h-3"})})]},$)}),j.data&&j.data.groups.length===0&&e.jsx("p",{className:"text-2xs text-text-quaternary",children:"No entities in this window."}),((A=j.data)==null?void 0:A.overflow)&&e.jsx("p",{className:"text-2xs text-text-quaternary",children:"top 8 by dwell"})]}))]})]})]})}const Nt=["15m","1h","24h","7d","30d"],vs=t=>Nt.includes(t),ks={"15m":.25,"1h":1,"24h":24,"7d":168,"30d":720};function Re(t){if(t==null)return"—";if(t<1){const s=Math.round(t*60);return s<=0?"< 1s":`${s}s`}return t<60?`${t.toFixed(0)}m`:`${(t/60).toFixed(1)}h`}function Pe({label:t,value:s}){return e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-2xs text-text-tertiary uppercase tracking-wider",children:t}),e.jsx("span",{className:"text-xs font-mono font-medium text-text-primary tabular-nums",children:s})]})}function $s({period:t,onChange:s}){return e.jsx("div",{className:"flex items-center gap-1 mb-4",children:Nt.map(l=>e.jsx("button",{onClick:()=>s(l),className:`px-2 py-0.5 text-2xs font-mono rounded transition-colors ${t===l?"bg-accent/10 text-accent font-semibold":"icon-link"}`,children:l},l))})}function Ss({role:t,globalPeriod:s,scopeFacets:l,onClose:i}){const[o,d]=f.useState(vs(s)?s:"24h"),{data:n}=ot(o,l),r=n==null?void 0:n.stations.find(N=>N.role===t.role),h=t.sla_minutes??void 0,u=t.target_per_hour??void 0,m=t.worker_count??void 0,g=rt(),j=f.useCallback((N,y)=>{g==null||g.setPanel(t.entity_facet?e.jsx(De,{facetKey:N,value:y,entity:t.entity_facet}):e.jsx(De,{facetKey:N,value:y,role:t.role}),{key:"entity-timeline",width:420})},[g,t.role,t.entity_facet]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-sm font-bold text-text-primary",children:Se(t)}),e.jsx("span",{className:"text-2xs font-mono text-text-secondary",children:t.role})]}),t.description&&e.jsx("p",{className:"text-2xs text-text-tertiary mt-1 line-clamp-2 leading-relaxed",children:t.description})]}),e.jsx("button",{onClick:i,className:"icon-link mt-0.5 shrink-0 ml-2",children:e.jsx(Gt,{className:"w-4 h-4"})})]}),r&&r.priority_count>0&&e.jsxs(le,{to:wt(t),className:"flex items-center justify-between group mb-4",children:[e.jsxs("span",{className:"text-2xs",style:{color:$e},children:[r.priority_count," in jeopardy — pull oldest first"]}),e.jsx(Ht,{className:"w-3 h-3 transition-colors",style:{color:$e}})]}),e.jsx($s,{period:o,onChange:d}),(u||h||m)&&e.jsxs("div",{className:"flex items-center gap-6 mb-6 text-2xs border-b border-surface-border/30 pb-5",children:[u&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-mono font-semibold text-text-primary text-sm",children:[u,"/h"]}),e.jsx("div",{className:"text-text-quaternary uppercase tracking-wider text-[8.5px] mt-0.5",children:"target"})]}),h&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-mono font-semibold text-text-primary text-sm",children:[h,"m"]}),e.jsx("div",{className:"text-text-quaternary uppercase tracking-wider text-[8.5px] mt-0.5",children:"SLA"})]}),m&&e.jsxs("div",{children:[e.jsx("div",{className:"font-mono font-semibold text-text-primary text-sm",children:m}),e.jsx("div",{className:"text-text-quaternary uppercase tracking-wider text-[8.5px] mt-0.5",children:"workers"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-text-quaternary uppercase tracking-wider mb-2",children:"Wait (queue)"}),e.jsx(Pe,{label:"P99",value:Re((r==null?void 0:r.wait.p99)??null)}),e.jsx(Pe,{label:"avg",value:Re((r==null?void 0:r.wait.avg)??null)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-text-quaternary uppercase tracking-wider mb-2",children:"Work (proc.)"}),e.jsx(Pe,{label:"P99",value:Re((r==null?void 0:r.work.p99)??null)}),e.jsx(Pe,{label:"avg",value:Re((r==null?void 0:r.work.avg)??null)})]})]}),h&&e.jsx("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-2xs text-text-tertiary",children:"SLA target"}),e.jsxs("span",{className:"text-xs font-mono text-text-secondary",children:[h,"m"]})]})}),e.jsx(Ns,{role:t,periodHours:ks[o],onOpenEntity:j})]})}function Ms({allMetrics:t,orderedRoles:s,period:l}){const i=t.reduce((u,m)=>u+m.pending,0),o=t.reduce((u,m)=>u+m.resolved,0),d=t.reduce((u,m)=>u+m.priority_count,0),n=new Map(t.map(u=>[u.role,u])),r=t.filter(u=>u.priority_count>0).length,h=t.filter(u=>u.pending>0).length;return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-2xs text-text-quaternary uppercase tracking-wider mb-3",children:["Pipeline · ",l]}),e.jsx("div",{className:"mb-4",children:r>0?e.jsxs("p",{className:"text-2xs",style:{color:$e},children:[r," role",r>1?"s":""," with items in jeopardy"]}):h>0?e.jsxs("p",{className:"text-2xs text-status-warning",children:[h," role",h>1?"s":""," with backlog"]}):o>0?e.jsx("p",{className:"text-2xs text-status-success",children:"Flowing — queue clear"}):e.jsx("p",{className:"text-2xs text-text-quaternary",children:"Quiet — awaiting work"})}),e.jsxs("div",{className:"space-y-1.5 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider",children:"Pending"}),e.jsx("span",{className:`text-xs font-mono tabular-nums ${i>0?"text-text-primary font-semibold":"text-text-quaternary"}`,children:i})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider",children:["Resolved · ",l]}),e.jsx("span",{className:"text-xs font-mono tabular-nums text-text-secondary",children:o})]}),d>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider",children:"Priority"}),e.jsx("span",{className:"text-xs font-mono tabular-nums font-semibold",style:{color:$e},children:d})]})]}),e.jsx("div",{className:"border-t border-surface-border/40 pt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider flex-1",children:"Role"}),e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider w-8 text-right shrink-0",children:"pend"}),e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider w-8 text-right shrink-0",children:"clmd"}),e.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider w-8 text-right shrink-0",children:"res"})]})}),e.jsx("div",{className:"space-y-0.5",children:s.map(u=>{const m=n.get(u.role),g=(m==null?void 0:m.pending)??0,j=(m==null?void 0:m.claimed)??0,N=(m==null?void 0:m.resolved)??0,y=(m==null?void 0:m.priority_count)??0,b=u.title||u.role,q=y>0,R=g>0;return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`text-2xs font-mono flex-1 truncate ${R?"text-text-primary":"text-text-quaternary"}`,title:b,children:b}),e.jsx("span",{className:"text-[0.625rem] leading-none font-semibold tabular-nums w-4 text-right shrink-0",style:{color:$e},title:q?`${y} priority — pull oldest first`:void 0,children:q?y:""}),e.jsx("span",{className:`text-2xs font-mono tabular-nums w-8 text-right shrink-0 ${R?"text-text-primary font-semibold":"text-text-quaternary"}`,children:g>0?g:"—"}),e.jsx("span",{className:`text-2xs font-mono tabular-nums w-8 text-right shrink-0 ${j>0?"text-accent font-semibold":"text-text-quaternary"}`,children:j>0?j:"—"}),e.jsx("span",{className:`text-2xs font-mono tabular-nums w-8 text-right shrink-0 ${N>0?"text-text-secondary":"text-text-quaternary"}`,children:N>0?N:"—"})]},u.role)})}),e.jsx("p",{className:"text-2xs text-text-quaternary mt-5",children:"Select a station for queue detail."})]})}function qs({role:t,allMetrics:s,orderedRoles:l,globalPeriod:i,scopeFacets:o,mixGroups:d,onClose:n}){return e.jsx("div",{className:"w-[280px] shrink-0 px-7 py-10 flex flex-col overflow-y-auto min-h-0",children:t?e.jsx(Ss,{role:t,globalPeriod:i,scopeFacets:o,onClose:n}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{allMetrics:s,orderedRoles:l,period:i}),e.jsx(Cs,{mixGroups:d,orderedRoles:l})]})})}function Cs({mixGroups:t,orderedRoles:s}){const l=new Set(s.map(r=>r.role)),i=(t??[]).filter(r=>r.role&&l.has(r.role)&&(r.dwellSeconds??0)>0);if(i.length===0)return null;const o=new Map(s.map(r=>[r.role,r.title||r.role])),d=et(i,r=>r.role),n=et(i,r=>Ee(r.subtype));return e.jsxs(e.Fragment,{children:[e.jsx(tt,{label:"Time by station",entries:d,display:r=>o.get(r)??r}),e.jsx(tt,{label:"Time by subtype",entries:n,display:r=>r})]})}function et(t,s){const l=new Map;for(const i of t){const o=s(i);l.set(o,(l.get(o)??0)+(i.dwellSeconds??0))}return[...l.entries()].sort(([,i],[,o])=>o-i)}function tt({label:t,entries:s,display:l}){const i=lt(s.map(([d,n])=>({label:d,weight:n}))),o=s.reduce((d,[,n])=>d+n,0)||1;return e.jsxs("div",{className:"border-t border-surface-border/40 pt-4 mt-5",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2.5",children:t}),e.jsx("div",{className:"h-2 flex rounded-full overflow-hidden bg-surface-sunken mb-2",children:s.map(([d,n])=>e.jsx("div",{style:{width:`${n/o*100}%`,backgroundColor:i.get(d)}},d))}),e.jsxs("div",{className:"space-y-0.5",children:[s.slice(0,6).map(([d,n])=>e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:i.get(d)}}),e.jsx("span",{className:"font-mono text-text-secondary truncate flex-1",children:l(d)}),e.jsx("span",{className:"font-mono tabular-nums text-text-tertiary shrink-0",children:he(n*1e3)}),e.jsxs("span",{className:"font-mono tabular-nums text-text-quaternary w-8 text-right shrink-0",children:[Math.round(n/o*100),"%"]})]},d)),s.length>6&&e.jsxs("p",{className:"text-2xs text-text-quaternary",children:["+",s.length-6," more"]})]})]})}function _s(t){const s=t.filter(n=>n.ops_visible),l=new Map(s.map(n=>[n.role,n])),i=new Set,d=s.filter(n=>!n.parent_role||!l.has(n.parent_role)).map(n=>{const r=[],h=[{role:n,depth:0}];for(;h.length>0;){const u=h.shift();i.has(u.role.role)||(i.add(u.role.role),r.push(u),s.filter(m=>m.parent_role===u.role.role&&!i.has(m.role)).forEach(m=>h.push({role:m,depth:u.depth+1})))}return{origin:n,stations:r}});return s.filter(n=>!i.has(n.role)).forEach(n=>d.push({origin:n,stations:[{role:n,depth:0}]})),d.sort((n,r)=>r.stations.length-n.stations.length||n.origin.role.localeCompare(r.origin.role))}const Rs=ie,Ie=Ae(ie,.12),vt=Ie,kt=Ie,$t=Ae(we,.24),St=Ae(ce,.24),Mt=Ae(ee,.24),st=["15m","1h","24h","7d","30d"],Le={"15m":.25,"1h":1,"24h":24,"7d":168,"30d":720};function Ge(t){return _s(t)}function nt(t){if(t==null)return"—";if(t<1){const s=Math.round(t*60);return s<=0?"< 1s":`${s}s`}return t<60?`${t.toFixed(0)}m`:`${(t/60).toFixed(1)}h`}function Ps(t,s){if(!s||t===0)return{pct:null,color:"bg-surface-border"};const l=t/s,i=Math.round(l*100),o=l>1?"bg-status-warning":l<.2?"bg-status-draft":"bg-status-success";return{pct:i,color:o}}function at({value:t,onSave:s}){const[l,i]=f.useState(t!=null?String(t):""),o=f.useRef(void 0),d=n=>{const r=parseInt(n,10);s(!n.trim()||isNaN(r)||r<0?null:r)};return e.jsx("input",{type:"number",min:0,step:1,value:l,onChange:n=>{const r=n.target.value;i(r),clearTimeout(o.current),o.current=setTimeout(()=>d(r),400)},onBlur:n=>{clearTimeout(o.current),d(n.target.value)},onClick:n=>n.stopPropagation(),onKeyDown:n=>n.stopPropagation(),className:"w-full bg-transparent text-xs font-mono tabular-nums text-right focus:outline-none"})}function Ls({role:t,metric:s,mixGroups:l,mixColors:i,selected:o,periodHours:d,onClick:n}){var P;const r=Ft(),{isBuilder:h,isOps:u}=At(),m=(s==null?void 0:s.pending)??0,g=(s==null?void 0:s.claimed)??0,j=(s==null?void 0:s.resolved)??0,N=(s==null?void 0:s.priority_count)??0,y=t.target_per_hour??null,{pct:b,color:q}=Ps(m,y),R=b!=null?Math.min(100,b):0,M=Bs(t.target_per_hour??null,t.sla_minutes??null,m,d),C=v=>r.mutate({role:t.role,target_per_hour:v}),S=v=>r.mutate({role:t.role,sla_minutes:v});return e.jsxs("tr",{tabIndex:0,onClick:n,onKeyDown:v=>{v.key==="Enter"&&n()},className:`cursor-pointer border-b border-surface-border/30 last:border-b-0 transition-colors ${o?"border-l-2 !border-l-accent":""}`,children:[e.jsx("td",{className:"pl-3 pr-2 py-1.5 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-bold text-text-primary truncate text-xs",children:Se(t)}),(((P=t.upstream_roles)==null?void 0:P.length)??0)>0&&e.jsx("span",{title:`Fed by ${t.upstream_roles.join(", ")}`,className:"shrink-0 leading-none",children:e.jsx(Vt,{className:"w-3 h-3 text-text-quaternary"})})]})}),e.jsx("td",{className:"hidden xl:table-cell pr-2 py-1.5 overflow-hidden",children:e.jsx("span",{className:"block font-mono text-2xs text-text-tertiary truncate",children:t.role})}),e.jsx("td",{className:"px-2 py-1.5",style:{backgroundColor:Ie},children:e.jsx(at,{value:t.target_per_hour??null,onSave:C})}),e.jsx("td",{className:"px-2 py-1.5",style:{backgroundColor:vt},children:e.jsx(at,{value:t.sla_minutes??null,onSave:S})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:kt},title:M!=null?`~${M} concurrent worker${M===1?"":"s"} to sustain ${t.target_per_hour}/h within ${t.sla_minutes}m SLA`:void 0,children:e.jsx("span",{className:`text-xs font-mono tabular-nums ${M!=null?"":"text-text-quaternary"}`,children:M??"—"})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:$t},children:e.jsx(le,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=available`,className:`text-xs font-mono tabular-nums hover:underline ${m>0?"text-text-primary font-semibold":"text-text-quaternary"}`,onClick:v=>v.stopPropagation(),children:m})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:St},children:e.jsx(le,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=claimed`,className:`text-xs font-mono tabular-nums hover:underline ${g>0?"font-semibold":"text-text-quaternary"}`,style:g>0?{color:ce}:void 0,onClick:v=>v.stopPropagation(),children:g})}),e.jsx("td",{className:"px-2 py-1.5 text-right",style:{backgroundColor:Mt},children:e.jsx(le,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=resolved`,className:`text-xs font-mono tabular-nums hover:underline ${j>0?"text-text-secondary":"text-text-quaternary"}`,style:j>0?{color:ee}:void 0,onClick:v=>v.stopPropagation(),children:j})}),e.jsx("td",{className:"hidden xl:table-cell px-2 py-1.5 text-right",children:e.jsx("span",{className:"text-xs font-mono tabular-nums text-text-secondary",children:nt((s==null?void 0:s.wait.p99)??null)})}),e.jsx("td",{className:"hidden xl:table-cell px-2 py-1.5 text-right",children:e.jsx("span",{className:"text-xs font-mono tabular-nums text-text-secondary",children:nt((s==null?void 0:s.work.p99)??null)})}),e.jsx("td",{className:"hidden lg:table-cell px-2 py-1.5",children:e.jsx(Jt,{groups:l,colors:i})}),e.jsx("td",{className:"hidden lg:table-cell px-2 py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-12 h-1.5 bg-surface-sunken rounded-full overflow-hidden shrink-0",children:e.jsx("div",{className:`h-full rounded-full ${q}`,style:{width:`${R}%`}})}),e.jsx("span",{className:`text-2xs font-mono tabular-nums ${b!=null&&b>100?"text-status-warning font-semibold":"text-text-quaternary"}`,children:b!=null?`${b}%`:"—"})]})}),e.jsx("td",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center justify-center gap-1.5",children:[e.jsx(le,{to:`/escalations/available?role=${encodeURIComponent(t.role)}&status=all`,className:"icon-link",title:"View all items in queue",onClick:v=>v.stopPropagation(),children:e.jsx(ut,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"w-3.5 flex items-center justify-center",children:(h||u)&&e.jsx(le,{to:`/admin/roles/${encodeURIComponent(t.role)}?section=pace-board`,className:"icon-link",title:"Configure this role",onClick:v=>v.stopPropagation(),children:e.jsx(Yt,{className:"w-3.5 h-3.5"})})}),e.jsx("span",{className:"w-3.5 flex items-center justify-center",children:N>0&&e.jsx(le,{to:wt(t),className:"text-status-error hover:opacity-70 transition-opacity",title:`${N} item${N===1?"":"s"} in jeopardy — pull oldest first`,onClick:v=>v.stopPropagation(),children:e.jsx(xt,{className:"w-3.5 h-3.5",strokeWidth:2})})})]})})]})}const Es=[{label:"TARGET/H",band:Ie,hue:ie,w:"w-[8%]"},{label:"SLA/M",band:vt,hue:Rs,w:"w-[7%]"},{label:"WORKERS",band:kt,hue:ie,w:"w-[8%]"},{label:"PENDING",band:$t,hue:we,w:"w-[8%]"},{label:"CLAIMED",band:St,hue:ce,w:"w-[8%]"},{label:"RESOLVED",band:Mt,hue:ee,w:"w-[8%]"}];function Bs(t,s,l,i){if(!t||!s)return null;const o=t*s/60,d=l>0?l*s/(60*i):0;return Math.ceil(o+d)}const oe="sticky top-0 z-10 bg-surface border-b border-surface-border py-1.5 text-2xs font-semibold uppercase tracking-wider whitespace-nowrap";function Os(){return e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:`${oe} pl-3 pr-2 text-left text-text-quaternary`,children:"NAME"}),e.jsx("th",{className:`${oe} hidden xl:table-cell w-[12%] pr-2 text-left text-text-quaternary`,children:"ROLE"}),Es.map(t=>e.jsx("th",{className:`${oe} ${t.w} px-2 text-right`,style:{color:t.hue,backgroundImage:`linear-gradient(${t.band}, ${t.band})`},children:t.label},t.label)),e.jsx("th",{className:`${oe} hidden xl:table-cell w-[8%] px-2 text-right text-text-quaternary`,children:"P99 WAIT"}),e.jsx("th",{className:`${oe} hidden xl:table-cell w-[8%] px-2 text-right text-text-quaternary`,children:"P99 WORK"}),e.jsx("th",{className:`${oe} hidden lg:table-cell w-[10%] px-2 text-left text-text-quaternary`,children:"MIX"}),e.jsx("th",{className:`${oe} hidden lg:table-cell w-[11%] px-2 text-left text-text-quaternary`,children:"TREND"}),e.jsx("th",{className:`${oe} w-20 px-1 text-center text-text-quaternary`,children:"ACTIONS"})]})})}function Fs(){var ke;const[t,s]=f.useState(null),[l,i]=f.useState(!1),[o,d]=f.useState(!0);Pt(),Lt();const{data:n,isLoading:r,refetch:h}=Et(),{declarations:u,values:m}=Bt(),g=f.useMemo(()=>Object.keys(m).length?m:void 0,[m]),[j,N]=f.useState(!1),[y,b]=pt(),q=Qt(),R=mt(),M=q.pathname==="/trends",C=y.get("period"),S=st.includes(C)?C:"1h",P=f.useCallback(x=>{b(a=>{const p=new URLSearchParams(a);return x==="1h"?p.delete("period"):p.set("period",x),p})},[b]),{data:v,isLoading:te,refetch:A}=ot(S,g),w=(n==null?void 0:n.roles)??[],$=(v==null?void 0:v.stations)??[],G=f.useMemo(()=>{const x=new Map($.map(p=>[p.role,p])),a=new Map;for(const p of Ge((n==null?void 0:n.roles)??[])){let U=0,Ye=0;for(const qt of p.stations){const be=x.get(qt.role.role);U+=(be==null?void 0:be.pending)??0,Ye+=(be==null?void 0:be.priority_count)??0}a.set(p.origin.role,{stations:p.stations.length,pending:U,jeopardy:Ye})}return a},[$,n]),O=f.useMemo(()=>Ge(w),[w]),fe=y.get("fragment"),D=O.find(x=>x.origin.role===fe)??O[0]??null,V=f.useCallback(x=>{s(null);const a=new URLSearchParams;x&&a.set("fragment",x),S!=="1h"&&a.set("period",S);const p=a.toString();R(p?`/pace?${p}`:"/pace")},[R,S]),E=(D==null?void 0:D.stations)??[],se=f.useMemo(()=>new Set(E.map(({role:x})=>x.role)),[E]),_=He(Le[S]),z=f.useMemo(()=>E.map(({role:x})=>x.role),[E]),{data:I}=F(z.length?{query:{roles:z,...g?{facets:g}:{}},groupBy:{columns:["role","subtype"]},measure:{kind:"dwell",window:_}}:null),Y=f.useMemo(()=>{const x=new Map;for(const a of(I==null?void 0:I.groups)??[]){if(!a.role)continue;const p=x.get(a.role)??[];p.push(a),x.set(a.role,p)}return x},[I]),ne=f.useMemo(()=>{const x=new Map;for(const[a,p]of Y)x.set(a,ct(p));return x},[Y]),ge=f.useMemo(()=>new Map,[]),de=f.useMemo(()=>$.filter(x=>se.has(x.role)),[$,se]),Ne=f.useMemo(()=>E.map(({role:x})=>({role:x.role,title:x.title,parent_role:x.parent_role,target_per_hour:x.target_per_hour??null,upstream_roles:x.upstream_roles??[],metric:$.find(a=>a.role===x.role)})),[E,$]),xe=f.useCallback(x=>{const a=O.find(p=>p.stations.some(({role:U})=>U.role===x));a&&V(a.origin.role)},[O,V]),ae=((ke=E.find(({role:x})=>x.role===t))==null?void 0:ke.role)??null,c=f.useMemo(()=>{const x=new Set;for(const a of w)a.ops_visible&&a.entity_facet&&x.add(a.entity_facet);return[...x].sort()},[w]),k=y.get("lens"),L=M?k&&c.includes(k)?k:c[0]??null:null,T=f.useCallback(x=>{s(null);const a=new URLSearchParams;x&&a.set("lens",x),S!=="1h"&&a.set("period",S);const p=a.toString();R(p?`/trends?${p}`:"/trends")},[R,S]),B=y.get("entity"),Q=y.get("find"),Z=f.useCallback(x=>{b(a=>{const p=new URLSearchParams(a);return x?p.set("entity",x):p.delete("entity"),p})},[b]),X=f.useCallback(x=>{b(a=>{const p=new URLSearchParams(a);return x?p.set("find",x):p.delete("find"),p},{replace:!0})},[b]),J=y.get("slice"),ue=y.get("sliceValue"),me=f.useCallback(x=>{b(a=>{const p=new URLSearchParams(a);return x?p.set("slice",x):p.delete("slice"),p.delete("sliceValue"),p})},[b]),ye=f.useCallback(x=>{b(a=>{const p=new URLSearchParams(a);return x?p.set("sliceValue",x):p.delete("sliceValue"),p})},[b]),K=r||te,Te=async()=>{i(!0),await Promise.all([h(),A()]),i(!1)},ve=x=>s(a=>a===x?null:x),Me=f.useMemo(()=>O.map(x=>{const a=G.get(x.origin.role);return{origin:x.origin.role,title:Se(x.origin),roleCount:(a==null?void 0:a.stations)??x.stations.length,pending:(a==null?void 0:a.pending)??0,jeopardy:(a==null?void 0:a.jeopardy)??0}}),[O,G]),qe=e.jsx("div",{className:"flex items-center gap-0.5",children:st.map(x=>e.jsx("button",{onClick:()=>P(x),className:`px-2.5 py-1 text-2xs font-mono rounded transition-colors ${S===x?"bg-accent/10 text-accent font-semibold":"icon-link"}`,children:x},x))});return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx(Zt,{title:L?"Trend Board":"Pace Board",docsHash:"#docs:dashboard.md:pace-board",center:qe,actions:e.jsxs("div",{className:"flex items-center gap-3",children:[u.length>0&&e.jsxs("button",{onClick:()=>N(!0),title:"Scope this board — bind facets for this device","data-testid":"board-scope-pill",className:`flex items-center gap-1.5 px-2 py-0.5 text-2xs rounded-full border transition-colors ${g?"border-accent/40 bg-accent/10 text-accent hover:bg-accent/15":"border-surface-border bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:[e.jsx(ut,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"truncate max-w-48 font-mono",children:g?Object.entries(m).map(([x,a])=>`${x} = ${a}`).join(", "):"All"})]}),e.jsx("button",{onClick:Te,disabled:l,className:"icon-link disabled:opacity-40",children:e.jsx(zt,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})}),K?e.jsxs("div",{className:"animate-pulse space-y-6 mt-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-64 bg-surface-sunken rounded w-full"}),e.jsx("div",{className:"space-y-3",children:[1,2,3].map(x=>e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-full"},x))})]}):O.length===0?e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-2",children:"Roles appear here once they are marked visible in Operations."}),e.jsxs("p",{className:"text-xs text-text-tertiary",children:["Go to"," ",e.jsx(le,{to:"/admin/roles",className:"text-accent hover:underline",children:"Roles"})," ","and enable ",e.jsx("strong",{children:"Visible in Operations"})," on the roles that belong to a pace segment."]})]}):e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[(O.length>1||c.length>0)&&e.jsx("div",{className:"flex items-end justify-end",children:e.jsx("div",{className:"px-4 pt-2 pb-0.5",children:e.jsx(ds,{fragments:Me,activeFragment:(D==null?void 0:D.origin.role)??null,lenses:c,activeLens:L,onSelectFragment:V,onSelectLens:T})})}),L?e.jsx(is,{entityKey:L,periodHours:Le[S],roles:w,scopeFacets:g,find:Q,onFindChange:X,entityValue:B,onEntityChange:Z,sliceKey:J,onSliceKeyChange:me,sliceValue:ue,onSliceValueChange:ye},L):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-h-[40vh] flex items-stretch overflow-hidden",children:[e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden px-2 py-4",children:[e.jsx("div",{className:"flex items-center justify-center gap-0.5 pb-2 shrink-0",children:["lin","log"].map(x=>e.jsx("button",{onClick:()=>d(x==="log"),className:`px-2 py-0.5 text-2xs font-mono rounded transition-colors ${(o?"log":"lin")===x?"text-accent font-semibold":"icon-link"}`,title:x==="lin"?"Linear Y axis":"Logarithmic Y axis — reveals shape across wide value ranges",children:x},x))}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(ws,{stations:Ne,selectedRole:t,onSelect:ve,onUpstreamSelect:xe,onCmdClick:x=>R(`/escalations/available?role=${encodeURIComponent(x)}`),periodHours:Le[S],logScale:o,fill:!0})})]}),e.jsx("div",{className:"w-px bg-surface-border shrink-0 self-stretch"}),e.jsx(qs,{role:ae,allMetrics:de,orderedRoles:E.map(x=>x.role),globalPeriod:S,scopeFacets:g,mixGroups:I==null?void 0:I.groups,onClose:()=>s(null)})]}),e.jsx("div",{className:"max-h-[30vh] flex-none overflow-y-auto border-t border-surface-border",children:e.jsxs("table",{className:"w-full table-fixed",children:[e.jsx(Os,{}),e.jsx("tbody",{children:E.map(({role:x})=>e.jsx(Ls,{role:x,metric:$.find(a=>a.role===x.role),mixGroups:Y.get(x.role),mixColors:ne.get(x.role)??ge,selected:t===x.role,periodHours:Le[S],onClick:()=>ve(x.role)},x.role))})]})})]})]}),e.jsx(Ot,{open:j,onClose:()=>N(!1)})]})}const Hs=Object.freeze(Object.defineProperty({__proto__:null,OperationsPage:Fs,buildFragments:Ge},Symbol.toStringTag,{value:"Module"}));export{Hs as O,ws as P,Ge as b,wt as j};
3
- //# sourceMappingURL=OperationsPage-BSu1o2gB.js.map
3
+ //# sourceMappingURL=OperationsPage-C03CeU5P.js.map