@hotmeshio/long-tail 0.25.2 → 0.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/build/routes/oauth-server/authorize.js +4 -4
  2. package/build/services/auth/oauth-server/authorization.d.ts +5 -0
  3. package/build/services/auth/oauth-server/authorization.js +8 -0
  4. package/build/services/auth/oauth-server/metadata.d.ts +1 -1
  5. package/build/services/auth/oauth-server/metadata.js +2 -1
  6. package/dashboard/dist/assets/{AdminDashboard-B8MqNLiB.js → AdminDashboard-DlItqxFS.js} +2 -2
  7. package/dashboard/dist/assets/{AdminDashboard-B8MqNLiB.js.map → AdminDashboard-DlItqxFS.js.map} +1 -1
  8. package/dashboard/dist/assets/{AgentConfigPage-Yg81Eiuo.js → AgentConfigPage-BUmT4a7n.js} +2 -2
  9. package/dashboard/dist/assets/{AgentConfigPage-Yg81Eiuo.js.map → AgentConfigPage-BUmT4a7n.js.map} +1 -1
  10. package/dashboard/dist/assets/{AgentDetailPage-ZUGYEONO.js → AgentDetailPage-Cww8rlBi.js} +3 -3
  11. package/dashboard/dist/assets/{AgentDetailPage-ZUGYEONO.js.map → AgentDetailPage-Cww8rlBi.js.map} +1 -1
  12. package/dashboard/dist/assets/AgentsPage-C9UuUKhr.js +2 -0
  13. package/dashboard/dist/assets/{AgentsPage-CZIWMwak.js.map → AgentsPage-C9UuUKhr.js.map} +1 -1
  14. package/dashboard/dist/assets/{AvailableEscalationsPage-BVtpc4xO.js → AvailableEscalationsPage-DrvfXz70.js} +2 -2
  15. package/dashboard/dist/assets/{AvailableEscalationsPage-BVtpc4xO.js.map → AvailableEscalationsPage-DrvfXz70.js.map} +1 -1
  16. package/dashboard/dist/assets/{BotPicker-8bf0yOCT.js → BotPicker-CDq9XRMp.js} +2 -2
  17. package/dashboard/dist/assets/{BotPicker-8bf0yOCT.js.map → BotPicker-CDq9XRMp.js.map} +1 -1
  18. package/dashboard/dist/assets/{BulkAssignModal-B2lr1J6P.js → BulkAssignModal-jsvqtrEA.js} +2 -2
  19. package/dashboard/dist/assets/{BulkAssignModal-B2lr1J6P.js.map → BulkAssignModal-jsvqtrEA.js.map} +1 -1
  20. package/dashboard/dist/assets/{CapabilitiesPage-BQQBR2sj.js → CapabilitiesPage-CSCrI6B1.js} +2 -2
  21. package/dashboard/dist/assets/{CapabilitiesPage-BQQBR2sj.js.map → CapabilitiesPage-CSCrI6B1.js.map} +1 -1
  22. package/dashboard/dist/assets/{CollapsibleSection-DFW8TYyU.js → CollapsibleSection-uD9mn-CQ.js} +2 -2
  23. package/dashboard/dist/assets/{CollapsibleSection-DFW8TYyU.js.map → CollapsibleSection-uD9mn-CQ.js.map} +1 -1
  24. package/dashboard/dist/assets/{ConfirmDeleteModal-DGlOlQAo.js → ConfirmDeleteModal-BRmx2hA4.js} +2 -2
  25. package/dashboard/dist/assets/{ConfirmDeleteModal-DGlOlQAo.js.map → ConfirmDeleteModal-BRmx2hA4.js.map} +1 -1
  26. package/dashboard/dist/assets/{ConnectedAppsPage-CIM9gzHj.js → ConnectedAppsPage-DlMzE5a-.js} +2 -2
  27. package/dashboard/dist/assets/{ConnectedAppsPage-CIM9gzHj.js.map → ConnectedAppsPage-DlMzE5a-.js.map} +1 -1
  28. package/dashboard/dist/assets/{CountdownTimer-BD_iWm6S.js → CountdownTimer-sRuM4eM5.js} +2 -2
  29. package/dashboard/dist/assets/{CountdownTimer-BD_iWm6S.js.map → CountdownTimer-sRuM4eM5.js.map} +1 -1
  30. package/dashboard/dist/assets/{CredentialsPage-CTtUkvoD.js → CredentialsPage-bLYydwqa.js} +2 -2
  31. package/dashboard/dist/assets/{CredentialsPage-CTtUkvoD.js.map → CredentialsPage-bLYydwqa.js.map} +1 -1
  32. package/dashboard/dist/assets/{CronLabel-rZMptkYQ.js → CronLabel-D_ATDL2N.js} +2 -2
  33. package/dashboard/dist/assets/{CronLabel-rZMptkYQ.js.map → CronLabel-D_ATDL2N.js.map} +1 -1
  34. package/dashboard/dist/assets/{ElapsedCell-CmK9gHC5.js → ElapsedCell-groSMfqB.js} +2 -2
  35. package/dashboard/dist/assets/{ElapsedCell-CmK9gHC5.js.map → ElapsedCell-groSMfqB.js.map} +1 -1
  36. package/dashboard/dist/assets/{EntityTimelinePanel-Cfg0EMZs.js → EntityTimelinePanel-D-F3_A9m.js} +2 -2
  37. package/dashboard/dist/assets/{EntityTimelinePanel-Cfg0EMZs.js.map → EntityTimelinePanel-D-F3_A9m.js.map} +1 -1
  38. package/dashboard/dist/assets/{EscalationListSchemaPage-CPcbC1-9.js → EscalationListSchemaPage-Bad6Jrmr.js} +2 -2
  39. package/dashboard/dist/assets/{EscalationListSchemaPage-CPcbC1-9.js.map → EscalationListSchemaPage-Bad6Jrmr.js.map} +1 -1
  40. package/dashboard/dist/assets/{EscalationSchemaPage-BsYdNVN7.js → EscalationSchemaPage-BKi_npI9.js} +2 -2
  41. package/dashboard/dist/assets/{EscalationSchemaPage-BsYdNVN7.js.map → EscalationSchemaPage-BKi_npI9.js.map} +1 -1
  42. package/dashboard/dist/assets/{EscalationTimeline-D1enxZDs.js → EscalationTimeline-DQUUm3b1.js} +2 -2
  43. package/dashboard/dist/assets/{EscalationTimeline-D1enxZDs.js.map → EscalationTimeline-DQUUm3b1.js.map} +1 -1
  44. package/dashboard/dist/assets/{EscalationTitleSelect-DwqhnPKX.js → EscalationTitleSelect-3mhXh77a.js} +2 -2
  45. package/dashboard/dist/assets/{EscalationTitleSelect-DwqhnPKX.js.map → EscalationTitleSelect-3mhXh77a.js.map} +1 -1
  46. package/dashboard/dist/assets/{EscalationsOverview-ChuKh02E.js → EscalationsOverview-Qaov-uML.js} +2 -2
  47. package/dashboard/dist/assets/{EscalationsOverview-ChuKh02E.js.map → EscalationsOverview-Qaov-uML.js.map} +1 -1
  48. package/dashboard/dist/assets/{EventTable-GqZIKPce.js → EventTable-V4RF_n58.js} +2 -2
  49. package/dashboard/dist/assets/{EventTable-GqZIKPce.js.map → EventTable-V4RF_n58.js.map} +1 -1
  50. package/dashboard/dist/assets/{FilterBar-CqPFZkVU.js → FilterBar-BygWrnB1.js} +2 -2
  51. package/dashboard/dist/assets/{FilterBar-CqPFZkVU.js.map → FilterBar-BygWrnB1.js.map} +1 -1
  52. package/dashboard/dist/assets/{GraphInvokePage-_fB7mtBU.js → GraphInvokePage-Djslhf96.js} +2 -2
  53. package/dashboard/dist/assets/{GraphInvokePage-_fB7mtBU.js.map → GraphInvokePage-Djslhf96.js.map} +1 -1
  54. package/dashboard/dist/assets/{HomePage-BXA0Cz0F.js → HomePage-EjcNxlKx.js} +2 -2
  55. package/dashboard/dist/assets/{HomePage-BXA0Cz0F.js.map → HomePage-EjcNxlKx.js.map} +1 -1
  56. package/dashboard/dist/assets/{ListToolbar-Bf4DFITI.js → ListToolbar-RrEAePOX.js} +2 -2
  57. package/dashboard/dist/assets/{ListToolbar-Bf4DFITI.js.map → ListToolbar-RrEAePOX.js.map} +1 -1
  58. package/dashboard/dist/assets/{McpOverview-H61XQRji.js → McpOverview-8gqiL3Vj.js} +2 -2
  59. package/dashboard/dist/assets/{McpOverview-H61XQRji.js.map → McpOverview-8gqiL3Vj.js.map} +1 -1
  60. package/dashboard/dist/assets/{McpQueryDetailPage-wbwK8WWq.js → McpQueryDetailPage-COyn6Ak5.js} +2 -2
  61. package/dashboard/dist/assets/{McpQueryDetailPage-wbwK8WWq.js.map → McpQueryDetailPage-COyn6Ak5.js.map} +1 -1
  62. package/dashboard/dist/assets/{McpQueryPage-CYvVEk3G.js → McpQueryPage-Dj6Qj72w.js} +2 -2
  63. package/dashboard/dist/assets/{McpQueryPage-CYvVEk3G.js.map → McpQueryPage-Dj6Qj72w.js.map} +1 -1
  64. package/dashboard/dist/assets/{McpRunDetailPage-TZBX68i4.js → McpRunDetailPage-80fQn9iX.js} +2 -2
  65. package/dashboard/dist/assets/{McpRunDetailPage-TZBX68i4.js.map → McpRunDetailPage-80fQn9iX.js.map} +1 -1
  66. package/dashboard/dist/assets/{McpRunsPage-Cu91Mh52.js → McpRunsPage-DaSsI-EM.js} +2 -2
  67. package/dashboard/dist/assets/{McpRunsPage-Cu91Mh52.js.map → McpRunsPage-DaSsI-EM.js.map} +1 -1
  68. package/dashboard/dist/assets/{OperationsPage-D-6sKw6y.js → OperationsPage-BSu1o2gB.js} +2 -2
  69. package/dashboard/dist/assets/{OperationsPage-D-6sKw6y.js.map → OperationsPage-BSu1o2gB.js.map} +1 -1
  70. package/dashboard/dist/assets/{OperatorDashboard-DD8JUU3L.js → OperatorDashboard-HFI4WGIV.js} +2 -2
  71. package/dashboard/dist/assets/{OperatorDashboard-DD8JUU3L.js.map → OperatorDashboard-HFI4WGIV.js.map} +1 -1
  72. package/dashboard/dist/assets/{PersonaDetailPage-CGri6okV.js → PersonaDetailPage-D0qlBuGi.js} +2 -2
  73. package/dashboard/dist/assets/{PersonaDetailPage-CGri6okV.js.map → PersonaDetailPage-D0qlBuGi.js.map} +1 -1
  74. package/dashboard/dist/assets/{PersonasPage-DtHW6-Qx.js → PersonasPage-BJClu-5H.js} +2 -2
  75. package/dashboard/dist/assets/{PersonasPage-DtHW6-Qx.js.map → PersonasPage-BJClu-5H.js.map} +1 -1
  76. package/dashboard/dist/assets/{PortalPage-Dgbk_mzr.js → PortalPage-CucNZn_w.js} +2 -2
  77. package/dashboard/dist/assets/{PortalPage-Dgbk_mzr.js.map → PortalPage-CucNZn_w.js.map} +1 -1
  78. package/dashboard/dist/assets/{ProcessDetailPage-BdkacBrD.js → ProcessDetailPage-B9wMw0RV.js} +2 -2
  79. package/dashboard/dist/assets/{ProcessDetailPage-BdkacBrD.js.map → ProcessDetailPage-B9wMw0RV.js.map} +1 -1
  80. package/dashboard/dist/assets/{ProcessesListPage-DO5A-OfZ.js → ProcessesListPage-B6k4RpmR.js} +2 -2
  81. package/dashboard/dist/assets/{ProcessesListPage-DO5A-OfZ.js.map → ProcessesListPage-B6k4RpmR.js.map} +1 -1
  82. package/dashboard/dist/assets/{ResolverForm-CqGE5lf-.js → ResolverForm-ZVufJ4G-.js} +2 -2
  83. package/dashboard/dist/assets/{ResolverForm-CqGE5lf-.js.map → ResolverForm-ZVufJ4G-.js.map} +1 -1
  84. package/dashboard/dist/assets/{RoleDetailPage-DgVp0Hih.js → RoleDetailPage-CTbq0mz4.js} +2 -2
  85. package/dashboard/dist/assets/{RoleDetailPage-DgVp0Hih.js.map → RoleDetailPage-CTbq0mz4.js.map} +1 -1
  86. package/dashboard/dist/assets/{RolesPage-BmsWq83e.js → RolesPage-DBKxeam4.js} +2 -2
  87. package/dashboard/dist/assets/{RolesPage-BmsWq83e.js.map → RolesPage-DBKxeam4.js.map} +1 -1
  88. package/dashboard/dist/assets/RosterWidget-BkLAwEYB.js +2 -0
  89. package/dashboard/dist/assets/RosterWidget-BkLAwEYB.js.map +1 -0
  90. package/dashboard/dist/assets/{RunAsSelector-CyUWGp5P.js → RunAsSelector-D2DC4iDf.js} +2 -2
  91. package/dashboard/dist/assets/{RunAsSelector-CyUWGp5P.js.map → RunAsSelector-D2DC4iDf.js.map} +1 -1
  92. package/dashboard/dist/assets/{ScanCodesPage-Cy05JOt4.js → ScanCodesPage-BlKleaT0.js} +2 -2
  93. package/dashboard/dist/assets/{ScanCodesPage-Cy05JOt4.js.map → ScanCodesPage-BlKleaT0.js.map} +1 -1
  94. package/dashboard/dist/assets/{ScanSchemeDetailPage-BX1afzOg.js → ScanSchemeDetailPage-CTW6gofi.js} +2 -2
  95. package/dashboard/dist/assets/{ScanSchemeDetailPage-BX1afzOg.js.map → ScanSchemeDetailPage-CTW6gofi.js.map} +1 -1
  96. package/dashboard/dist/assets/{ScanStationPage-DLAB41tb.js → ScanStationPage-DPRjSPyT.js} +2 -2
  97. package/dashboard/dist/assets/{ScanStationPage-DLAB41tb.js.map → ScanStationPage-DPRjSPyT.js.map} +1 -1
  98. package/dashboard/dist/assets/{StickyPagination-BzUTnYYE.js → StickyPagination-CkmX3-Gu.js} +2 -2
  99. package/dashboard/dist/assets/{StickyPagination-BzUTnYYE.js.map → StickyPagination-CkmX3-Gu.js.map} +1 -1
  100. package/dashboard/dist/assets/{StreamMessageDetail-D0W1ekgG.js → StreamMessageDetail-Xm_n510s.js} +2 -2
  101. package/dashboard/dist/assets/{StreamMessageDetail-D0W1ekgG.js.map → StreamMessageDetail-Xm_n510s.js.map} +1 -1
  102. package/dashboard/dist/assets/{SwimlaneTimeline-BPBwmwuO.js → SwimlaneTimeline-De48aJan.js} +2 -2
  103. package/dashboard/dist/assets/{SwimlaneTimeline-BPBwmwuO.js.map → SwimlaneTimeline-De48aJan.js.map} +1 -1
  104. package/dashboard/dist/assets/{TaskDetailPage-VuaIXISy.js → TaskDetailPage-HycMx3O9.js} +2 -2
  105. package/dashboard/dist/assets/{TaskDetailPage-VuaIXISy.js.map → TaskDetailPage-HycMx3O9.js.map} +1 -1
  106. package/dashboard/dist/assets/{TasksListPage-KaUSoqos.js → TasksListPage-OIcFFp1C.js} +2 -2
  107. package/dashboard/dist/assets/{TasksListPage-KaUSoqos.js.map → TasksListPage-OIcFFp1C.js.map} +1 -1
  108. package/dashboard/dist/assets/{TimeAgo-C_E6u0fr.js → TimeAgo-OTC_55oZ.js} +2 -2
  109. package/dashboard/dist/assets/{TimeAgo-C_E6u0fr.js.map → TimeAgo-OTC_55oZ.js.map} +1 -1
  110. package/dashboard/dist/assets/{TimestampCell-CUJiAmax.js → TimestampCell-CAwIj_AI.js} +2 -2
  111. package/dashboard/dist/assets/{TimestampCell-CUJiAmax.js.map → TimestampCell-CAwIj_AI.js.map} +1 -1
  112. package/dashboard/dist/assets/{ToolTestPanel-Ch5nQANh.js → ToolTestPanel-8Vf6pfw4.js} +2 -2
  113. package/dashboard/dist/assets/{ToolTestPanel-Ch5nQANh.js.map → ToolTestPanel-8Vf6pfw4.js.map} +1 -1
  114. package/dashboard/dist/assets/{TopicDetailPage-BprToO7w.js → TopicDetailPage-iZW8rK9L.js} +2 -2
  115. package/dashboard/dist/assets/{TopicDetailPage-BprToO7w.js.map → TopicDetailPage-iZW8rK9L.js.map} +1 -1
  116. package/dashboard/dist/assets/{TopicsPage-8SmCnQ-E.js → TopicsPage-CqiEcj-W.js} +2 -2
  117. package/dashboard/dist/assets/{TopicsPage-8SmCnQ-E.js.map → TopicsPage-CqiEcj-W.js.map} +1 -1
  118. package/dashboard/dist/assets/{UserName-BkJryunF.js → UserName-DQFjuoib.js} +2 -2
  119. package/dashboard/dist/assets/{UserName-BkJryunF.js.map → UserName-DQFjuoib.js.map} +1 -1
  120. package/dashboard/dist/assets/{WorkflowExecutionPage-B2S5ODie.js → WorkflowExecutionPage-Di08wCbs.js} +2 -2
  121. package/dashboard/dist/assets/{WorkflowExecutionPage-B2S5ODie.js.map → WorkflowExecutionPage-Di08wCbs.js.map} +1 -1
  122. package/dashboard/dist/assets/{WorkflowsDashboard-CABuRCXp.js → WorkflowsDashboard-Bb8HlrTJ.js} +2 -2
  123. package/dashboard/dist/assets/{WorkflowsDashboard-CABuRCXp.js.map → WorkflowsDashboard-Bb8HlrTJ.js.map} +1 -1
  124. package/dashboard/dist/assets/{WorkflowsOverview-BPUHAj8T.js → WorkflowsOverview-Dta1kurk.js} +2 -2
  125. package/dashboard/dist/assets/{WorkflowsOverview-BPUHAj8T.js.map → WorkflowsOverview-Dta1kurk.js.map} +1 -1
  126. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DZGjT-Tl.js → YamlWorkflowDetailPage-CfAajg68.js} +2 -2
  127. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DZGjT-Tl.js.map → YamlWorkflowDetailPage-CfAajg68.js.map} +1 -1
  128. package/dashboard/dist/assets/{YamlWorkflowsPage-DIxHURlM.js → YamlWorkflowsPage-CQFUzT4t.js} +2 -2
  129. package/dashboard/dist/assets/{YamlWorkflowsPage-DIxHURlM.js.map → YamlWorkflowsPage-CQFUzT4t.js.map} +1 -1
  130. package/dashboard/dist/assets/{agents-BnDp2rcb.js → agents-PuftRTB2.js} +2 -2
  131. package/dashboard/dist/assets/{agents-BnDp2rcb.js.map → agents-PuftRTB2.js.map} +1 -1
  132. package/dashboard/dist/assets/{bots-maURYoyr.js → bots-BmEiPAWY.js} +2 -2
  133. package/dashboard/dist/assets/{bots-maURYoyr.js.map → bots-BmEiPAWY.js.map} +1 -1
  134. package/dashboard/dist/assets/{capabilities-5-TakMUh.js → capabilities-CRii4Soa.js} +2 -2
  135. package/dashboard/dist/assets/{capabilities-5-TakMUh.js.map → capabilities-CRii4Soa.js.map} +1 -1
  136. package/dashboard/dist/assets/{controlplane-BXVVTWoh.js → controlplane-DO_czaYo.js} +2 -2
  137. package/dashboard/dist/assets/{controlplane-BXVVTWoh.js.map → controlplane-DO_czaYo.js.map} +1 -1
  138. package/dashboard/dist/assets/{escalation-columns-v8gx8wFb.js → escalation-columns-CzCquCPh.js} +2 -2
  139. package/dashboard/dist/assets/{escalation-columns-v8gx8wFb.js.map → escalation-columns-CzCquCPh.js.map} +1 -1
  140. package/dashboard/dist/assets/{escalation-items-OWntjDaH.js → escalation-items-Cy0ZgJqV.js} +2 -2
  141. package/dashboard/dist/assets/{escalation-items-OWntjDaH.js.map → escalation-items-Cy0ZgJqV.js.map} +1 -1
  142. package/dashboard/dist/assets/{index-BIfY4mR2.js → index-2SM2_onB.js} +2 -2
  143. package/dashboard/dist/assets/{index-BIfY4mR2.js.map → index-2SM2_onB.js.map} +1 -1
  144. package/dashboard/dist/assets/{index-vgHzaGmW.js → index-4YaDUcKd.js} +2 -2
  145. package/dashboard/dist/assets/{index-vgHzaGmW.js.map → index-4YaDUcKd.js.map} +1 -1
  146. package/dashboard/dist/assets/{index-YGTGxcTF.js → index-CL_1VpGb.js} +2 -2
  147. package/dashboard/dist/assets/{index-YGTGxcTF.js.map → index-CL_1VpGb.js.map} +1 -1
  148. package/dashboard/dist/assets/{index-Dk7nwVpm.js → index-CZ7A3AcD.js} +2 -2
  149. package/dashboard/dist/assets/{index-Dk7nwVpm.js.map → index-CZ7A3AcD.js.map} +1 -1
  150. package/dashboard/dist/assets/{index-CvKegIVe.js → index-CfP2nKRc.js} +2 -2
  151. package/dashboard/dist/assets/{index-CvKegIVe.js.map → index-CfP2nKRc.js.map} +1 -1
  152. package/dashboard/dist/assets/{index-CR9rhAvN.js → index-Cga5IW3D.js} +2 -2
  153. package/dashboard/dist/assets/{index-CR9rhAvN.js.map → index-Cga5IW3D.js.map} +1 -1
  154. package/dashboard/dist/assets/{index-BTm3-qwq.js → index-Cx8xb-oU.js} +2 -2
  155. package/dashboard/dist/assets/{index-BTm3-qwq.js.map → index-Cx8xb-oU.js.map} +1 -1
  156. package/dashboard/dist/assets/{index-Dafrbwk_.js → index-DhSCCpqM.js} +2 -2
  157. package/dashboard/dist/assets/{index-Dafrbwk_.js.map → index-DhSCCpqM.js.map} +1 -1
  158. package/dashboard/dist/assets/{index-WPVpyoD3.js → index-DiaRlFYI.js} +2 -2
  159. package/dashboard/dist/assets/{index-WPVpyoD3.js.map → index-DiaRlFYI.js.map} +1 -1
  160. package/dashboard/dist/assets/{index-D7peGNN0.js → index-Dz6R8-Dw.js} +11 -11
  161. package/dashboard/dist/assets/index-Dz6R8-Dw.js.map +1 -0
  162. package/dashboard/dist/assets/{index-D_ojXTgO.js → index-Rwqrflm-.js} +2 -2
  163. package/dashboard/dist/assets/{index-D_ojXTgO.js.map → index-Rwqrflm-.js.map} +1 -1
  164. package/dashboard/dist/assets/{index-DvkcyTE2.js → index-XntldBd0.js} +2 -2
  165. package/dashboard/dist/assets/{index-DvkcyTE2.js.map → index-XntldBd0.js.map} +1 -1
  166. package/dashboard/dist/assets/{index-CWKs10VQ.js → index-jL2K6us4.js} +2 -2
  167. package/dashboard/dist/assets/{index-CWKs10VQ.js.map → index-jL2K6us4.js.map} +1 -1
  168. package/dashboard/dist/assets/{knowledge-L_zY1zmy.js → knowledge-CeUqGPuo.js} +2 -2
  169. package/dashboard/dist/assets/{knowledge-L_zY1zmy.js.map → knowledge-CeUqGPuo.js.map} +1 -1
  170. package/dashboard/dist/assets/{mcp-wCWFRA0T.js → mcp-Cx96NTeD.js} +2 -2
  171. package/dashboard/dist/assets/{mcp-wCWFRA0T.js.map → mcp-Cx96NTeD.js.map} +1 -1
  172. package/dashboard/dist/assets/{mcp-query-CFbGudkb.js → mcp-query-XAzWl0gm.js} +2 -2
  173. package/dashboard/dist/assets/{mcp-query-CFbGudkb.js.map → mcp-query-XAzWl0gm.js.map} +1 -1
  174. package/dashboard/dist/assets/{personas-B_VIacZJ.js → personas--4kjwyOw.js} +2 -2
  175. package/dashboard/dist/assets/{personas-B_VIacZJ.js.map → personas--4kjwyOw.js.map} +1 -1
  176. package/dashboard/dist/assets/{pipelines-Bv0Z8xQA.js → pipelines-PgkwvG7f.js} +2 -2
  177. package/dashboard/dist/assets/{pipelines-Bv0Z8xQA.js.map → pipelines-PgkwvG7f.js.map} +1 -1
  178. package/dashboard/dist/assets/{tasks-DP6yaNZs.js → tasks-CcYxdBa3.js} +2 -2
  179. package/dashboard/dist/assets/{tasks-DP6yaNZs.js.map → tasks-CcYxdBa3.js.map} +1 -1
  180. package/dashboard/dist/assets/{topics-UBSIcpSR.js → topics-_lik7cNY.js} +2 -2
  181. package/dashboard/dist/assets/{topics-UBSIcpSR.js.map → topics-_lik7cNY.js.map} +1 -1
  182. package/dashboard/dist/assets/{useDebouncedValue-R62q3Xpx.js → useDebouncedValue-Bm_AoxVx.js} +2 -2
  183. package/dashboard/dist/assets/{useDebouncedValue-R62q3Xpx.js.map → useDebouncedValue-Bm_AoxVx.js.map} +1 -1
  184. package/dashboard/dist/assets/{useNamespace-CAaszJDE.js → useNamespace-DgXXKdx5.js} +2 -2
  185. package/dashboard/dist/assets/{useNamespace-CAaszJDE.js.map → useNamespace-DgXXKdx5.js.map} +1 -1
  186. package/dashboard/dist/assets/{useYamlActivityEvents-emCp9U69.js → useYamlActivityEvents-Dj2qtGSd.js} +2 -2
  187. package/dashboard/dist/assets/{useYamlActivityEvents-emCp9U69.js.map → useYamlActivityEvents-Dj2qtGSd.js.map} +1 -1
  188. package/dashboard/dist/assets/{validate-C7yskdEn.js → validate-FlXCBBT6.js} +2 -2
  189. package/dashboard/dist/assets/{validate-C7yskdEn.js.map → validate-FlXCBBT6.js.map} +1 -1
  190. package/dashboard/dist/assets/{yaml-workflows-C2sOwz1p.js → yaml-workflows-B0_JxRYQ.js} +2 -2
  191. package/dashboard/dist/assets/{yaml-workflows-C2sOwz1p.js.map → yaml-workflows-B0_JxRYQ.js.map} +1 -1
  192. package/dashboard/dist/index.html +1 -1
  193. package/docs/hitl/x-lt-roster.md +1 -1
  194. package/docs/mcp.md +6 -1
  195. package/docs/scan-codes.md +5 -0
  196. package/package.json +1 -1
  197. package/dashboard/dist/assets/AgentsPage-CZIWMwak.js +0 -2
  198. package/dashboard/dist/assets/RosterWidget-DR-T4Izu.js +0 -2
  199. package/dashboard/dist/assets/RosterWidget-DR-T4Izu.js.map +0 -1
  200. package/dashboard/dist/assets/index-D7peGNN0.js.map +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-DO5A-OfZ.js","./vendor-query-DvWWuNIB.js","./tasks-DP6yaNZs.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-R62q3Xpx.js","./api-path-u2Jf9QXS.js","./DataTable-FjFhx0SE.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-CUJiAmax.js","./StickyPagination-BzUTnYYE.js","./FilterBar-CqPFZkVU.js","./vendor-icons-DUYcKTjP.js","./PageHeader-BSWIspNB.js","./ListToolbar-Bf4DFITI.js","./WorkflowPill-DJLcK_CM.js","./ProcessDetailPage-BdkacBrD.js","./PageHeaderWithStats-DDjopQ-k.js","./StatusBadge-DHVwxre2.js","./RolePill-CoETDpjF.js","./UserName-BkJryunF.js","./McpOverview-H61XQRji.js","./mcp-wCWFRA0T.js","./pipelines-Bv0Z8xQA.js","./yaml-workflows-C2sOwz1p.js","./controlplane-BXVVTWoh.js","./StatCard-nWY4sndl.js","./McpRunsPage-Cu91Mh52.js","./useNamespace-CAaszJDE.js","./ElapsedCell-CmK9gHC5.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-TZBX68i4.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-GqZIKPce.js","./SwimlaneTimeline-BPBwmwuO.js","./StreamMessageDetail-D0W1ekgG.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-CYvVEk3G.js","./mcp-query-CFbGudkb.js","./McpQueryDetailPage-wbwK8WWq.js","./TagInput-S7UuVT_M.js","./CollapsibleSection-DFW8TYyU.js","./useYamlActivityEvents-emCp9U69.js","./helpers-DzO-OGPe.js","./RunAsSelector-CyUWGp5P.js","./BotPicker-8bf0yOCT.js","./bots-maURYoyr.js","./ToolPill-D40uLM_v.js","./TimeAgo-C_E6u0fr.js","./EscalationsOverview-ChuKh02E.js","./AvailableEscalationsPage-BVtpc4xO.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-B2lr1J6P.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-DwqhnPKX.js","./EscalationTimeline-D1enxZDs.js","./escalation-items-OWntjDaH.js","./validate-C7yskdEn.js","./escalation-columns-v8gx8wFb.js","./EntityTimelinePanel-Cfg0EMZs.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-BD_iWm6S.js","./OperatorDashboard-DD8JUU3L.js","./index-CvKegIVe.js","./ResolverForm-CqGE5lf-.js","./RosterWidget-DR-T4Izu.js","./metadata-display-B7X5hGxG.js","./WorkflowsOverview-BPUHAj8T.js","./index-Dafrbwk_.js","./NamespacePill-C5epAgq6.js","./WorkflowsDashboard-CABuRCXp.js","./YamlWorkflowsPage-DIxHURlM.js","./GraphInvokePage-_fB7mtBU.js","./YamlWorkflowDetailPage-DZGjT-Tl.js","./TasksListPage-KaUSoqos.js","./TaskDetailPage-VuaIXISy.js","./WorkflowExecutionPage-B2S5ODie.js","./AdminDashboard-B8MqNLiB.js","./index-CR9rhAvN.js","./TaskQueuePill-BlHNpYiZ.js","./index-CWKs10VQ.js","./ConfirmDeleteModal-DGlOlQAo.js","./index-BTm3-qwq.js","./ToolTestPanel-Ch5nQANh.js","./index-BIfY4mR2.js","./index-YGTGxcTF.js","./personas-B_VIacZJ.js","./ScopeBadge-CGsTtqFr.js","./RolesPage-BmsWq83e.js","./RoleDetailPage-DgVp0Hih.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-DtHW6-Qx.js","./PersonaDetailPage-CGri6okV.js","./EscalationSchemaPage-BsYdNVN7.js","./PortalPage-Dgbk_mzr.js","./EscalationListSchemaPage-CPcbC1-9.js","./ScanCodesPage-Cy05JOt4.js","./GrantScopeField-BzWGzBfA.js","./ScanSchemeDetailPage-BX1afzOg.js","./ScanStationPage-DLAB41tb.js","./index-Dk7nwVpm.js","./OperationsPage-D-6sKw6y.js","./index-vgHzaGmW.js","./index-WPVpyoD3.js","./CredentialsPage-CTtUkvoD.js","./ConnectedAppsPage-CIM9gzHj.js","./index-DvkcyTE2.js","./DropZone-u1JGfR9G.js","./index-D_ojXTgO.js","./knowledge-L_zY1zmy.js","./HomePage-BXA0Cz0F.js","./AgentsPage-CZIWMwak.js","./agents-BnDp2rcb.js","./AgentDetailPage-ZUGYEONO.js","./CronLabel-rZMptkYQ.js","./AgentConfigPage-Yg81Eiuo.js","./capabilities-5-TakMUh.js","./topics-UBSIcpSR.js","./CapabilitiesPage-BQQBR2sj.js","./TopicsPage-8SmCnQ-E.js","./TopicDetailPage-BprToO7w.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-B6k4RpmR.js","./vendor-query-DvWWuNIB.js","./tasks-CcYxdBa3.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-Bm_AoxVx.js","./api-path-u2Jf9QXS.js","./DataTable-FjFhx0SE.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-CAwIj_AI.js","./StickyPagination-CkmX3-Gu.js","./FilterBar-BygWrnB1.js","./vendor-icons-DUYcKTjP.js","./PageHeader-BSWIspNB.js","./ListToolbar-RrEAePOX.js","./WorkflowPill-DJLcK_CM.js","./ProcessDetailPage-B9wMw0RV.js","./PageHeaderWithStats-DDjopQ-k.js","./StatusBadge-DHVwxre2.js","./RolePill-CoETDpjF.js","./UserName-DQFjuoib.js","./McpOverview-8gqiL3Vj.js","./mcp-Cx96NTeD.js","./pipelines-PgkwvG7f.js","./yaml-workflows-B0_JxRYQ.js","./controlplane-DO_czaYo.js","./StatCard-nWY4sndl.js","./McpRunsPage-DaSsI-EM.js","./useNamespace-DgXXKdx5.js","./ElapsedCell-groSMfqB.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-80fQn9iX.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-V4RF_n58.js","./SwimlaneTimeline-De48aJan.js","./StreamMessageDetail-Xm_n510s.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-Dj6Qj72w.js","./mcp-query-XAzWl0gm.js","./McpQueryDetailPage-COyn6Ak5.js","./TagInput-S7UuVT_M.js","./CollapsibleSection-uD9mn-CQ.js","./useYamlActivityEvents-Dj2qtGSd.js","./helpers-DzO-OGPe.js","./RunAsSelector-D2DC4iDf.js","./BotPicker-CDq9XRMp.js","./bots-BmEiPAWY.js","./ToolPill-D40uLM_v.js","./TimeAgo-OTC_55oZ.js","./EscalationsOverview-Qaov-uML.js","./AvailableEscalationsPage-DrvfXz70.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-jsvqtrEA.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-3mhXh77a.js","./EscalationTimeline-DQUUm3b1.js","./escalation-items-Cy0ZgJqV.js","./validate-FlXCBBT6.js","./escalation-columns-CzCquCPh.js","./EntityTimelinePanel-D-F3_A9m.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-sRuM4eM5.js","./OperatorDashboard-HFI4WGIV.js","./index-CfP2nKRc.js","./ResolverForm-ZVufJ4G-.js","./RosterWidget-BkLAwEYB.js","./metadata-display-B7X5hGxG.js","./WorkflowsOverview-Dta1kurk.js","./index-DhSCCpqM.js","./NamespacePill-C5epAgq6.js","./WorkflowsDashboard-Bb8HlrTJ.js","./YamlWorkflowsPage-CQFUzT4t.js","./GraphInvokePage-Djslhf96.js","./YamlWorkflowDetailPage-CfAajg68.js","./TasksListPage-OIcFFp1C.js","./TaskDetailPage-HycMx3O9.js","./WorkflowExecutionPage-Di08wCbs.js","./AdminDashboard-DlItqxFS.js","./index-Cga5IW3D.js","./TaskQueuePill-BlHNpYiZ.js","./index-jL2K6us4.js","./ConfirmDeleteModal-BRmx2hA4.js","./index-Cx8xb-oU.js","./ToolTestPanel-8Vf6pfw4.js","./index-2SM2_onB.js","./index-CL_1VpGb.js","./personas--4kjwyOw.js","./ScopeBadge-CGsTtqFr.js","./RolesPage-DBKxeam4.js","./RoleDetailPage-CTbq0mz4.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-BJClu-5H.js","./PersonaDetailPage-D0qlBuGi.js","./EscalationSchemaPage-BKi_npI9.js","./PortalPage-CucNZn_w.js","./EscalationListSchemaPage-Bad6Jrmr.js","./ScanCodesPage-BlKleaT0.js","./GrantScopeField-BzWGzBfA.js","./ScanSchemeDetailPage-CTW6gofi.js","./ScanStationPage-DPRjSPyT.js","./index-CZ7A3AcD.js","./OperationsPage-BSu1o2gB.js","./index-4YaDUcKd.js","./index-DiaRlFYI.js","./CredentialsPage-bLYydwqa.js","./ConnectedAppsPage-DlMzE5a-.js","./index-XntldBd0.js","./DropZone-u1JGfR9G.js","./index-Rwqrflm-.js","./knowledge-CeUqGPuo.js","./HomePage-EjcNxlKx.js","./AgentsPage-C9UuUKhr.js","./agents-PuftRTB2.js","./AgentDetailPage-Cww8rlBi.js","./CronLabel-D_ATDL2N.js","./AgentConfigPage-BUmT4a7n.js","./capabilities-CRii4Soa.js","./topics-_lik7cNY.js","./CapabilitiesPage-CSCrI6B1.js","./TopicsPage-CqiEcj-W.js","./TopicDetailPage-iZW8rK9L.js"])))=>i.map(i=>d[i]);
2
2
  var oS=Object.defineProperty;var lS=(n,e,s)=>e in n?oS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var j=(n,e,s)=>lS(n,typeof e!="symbol"?e+"":e,s);import{r as cS,u as qe,a as E,j as h,b as Pe,c as $e,g as uS,d as fS,Q as hS,e as dS}from"./vendor-query-DvWWuNIB.js";import{r as mS,u as ni,a as en,b as sm,L as ar,N as Es,c as Sn,O as ei,d as pS,R as yS}from"./vendor-react-_9U4mKFr.js";import{X as Zt,E as gS,S as bS,M as xS,a as Mo,C as im,b as vS,B as _S,c as wS,d as cx,e as gd,I as bd,U as SS,L as xd,f as ES,G as OS,T as AS,R as ux,g as jS,Z as kS,P as Mg,h as fx,i as NS,j as Rg,k as vd,l as Dg,m as TS,W as am,n as CS,o as MS,F as RS,p as hx,q as DS,D as LS,N as qS,r as PS,s as dx,t as mx,u as px,v as BS,w as US,x as zS,y as IS,z as $S,A as HS,H as FS,J as GS,K as VS}from"./vendor-icons-DUYcKTjP.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const m of c.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();var Jh={exports:{}},no={},Qh={exports:{}},Xh={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -50,18 +50,18 @@ ${g}`),b(_);return}p(null,S),i.strategy===Wn.Count&&(u--,u===0&&b()),i.strategy=
50
50
 
51
51
  ${p.stack}`),g.unsubscribe(),m.reject(u)):(u=vx(d),u?(p&&(u.stack+=`
52
52
 
53
- ${p.stack}`),m.reject(u)):m.resolve(d))}});return g.requestSubject=e,this.protocol.publish(e,s,{reply:c,headers:i.headers}),m}else{const c=new Sx(this.protocol.muxSubscriptions,e,i,o);this.protocol.request(c);try{this.publish(e,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(p){c.cancel(p)}const m=Promise.race([c.timer,c.deferred]);return m.catch(()=>{c.cancel()}),m}}flush(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(ge.errorForCode(fe.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Ut;return e.iterClosed.then(()=>{const s=this.listeners.indexOf(e);this.listeners.splice(s,1)}),this.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,i)=>s==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(e={}){const s=new V2(this,e);if(e.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===fe.NoResponders&&(o.code=fe.JetStreamNotEnabled),o}return s}jetstream(e={}){return new pm(this,e)}getServerVersion(){const e=this.info;return e?ti(e.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ge.errorForCode(fe.Disconnect);const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}get services(){return this._services||(this._services=new Q2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(ge.errorForCode(fe.ConnectionDraining)):this.protocol.reconnect()}}class Q2{constructor(e){j(this,"nc");this.nc=e}add(e){try{return new Do(this.nc,e).start()}catch(s){return Promise.reject(s)}}client(e,s){return new N2(this.nc,e,s)}}class X2{constructor(e,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=e,this.prefixLen=s,this.sm=i}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(gu)||"PUT"}get length(){const e=this.sm.header.get(Wt.MessageSizeHdr)||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class W2{constructor(e,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=e,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(um(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var e;return((e=this.sm.headers)==null?void 0:e.get(gu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const e=((s=this.sm.headers)==null?void 0:s.get(Wt.MessageSizeHdr))||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Rx extends IE{constructor(s,i,o){super(s.nc,i,o);j(this,"js");j(this,"monitor");this.js=s,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(s){this.sub.info=s}get info(){return this.sub.info}_resetOrderedConsumer(s){if(this.info===null||this.sub.isClosed())return;const i=Lr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=Os.next(),c.ordered_consumer_sequence.delivery_seq=0,c.flow_control.heartbeat_count=0,c.flow_control.fc_count=0,c.flow_control.consumer_restarts++,c.deliver=i,c.config.deliver_subject=i,c.config.deliver_policy=Et.StartSequence,c.config.opt_start_seq=s;const m={};m.stream_name=this.info.stream,m.config=c.config;const p=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(p,m,{retries:-1}).then(g=>{const u=g,d=this.sub.info;d.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new ge(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,fe.RequestError,g);this.sub.callback(u,{})})}_maybeSetupHbMonitoring(){var i,o;const s=((o=(i=this.info)==null?void 0:i.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(um(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,m=p=>{var d,b,x,v;const g=_E(409,`${In.IdleHeartbeatMissed}: ${p}`,this.sub.subject);if(!((d=this.info)==null?void 0:d.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const _=((x=(b=this.info)==null?void 0:b.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(_+1),(v=this.monitor)==null||v.restart(),!1}return!c.noIterator};this.monitor=new hm(s,m,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Wt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Wt.LastConsumerSeqHdr),10),c=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==c.delivery_seq&&this._resetOrderedConsumer(c.stream_seq+1),!1}_checkOrderedConsumer(s){const i=this.info.ordered_consumer_sequence,o=s.info.streamSequence,c=s.info.deliverySequence;return c!=i.delivery_seq+1?(this._resetOrderedConsumer(i.stream_seq+1),!1):(i.delivery_seq=c,i.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${i}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${i}`,c=await s.api._request(o);return s.last=c,c}}class Z2 extends Rx{constructor(e,s,i){super(e,s,i)}pull(e={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,m={};if(m.batch=e.batch||1,m.no_wait=e.no_wait||!1,(e.max_bytes??0)>0){const u=this.js.nc.features.get(Ye.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);m.max_bytes=e.max_bytes}let p=0;e.expires&&e.expires>0&&(p=e.expires,m.expires=dt(p));let g=0;if(e.idle_heartbeat&&e.idle_heartbeat>0&&(g=e.idle_heartbeat,m.idle_heartbeat=dt(g)),g&&p===0)throw new Error("idle_heartbeat requires expires");if(g>p)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),p&&g&&(this.monitor?this.monitor._change(g,p):this._setupHbMonitoring(g,p));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(d,u.jc.encode(m),{reply:b})}}}function eO(n,e){return n?nO(e):tO(e)}function tO(n){return(e,s)=>e?[e,null]:(e=Xi(s),e?[e,null]:[null,ko(s,n)])}function nO(n){return(e,s)=>{if(e)return[e,null];const i=Xi(s);return i!==null?[Dx(i),null]:[null,ko(s,n)]}}function Dx(n){if(n!==null)switch(n.code){case fe.JetStream404NoMessages:case fe.JetStream408RequestTimeout:return null;case fe.JetStream409:return wE(n)?n:null;default:return n}return null}function rO(n){n&&n.ack()}function sO(n){const e=n.split(".");if(e.length===9&&e.splice(2,0,"_",""),e.length<11||e[0]!=="$JS"||e[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=e[2]==="_"?"":e[2],s.account_hash=e[3],s.stream=e[4],s.consumer=e[5],s.deliveryCount=parseInt(e[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(e[7],10),s.deliverySequence=parseInt(e[8],10),s.timestampNanos=parseInt(e[9],10),s.pending=parseInt(e[10],10),s}class iO{constructor(e,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=e,this.didAck=!1,this.timeout=s}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=sO(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===so[0]&&e[1]===so[1]&&e[2]===so[2]&&e[3]===so[3]}async ackAck(e){var i;e=e||{},e.timeout=e.timeout||this.timeout;const s=mt();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,m=!((i=c.options)!=null&&i.noAsyncTraces),p=new Sx(c.muxSubscriptions,this.msg.reply,{timeout:e.timeout},m);c.request(p);try{c.publish(this.msg.reply,pb,{reply:`${c.muxSubscriptions.baseInbox}${p.token}`})}catch(g){p.cancel(g)}try{await Promise.race([p.timer,p.deferred]),s.resolve(!0)}catch(g){p.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(pb)}nak(e){let s=U2;e&&(s=Ed().encode(`-NAK ${JSON.stringify({delay:dt(e)})}`)),this.doAck(s)}working(){this.doAck(so)}next(e,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=dt(s.expires));const o=Zn().encode(i),c=sa.concat(z2,$2,o),m=e?{reply:e}:void 0;this.msg.respond(c,m)}term(e=""){let s=I2;(e==null?void 0:e.length)>0&&(s=Ed().encode(`+TERM ${e}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const aO="1.30.3",oO="nats.ws";class lO{constructor(){j(this,"version");j(this,"lang");j(this,"closeError");j(this,"connected");j(this,"done");j(this,"socket");j(this,"options");j(this,"socketClosed");j(this,"encrypted");j(this,"peeked");j(this,"yields");j(this,"signal");j(this,"closedNotification");this.version=aO,this.lang=oO,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=mt(),this.closedNotification=mt()}async connect(e,s){const i=mt();if(s.tls)return i.reject(new ge("tls",fe.InvalidOption)),i;this.options=s;const o=e.src;if(s.wsFactory){const{socket:c,encrypted:m}=await s.wsFactory(e.src,s);this.socket=c,this.encrypted=m}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=c=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(c.data)),this.peeked){this.signal.resolve();return}const m=sa.concat(...this.yields),p=YE(m);if(p!==""){const g=_2.exec(p);if(!g){s.debug&&console.error("!!!",ac(m)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);x2(u,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(u){i.reject(u);return}}},this.socket.onclose=c=>{if(this.isDiscarded())return;this.socketClosed=!0;let m;this.done||(c.wasClean||(m=new Error(c.reason)),this._closed(m))},this.socket.onerror=c=>{if(this.isDiscarded())return;const m=c,p=new ge(m.message,fe.Unknown,new Error(m.error));i.reject(p)},i}disconnect(){this._closed(void 0,!0)}async _closed(e,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await ia(100);this.done=!0;try{this.socket.close(e?1002:1e3,e?e.message:void 0)}catch{}s&&this.closedNotification.resolve(e)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let s=0;s<e.length;s++)this.options.debug&&console.info(`> ${ac(e[s])}`),yield e[s];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=mt())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.isDiscarded())try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${ac(e)}`);return}catch(s){this.options.debug&&console.error(`!!! ${ac(e)}: ${s}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var e;this.done=!0;try{(e=this.socket)==null||e.close()}catch{}}}function cO(n,e){/^(.*:\/\/)(.*)/.test(n)||(typeof e=="boolean"?n=`${e===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(e=!1),o==="wss:"&&(e=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,m;const p=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":m=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":m=i.port||"443",c="wss:";break;default:m=i.port||e===!0?"443":"80",c=e===!0?"wss:":"ws:";break}return`${c}//${p}:${m}${g}${u}`}function uO(n={}){return $E({defaultPort:443,urlParseFn:cO,factory:()=>new lO}),ym.connect(n)}const fO=null,hO=null,Xt="lt.events";function Lx(n,e){const s=n.split("."),i=e.split(".");for(let o=0;o<i.length;o++){const c=i[o];if(c===">")return!0;if(o>=s.length||c!=="*"&&c!==s[o])return!1}return s.length===i.length}const aa=E.createContext({connected:!1,subscribe:()=>()=>{}});function qx(){const{connected:n}=E.useContext(aa);return{connected:n}}function An(n,e){const{subscribe:s}=E.useContext(aa),i=E.useRef(e);i.current=e,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function js(n,e){const{subscribe:s}=E.useContext(aa),i=E.useRef(e);i.current=e;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const m=g=>i.current(g),p=c.map(g=>s(g,m));return()=>p.forEach(g=>g())},[s,c])}const Px=E.createContext({connected:!1,unavailable:!1,subscribe:()=>()=>{}});function dO(){const{connected:n,unavailable:e}=E.useContext(Px);return{connected:n,unavailable:e}}const mO=Ed();function pO({children:n,url:e,token:s,resolveCredentials:i,policy:o=yo,onReconnect:c,sessionKey:m}){const p=E.useRef(null),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(!1),_=E.useRef({url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c});_.current={url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c};const S=E.useRef(new Map),C=E.useRef(new Map),P=E.useCallback((te,M)=>{(async()=>{for await(const U of M)try{if(!Lx(U.subject,te))continue;const ae=JSON.parse(mO.decode(U.data)),z=S.current.get(te);if(!z)continue;for(const I of z)try{I(ae)}catch{}}catch{}})()},[]),q=E.useCallback(te=>{var U;const M=p.current;if(!(!M||(U=M.isClosed)!=null&&U.call(M)||C.current.has(te)))try{const ae=M.subscribe(te);C.current.set(te,ae),P(te,ae)}catch{}},[P]),ne=E.useCallback((te,M)=>{const U=S.current;return U.has(te)||U.set(te,new Set),U.get(te).add(M),q(te),()=>{const ae=U.get(te);if(ae&&(ae.delete(M),ae.size===0)){U.delete(te);const z=C.current.get(te);if(z){C.current.delete(te);try{z.unsubscribe()}catch{}}}}},[q]);return E.useEffect(()=>{let te=!1,M=!1,U=!1,ae=!1,z=0,I,D;v(!1);const X=()=>typeof document<"u"&&document.visibilityState==="hidden",W=async()=>{const{url:J,token:le,resolveCredentials:pe}=_.current;if(pe)return pe();const ye=J||fO;return ye?{kind:"ok",url:ye,token:le||hO||null}:{kind:"unavailable"}},he=(J=uE(z++,_.current.policy))=>{te||M||(I=setTimeout(Oe,J))},we=J=>{J.closed().then(()=>{p.current===J&&(p.current=null,C.current.clear(),u(!1),he(Gg(_.current.policy)))})};async function Oe(){if(I=void 0,!(te||M||U||p.current)&&!X()){U=!0;try{const J=await W();if(te)return;if(J.kind==="session-ended"){M=!0,v(!0);return}if(J.kind==="unavailable"){he();return}const le=await uO({servers:J.url,token:J.token??void 0,reconnect:!1});if(te){le.close().catch(()=>{});return}p.current=le,z=0,u(!0),C.current.clear();for(const pe of S.current.keys())q(pe);ae&&(D=setTimeout(()=>{var pe,ye;return(ye=(pe=_.current).onReconnect)==null?void 0:ye.call(pe)},Gg(_.current.policy))),ae=!0,we(le)}catch{te||he()}finally{U=!1}}}const F=()=>{te||M||U||p.current||X()||(I&&clearTimeout(I),z=0,Oe())};return document.addEventListener("visibilitychange",F),window.addEventListener("online",F),Oe(),()=>{te=!0,I&&clearTimeout(I),D&&clearTimeout(D),document.removeEventListener("visibilitychange",F),window.removeEventListener("online",F);for(const J of C.current.values())try{J.unsubscribe()}catch{}C.current.clear(),p.current&&(p.current.close().catch(()=>{}),p.current=null),u(!1)}},[q,m]),E.useEffect(()=>{if(g||x){b(!1);return}const te=setTimeout(()=>b(!0),o.noticeAfterMs);return()=>clearTimeout(te)},[g,x,o.noticeAfterMs]),h.jsx(Px.Provider,{value:{connected:g,unavailable:d,subscribe:ne},children:h.jsx(aa.Provider,{value:{connected:g,subscribe:ne},children:n})})}const ur=Object.create(null);ur.open="0";ur.close="1";ur.ping="2";ur.pong="3";ur.message="4";ur.upgrade="5";ur.noop="6";const iu=Object.create(null);Object.keys(ur).forEach(n=>{iu[ur[n]]=n});const Bd={type:"error",data:"parser error"},Bx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ux=typeof ArrayBuffer=="function",zx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,gm=({type:n,data:e},s,i)=>Bx&&e instanceof Blob?s?i(e):gb(e,i):Ux&&(e instanceof ArrayBuffer||zx(e))?s?i(e):gb(new Blob([e]),i):i(ur[n]+(e||"")),gb=(n,e)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];e("b"+(i||""))},s.readAsDataURL(n)};function bb(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let ad;function yO(n,e){if(Bx&&n.data instanceof Blob)return n.data.arrayBuffer().then(bb).then(e);if(Ux&&(n.data instanceof ArrayBuffer||zx(n.data)))return e(bb(n.data));gm(n,!1,s=>{ad||(ad=new TextEncoder),e(ad.encode(s))})}const xb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<xb.length;n++)xo[xb.charCodeAt(n)]=n;const gO=n=>{let e=n.length*.75,s=n.length,i,o=0,c,m,p,g;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const u=new ArrayBuffer(e),d=new Uint8Array(u);for(i=0;i<s;i+=4)c=xo[n.charCodeAt(i)],m=xo[n.charCodeAt(i+1)],p=xo[n.charCodeAt(i+2)],g=xo[n.charCodeAt(i+3)],d[o++]=c<<2|m>>4,d[o++]=(m&15)<<4|p>>2,d[o++]=(p&3)<<6|g&63;return u},bO=typeof ArrayBuffer=="function",bm=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ix(n,e)};const s=n.charAt(0);return s==="b"?{type:"message",data:xO(n.substring(1),e)}:iu[s]?n.length>1?{type:iu[s],data:n.substring(1)}:{type:iu[s]}:Bd},xO=(n,e)=>{if(bO){const s=gO(n);return Ix(s,e)}else return{base64:!0,data:n}},Ix=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},$x="",vO=(n,e)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,m)=>{gm(c,!1,p=>{i[m]=p,++o===s&&e(i.join($x))})})},_O=(n,e)=>{const s=n.split($x),i=[];for(let o=0;o<s.length;o++){const c=bm(s[o],e);if(i.push(c),c.type==="error")break}return i};function wO(){return new TransformStream({transform(n,e){yO(n,s=>{const i=s.length;let o;if(i<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,i);else if(i<65536){o=new Uint8Array(3);const c=new DataView(o.buffer);c.setUint8(0,126),c.setUint16(1,i)}else{o=new Uint8Array(9);const c=new DataView(o.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(o[0]|=128),e.enqueue(o),e.enqueue(s)})}})}let od;function uc(n){return n.reduce((e,s)=>e+s.length,0)}function fc(n,e){if(n[0].length===e)return n.shift();const s=new Uint8Array(e);let i=0;for(let o=0;o<e;o++)s[o]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),s}function SO(n,e){od||(od=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(m,p){for(s.push(m);;){if(i===0){if(uc(s)<1)break;const g=fc(s,1);c=(g[0]&128)===128,o=g[0]&127,o<126?i=3:o===126?i=1:i=2}else if(i===1){if(uc(s)<2)break;const g=fc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(uc(s)<8)break;const g=fc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){p.enqueue(Bd);break}o=d*Math.pow(2,32)+u.getUint32(4),i=3}else{if(uc(s)<o)break;const g=fc(s,o);p.enqueue(bm(c?g:od.decode(g),e)),i=0}if(o===0||o>n){p.enqueue(Bd);break}}}})}const Hx=4;function Tt(n){if(n)return EO(n)}function EO(n){for(var e in Tt.prototype)n[e]=Tt.prototype[e];return n}Tt.prototype.on=Tt.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};Tt.prototype.once=function(n,e){function s(){this.off(n,s),e.apply(this,arguments)}return s.fn=e,this.on(n,s),this};Tt.prototype.off=Tt.prototype.removeListener=Tt.prototype.removeAllListeners=Tt.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,o=0;o<s.length;o++)if(i=s[o],i===e||i.fn===e){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};Tt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,e)}return this};Tt.prototype.emitReserved=Tt.prototype.emit;Tt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Tt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Nu=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,s)=>s(e,0),$n=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),OO="arraybuffer";function Fx(n,...e){return e.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const AO=$n.setTimeout,jO=$n.clearTimeout;function Tu(n,e){e.useNativeTimers?(n.setTimeoutFn=AO.bind($n),n.clearTimeoutFn=jO.bind($n)):(n.setTimeoutFn=$n.setTimeout.bind($n),n.clearTimeoutFn=$n.clearTimeout.bind($n))}const kO=1.33;function NO(n){return typeof n=="string"?TO(n):Math.ceil((n.byteLength||n.size)*kO)}function TO(n){let e=0,s=0;for(let i=0,o=n.length;i<o;i++)e=n.charCodeAt(i),e<128?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(i++,s+=4);return s}function Gx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function CO(n){let e="";for(let s in n)n.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return e}function MO(n){let e={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");e[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return e}class RO extends Error{constructor(e,s,i){super(e),this.description=s,this.context=i,this.type="TransportError"}}class xm extends Tt{constructor(e){super(),this.writable=!1,Tu(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,s,i){return super.emitReserved("error",new RO(e,s,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const s=bm(e,this.socket.binaryType);this.onPacket(s)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,s={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const s=CO(e);return s.length?"?"+s:""}}class DO extends xm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const s=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||s()})),this.writable||(i++,this.once("drain",function(){--i||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const s=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};_O(e,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,vO(e,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Gx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(e,s)}}let Vx=!1;try{Vx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const LO=Vx;function qO(){}class PO extends DO{constructor(e){if(super(e),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,s){const i=this.request({method:"POST",data:e});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=e}}class cr extends Tt{constructor(e,s,i){super(),this.createRequest=e,Tu(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var e;const s=Fx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&i.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var o;i.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=cr.requestsCount++,cr.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=qO,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete cr.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}cr.requestsCount=0;cr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",vb);else if(typeof addEventListener=="function"){const n="onpagehide"in $n?"pagehide":"unload";addEventListener(n,vb,!1)}}function vb(){for(let n in cr.requests)cr.requests.hasOwnProperty(n)&&cr.requests[n].abort()}const BO=(function(){const n=Yx({xdomain:!1});return n&&n.responseType!==null})();class UO extends PO{constructor(e){super(e);const s=e&&e.forceBase64;this.supportsBinary=BO&&!s}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new cr(Yx,this.uri(),e)}}function Yx(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||LO))return new XMLHttpRequest}catch{}if(!e)try{return new $n[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Kx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class zO extends xm{get name(){return"websocket"}doOpen(){const e=this.uri(),s=this.opts.protocols,i=Kx?{}:Fx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,s,i)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;gm(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Gx()),this.supportsBinary||(s.b64=1),this.createUri(e,s)}}const ld=$n.WebSocket||$n.MozWebSocket;class IO extends zO{createSocket(e,s,i){return Kx?new ld(e,s,i):s?new ld(e,s):new ld(e)}doWrite(e,s){this.ws.send(s)}}class $O extends xm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const s=SO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(s).getReader(),o=wO();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:p,value:g})=>{p||(this.onPacket(g),c())}).catch(p=>{})};c();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;this._writer.write(i).then(()=>{o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const HO={websocket:IO,webtransport:$O,polling:UO},FO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,GO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ud(n){if(n.length>8e3)throw"URI too long";const e=n,s=n.indexOf("["),i=n.indexOf("]");s!=-1&&i!=-1&&(n=n.substring(0,s)+n.substring(s,i).replace(/:/g,";")+n.substring(i,n.length));let o=FO.exec(n||""),c={},m=14;for(;m--;)c[GO[m]]=o[m]||"";return s!=-1&&i!=-1&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=VO(c,c.path),c.queryKey=YO(c,c.query),c}function VO(n,e){const s=/\/{2,9}/g,i=e.replace(s,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function YO(n,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const zd=typeof addEventListener=="function"&&typeof removeEventListener=="function",au=[];zd&&addEventListener("offline",()=>{au.forEach(n=>n())},!1);class Ss extends Tt{constructor(e,s){if(super(),this.binaryType=OO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(s=e,e=null),e){const i=Ud(e);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=Ud(s.host).host);Tu(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(i=>{const o=i.prototype.name;this.transports.push(o),this._transportsByName[o]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=MO(this.opts.query)),zd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},au.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const s=Object.assign({},this.opts.query);s.EIO=Hx,s.transport=e,this.id&&(s.sid=this.id);const i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Ss.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(e);s.open(),this.setTransport(s)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",Ss.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const s=new Error("server error");s.code=e.data,this._onError(s);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){const o=this.writeBuffer[i].data;if(o&&(s+=NO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Nu(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,s,i){return this._sendPacket("message",e,s,i),this}send(e,s,i){return this._sendPacket("message",e,s,i),this}_sendPacket(e,s,i,o){if(typeof s=="function"&&(o=s,s=void 0),typeof i=="function"&&(o=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const c={type:e,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),e()},i=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(Ss.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),zd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=au.indexOf(this._offlineEventListener);i!==-1&&au.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,s),this.writeBuffer=[],this._prevBufferLen=0}}}Ss.protocol=Hx;class KO extends Ss{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let s=this.createTransport(e),i=!1;Ss.priorWebsocketSuccess=!1;const o=()=>{i||(s.send([{type:"ping",data:"probe"}]),s.once("packet",b=>{if(!i)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Ss.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(d(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=s.name,this.emitReserved("upgradeError",x)}}))};function c(){i||(i=!0,d(),s.close(),s=null)}const m=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function p(){m("transport closed")}function g(){m("socket closed")}function u(b){s&&b.name!==s.name&&c()}const d=()=>{s.removeListener("open",o),s.removeListener("error",m),s.removeListener("close",p),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",m),s.once("close",p),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const s=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&s.push(e[i]);return s}}let JO=class extends KO{constructor(e,s={}){const i=typeof e=="object"?e:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>HO[o]).filter(o=>!!o)),super(e,i)}};function QO(n,e="",s){let i=n;s=s||typeof location<"u"&&location,n==null&&(n=s.protocol+"//"+s.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=s.protocol+n:n=s.host+n),/^(https?|wss?):\/\//.test(n)||(typeof s<"u"?n=s.protocol+"//"+n:n="https://"+n),i=Ud(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const c=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+c+":"+i.port+e,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const XO=typeof ArrayBuffer=="function",WO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Jx=Object.prototype.toString,ZO=typeof Blob=="function"||typeof Blob<"u"&&Jx.call(Blob)==="[object BlobConstructor]",eA=typeof File=="function"||typeof File<"u"&&Jx.call(File)==="[object FileConstructor]";function vm(n){return XO&&(n instanceof ArrayBuffer||WO(n))||ZO&&n instanceof Blob||eA&&n instanceof File}function ou(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(ou(n[s]))return!0;return!1}if(vm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return ou(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&ou(n[s]))return!0;return!1}function tA(n){const e=[],s=n.data,i=n;return i.data=Id(s,e),i.attachments=e.length,{packet:i,buffers:e}}function Id(n,e){if(!n)return n;if(vm(n)){const s={_placeholder:!0,num:e.length};return e.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Id(n[i],e);return s}else if(typeof n=="object"&&!(n instanceof Date)){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=Id(n[i],e));return s}return n}function nA(n,e){return n.data=$d(n.data,e),delete n.attachments,n}function $d(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=$d(n[s],e);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=$d(n[s],e));return n}const rA=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ve;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ve||(Ve={}));class sA{constructor(e){this.replacer=e}encode(e){return(e.type===Ve.EVENT||e.type===Ve.ACK)&&ou(e)?this.encodeAsBinary({type:e.type===Ve.EVENT?Ve.BINARY_EVENT:Ve.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let s=""+e.type;return(e.type===Ve.BINARY_EVENT||e.type===Ve.BINARY_ACK)&&(s+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(s+=e.nsp+","),e.id!=null&&(s+=e.id),e.data!=null&&(s+=JSON.stringify(e.data,this.replacer)),s}encodeAsBinary(e){const s=tA(e),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class _m extends Tt{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let s;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(e);const i=s.type===Ve.BINARY_EVENT;i||s.type===Ve.BINARY_ACK?(s.type=i?Ve.EVENT:Ve.ACK,this.reconstructor=new iA(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(vm(e)||e.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(e),s&&(this.reconstructor=null,super.emitReserved("decoded",s));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let s=0;const i={type:Number(e.charAt(0))};if(Ve[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Ve.BINARY_EVENT||i.type===Ve.BINARY_ACK){const c=s+1;for(;e.charAt(++s)!=="-"&&s!=e.length;);const m=e.substring(c,s);if(m!=Number(m)||e.charAt(s)!=="-")throw new Error("Illegal attachments");const p=Number(m);if(!aA(p)||p<0)throw new Error("Illegal attachments");if(p>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=p}if(e.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(e.charAt(s)===","||s===e.length););i.nsp=e.substring(c,s)}else i.nsp="/";const o=e.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const m=e.charAt(s);if(m==null||Number(m)!=m){--s;break}if(s===e.length)break}i.id=Number(e.substring(c,s+1))}if(e.charAt(++s)){const c=this.tryParse(e.substr(s));if(_m.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,s){switch(e){case Ve.CONNECT:return _b(s);case Ve.DISCONNECT:return s===void 0;case Ve.CONNECT_ERROR:return typeof s=="string"||_b(s);case Ve.EVENT:case Ve.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&rA.indexOf(s[0])===-1);case Ve.ACK:case Ve.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class iA{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const s=nA(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const aA=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function _b(n){return Object.prototype.toString.call(n)==="[object Object]"}const oA=Object.freeze(Object.defineProperty({__proto__:null,Decoder:_m,Encoder:sA,get PacketType(){return Ve}},Symbol.toStringTag,{value:"Module"}));function Xn(n,e,s){return n.on(e,s),function(){n.off(e,s)}}const lA=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Qx extends Tt{constructor(e,s,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Xn(e,"open",this.onopen.bind(this)),Xn(e,"packet",this.onpacket.bind(this)),Xn(e,"error",this.onerror.bind(this)),Xn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...s){var i,o,c;if(lA.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(s.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const m={type:Ve.EVENT,data:s};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const d=this.ids++,b=s.pop();this._registerAckCallback(d,b),m.id=d}const p=(o=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!p||(g?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(e,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[e]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===e&&this.sendBuffer.splice(p,1);s.call(this,new Error("operation has timed out"))},o),m=(...p)=>{this.io.clearTimeoutFn(c),s.apply(this,p)};m.withError=!0,this.acks[e]=m}emitWithAck(e,...s){return new Promise((i,o)=>{const c=(m,p)=>m?o(m):i(p);c.withError=!0,s.push(c),this.emit(e,...s)})}_addToQueue(e){let s;typeof e[e.length-1]=="function"&&(s=e.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...c)=>(this._queue[0],o!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!e||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Ve.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(i=>String(i.id)===e)){const i=this.acks[e];delete this.acks[e],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Ve.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ve.EVENT:case Ve.BINARY_EVENT:this.onevent(e);break;case Ve.ACK:case Ve.BINARY_ACK:this.onack(e);break;case Ve.DISCONNECT:this.ondisconnect();break;case Ve.CONNECT_ERROR:this.destroy();const i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){const s=e.data||[];e.id!=null&&s.push(this.ack(e.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:Ve.ACK,id:e,data:o}))}}onack(e){const s=this.acks[e.id];typeof s=="function"&&(delete this.acks[e.id],s.withError&&e.data.unshift(null),s.apply(this,e.data))}onconnect(e,s){this.id=e,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ve.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,e.data)}}}function oa(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}oa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};oa.prototype.reset=function(){this.attempts=0};oa.prototype.setMin=function(n){this.ms=n};oa.prototype.setMax=function(n){this.max=n};oa.prototype.setJitter=function(n){this.jitter=n};class Hd extends Tt{constructor(e,s){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(s=e,e=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,Tu(this,s),this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor((i=s.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new oa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=e;const o=s.parser||oA;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var s;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(s=this.backoff)===null||s===void 0||s.setMin(e),this)}randomizationFactor(e){var s;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(s=this.backoff)===null||s===void 0||s.setJitter(e),this)}reconnectionDelayMax(e){var s;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(s=this.backoff)===null||s===void 0||s.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new JO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Xn(s,"open",function(){i.onopen(),e&&e()}),c=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),e?e(p):this.maybeReconnectOnOpen()},m=Xn(s,"error",c);if(this._timeout!==!1){const p=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},p);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(m),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Xn(e,"ping",this.onping.bind(this)),Xn(e,"data",this.ondata.bind(this)),Xn(e,"error",this.onerror.bind(this)),Xn(e,"close",this.onclose.bind(this)),Xn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(s){this.onclose("parse error",s)}}ondecoded(e){Nu(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,s){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new Qx(this,e,s),this.nsps[e]=i),i}_destroy(e){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(e){const s=this.encoder.encode(e);for(let i=0;i<s.length;i++)this.engine.write(s[i],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const s=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const io={};function lu(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const s=QO(n,e.path||"/socket.io"),i=s.source,o=s.id,c=s.path,m=io[o]&&c in io[o].nsps,p=e.forceNew||e["force new connection"]||e.multiplex===!1||m;let g;return p?g=new Hd(i,e):(io[o]||(io[o]=new Hd(i,e)),g=io[o]),s.query&&!e.query&&(e.query=s.queryKey),g.socket(s.path,e)}Object.assign(lu,{Manager:Hd,Socket:Qx,io:lu,connect:lu});const cA=E.createContext({connected:!1,subscribe:()=>()=>{}});function uA({children:n}){const{isAuthenticated:e}=qt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),m=E.useCallback((g,u)=>{var b;const d=c.current;return d.has(g)||(d.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),d.get(g).add(u),()=>{var v;const x=d.get(g);x&&(x.delete(u),x.size===0&&(d.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),p=E.useCallback((g,u)=>{for(const[d,b]of c.current)if(Lx(g,d))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!e)return;const g=lu({path:`${Vt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const d=wd();u(d?{token:d}:{})}});return s.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),o(!0);for(const u of c.current.keys())g.emit("lt.subscribe",u)}),g.on("disconnect",u=>{console.log("[lt-socketio] disconnected:",u),o(!1)}),g.on("connect_error",u=>{console.warn("[lt-socketio] connect error:",u.message),o(!1)}),g.onAny((u,d)=>{if(u.startsWith("lt."))try{const b=typeof d=="string"?JSON.parse(d):d;p(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[p,e]),h.jsx(cA.Provider,{value:{connected:i,subscribe:m},children:h.jsx(aa.Provider,{value:{connected:i,subscribe:m},children:n})})}function fA({children:n}){const{isAuthenticated:e}=qt(),s=Pe(),[i,o]=E.useState(null),[c,m]=E.useState({url:null,policy:Vg(null)});E.useEffect(()=>{let u=!1;async function d(){var b;try{console.log("[lt-transport] detecting event transport...");const x=await lm(),v=(b=x==null?void 0:x.events)==null?void 0:b.transport;console.log("[lt-transport] server reports:",v),u||(v==="nats"&&m({url:x.events.natsWsUrl??null,policy:Vg(x.events.reconnect)}),o(v==="nats"?"nats":"socketio"))}catch(x){console.warn("[lt-transport] settings fetch error, falling back to socketio",x),u||o("socketio")}}return d(),()=>{u=!0}},[e]);const p=E.useCallback(()=>cE(c.url),[c.url]),g=E.useCallback(()=>{s.invalidateQueries({refetchType:"active"})},[s]);return i==="nats"?h.jsx(pO,{resolveCredentials:p,policy:c.policy,onReconnect:g,sessionKey:e,children:n}):i==="socketio"?h.jsx(uA,{children:n}):h.jsx(h.Fragment,{children:n})}const wm="lt_view_as",Sm="lt_ai_override",Fd="lt_graph_enabled",Gd="lt_infrastructure_enabled",Em="lt_scan_override";function Xx(){try{const n=localStorage.getItem(Sm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function hA(n){try{localStorage.setItem(Sm,String(n))}catch{}}function dA(){try{localStorage.removeItem(Sm)}catch{}}function Om(){try{const n=localStorage.getItem(wm);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function mA(n){try{localStorage.setItem(wm,n)}catch{}window.location.reload()}function Vd(){try{localStorage.removeItem(wm)}catch{}window.location.reload()}function Wx(){try{return localStorage.getItem(Fd)==="true"}catch{return!1}}function pA(n){try{n?localStorage.setItem(Fd,"true"):localStorage.removeItem(Fd)}catch{}}function Zx(){try{return localStorage.getItem(Gd)==="true"}catch{return!1}}function yA(n){try{n?localStorage.setItem(Gd,"true"):localStorage.removeItem(Gd)}catch{}}function ev(){try{const n=localStorage.getItem(Em);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function gA(n){try{localStorage.setItem(Em,String(n))}catch{}}function bA(){try{localStorage.removeItem(Em)}catch{}}function tv(){const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=qt(),i=Om(),o=n||s("engineer"),c=e("admin"),m=n||e("admin");return{isBuilder:i?!1:o,isOps:i?i==="admin"||i==="engineer":c,canBulk:i?i==="admin":m,viewAs:i,realIsBuilder:o}}function nv(){var u;const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=qt(),{data:i}=er(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":e("admin")?"admin":s("engineer")?"engineer":"operator",m=Om(),p=m==="admin"||m==="engineer"||m==="operator"?m:null,g=p??c;return{tier:g,realTier:c,viewAs:p,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}const Am=E.createContext(null);function Cu(){const n=E.useContext(Am);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function xA(){var n;return((n=E.useContext(Am))==null?void 0:n.identity)??null}function vA({children:n}){const[e,s]=E.useState(null),i=E.useRef(e);i.current=e,E.useEffect(()=>{if(!(e!=null&&e.expiresAt))return;const d=new Date(e.expiresAt).getTime()-Date.now();if(d<=0){s(null);return}const b=setTimeout(()=>s(null),d);return()=>clearTimeout(b)},[e]);const o=E.useCallback(d=>{var x;if(!d.actingToken||!d.actor)return null;const b=((x=i.current)==null?void 0:x.actingToken)??null;return s({actingToken:d.actingToken,actorId:d.actor.id,displayName:d.actor.displayName,expiresAt:d.expiresAt??null,subjectScoped:d.grantScope==="subject"}),b},[]),c=E.useCallback(()=>s(null),[]),m=E.useCallback((d,b)=>{const x=i.current;b===0&&(x==null?void 0:x.actingToken)===d&&s(null)},[]),p=E.useCallback((d,b)=>{const x=i.current;if(!x||x.actingToken!==d||!b.acting)return;const{consumed:v,remaining:_,bound:S}=b.acting;(v&&_===0||S&&b.clearSubject)&&s(null)},[]);E.useEffect(()=>(Ig(()=>{var d;return((d=i.current)==null?void 0:d.actingToken)??null}),Hg(c),$g(m),()=>{Ig(null),Hg(null),$g(null)}),[c,m]);const g=E.useCallback(()=>{var b;const d=(b=i.current)==null?void 0:b.expiresAt;return d?Math.max(0,Math.floor((new Date(d).getTime()-Date.now())/1e3)):0},[]),u=E.useMemo(()=>({identity:e,prime:o,clear:c,settle:p,remainingSeconds:g}),[e,o,c,p,g]);return h.jsx(Am.Provider,{value:u,children:n})}function _A(){const{user:n}=qt(),{identity:e}=Cu(),s=n==null?void 0:n.userId,i=e==null?void 0:e.actorId,o=E.useCallback(c=>!!c&&(c===i||c===s),[i,s]);return{viewerId:i??s,isViewer:o}}function rv(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function fr(n={}){const e=n.role?rv(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Xt}.system.escalation.${e}.${s}.${i}`}function Yd(n){return n.verbs.map(e=>fr({role:n.role,verb:e}))}function jm(n){const{user:e,isSuperAdmin:s,hasRoleType:i}=qt(),o=s||i("admin"),c=((e==null?void 0:e.roles)??[]).map(p=>p.role).sort().join(","),m=(n??[]).join(",");return E.useMemo(()=>{const p=m?m.split(","):null;return o||!c?p?Yd({verbs:p}):[fr({})]:c.split(",").flatMap(g=>p?Yd({role:g,verbs:p}):[fr({role:g})])},[o,c,m])}const Kd="/escalations/detail/";function wA(n){return n.startsWith(Kd)&&n.slice(Kd.length).split("/")[0]||void 0}function SA(){const{isViewer:n}=_A(),e=ni(),s=en(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n);o.current=n;const c=E.useCallback(m=>{var b,x,v;if((m==null?void 0:m.assignedAtCreation)!==!0)return;const p=(m==null?void 0:m.escalationId)??((b=m==null?void 0:m.data)==null?void 0:b.id),g=(x=m==null?void 0:m.data)==null?void 0:x.assigned_to,u=(v=m==null?void 0:m.data)==null?void 0:v.parent_id;if(!p||!o.current(g)||!u||u!==wA(i.current))return;const d=`${Kd}${p}`;i.current!==d&&e(d)},[e]);js(jm(["claimed"]),c)}const sv=6048e5,EA=864e5,wb=6e4,Sb=525600,Eb=43200,Ob=1440,Ab=Symbol.for("constructDateFrom");function Br(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&Ab in n?n[Ab](e):n instanceof Date?new n.constructor(e):new Date(e)}function kn(n,e){return Br(e||n,n)}let OA={};function Lo(){return OA}function No(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.weekStartsOn)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=kn(n,e==null?void 0:e.in),c=o.getDay(),m=(c<i?7:0)+c-i;return o.setDate(o.getDate()-m),o.setHours(0,0,0,0),o}function bu(n,e){return No(n,{...e,weekStartsOn:1})}function iv(n,e){const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),m=Br(s,0);m.setFullYear(i,0,4),m.setHours(0,0,0,0);const p=bu(m);return s.getTime()>=c.getTime()?i+1:s.getTime()>=p.getTime()?i:i-1}function xu(n){const e=kn(n),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+n-+s}function av(n,...e){const s=Br.bind(null,n||e.find(i=>typeof i=="object"));return e.map(s)}function jb(n,e){const s=kn(n,e==null?void 0:e.in);return s.setHours(0,0,0,0),s}function AA(n,e,s){const[i,o]=av(s==null?void 0:s.in,n,e),c=jb(i),m=jb(o),p=+c-xu(c),g=+m-xu(m);return Math.round((p-g)/EA)}function jA(n,e){const s=iv(n,e),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function kA(n,e){const s=+kn(n)-+kn(e);return s<0?-1:s>0?1:s}function NA(n){return Br(n,Date.now())}function TA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function CA(n){return!(!TA(n)&&typeof n!="number"||isNaN(+kn(n)))}function MA(n){return e=>{const i=(n?Math[n]:Math.trunc)(e);return i===0?0:i}}function RA(n,e){const s=kn(n,e==null?void 0:e.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const DA={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},LA=(n,e,s)=>{let i;const o=DA[n];return typeof o=="string"?i=o:e===1?i=o.one:i=o.other.replace("{{count}}",e.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function cd(n){return(e={})=>{const s=e.width?String(e.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const qA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},PA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},BA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},UA={date:cd({formats:qA,defaultWidth:"full"}),time:cd({formats:PA,defaultWidth:"full"}),dateTime:cd({formats:BA,defaultWidth:"full"})},zA={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},IA=(n,e,s,i)=>zA[n];function ao(n){return(e,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const m=n.defaultFormattingWidth||n.defaultWidth,p=s!=null&&s.width?String(s.width):m;o=n.formattingValues[p]||n.formattingValues[m]}else{const m=n.defaultWidth,p=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[p]||n.values[m]}const c=n.argumentCallback?n.argumentCallback(e):e;return o[c]}}const $A={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},HA={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},FA={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},GA={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},VA={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},YA={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},KA=(n,e)=>{const s=Number(n),i=s%100;if(i>20||i<10)switch(i%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},JA={ordinalNumber:KA,era:ao({values:$A,defaultWidth:"wide"}),quarter:ao({values:HA,defaultWidth:"wide",argumentCallback:n=>n-1}),month:ao({values:FA,defaultWidth:"wide"}),day:ao({values:GA,defaultWidth:"wide"}),dayPeriod:ao({values:VA,defaultWidth:"wide",formattingValues:YA,defaultFormattingWidth:"wide"})};function oo(n){return(e,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=e.match(o);if(!c)return null;const m=c[0],p=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(p)?XA(p,b=>b.test(m)):QA(p,b=>b.test(m));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const d=e.slice(m.length);return{value:u,rest:d}}}function QA(n,e){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&e(n[s]))return s}function XA(n,e){for(let s=0;s<n.length;s++)if(e(n[s]))return s}function WA(n){return(e,s={})=>{const i=e.match(n.matchPattern);if(!i)return null;const o=i[0],c=e.match(n.parsePattern);if(!c)return null;let m=n.valueCallback?n.valueCallback(c[0]):c[0];m=s.valueCallback?s.valueCallback(m):m;const p=e.slice(o.length);return{value:m,rest:p}}}const ZA=/^(\d+)(th|st|nd|rd)?/i,ej=/\d+/i,tj={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},nj={any:[/^b/i,/^(a|c)/i]},rj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},sj={any:[/1/i,/2/i,/3/i,/4/i]},ij={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},aj={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},oj={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},lj={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},cj={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},uj={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},fj={ordinalNumber:WA({matchPattern:ZA,parsePattern:ej,valueCallback:n=>parseInt(n,10)}),era:oo({matchPatterns:tj,defaultMatchWidth:"wide",parsePatterns:nj,defaultParseWidth:"any"}),quarter:oo({matchPatterns:rj,defaultMatchWidth:"wide",parsePatterns:sj,defaultParseWidth:"any",valueCallback:n=>n+1}),month:oo({matchPatterns:ij,defaultMatchWidth:"wide",parsePatterns:aj,defaultParseWidth:"any"}),day:oo({matchPatterns:oj,defaultMatchWidth:"wide",parsePatterns:lj,defaultParseWidth:"any"}),dayPeriod:oo({matchPatterns:cj,defaultMatchWidth:"any",parsePatterns:uj,defaultParseWidth:"any"})},ov={code:"en-US",formatDistance:LA,formatLong:UA,formatRelative:IA,localize:JA,match:fj,options:{weekStartsOn:0,firstWeekContainsDate:1}};function hj(n,e){const s=kn(n,e==null?void 0:e.in);return AA(s,RA(s))+1}function dj(n,e){const s=kn(n,e==null?void 0:e.in),i=+bu(s)-+jA(s);return Math.round(i/sv)+1}function lv(n,e){var d,b,x,v;const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Lo(),c=(e==null?void 0:e.firstWeekContainsDate)??((b=(d=e==null?void 0:e.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,m=Br((e==null?void 0:e.in)||n,0);m.setFullYear(i+1,0,c),m.setHours(0,0,0,0);const p=No(m,e),g=Br((e==null?void 0:e.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=No(g,e);return+s>=+p?i+1:+s>=+u?i:i-1}function mj(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.firstWeekContainsDate)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=lv(n,e),c=Br((e==null?void 0:e.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),No(c,e)}function pj(n,e){const s=kn(n,e==null?void 0:e.in),i=+No(s,e)-+mj(s,e);return Math.round(i/sv)+1}function tt(n,e){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(e,"0");return s+i}const ys={y(n,e){const s=n.getFullYear(),i=s>0?s:1-s;return tt(e==="yy"?i%100:i,e.length)},M(n,e){const s=n.getMonth();return e==="M"?String(s+1):tt(s+1,2)},d(n,e){return tt(n.getDate(),e.length)},a(n,e){const s=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(n,e){return tt(n.getHours()%12||12,e.length)},H(n,e){return tt(n.getHours(),e.length)},m(n,e){return tt(n.getMinutes(),e.length)},s(n,e){return tt(n.getSeconds(),e.length)},S(n,e){const s=e.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return tt(o,e.length)}},Hi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},kb={G:function(n,e,s){const i=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return s.era(i,{width:"abbreviated"});case"GGGGG":return s.era(i,{width:"narrow"});case"GGGG":default:return s.era(i,{width:"wide"})}},y:function(n,e,s){if(e==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ys.y(n,e)},Y:function(n,e,s,i){const o=lv(n,i),c=o>0?o:1-o;if(e==="YY"){const m=c%100;return tt(m,2)}return e==="Yo"?s.ordinalNumber(c,{unit:"year"}):tt(c,e.length)},R:function(n,e){const s=iv(n);return tt(s,e.length)},u:function(n,e){const s=n.getFullYear();return tt(s,e.length)},Q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(i);case"QQ":return tt(i,2);case"Qo":return s.ordinalNumber(i,{unit:"quarter"});case"QQQ":return s.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(i,{width:"wide",context:"formatting"})}},q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(i);case"qq":return tt(i,2);case"qo":return s.ordinalNumber(i,{unit:"quarter"});case"qqq":return s.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(i,{width:"wide",context:"standalone"})}},M:function(n,e,s){const i=n.getMonth();switch(e){case"M":case"MM":return ys.M(n,e);case"Mo":return s.ordinalNumber(i+1,{unit:"month"});case"MMM":return s.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(i,{width:"wide",context:"formatting"})}},L:function(n,e,s){const i=n.getMonth();switch(e){case"L":return String(i+1);case"LL":return tt(i+1,2);case"Lo":return s.ordinalNumber(i+1,{unit:"month"});case"LLL":return s.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(i,{width:"wide",context:"standalone"})}},w:function(n,e,s,i){const o=pj(n,i);return e==="wo"?s.ordinalNumber(o,{unit:"week"}):tt(o,e.length)},I:function(n,e,s){const i=dj(n);return e==="Io"?s.ordinalNumber(i,{unit:"week"}):tt(i,e.length)},d:function(n,e,s){return e==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ys.d(n,e)},D:function(n,e,s){const i=hj(n);return e==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):tt(i,e.length)},E:function(n,e,s){const i=n.getDay();switch(e){case"E":case"EE":case"EEE":return s.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(i,{width:"short",context:"formatting"});case"EEEE":default:return s.day(i,{width:"wide",context:"formatting"})}},e:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"e":return String(c);case"ee":return tt(c,2);case"eo":return s.ordinalNumber(c,{unit:"day"});case"eee":return s.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(o,{width:"short",context:"formatting"});case"eeee":default:return s.day(o,{width:"wide",context:"formatting"})}},c:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"c":return String(c);case"cc":return tt(c,e.length);case"co":return s.ordinalNumber(c,{unit:"day"});case"ccc":return s.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(o,{width:"narrow",context:"standalone"});case"cccccc":return s.day(o,{width:"short",context:"standalone"});case"cccc":default:return s.day(o,{width:"wide",context:"standalone"})}},i:function(n,e,s){const i=n.getDay(),o=i===0?7:i;switch(e){case"i":return String(o);case"ii":return tt(o,e.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(i,{width:"short",context:"formatting"});case"iiii":default:return s.day(i,{width:"wide",context:"formatting"})}},a:function(n,e,s){const o=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(n,e,s){const i=n.getHours();let o;switch(i===12?o=Hi.noon:i===0?o=Hi.midnight:o=i/12>=1?"pm":"am",e){case"b":case"bb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(n,e,s){const i=n.getHours();let o;switch(i>=17?o=Hi.evening:i>=12?o=Hi.afternoon:i>=4?o=Hi.morning:o=Hi.night,e){case"B":case"BB":case"BBB":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(n,e,s){if(e==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ys.h(n,e)},H:function(n,e,s){return e==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ys.H(n,e)},K:function(n,e,s){const i=n.getHours()%12;return e==="Ko"?s.ordinalNumber(i,{unit:"hour"}):tt(i,e.length)},k:function(n,e,s){let i=n.getHours();return i===0&&(i=24),e==="ko"?s.ordinalNumber(i,{unit:"hour"}):tt(i,e.length)},m:function(n,e,s){return e==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ys.m(n,e)},s:function(n,e,s){return e==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ys.s(n,e)},S:function(n,e){return ys.S(n,e)},X:function(n,e,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(e){case"X":return Tb(i);case"XXXX":case"XX":return Ws(i);case"XXXXX":case"XXX":default:return Ws(i,":")}},x:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"x":return Tb(i);case"xxxx":case"xx":return Ws(i);case"xxxxx":case"xxx":default:return Ws(i,":")}},O:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Nb(i,":");case"OOOO":default:return"GMT"+Ws(i,":")}},z:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Nb(i,":");case"zzzz":default:return"GMT"+Ws(i,":")}},t:function(n,e,s){const i=Math.trunc(+n/1e3);return tt(i,e.length)},T:function(n,e,s){return tt(+n,e.length)}};function Nb(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=Math.trunc(i/60),c=i%60;return c===0?s+String(o):s+String(o)+e+tt(c,2)}function Tb(n,e){return n%60===0?(n>0?"-":"+")+tt(Math.abs(n)/60,2):Ws(n,e)}function Ws(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=tt(Math.trunc(i/60),2),c=tt(i%60,2);return s+o+e+c}const Cb=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},cv=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},yj=(n,e)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return Cb(n,e);let c;switch(i){case"P":c=e.dateTime({width:"short"});break;case"PP":c=e.dateTime({width:"medium"});break;case"PPP":c=e.dateTime({width:"long"});break;case"PPPP":default:c=e.dateTime({width:"full"});break}return c.replace("{{date}}",Cb(i,e)).replace("{{time}}",cv(o,e))},gj={p:cv,P:yj},bj=/^D+$/,xj=/^Y+$/,vj=["D","DD","YY","YYYY"];function _j(n){return bj.test(n)}function wj(n){return xj.test(n)}function Sj(n,e,s){const i=Ej(n,e,s);if(console.warn(i),vj.includes(n))throw new RangeError(i)}function Ej(n,e,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Oj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Aj=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,jj=/^'([^]*?)'?$/,kj=/''/g,Nj=/[a-zA-Z]/;function Tj(n,e,s){var d,b,x,v;const i=Lo(),o=i.locale??ov,c=i.firstWeekContainsDate??((b=(d=i.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??1,m=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,p=kn(n,s==null?void 0:s.in);if(!CA(p))throw new RangeError("Invalid time value");let g=e.match(Aj).map(_=>{const S=_[0];if(S==="p"||S==="P"){const C=gj[S];return C(_,o.formatLong)}return _}).join("").match(Oj).map(_=>{if(_==="''")return{isToken:!1,value:"'"};const S=_[0];if(S==="'")return{isToken:!1,value:Cj(_)};if(kb[S])return{isToken:!0,value:_};if(S.match(Nj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:_}});o.localize.preprocessor&&(g=o.localize.preprocessor(p,g));const u={firstWeekContainsDate:c,weekStartsOn:m,locale:o};return g.map(_=>{if(!_.isToken)return _.value;const S=_.value;(wj(S)||_j(S))&&Sj(S,e,String(n));const C=kb[S[0]];return C(p,S,o.localize,u)}).join("")}function Cj(n){const e=n.match(jj);return e?e[1].replace(kj,"'"):n}function Mj(n,e,s){const i=Lo(),o=(s==null?void 0:s.locale)??i.locale??ov,c=kA(n,e);if(isNaN(c))throw new RangeError("Invalid time value");const m=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[p,g]=av(s==null?void 0:s.in,...c>0?[e,n]:[n,e]),u=MA((s==null?void 0:s.roundingMethod)??"round"),d=g.getTime()-p.getTime(),b=d/wb,x=xu(g)-xu(p),v=(d-x)/wb,_=s==null?void 0:s.unit;let S;if(_?S=_:b<1?S="second":b<60?S="minute":b<Ob?S="hour":v<Eb?S="day":v<Sb?S="month":S="year",S==="second"){const C=u(d/1e3);return o.formatDistance("xSeconds",C,m)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,m)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,m)}else if(S==="day"){const C=u(v/Ob);return o.formatDistance("xDays",C,m)}else if(S==="month"){const C=u(v/Eb);return C===12&&_!=="month"?o.formatDistance("xYears",1,m):o.formatDistance("xMonths",C,m)}else{const C=u(v/Sb);return o.formatDistance("xYears",C,m)}}function Rj(n,e){return Mj(n,NA(n),e)}let vu=null;function Dj(n){vu=n||null}function Lj(){return vu}function qj(n,e,s){const i=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...s?{second:"2-digit"}:{},hour12:!0}).formatToParts(n);return Object.fromEntries(i.map(o=>[o.type,o.value]))}function km(n,e=!1){const s=typeof n=="string"?new Date(n):n;if(Number.isNaN(s.getTime()))return String(n);if(!vu)return Tj(s,e?"MMM d, yyyy h:mm:ss a":"MMM d, yyyy h:mm a");const i=qj(s,vu,e),o=`${i.hour}:${i.minute}${e?`:${i.second}`:""}`;return`${i.month} ${i.day}, ${i.year} ${o} ${i.dayPeriod}`}function uv(n){const e=n??[];return e.length>0&&e.every(s=>s.type==="member"&&s.write_scope==="none")}function d5(n,e,s){return!e||!uv(n)?!0:!!s&&!s.subjectScoped}const Nm={staleTime:5*6e4,refetchOnWindowFocus:!1};function m5(n={},e={}){const s=new URLSearchParams;return n.role&&s.set("role",n.role),n.roleType&&s.set("roleType",n.roleType),n.status&&s.set("status",n.status),n.search&&s.set("search",n.search),n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),qe({queryKey:["users",n],queryFn:()=>ue(`/users?${s}`),enabled:e.enabled??!0,...Nm})}const Mb=200;async function Pj(n){const e=[];for(let s=0;s<n.length;s+=Mb){const i=await ue("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+Mb)})});e.push(...i.users??[])}return e}let Jd=[],Qd=new Map,Xd=!1;function Bj(){const n=Jd,e=Qd;Jd=[],Qd=new Map,Xd=!1,Pj(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of e)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of e.values())i.reject(s)})}function Uj(n){return new Promise((e,s)=>{Jd.push(n),Qd.set(n,{resolve:e,reject:s}),Xd||(Xd=!0,setTimeout(Bj,0))})}function p5(n){return qe({queryKey:["user-name",n],queryFn:()=>Uj(n),enabled:!!n,...Nm})}function zj(n){return qe({queryKey:["users",n,"roles"],queryFn:async()=>(await ue(`/users/${n}/roles`)).roles??[],enabled:!!n,...Nm})}function y5(){const n=Pe();return $e({mutationFn:e=>ue("/users",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function g5(){const n=Pe();return $e({mutationFn:({id:e,...s})=>ue(`/users/${e}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function b5(){const n=Pe();return $e({mutationFn:({id:e,ops:s})=>ue(`/users/${e}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function x5(){return qe({queryKey:["users","system-property-keys"],queryFn:()=>ue("/users/system-property-keys")})}function v5(){const n=Pe();return $e({mutationFn:e=>ue(`/users/${e}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function _5(){const n=Pe();return $e({mutationFn:({userId:e,role:s,type:i,read_scope:o,write_scope:c})=>ue(`/users/${e}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function w5(){const n=Pe();return $e({mutationFn:({userId:e,role:s})=>ue(`/users/${e}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const S5={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function Ij(){return qe({queryKey:["roles"],queryFn:()=>ue("/roles")})}function Mu(n){return qe({queryKey:["roles","details"],queryFn:()=>ue("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function E5(n,e,s=!0){return qe({queryKey:["roles",n,"schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function O5(n){return qe({queryKey:["roles",n,"schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function A5(n,e,s=!0){return qe({queryKey:["roles",n,"list-schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function j5(n){return qe({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function k5(){const n=Pe();return $e({mutationFn:e=>ue("/roles",{method:"POST",body:JSON.stringify({role:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function N5(){const n=Pe();return $e({mutationFn:({role:e,...s})=>ue(`/roles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:e,...s})=>{await n.cancelQueries({queryKey:["roles","details"]});const i=n.getQueryData(["roles","details"]);return i&&n.setQueryData(["roles","details"],{roles:i.roles.map(o=>o.role===e?{...o,...s}:o)}),{previous:i}},onError:(e,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function T5(){const n=Pe();return $e({mutationFn:e=>ue(`/roles/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const fv="lt:station:kiosk-role:";function Wd(n){return`${fv}${n}`}const Zd=new Set;function $j(){for(const n of Zd)n()}function Hj(n){try{return localStorage.getItem(Wd(n))}catch{return null}}function Fj(n,e){try{e===null?localStorage.removeItem(Wd(n)):localStorage.setItem(Wd(n),e)}catch{}$j()}function Gj(n){Zd.add(n);const e=s=>{(s.key===null||s.key.startsWith(fv))&&n()};try{window.addEventListener("storage",e)}catch{}return()=>{Zd.delete(n);try{window.removeEventListener("storage",e)}catch{}}}function Vj(n){return E.useSyncExternalStore(Gj,()=>n?Hj(n):null)}const _u="/portal";function Yj(n){return n===_u||n.startsWith(`${_u}/`)}function Tm(n,e){const s=`${_u}/${encodeURIComponent(n)}`;return e?`${s}/${encodeURIComponent(e)}`:s}function ea(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function Kj(n){return ea(n).length>0}function C5(n,e){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(e);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function hv(n,e){return e.length>0?Tm(n,e[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Cm(){const{user:n}=qt(),e=(n==null?void 0:n.userId)??null,{data:s}=zj(e),{data:i}=Mu(),o=Vj(e),c=E.useCallback(m=>{e&&Fj(e,m)},[e]);return E.useMemo(()=>{const m={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},p=s??[];if(p.length===0||p.some(v=>v.type!=="member"))return m;const g=v=>{var _;return(_=i==null?void 0:i.roles)==null?void 0:_.find(S=>S.role===v)},u=v=>{var _,S;return((S=(_=g(v))==null?void 0:_.properties)==null?void 0:S.kiosk)===!0},d=p.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:hv(v,ea(g(v))),targets:d,selectable:d.length>=2,selectRole:c});if(p.length===1)return d.length===1?b(d[0]):m;if(!uv(p)||d.length===0)return m;const x=o&&d.includes(o)?o:d.length===1?d[0]:null;return x?b(x):{...m,targets:d,selectable:!0}},[s,i,o,c])}const Jj="/escalations/available",Qj=["/escalations",_u,"/scan","/login"];function Xj(n,e=""){if(n===Jj){const s=new URLSearchParams(e);if(!s.get("role")&&!s.get("facets"))return!1}return Qj.some(s=>n===s||n.startsWith(`${s}/`)||n.startsWith(`${s}?`))}const Mm=E.createContext(null),ud="lt_sidebar_collapsed",dv="(max-width: 1023px)";function Wj(){try{return window.matchMedia(dv).matches}catch{return!1}}function Zj({children:n}){const[e,s]=E.useState(()=>{if(Wj())return!0;try{return localStorage.getItem(ud)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(dv)}catch{return}const c=m=>{if(m.matches)s(!0);else try{s(localStorage.getItem(ud)==="true")}catch{s(!1)}};return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[]);const i=E.useCallback(()=>{s(o=>{const c=!o;try{localStorage.setItem(ud,String(c))}catch{}return c})},[]);return h.jsx(Mm.Provider,{value:{collapsed:e,toggle:i},children:n})}function ek({children:n}){return h.jsx(Mm.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Rm(){const n=E.useContext(Mm);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const Rb=380,Dm=E.createContext(null);function tk({children:n}){const[e,s]=E.useState({node:null,width:Rb,open:!1,ownerKey:null}),i=en(),o=E.useRef(i.pathname),c=E.useCallback((p,g)=>{s({node:p,width:(g==null?void 0:g.width)??Rb,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),m=E.useCallback(p=>{s(g=>typeof p=="string"&&g.ownerKey!==p?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(p=>p.open||p.node?{...p,node:null,open:!1,ownerKey:null}:p))},[i.pathname]),h.jsx(Dm.Provider,{value:{...e,setPanel:c,closePanel:m},children:n})}function Lm(){const n=E.useContext(Dm);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function M5(){return E.useContext(Dm)}function nk({open:n,width:e=380,children:s,className:i=""}){const[o,c]=E.useState(n);return E.useEffect(()=>{n&&c(!0)},[n]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${i}`,style:{width:n?e:0,maxWidth:"50%"},onTransitionEnd:m=>{!n&&m.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:e},className:"h-full",children:o?s:null})})}function R5({label:n,children:e}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:n}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:e})]})}function D5({views:n,activeId:e,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:m}){const p=n.find(g=>g.id===e)??n[0];return p?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${c??"sticky top-0 z-10 max-h-[calc(100vh-3.5rem)]"}`,children:[h.jsxs("div",{className:`flex items-center justify-between pl-4 pr-3 shrink-0 ${m?"pt-10 pb-2":"pt-3"}`,children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1 shrink-0",role:"radiogroup","aria-label":"Panel view",children:n.map(g=>{const u=g.icon,d=g.id===p.id;return h.jsx("button",{role:"radio","aria-checked":d,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${d?"bg-accent/10 text-accent":"text-accent/60 hover:text-accent hover:bg-surface-hover"}`,children:h.jsx(u,{className:"w-3.5 h-3.5"})},g.id)})}),m&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:p.label})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o,i&&h.jsx("button",{onClick:i,title:"Close panel",className:"p-1 rounded text-accent/60 hover:text-accent hover:bg-surface-hover transition-colors",children:h.jsx(Zt,{className:"w-3.5 h-3.5"})})]})]}),!m&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:p.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${m?"pt-4 pb-8":"pb-5 pt-1"}`,children:p.content})]})}):null}function mv(n,e){var s,i,o,c,m;e.facets&&Object.keys(e.facets).length&&n.set("facets",JSON.stringify(e.facets)),(s=e.block)!=null&&s.length&&n.set("block",JSON.stringify(e.block)),(i=e.range)!=null&&i.length&&n.set("range",JSON.stringify(e.range)),(o=e.exists)!=null&&o.length&&n.set("exists",JSON.stringify(e.exists)),(c=e.roles)!=null&&c.length&&n.set("roles",JSON.stringify(e.roles)),(m=e.orderBy)!=null&&m.length&&n.set("orderBy",JSON.stringify(e.orderBy)),e.available!==void 0&&n.set("available",String(e.available)),e.jeopardy===!0&&n.set("jeopardy","1"),e.include&&n.set("include",e.include),e.groupBy&&n.set("groupBy",e.groupBy)}function L5(n,e,s){const i=n??"24h",o=e&&Object.keys(e).length?JSON.stringify(e):null;return qe({queryKey:["stationMetrics",i,o],queryFn:()=>ue(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function q5(n){const e=n?`?period=${n}`:"";return qe({queryKey:["escalationStats",n],queryFn:()=>ue(`/escalations/stats${e}`)})}function P5(){return qe({queryKey:["escalationTypes"],queryFn:()=>ue("/escalations/types")})}function B5(n=!0){return qe({queryKey:["escalationFacetKeys"],queryFn:()=>ue("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function rk(n){return qe({queryKey:["escalationFacetValues",n],queryFn:()=>ue(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function sk(n){const e=new URLSearchParams;return n.status&&e.set("status",n.status),n.role&&e.set("role",n.role),n.type&&e.set("type",n.type),n.subtype&&e.set("subtype",n.subtype),n.assigned_to&&e.set("assigned_to",n.assigned_to),n.parent_id&&e.set("parent_id",n.parent_id),n.claimed&&e.set("claimed","true"),n.priority&&e.set("priority",String(n.priority)),n.limit&&e.set("limit",String(n.limit)),n.offset!==void 0&&e.set("offset",String(n.offset)),n.sort_by&&e.set("sort_by",n.sort_by),n.order&&e.set("order",n.order),n.search&&e.set("search",n.search),mv(e,n),e}function ik(n){return{queryKey:["escalations",n],queryFn:()=>ue(`/escalations?${sk(n)}`)}}function pv(n){const{enabled:e=!0,staleTime:s,...i}=n;return qe({...ik(i),enabled:e,...s!==void 0?{staleTime:s}:{}})}function yv(n){const{enabled:e=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),mv(o,i),qe({queryKey:["escalations","available",i],queryFn:()=>ue(`/escalations/available?${o}`),enabled:e,...s!==void 0?{staleTime:s}:{}})}function U5(n){return qe({queryKey:["escalations","by-workflow",n],queryFn:()=>ue(`/escalations/by-workflow/${n}`),enabled:!!n})}function z5(n){return qe({queryKey:["escalations",n],queryFn:()=>ue(`/escalations/${n}`),enabled:!!n})}function I5(n,e){return qe({queryKey:["escalations",n,"lookups"],queryFn:()=>ue(`/escalations/${n}/lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function $5(){const n=Pe();return $e({mutationFn:({id:e,durationMinutes:s})=>ue(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function H5(){const n=Pe();return $e({mutationFn:e=>ue(`/escalations/${e}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function F5(){const n=Pe();return $e({mutationFn:({id:e,resolverPayload:s})=>ue(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),n.resetQueries({queryKey:["tasks"]}),n.resetQueries({queryKey:["jobs"]})}})}const G5={NEEDS_BADGE:"needs_badge",ROLE_REFUSED:"role_refused"};function V5(){const n=Pe();return $e({mutationFn:({id:e,...s})=>ue(`/escalations/${e}/roster-action`,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]}),n.invalidateQueries({queryKey:["escalationStats"]})}})}function Y5(){const n=Pe();return $e({mutationFn:({id:e,itemKey:s,payload:i})=>ue(`/escalations/${e}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function K5(){const n=Pe();return $e({mutationFn:({id:e,itemKey:s})=>ue(`/escalations/${e}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function J5(){const n=Pe();return $e({mutationFn:({id:e,targetRole:s})=>ue(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function Q5(){const n=Pe();return $e({mutationFn:({ids:e,priority:s})=>ue("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:e,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function X5(){const n=Pe();return $e({mutationFn:({ids:e,durationMinutes:s})=>ue("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:e,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function W5(){const n=Pe();return $e({mutationFn:({ids:e,targetUserId:s,durationMinutes:i,reassign:o})=>ue("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:e,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function Z5(){const n=Pe();return $e({mutationFn:({ids:e})=>ue("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function eM(){const n=Pe();return $e({mutationFn:({ids:e,hint:s})=>ue("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:e,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function tM(){const n=Pe();return $e({mutationFn:e=>ue(`/escalations/${e}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function nM(){const n=Pe();return $e({mutationFn:({ids:e})=>ue("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function qm(n){const e=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":e.push(["tasks"]),e.push(["jobs"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),n.originId&&e.push(["processes",n.originId]);break;case"escalation":e.push(["escalations"]),e.push(["escalationStats"]),e.push(["stationMetrics"]),n.workflowId&&e.push(["workflowExecution",n.workflowId]);break;case"workflow":e.push(["jobs"]),e.push(["tasks"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId]),e.push(["mcpQueryResult",n.workflowId]),e.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&e.push(["mcpRunExecution",n.workflowId]),e.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),e.push(["tasks"]);break;case"knowledge":e.push(["knowledge"]);break;case"file":e.push(["files"]);break;case"agent":e.push(["agents"]);break;default:e.push(["jobs"]),e.push(["tasks"]);break}return e}const ak={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},rM=300,Db={DETAIL:0,LIST:1,SUMMARY:2};function ok(n){const e=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function m(d){delete s[d],i[d]=Date.now();const b=[];for(const[v,_]of e)_===d&&b.push(v);for(const v of b)e.delete(v);if(b.length===0)return;const x=c();x&&(o=!0);for(const v of b)n.invalidateQueries({queryKey:JSON.parse(v),...x?{refetchType:"none"}:{}})}function p(d){if(s[d])return;const{coalesceMs:b,minIntervalMs:x}=ak[d],v=i[d],_=v===void 0?0:v+x-Date.now(),S=Math.max(b,_);s[d]=setTimeout(()=>m(d),S)}function g(d,b){for(const x of b){const v=JSON.stringify(x),_=e.get(v);(_===void 0||Db[d]<Db[_])&&e.set(v,d)}p(d)}const u=()=>{typeof document>"u"||document.visibilityState==="visible"&&o&&(o=!1,n.refetchQueries({type:"active",stale:!0}))};return typeof document<"u"&&document.addEventListener("visibilitychange",u),{request:g,dispose(){for(const d of Object.keys(s)){const b=s[d];b&&clearTimeout(b),delete s[d]}e.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const Lb=new WeakMap;function lk(n){let e=Lb.get(n);return e||(e=ok(n),Lb.set(n,e)),e}function tn(n){const e=Pe();return E.useCallback(s=>{lk(e).request(n,s)},[e,n])}function Pm(n){return n?[`${Xt}.system.workflow.>`,`${Xt}.system.activity.>`,`${Xt}.system.milestone.>`,`${Xt}.system.task.>`,`${Xt}.system.escalation.>`]:[]}function sM(){const n=tn("LIST");An(`${Xt}.system.task.>`,()=>{n([["jobs"]])}),An(`${Xt}.system.workflow.>`,()=>{n([["jobs"]])})}function iM(n){const e=tn("DETAIL");js(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function aM(n){const e=tn("DETAIL");js(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function oM(n){const e=tn("DETAIL");js(Pm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=qm(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),e(o)})}function lM(n){const e=tn("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||e([["processes",n]]))},[n,e]);An(`${Xt}.system.task.>`,s),An(`${Xt}.system.workflow.>`,s),An(`${Xt}.system.escalation.>`,s)}function cM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["escalationStats"]])})}function uM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["stationMetrics"]])})}function fM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function hM(n){const e=tn("LIST"),s=(n==null?void 0:n.role)??null,i=((n==null?void 0:n.verbs)??[]).join(","),o=E.useMemo(()=>{const c=i?i.split(","):null;return c?Yd({role:s,verbs:c}):[fr({role:s})]},[s,i]);js(o,()=>{e([["escalations"]])})}const ck=[["escalations","related"],["escalations","related-rows"]];function dM(n){const e=tn("LIST"),s=[...new Set(n)].sort().join(","),i=E.useMemo(()=>s?s.split(",").map(o=>fr({role:o})):[],[s]);js(i,()=>{e(ck)})}function mM(n){const e=tn("DETAIL");An(fr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||e([["escalations",n]])})}function pM(){const n=tn("LIST");An(`${Xt}.system.agent.>`,()=>{n([["agents"]])})}function yM(){const n=tn("LIST");An(`${Xt}.system.task.>`,()=>{n([["processes"]])}),An(`${Xt}.system.workflow.>`,()=>{n([["processes"]])})}function uk(){const{user:n}=qt(),e=n==null?void 0:n.userId,s=tn("SUMMARY");js(jm(),()=>{s([["escalations"]])});const{data:i}=yv({limit:1}),{data:o}=pv({assigned_to:e,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function Ru({size:n="sm",hideLabel:e=!1,className:s="",appName:i="LongTail",variant:o="full"}){const c=n==="lg";if(o==="comet")return h.jsx("div",{className:`relative overflow-visible ${s}`,style:{width:"2.5rem",height:"2.5rem",flexShrink:0},children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Vt}/logo512.png)`,width:"82px",height:"82px",top:"-12px",left:"-80px",transform:"rotate(232deg)",zIndex:-1,opacity:.55}})});if(o==="mark")return h.jsx("div",{className:`flex items-center ${s}`,children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Vt}/logo512.png)`}})});const m=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",p=c?"text-[44px] font-normal text-text-primary tracking-[0.15em] -ml-[12.5rem]":"text-[36px] font-normal text-text-primary tracking-[0.15em] -ml-[9.75rem]";return h.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[h.jsx("span",{role:"img","aria-label":i,className:`logo-mark shrink-0 z-0 ${m}`,style:{"--logo-url":`url(${Vt}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${p} ${e?"opacity-0":""}`,children:i})]})}const fk="system.surfaces.dashboard",hk=`${Xt}.${fk}`;function gv(n=!0){return qe({queryKey:["announcements"],queryFn:()=>ue("/announcements"),enabled:n,staleTime:3e4})}function dk(){const n=Pe();return $e({mutationFn:e=>ue("/announcements",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function mk(){const n=Pe();return $e({mutationFn:e=>ue(`/announcements/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function gM(n){return n.toLocaleString()}function bM(n){return n>=1e9?`${(n/1e9).toFixed(1).replace(/\.0$/,"")}B`:n>=1e6?`${(n/1e6).toFixed(1).replace(/\.0$/,"")}M`:n>=1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}K`:n.toLocaleString()}function pk(n){const e=new Date(n);return e.getTime()>Date.now()?"just now":Rj(e,{addSuffix:!0})}function xM(n){const e=Date.now()-new Date(n).getTime();if(e<0)return"now";const s=Math.floor(e/1e3);if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const o=Math.floor(i/60);if(o<24)return`${o}h`;const c=Math.floor(o/24);return c<7?`${c}d`:c<30?`${Math.floor(c/7)}w`:c<365?`${Math.floor(c/30)}mo`:`${Math.floor(c/365)}y`}function vM(n){return n<=0?"Expired":Bm(n)}function yk(n){return n==null?"--":Bm(n)}function _M(n){return n?km(n):"--"}function Bm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const m=n/1e3;return Number.isInteger(m)?`${m}s`:`${m.toFixed(1)}s`}const e=Math.floor(n/1e3),s=Math.floor(e/86400),i=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),c=e%60;return s>0?i>0?`${s}d ${i}h`:`${s}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:c>0?`${o}m ${c}s`:`${o}m`}function wM(n,e){const s=new Date(n).getTime(),i=e?new Date(e).getTime():Date.now();return Bm(i-s)}function bv({options:n,children:e,className:s=""}){const[i,o]=E.useState(!1),[c,m]=E.useState(null),[p,g]=E.useState(null),u=E.useRef(null),d=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const P=u.current.getBoundingClientRect(),q=window.innerWidth-x-8,ne=Math.max(8,Math.min(P.left,q));g({top:P.bottom+4,left:ne})},[]),_=E.useCallback(async(P,q)=>{try{await navigator.clipboard.writeText(P),m(q),clearTimeout(d.current),d.current=setTimeout(()=>m(null),1200)}catch{}},[]),S=E.useCallback(()=>{clearTimeout(b.current),v(),o(!0)},[v]),C=E.useCallback(()=>{b.current=setTimeout(()=>o(!1),150)},[]);return E.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[e,i&&p&&sm.createPortal(h.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:p.top,left:p.left},onMouseEnter:S,onMouseLeave:C,children:n.map(P=>h.jsxs("button",{onClick:q=>{q.stopPropagation(),_(P.value,P.label)},className:"flex items-center justify-between w-full px-2.5 py-1 text-left hover:bg-surface-hover transition-colors",children:[h.jsx("span",{className:"text-2xs font-medium uppercase tracking-wider text-text-tertiary w-10 shrink-0",children:P.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===P.label?"✓":P.value})]},P.label))}),document.body)]})}function gk(n,e){const s=new Date(n);switch(e){case"relative":return pk(n);case"datetime":return km(s);case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:Lj()??void 0})}}function bk(n){const e=new Date(n);return[{label:"ms",value:String(e.getTime())},{label:"utc",value:e.toISOString()},{label:"local",value:km(e,!0)}]}function xv({date:n,format:e="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(e!=="relative")return;const c=setInterval(()=>i(m=>m+1),3e4);return()=>clearInterval(c)},[e]);const o=E.useMemo(()=>bk(n),[n]);return h.jsx(bv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:gk(n,e)})})}function xk({values:n,options:e,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const m=e.filter(p=>!n.includes(p));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(p=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==p)),className:"inline-flex items-center gap-1 text-2xs font-mono text-text-primary border border-surface-border px-1.5 py-0.5 hover:text-status-error hover:border-status-error/50 transition-colors",title:`Remove ${p}`,children:[p,h.jsx(Zt,{className:"w-3 h-3",strokeWidth:1.5})]},p)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),m.length>0&&h.jsxs("select",{value:"",onChange:p=>p.target.value&&s([...n,p.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),m.map(p=>h.jsx("option",{value:p,children:p},p))]})]})}const vk=[{minutes:1,label:"1 minute"},{minutes:15,label:"15 minutes"},{minutes:30,label:"30 minutes"},{minutes:60,label:"1 hour"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:4320,label:"3 days"},{minutes:10080,label:"7 days"}];function _k(){const{data:n}=gv(),{data:e}=Ij(),s=dk(),i=mk(),[o,c]=E.useState(""),[m,p]=E.useState(""),[g,u]=E.useState(1440),[d,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{m.trim()&&s.mutate({body:m.trim(),...o.trim()?{title:o.trim()}:{},...d.length?{roles:d}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),p(""),b([])}})};return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Alerts"}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Title"}),h.jsx("input",{type:"text",value:o,onChange:_=>c(_.target.value),placeholder:"Optional headline",className:"input text-xs w-full"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Summary"}),h.jsx("textarea",{value:m,onChange:_=>p(_.target.value),placeholder:"What everyone should know (markdown supported)",rows:3,className:"input text-xs w-full resize-y"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible for"}),h.jsx("select",{value:g,onChange:_=>u(Number(_.target.value)),className:"select text-xs w-full",children:vk.map(_=>h.jsx("option",{value:_.minutes,children:_.label},_.minutes))})]}),h.jsxs("div",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible to"}),h.jsx(xk,{values:d,options:(e==null?void 0:e.roles)??[],onChange:b,addLabel:"Add a role…",emptyText:"Everyone",ariaLabel:"Add a role"})]}),s.error&&h.jsx("p",{className:"text-xs text-status-error",children:s.error.message}),h.jsx("button",{onClick:v,disabled:!m.trim()||s.isPending,className:"btn-primary text-xs w-full disabled:opacity-50",children:s.isPending?"Publishing…":"Publish alert"})]}),x.length>0&&h.jsxs("div",{className:"mt-6",children:[h.jsx("p",{className:"text-2xs text-text-tertiary mb-2",children:"Active now — stacked as banner rows, newest first"}),h.jsx("div",{className:"space-y-1",children:x.map(_=>h.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-surface-border/40 last:border-b-0",children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block text-xs text-text-primary truncate",children:_.title??_.body.split(`
54
- `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(xv,{date:_.expires_at,format:"relative"})]})]}),h.jsx("button",{onClick:()=>i.mutate(_.id),disabled:i.isPending,className:"icon-link shrink-0 mt-0.5",title:"Remove for everyone","aria-label":`Remove ${_.title??"announcement"}`,children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},_.id))})]})]})}const wk=[{id:null,label:"Your view",description:"Full access based on your account role",minTier:"operator"},{id:"admin",label:"Admin",description:"Pace Board + identity management",minTier:"superadmin"},{id:"engineer",label:"Engineer",description:"Work queue + identity management",minTier:"admin"},{id:"operator",label:"Operator",description:"Escalation queue only",minTier:"engineer"}],Sk=["operator","engineer","admin","superadmin"];function qb(n){return Sk.indexOf(n)}function Ek(n,e){return qb(n)>=qb(e)}function Ok({onClose:n}){var Ne,Me,We,pt,Ct,Se,Re;const{isSuperAdmin:e,hasRoleType:s,hasRole:i}=qt(),{data:o}=er(),c=Om(),m=!!((Ne=o==null?void 0:o.ai)!=null&&Ne.enabled),p=Xx(),g=p!==null?p:m,[u,d]=E.useState(g),b=(Me=o==null?void 0:o.features)==null?void 0:Me.graphWorkflows,x=b==null,[v,_]=E.useState(b===!0||x&&Wx()),S=e||i("engineer"),[C,P]=E.useState(Zx()),q=!!((We=o==null?void 0:o.features)!=null&&We.scanCodes),ne=ev(),[te,M]=E.useState(ne!==null?ne:q),U=e?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ae=((pt=o==null?void 0:o.branding)==null?void 0:pt.appName)??"LongTail",z=(Ct=o==null?void 0:o.environment)==null?void 0:Ct.longTailVersion,I=(Se=o==null?void 0:o.environment)==null?void 0:Se.hotmeshVersion,D=(Re=o==null?void 0:o.environment)==null?void 0:Re.nodeEnv;E.useEffect(()=>{const ce=Ue=>{Ue.key==="Escape"&&n()};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[n]);const X=wk.filter(ce=>Ek(U,ce.minTier)),W=X.length>1,he=U!=="operator",we=[...W?[{id:"viewas",label:"View As",icon:gS}]:[],{id:"features",label:"Features",icon:bS},...he?[{id:"alerts",label:"Alerts",icon:xS}]:[]],[Oe,F]=E.useState(we[0].id),J=ce=>{ce===null?Vd():mA(ce)},le=()=>{const ce=!u;d(ce),ce===m?dA():hA(ce),window.location.reload()},pe=()=>{const ce=!v;_(ce),pA(ce),window.location.reload()},ye=()=>{const ce=!C;P(ce),yA(ce),window.location.reload()},Ce=()=>{const ce=!te;M(ce),ce===q?bA():gA(ce),window.location.reload()};return h.jsx("div",{className:"fixed inset-0 z-[100] bg-surface-sunken/75 backdrop-blur-sm flex items-center justify-center",onClick:n,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:ce=>ce.stopPropagation(),children:[h.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Zt,{className:"w-4 h-4",strokeWidth:1.5})}),h.jsxs("div",{className:"flex flex-col items-center gap-3 pb-8",children:[h.jsx("span",{className:"logo-mark block w-20 h-20 opacity-50",style:{"--logo-url":`url(${Vt}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ae}),z&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",z,I&&h.jsxs(h.Fragment,{children:[" · HotMesh v",I]}),D&&D!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:D})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),we.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:we.map(ce=>{const Ue=Oe===ce.id;return h.jsxs("button",{role:"tab","aria-selected":Ue,onClick:()=>F(ce.id),title:ce.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Ue?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(ce.icon,{className:"w-5 h-5",strokeWidth:1.5,...Ue?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:ce.label})]},ce.id)})}),Oe==="viewas"&&W&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"View As"}),X.map(ce=>{const Ue=c===ce.id,Xe=ce.id===null?`Your view · ${U}`:ce.label;return h.jsxs("button",{onClick:()=>J(ce.id),className:"w-full text-left flex items-start gap-3 py-2.5 px-1 group",children:[h.jsx("span",{className:`mt-0.5 w-4 h-4 rounded-full border shrink-0 flex items-center justify-center transition-colors ${Ue?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Ue&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"})}),h.jsxs("span",{children:[h.jsx("span",{className:`block text-sm font-medium transition-colors ${Ue?"text-accent":"text-text-primary group-hover:text-accent"}`,children:Xe}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:ce.description})]})]},String(ce.id))})]}),Oe==="features"&&h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Features"}),h.jsxs("button",{onClick:le,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"AI features"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:u?"Enabled — AI assist, agent labels, bulk AI actions":"Hidden — automation labels, no AI surfaces"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${u?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${u?"translate-x-4":"translate-x-0"}`})})]}),x&&h.jsxs("button",{onClick:pe,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Graph workflows"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:v?"Visible — Graph section shown in Orchestrate sidebar":"Hidden — use Procedural workflows instead"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${v?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${v?"translate-x-4":"translate-x-0"}`})})]}),S&&h.jsxs("button",{onClick:ye,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group","data-testid":"feature-infrastructure",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Infrastructure"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:C?"Visible — Routers, Messages, and DB Maintenance in the sidebar":"Hidden — routers, message streams, and database maintenance"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${C?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${C?"translate-x-4":"translate-x-0"}`})})]}),h.jsxs("button",{onClick:Ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Scan input"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:te?"Enabled — header scan affordance, panel, and keyboard-wedge capture":"Hidden — the deployment opts in with features.scanCodes"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${te?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${te?"translate-x-4":"translate-x-0"}`})})]})]}),Oe==="alerts"&&he&&h.jsx(_k,{}),h.jsx("hr",{className:"border-surface-border/50 mt-8"}),h.jsx("p",{className:"mt-4 text-2xs text-text-quaternary text-center",children:"Esc or click outside to close"})]})})}const vv=[{id:"violet",label:"Violet",swatch:"#7B3BE0"},{id:"red",label:"Brick",swatch:"#DC382D"},{id:"green",label:"Emerald",swatch:"#059669"},{id:"blue",label:"Electric",swatch:"#2563EB"},{id:"rose",label:"Raspberry",swatch:"#D6246E"},{id:"orange",label:"Harvest",swatch:"#E85D04"}],Pb="blue",_v="lt.theme";let wv=[];function Ak(n){const e=new Set(vv.map(i=>i.id)),s=new Set;wv=n.filter(i=>!(i!=null&&i.id)||e.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function jk(){return[...vv,...wv]}function Sv(){try{return localStorage.getItem(_v)||Pb}catch{return Pb}}function Ev(n){document.documentElement.dataset.theme=n}function kk(n){try{localStorage.setItem(_v,n)}catch{}Ev(n)}const Nk=[8,12,13,14];function Tk(n){if(!/^[0-9]+$/.test(n)||!Nk.includes(n.length))return!1;const e=n.split("").map(Number),s=e.pop();let i=0;for(let o=e.length-1,c=3;o>=0;o--,c=c===3?1:3)i+=e[o]*c;return(10-i%10)%10===s}function SM(n){return n.padStart(14,"0")}const cu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},Ov="lt_scan_wedge_config";function Av(){try{const n=localStorage.getItem(Ov);return n?{...cu,...JSON.parse(n)}:cu}catch{return cu}}function Ck(n){const e={...Av(),...n};return localStorage.setItem(Ov,JSON.stringify(e)),e}const Um=[{pattern:/(?:^|[^0-9])([1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+)$/,digitsOnly:!1},{pattern:/(?:^|[^0-9])([1-9][0-9]{7,})$/,digitsOnly:!0}];function Mk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rk(n){const e=[];for(const s of n.filter(i=>i.enabled))if(s.encoding==="delimited"){const i=Mk(s.delimiter);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}${i}[0-9]${i}[a-zA-Z0-9._-]+)$`),digitsOnly:!1})}else if(s.encoding==="fixed"){const i=1+(s.target_length??0);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}[0-9]{${i},${i+1}})$`),digitsOnly:!0})}else s.encoding==="gtin"&&e.push({pattern:/(?:^|[^0-9])([0-9]{8}|[0-9]{12,14})$/,digitsOnly:!0,accept:Tk});return e.length?e:Um}function Dk(n,e=Um){var i;let s=null;for(const o of e){const c=(i=n.match(o.pattern))==null?void 0:i[1];!c||o.accept&&!o.accept(c)||(!s||c.length>s.code.length)&&(s={code:c,shape:o})}return s}const Lk=new Set(["Shift","CapsLock"]),hc={suppress:!1,emit:null};function qk(n=cu,e=Um){let s={buffer:"",times:[],lastKeyMs:0};function i(u){const d=s.times.slice(-u.length);return d.length<2?!1:(d[d.length-1]-d[0])/(d.length-1)<=n.autoFireMaxAvgKeyMs}function o(){const u=Dk(s.buffer,e);return!u||u.code.length<n.minLength||u.shape.digitsOnly&&!i(u.code)?null:u.code}function c(){s={buffer:"",times:[],lastKeyMs:0}}function m(u){const{key:d,timeMs:b,hasModifier:x,isRepeat:v}=u;if(Lk.has(d))return hc;if(n.terminators.includes(d)){const q=o();return c(),q?{suppress:!0,emit:q,consumedLength:q.length}:hc}if(x||v||d.length!==1)return c(),hc;const _=b-s.lastKeyMs,S=s.lastKeyMs>0&&_<=n.maxKeyGapMs,C=(S?s.buffer+d:d).slice(-128),P=(S?[...s.times,b]:[b]).slice(-128);return s={buffer:C,times:P,lastKeyMs:b},hc}function p(){return{buffer:s.buffer}}function g(){const u=o();return!u||!i(u)?null:{code:u,consumedLength:u.length}}return{step:m,reset:c,snapshot:p,pendingAutoFire:g}}function Pk(){const n=document.activeElement;return n instanceof HTMLInputElement?["text","search","tel","url","email","password","number"].includes(n.type)?n:null:n instanceof HTMLTextAreaElement?n:null}function Bk(n,e,s){var c;const i=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,o=(c=Object.getOwnPropertyDescriptor(i,"value"))==null?void 0:c.set;o?o.call(n,e):n.value=e;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function Bb(n){if(n<=0)return;const e=Pk();if(!e)return;const s=e.selectionStart??e.value.length,i=Math.max(0,s-n);Bk(e,e.value.slice(0,i)+e.value.slice(s),i)}function Uk({active:n,wedgeConfig:e,tailShapes:s,diagnosticsOn:i,onScan:o,onDiag:c}){const m=E.useRef({diagnosticsOn:i,onScan:o,onDiag:c});m.current={diagnosticsOn:i,onScan:o,onDiag:c};const p=E.useRef(0),g=E.useRef(0);E.useEffect(()=>{if(!n)return;const u=qk(e,s);let d=null;const b=()=>{d&&(clearTimeout(d),d=null)},x=(S,C,P)=>{C&&Bb(C),m.current.diagnosticsOn&&(console.debug("[scan]",P),m.current.onDiag({seq:++p.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:P})),m.current.onScan(S)},v=()=>{b(),u.pendingAutoFire()&&(d=setTimeout(()=>{d=null;const S=u.pendingAutoFire();S&&(u.reset(),x(S.code,S.consumedLength,`capture → ${S.code} (quiet period — no suffix)`))},e.autoFireQuietMs))},_=S=>{const C=u.snapshot().buffer,{suppress:P,emit:q,consumedLength:ne}=u.step({key:S.key,timeMs:S.timeStamp,hasModifier:S.ctrlKey||S.metaKey||S.altKey,isRepeat:S.repeat});if(P&&(S.preventDefault(),S.stopPropagation()),m.current.diagnosticsOn){const te=u.snapshot().buffer,M=e.terminators.includes(S.key),U=q?`capture → ${q}`:M?`terminator — no code tail in "${C.slice(-24)}"`:te===C?C?"neutral (chord key)":"ignored":te===""?"reset (edit/chord/non-printable)":te.length<=1&&C.length>1?"gap — new episode":"accumulate",ae=g.current?Math.round(S.timeStamp-g.current):0,z={seq:++p.current,key:S.key,code:S.code!==S.key?S.code:"",deltaMs:ae,buffer:te.slice(-24),note:U};console.debug("[scan]",z.key,z.code,`${z.deltaMs}ms`,z.note),m.current.onDiag(z)}g.current=S.timeStamp,q?(b(),ne&&Bb(ne),m.current.onScan(q)):v()};return window.addEventListener("keydown",_,{capture:!0}),()=>{b(),window.removeEventListener("keydown",_,{capture:!0})}},[n,e,s])}const je={EXECUTED:"executed",MATCHED_LIST:"matched_list",CONFIRM_REQUIRED:"confirm_required",NO_MATCH_FALLBACK:"no_match_fallback",UNCONFIGURED:"unconfigured",INVALID_CODE:"invalid_code",FORBIDDEN:"forbidden",CONFLICT:"conflict",IDENTITY_PRIMED:"identity_primed",IDENTITY_UNKNOWN:"identity_unknown",NOT_PRIMED:"not_primed",CHOICES:"choices",NO_OPEN_CONTAINER:"no_open_container",HELD:"held",REFUSED:"refused",SUBJECT_STALE:"subject_stale"},dc={SHOW_DETAIL:"show-detail",SHOW_LIST:"show-list",CLAIM:"claim",CLAIM_SHOW_DETAIL:"claim-show-detail",RELEASE:"release",RESOLVE:"resolve",ESCALATE:"escalate",CANCEL:"cancel",ACCUMULATE:"accumulate",PRESENT:"present",HOLD:"hold",FILL:"fill"},zk={ACTION:"action",IDENTITY:"identity"};function Ik(n,e){return ue("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...e!=null&&e.actingToken?{actingToken:e.actingToken}:{},...e!=null&&e.previousActingToken?{previousActingToken:e.previousActingToken}:{},...e!=null&&e.subject?{subject:e.subject}:{},...e!=null&&e.stationRole?{stationRole:e.stationRole}:{}})})}function EM(n){return ue("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function jv(n){return qe({queryKey:["scan-schemes"],queryFn:()=>ue("/scan-codes/schemes"),...n})}function OM(n){return qe({queryKey:["scan-schemes",n],queryFn:()=>ue(`/scan-codes/schemes/${n}`),enabled:n!=null})}function AM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.version}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function jM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function kM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function NM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"DELETE"}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const $k=3e4;function Hk(n,e=Date.now()){if(!(!n||Date.parse(n.expiresAt)<=e))return{code:n.code,escalationId:n.escalationId}}function Ub(n,e,s=Date.now()){if(e.outcome===je.HELD&&e.subject){const i=Math.max(0,Date.parse(e.subject.expiresAt)-s);return{...e.subject,ttlMs:i}}return e.clearSubject||!n?null:e.outcome===je.EXECUTED&&e.progress&&e.progress.remaining>0?{...n,expiresAt:new Date(s+n.ttlMs).toISOString()}:n}function zb(n){return n.outcome===je.NOT_PRIMED&&n.replayable===!0}function Fk(n,e=Date.now()){return n&&e-n.at<=$k?n:null}const Gk=[je.HELD,je.REFUSED,je.SUBJECT_STALE],To={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar"},Fi=n=>{if(n)try{return JSON.parse(n)}catch{return}},Zs=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function Vk(n){const e={},s=Fi(n.get("facets"));Zs(s)||(e.facets=s);const i=Fi(n.get("block"));Zs(i)||(e.block=i);const o=Fi(n.get("range"));Zs(o)||(e.range=o);const c=Fi(n.get("exists"));Zs(c)||(e.exists=c);const m=Fi(n.get("roles"));Zs(m)||(e.roles=m);const p=Fi(n.get("orderBy"));Zs(p)||(e.orderBy=p),n.get("available")!=null&&(e.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(e.jeopardy=!0),e}function TM(n,e){const s=(i,o)=>Zs(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",e.facets),s("block",e.block),s("range",e.range),s("exists",e.exists),s("roles",e.roles),s("orderBy",e.orderBy),e.available==null?n.delete("available"):n.set("available",String(e.available)),e.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const Ib=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function kv(n,e){const s={};for(const[o,c]of Object.entries(n))s[o]=typeof c=="object"&&c!==null?JSON.stringify(c):c;const i=encodeURIComponent(JSON.stringify(s));return e?`/escalations/available?role=${encodeURIComponent(e)}&facets=${i}${Ib}`:`/escalations/available?facets=${i}${Ib}`}function Yk(n,e,s){return kv({[n]:e},s)}function CM(n){var e,s,i;return Object.keys(n.facets??{}).length+(((e=n.block)==null?void 0:e.length)??0)+(((s=n.range)==null?void 0:s.length)??0)+(((i=n.exists)==null?void 0:i.length)??0)+(n.available!=null?1:0)+(n.jeopardy===!0?1:0)}function zm(){var s;const{data:n}=er(),e=ev();return e!==null?e:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const Im=E.createContext(null);function $m(){const n=E.useContext(Im);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}function MM(){return E.useContext(Im)}const Kk="scanPendingAction",Jk="scanChoices",fd="/scan/station";function Qk({children:n}){const{user:e}=qt(),s=zm(),i=ni(),o=en(),{identity:c,prime:m,clear:p,settle:g}=Cu(),[u,d]=E.useState(null),[b,x]=E.useState(null),[v,_]=E.useState(null),{data:S}=jv({enabled:!!e&&s,staleTime:6e4}),C=E.useRef(null);C.current=Cm().role;const P=E.useMemo(()=>Rk((S==null?void 0:S.schemes)??[]),[S]),[q,ne]=E.useState(!1),[te,M]=E.useState(()=>Av()),[U,ae]=E.useState([]),[z,I]=E.useState(!1),D=E.useCallback(Se=>{var Ue;const{outcome:Re}=Se;if(Re===je.CONFIRM_REQUIRED&&Se.pendingAction)return i(`/escalations/detail/${Se.pendingAction.escalationId}`,{state:{[Kk]:Se.pendingAction}}),!0;const ce=Re===je.EXECUTED&&!!F.current;if(Gk.includes(Re)||zb(Se)||ce)return le.current!==fd&&i(fd),!0;if(Re===je.EXECUTED&&Se.escalation){const Xe=[dc.SHOW_DETAIL,dc.CLAIM_SHOW_DETAIL,dc.CLAIM,dc.ESCALATE];return Se.verb&&Xe.includes(Se.verb)?(i(`/escalations/detail/${Se.escalation.id}`),!0):!1}if(Re===je.MATCHED_LIST&&Se.listQuery){const{targetFacet:Xe,target:cn,roles:Mt}=Se.listQuery;return i(kv({[Xe]:cn},(Mt==null?void 0:Mt[0])??null)),!0}return Re===je.CHOICES&&Se.choices?(i(fd,{state:{[Jk]:Se}}),!0):Re===je.NO_MATCH_FALLBACK&&((Ue=Se.fallback)!=null&&Ue.route)?(i(Se.fallback.route),!0):!1},[i]),X=E.useRef(null);X.current=(c==null?void 0:c.actingToken)??null;const W=E.useRef(null),he=E.useRef([]),we=E.useCallback(Se=>(he.current=[Se,...he.current],()=>{he.current=he.current.filter(Re=>Re!==Se)}),[]),Oe=E.useRef(null);Oe.current=b;const F=E.useRef(void 0),J=E.useRef(null);J.current=v;const le=E.useRef(o.pathname);le.current=o.pathname,E.useEffect(()=>{if(!b)return;const Se=Date.parse(b.expiresAt)-Date.now();if(Se<=0){x(null);return}const Re=setTimeout(()=>x(null),Se);return()=>clearTimeout(Re)},[b]);const pe=E.useCallback(async(Se,Re,ce)=>{ne(!0);const Ue=Date.now();try{F.current=Hk(Oe.current);const Xe=await Ik(Se,{actingToken:ce??void 0,previousActingToken:W.current??void 0,subject:F.current,stationRole:C.current??void 0});if(ce&&g(ce,Xe),x(Mt=>Ub(Mt,Xe)),Xe.outcome===je.IDENTITY_PRIMED){W.current=m(Xe);const Mt=Fk(J.current);if(_(null),Mt&&Xe.actingToken){d({code:Se,source:Re,at:Ue,response:Xe,error:null,navigated:!1}),await pe(Mt.code,Re,Xe.actingToken);return}}else zb(Xe)?_({code:Se,at:Ue}):_(null);Xe.outcome===je.NOT_PRIMED&&ce&&p();const cn=D(Xe);d({code:Se,source:Re,at:Ue,response:Xe,error:null,navigated:cn})}catch(Xe){d({code:Se,source:Re,at:Ue,response:null,error:Xe.message,navigated:!1})}finally{ne(!1)}},[D,m,p,g]),ye=E.useCallback(async(Se,Re=To.MANUAL)=>{for(const ce of he.current)if(ce(Se))return;await pe(Se,Re,X.current)},[pe]),Ce=E.useCallback(()=>x(null),[]),Ne=E.useCallback(Se=>{x(Re=>Ub(Re,Se))},[]),Me=E.useCallback(()=>_(null),[]),We=E.useRef(ye);We.current=ye,Uk({active:!!e&&s,wedgeConfig:te,tailShapes:P,diagnosticsOn:z,onScan:Se=>void We.current(Se,To.KEYBOARD_WEDGE),onDiag:Se=>ae(Re=>[...Re.slice(-29),Se])});const pt=E.useCallback(Se=>{M(Ck(Se))},[]),Ct=E.useMemo(()=>({submitCode:ye,pushCodeInterceptor:we,lastResult:u,subject:b,dropSubject:Ce,adoptResponse:Ne,pendingScan:v,dropPendingScan:Me,busy:q,wedgeConfig:te,updateWedgeConfig:pt,diagnostics:U,diagnosticsOn:z,setDiagnosticsOn:I}),[ye,we,u,b,Ce,Ne,v,Me,q,te,pt,U,z]);return h.jsx(Im.Provider,{value:Ct,children:n})}var mc={},lo={},pc={},$b;function Nn(){if($b)return pc;$b=1,Object.defineProperty(pc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var e=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return pc.default=e,pc}var Hb;function Xk(){if(Hb)return lo;Hb=1,Object.defineProperty(lo,"__esModule",{value:!0}),lo.CODE39=void 0;var n=(function(){function S(C,P){for(var q=0;q<P.length;q++){var ne=P[q];ne.enumerable=ne.enumerable||!1,ne.configurable=!0,"value"in ne&&(ne.writable=!0),Object.defineProperty(C,ne.key,ne)}}return function(C,P,q){return P&&S(C.prototype,P),q&&S(C,q),C}})(),e=Nn(),s=i(e);function i(S){return S&&S.__esModule?S:{default:S}}function o(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function c(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function m(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var p=(function(S){m(C,S);function C(P,q){return o(this,C),P=P.toUpperCase(),q.mod43&&(P+=x(_(P))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,P,q))}return n(C,[{key:"encode",value:function(){for(var q=d("*"),ne=0;ne<this.data.length;ne++)q+=d(this.data[ne])+"0";return q+=d("*"),{data:q,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),C})(s.default),g=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],u=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(S){return b(v(S))}function b(S){return u[S].toString(2)}function x(S){return g[S]}function v(S){return g.indexOf(S)}function _(S){for(var C=0,P=0;P<S.length;P++)C+=v(S[P]);return C=C%43,C}return lo.CODE39=p,lo}var Jn={},yc={},gc={},vt={},Fb;function qo(){if(Fb)return vt;Fb=1,Object.defineProperty(vt,"__esModule",{value:!0});var n;function e(g,u,d){return u in g?Object.defineProperty(g,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):g[u]=d,g}var s=vt.SET_A=0,i=vt.SET_B=1,o=vt.SET_C=2;vt.SHIFT=98;var c=vt.START_A=103,m=vt.START_B=104,p=vt.START_C=105;return vt.MODULO=103,vt.STOP=106,vt.FNC1=207,vt.SET_BY_CODE=(n={},e(n,c,s),e(n,m,i),e(n,p,o),n),vt.SWAP={101:s,100:i,99:o},vt.A_START_CHAR="Ð",vt.B_START_CHAR="Ñ",vt.C_START_CHAR="Ò",vt.A_CHARS="[\0-_È-Ï]",vt.B_CHARS="[ -È-Ï]",vt.C_CHARS="(Ï*[0-9]{2}Ï*)",vt.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],vt}var Gb;function Du(){if(Gb)return gc;Gb=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){c(this,d);var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(_){return _.charCodeAt(0)}),v}return n(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.bytes,v=x.shift()-105,_=i.SET_BY_CODE[v];if(_===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&x.unshift(i.FNC1);var S=d.next(x,1,_);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(v)+S.result+d.getBar((S.checksum+v)%i.MODULO)+d.getBar(i.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var x=this.options.ean128||!1;return typeof x=="string"&&(x=x.toLowerCase()==="true"),x}}],[{key:"getBar",value:function(x){return i.BARS[x]?i.BARS[x].toString():""}},{key:"correctIndex",value:function(x,v){if(v===i.SET_A){var _=x.shift();return _<32?_+64:_-32}else return v===i.SET_B?x.shift()-32:(x.shift()-48)*10+x.shift()-48}},{key:"next",value:function(x,v,_){if(!x.length)return{result:"",checksum:0};var S=void 0,C=void 0;if(x[0]>=200){C=x.shift()-105;var P=i.SWAP[C];P!==void 0?S=d.next(x,v+1,P):((_===i.SET_A||_===i.SET_B)&&C===i.SHIFT&&(x[0]=_===i.SET_A?x[0]>95?x[0]-96:x[0]:x[0]<32?x[0]+96:x[0]),S=d.next(x,v+1,_))}else C=d.correctIndex(x,_),S=d.next(x,v+1,_);var q=d.getBar(C),ne=C*v;return{result:q+S.result,checksum:ne+S.checksum}}}]),d})(s.default);return gc.default=g,gc}var bc={},Vb;function Wk(){if(Vb)return bc;Vb=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=qo(),e=function(p){return p.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(p){return p.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(p){return p.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(m,p){var g=p?n.A_CHARS:n.B_CHARS,u=m.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(m.substring(u[1].length));var d=m.match(new RegExp("^"+g+"+"))[0];return d.length===m.length?m:d+String.fromCharCode(p?205:206)+o(m.substring(d.length),!p)}function c(m){var p=i(m),g=p.length;if(g===m.length)return m;m=m.substring(g);var u=e(m)>=s(m);return p+String.fromCharCode(u?206:205)+o(m,u)}return bc.default=function(m){var p=void 0,g=i(m).length;if(g>=2)p=n.C_START_CHAR+c(m);else{var u=e(m)>s(m);p=(u?n.A_START_CHAR:n.B_START_CHAR)+o(m,u)}return p.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,b){return"Ë"+b})},bc}var Yb;function Zk(){if(Yb)return yc;Yb=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Du(),e=o(n),s=Wk(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){if(c(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,i.default)(b),x));else var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x));return m(v)}return d})(e.default);return yc.default=g,yc}var xc={},Kb;function eN(){if(Kb)return xc;Kb=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.A_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),d})(s.default);return xc.default=g,xc}var vc={},Jb;function tN(){if(Jb)return vc;Jb=1,Object.defineProperty(vc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.B_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),d})(s.default);return vc.default=g,vc}var _c={},Qb;function nN(){if(Qb)return _c;Qb=1,Object.defineProperty(_c,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.C_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),d})(s.default);return _c.default=g,_c}var Xb;function rN(){if(Xb)return Jn;Xb=1,Object.defineProperty(Jn,"__esModule",{value:!0}),Jn.CODE128C=Jn.CODE128B=Jn.CODE128A=Jn.CODE128=void 0;var n=Zk(),e=g(n),s=eN(),i=g(s),o=tN(),c=g(o),m=nN(),p=g(m);function g(u){return u&&u.__esModule?u:{default:u}}return Jn.CODE128=e.default,Jn.CODE128A=i.default,Jn.CODE128B=c.default,Jn.CODE128C=p.default,Jn}var Kt={},wc={},Rr={},Wb;function Po(){return Wb||(Wb=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.SIDE_BIN="101",Rr.MIDDLE_BIN="01010",Rr.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},Rr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Rr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Rr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Rr}var Sc={},Ec={},Zb;function Bo(){if(Zb)return Ec;Zb=1,Object.defineProperty(Ec,"__esModule",{value:!0});var n=Po(),e=function(i,o,c){var m=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var p=i.length-1;m=m.map(function(g,u){return u<p?g+c:g})}return m.join("")};return Ec.default=e,Ec}var e1;function Nv(){if(e1)return Sc;e1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){p(this,x);var S=g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.fontSize=!_.flat&&_.fontSize>_.width*10?_.width*10:_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(_,S){return this.text.substr(_,S)}},{key:"leftEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"rightText",value:function(_,S){return this.text.substr(_,S)}},{key:"rightEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"encodeGuarded",value:function(){var _={fontSize:this.fontSize},S={height:this.guardHeight};return[{data:e.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:_},{data:e.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:_},{data:e.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var _=[e.SIDE_BIN,this.leftEncode(),e.MIDDLE_BIN,this.rightEncode(),e.SIDE_BIN];return{data:_.join(""),text:this.text}}}]),x})(c.default);return Sc.default=d,Sc}var t1;function sN(){if(t1)return wc;t1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=function b(x,v,_){x===null&&(x=Function.prototype);var S=Object.getOwnPropertyDescriptor(x,v);if(S===void 0){var C=Object.getPrototypeOf(x);return C===null?void 0:b(C,v,_)}else{if("value"in S)return S.value;var P=S.get;return P===void 0?void 0:P.call(_)}},s=Po(),i=Nv(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=function(x){var v=x.substr(0,12).split("").map(function(_){return+_}).reduce(function(_,S,C){return C%2?_+S*3:_+S},0);return(10-v%10)%10},d=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.lastChar=_.lastChar,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===u(this.data)}},{key:"leftText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var _=this.data.substr(1,6),S=s.EAN13_STRUCTURE[this.data[0]];return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,_,S)}},{key:"rightText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var _=this.data.substr(7,6);return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,_,"RRRRRR")}},{key:"encodeGuarded",value:function(){var _=e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(_.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(_.push({data:"00"}),_.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),_}}]),x})(o.default);return wc.default=d,wc}var Oc={},n1;function iN(){if(n1)return Oc;n1=1,Object.defineProperty(Oc,"__esModule",{value:!0});var n=(function(){function d(b,x){for(var v=0;v<x.length;v++){var _=x[v];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,x,v){return x&&d(b.prototype,x),v&&d(b,v),b}})(),e=function d(b,x,v){b===null&&(b=Function.prototype);var _=Object.getOwnPropertyDescriptor(b,x);if(_===void 0){var S=Object.getPrototypeOf(b);return S===null?void 0:d(S,x,v)}else{if("value"in _)return _.value;var C=_.get;return C===void 0?void 0:C.call(v)}},s=Nv(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d,b){if(!(d instanceof b))throw new TypeError("Cannot call a class as a function")}function m(d,b){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:d}function p(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);d.prototype=Object.create(b&&b.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(d,b):d.__proto__=b)}var g=function(b){var x=b.substr(0,7).split("").map(function(v){return+v}).reduce(function(v,_,S){return S%2?v+_:v+_*3},0);return(10-x%10)%10},u=(function(d){p(b,d);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),m(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,x,v))}return n(b,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===g(this.data)}},{key:"leftText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var v=this.data.substr(0,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var v=this.data.substr(4,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Oc.default=u,Oc}var Ac={},r1;function aN(){if(r1)return Ac;r1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function x(v,_){for(var S=0;S<_.length;S++){var C=_[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}return function(v,_,S){return _&&x(v.prototype,_),S&&x(v,S),v}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(x){return x&&x.__esModule?x:{default:x}}function p(x,v){if(!(x instanceof v))throw new TypeError("Cannot call a class as a function")}function g(x,v){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:x}function u(x,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);x.prototype=Object.create(v&&v.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(x,v):x.__proto__=v)}var d=function(v){var _=v.split("").map(function(S){return+S}).reduce(function(S,C,P){return P%2?S+C*9:S+C*3},0);return _%10},b=(function(x){u(v,x);function v(_,S){return p(this,v),g(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,_,S))}return n(v,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var S=e.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ac.default=b,Ac}var jc={},s1;function oN(){if(s1)return jc;s1=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){return p(this,x),g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_))}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var _=e.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,_,"01"),text:this.text}}}]),x})(c.default);return jc.default=d,jc}var co={},i1;function Tv(){if(i1)return co;i1=1,Object.defineProperty(co,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})();co.checksum=d;var e=Bo(),s=c(e),i=Nn(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=d(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.displayValue=_.displayValue,_.fontSize>_.width*10?S.fontSize=_.width*10:S.fontSize=_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var _="";return _+="101",_+=(0,s.default)(this.data.substr(0,6),"LLLLLL"),_+="01010",_+=(0,s.default)(this.data.substr(6,6),"RRRRRR"),_+="101",{data:_,text:this.text}}},{key:"guardedEncoding",value:function(){var _=[];return this.displayValue&&_.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),_.push({data:"101"+(0,s.default)(this.data[0],"L"),options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),_.push({data:"01010",options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),_.push({data:(0,s.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&_.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),_}}]),x})(o.default);function d(b){var x=0,v;for(v=1;v<11;v+=2)x+=parseInt(b[v]);for(v=0;v<11;v+=2)x+=parseInt(b[v])*3;return(10-x%10)%10}return co.default=u,co}var kc={},a1;function lN(){if(a1)return kc;a1=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function _(S,C){for(var P=0;P<C.length;P++){var q=C[P];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(S,q.key,q)}}return function(S,C,P){return C&&_(S.prototype,C),P&&_(S,P),S}})(),e=Bo(),s=m(e),i=Nn(),o=m(i),c=Tv();function m(_){return _&&_.__esModule?_:{default:_}}function p(_,S){if(!(_ instanceof S))throw new TypeError("Cannot call a class as a function")}function g(_,S){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:_}function u(_,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);_.prototype=Object.create(S&&S.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(_,S):_.__proto__=S)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],b=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],x=(function(_){u(S,_);function S(C,P){p(this,S);var q=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,P));if(q.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)q.middleDigits=C,q.upcA=v(C,"0"),q.text=P.text||""+q.upcA[0]+C+q.upcA[q.upcA.length-1],q.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(q.middleDigits=C.substring(1,C.length-1),q.upcA=v(q.middleDigits,C[0]),q.upcA[q.upcA.length-1]===C[C.length-1])q.isValid=!0;else return g(q);else return g(q);return q.displayValue=P.displayValue,P.fontSize>P.width*10?q.fontSize=P.width*10:q.fontSize=P.fontSize,q.guardHeight=P.height+q.fontSize/2+P.textMargin,q}return n(S,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var P="";return P+="101",P+=this.encodeMiddleDigits(),P+="010101",{data:P,text:this.text}}},{key:"guardedEncoding",value:function(){var P=[];return this.displayValue&&P.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),P.push({data:"101",options:{height:this.guardHeight}}),P.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),P.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&P.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),P}},{key:"encodeMiddleDigits",value:function(){var P=this.upcA[0],q=this.upcA[this.upcA.length-1],ne=b[parseInt(q)][parseInt(P)];return(0,s.default)(this.middleDigits,ne)}}]),S})(o.default);function v(_,S){for(var C=parseInt(_[_.length-1]),P=d[C],q="",ne=0,te=0;te<P.length;te++){var M=P[te];M==="X"?q+=_[ne++]:q+=M}return q=""+S+q,""+q+(0,c.checksum)(q)}return kc.default=x,kc}var o1;function cN(){if(o1)return Kt;o1=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.UPCE=Kt.UPC=Kt.EAN2=Kt.EAN5=Kt.EAN8=Kt.EAN13=void 0;var n=sN(),e=x(n),s=iN(),i=x(s),o=aN(),c=x(o),m=oN(),p=x(m),g=Tv(),u=x(g),d=lN(),b=x(d);function x(v){return v&&v.__esModule?v:{default:v}}return Kt.EAN13=e.default,Kt.EAN8=i.default,Kt.EAN5=c.default,Kt.EAN2=p.default,Kt.UPC=u.default,Kt.UPCE=b.default,Kt}var Qs={},Nc={},Gi={},l1;function uN(){return l1||(l1=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.START_BIN="1010",Gi.END_BIN="11101",Gi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Gi}var c1;function Cv(){if(c1)return Nc;c1=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=uN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return n(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var x=this,v=this.data.match(/.{2}/g).map(function(_){return x.encodePair(_)}).join("");return{data:e.START_BIN+v+e.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=e.BINARIES[x[1]];return e.BINARIES[x[0]].split("").map(function(_,S){return(_==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),d})(i.default);return Nc.default=g,Nc}var Tc={},u1;function fN(){if(u1)return Tc;u1=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Cv(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=function(d){var b=d.substr(0,13).split("").map(function(x){return parseInt(x,10)}).reduce(function(x,v,_){return x+v*(3-_%2*2)},0);return Math.ceil(b/10)*10-b},g=(function(u){m(d,u);function d(b,x){return o(this,d),b.search(/^[0-9]{13}$/)!==-1&&(b+=p(b)),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===p(this.data)}}]),d})(s.default);return Tc.default=g,Tc}var f1;function hN(){if(f1)return Qs;f1=1,Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.ITF14=Qs.ITF=void 0;var n=Cv(),e=o(n),s=fN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Qs.ITF=e.default,Qs.ITF14=i.default,Qs}var xn={},Cc={},h1;function Uo(){if(h1)return Cc;h1=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=(function(u){m(d,u);function d(b,x){return o(this,d),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"encode",value:function(){for(var x="110",v=0;v<this.data.length;v++){var _=parseInt(this.data[v]),S=_.toString(2);S=g(S,4-S.length);for(var C=0;C<S.length;C++)x+=S[C]=="0"?"100":"110"}return x+="1001",{data:x,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(s.default);function g(u,d){for(var b=0;b<d;b++)u="0"+u;return u}return Cc.default=p,Cc}var Mc={},uo={},d1;function Lu(){if(d1)return uo;d1=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.mod10=n,uo.mod11=e;function n(s){for(var i=0,o=0;o<s.length;o++){var c=parseInt(s[o]);(o+s.length)%2===0?i+=c:i+=c*2%10+Math.floor(c*2/10)}return(10-i%10)%10}function e(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var m=parseInt(s[s.length-1-c]);i+=o[c%o.length]*m}return(11-i%11)%11}return uo}var m1;function dN(){if(m1)return Mc;m1=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod10)(d),b))}return u})(e.default);return Mc.default=p,Mc}var Rc={},p1;function mN(){if(p1)return Rc;p1=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod11)(d),b))}return u})(e.default);return Rc.default=p,Rc}var Dc={},y1;function pN(){if(y1)return Dc;y1=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod10)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Dc.default=p,Dc}var Lc={},g1;function yN(){if(g1)return Lc;g1=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod11)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Lc.default=p,Lc}var b1;function gN(){if(b1)return xn;b1=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.MSI1110=xn.MSI1010=xn.MSI11=xn.MSI10=xn.MSI=void 0;var n=Uo(),e=d(n),s=dN(),i=d(s),o=mN(),c=d(o),m=pN(),p=d(m),g=yN(),u=d(g);function d(b){return b&&b.__esModule?b:{default:b}}return xn.MSI=e.default,xn.MSI10=i.default,xn.MSI11=c.default,xn.MSI1010=p.default,xn.MSI1110=u.default,xn}var fo={},x1;function bN(){if(x1)return fo;x1=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.pharmacode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b));return x.number=parseInt(d,10),x}return n(u,[{key:"encode",value:function(){for(var b=this.number,x="";!isNaN(b)&&b!=0;)b%2===0?(x="11100"+x,b=(b-2)/2):(x="100"+x,b=(b-1)/2);return x=x.slice(0,-2),{data:x,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),u})(s.default);return fo.pharmacode=p,fo}var ho={},v1;function xN(){if(v1)return ho;v1=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.codabar=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d.toUpperCase(),b));return x.text=x.options.text||x.text.replace(/[A-D]/g,""),x}return n(u,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var b=[],x=this.getEncodings(),v=0;v<this.data.length;v++)b.push(x[this.data.charAt(v)]),v!==this.data.length-1&&b.push("0");return{text:this.text,data:b.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),u})(s.default);return ho.codabar=p,ho}var Xs={},qc={},Vi={},_1;function vN(){return _1||(_1=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Vi.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],Vi.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),Vi}var w1;function Mv(){if(w1)return qc;w1=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=vN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return e.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return d.getEncoding(C)}).join(""),_=d.checksum(x,20),S=d.checksum(x.concat(_),15);return{text:this.text,data:d.getEncoding("ÿ")+v+d.getEncoding(_)+d.getEncoding(S)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return e.BINARIES[d.symbolValue(x)]}},{key:"getSymbol",value:function(x){return e.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return e.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var _=x.slice().reverse().reduce(function(S,C,P){var q=P%v+1;return S+d.symbolValue(C)*q},0);return d.getSymbol(_%47)}}]),d})(i.default);return qc.default=g,qc}var Pc={},S1;function _N(){if(S1)return Pc;S1=1,Object.defineProperty(Pc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Mv(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return Pc.default=p,Pc}var E1;function wN(){if(E1)return Xs;E1=1,Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.CODE93FullASCII=Xs.CODE93=void 0;var n=Mv(),e=o(n),s=_N(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Xs.CODE93=e.default,Xs.CODE93FullASCII=i.default,Xs}var mo={},O1;function SN(){if(O1)return mo;O1=1,Object.defineProperty(mo,"__esModule",{value:!0}),mo.GenericBarcode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return mo.GenericBarcode=p,mo}var A1;function EN(){if(A1)return mc;A1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=Xk(),e=rN(),s=cN(),i=hN(),o=gN(),c=bN(),m=xN(),p=wN(),g=SN();return mc.default={CODE39:n.CODE39,CODE128:e.CODE128,CODE128A:e.CODE128A,CODE128B:e.CODE128B,CODE128C:e.CODE128C,EAN13:s.EAN13,EAN8:s.EAN8,EAN5:s.EAN5,EAN2:s.EAN2,UPC:s.UPC,UPCE:s.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:c.pharmacode,codabar:m.codabar,CODE93:p.CODE93,CODE93FullASCII:p.CODE93FullASCII,GenericBarcode:g.GenericBarcode},mc}var Bc={},j1;function qu(){if(j1)return Bc;j1=1,Object.defineProperty(Bc,"__esModule",{value:!0});var n=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e};return Bc.default=function(e,s){return n({},e,s)},Bc}var Uc={},k1;function ON(){if(k1)return Uc;k1=1,Object.defineProperty(Uc,"__esModule",{value:!0}),Uc.default=n;function n(e){var s=[];function i(o){if(Array.isArray(o))for(var c=0;c<o.length;c++)i(o[c]);else o.text=o.text||"",o.data=o.data||"",s.push(o)}return i(e),s}return Uc}var zc={},N1;function AN(){if(N1)return zc;N1=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.default=n;function n(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}return zc}var Ic={},$c={},Hc={},T1;function Rv(){if(T1)return Hc;T1=1,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.default=n;function n(e){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof e[i]=="string"&&(e[i]=parseInt(e[i],10)));return typeof e.displayValue=="string"&&(e.displayValue=e.displayValue!="false"),e}return Hc}var Fc={},C1;function Dv(){if(C1)return Fc;C1=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Fc.default=n,Fc}var M1;function jN(){if(M1)return $c;M1=1,Object.defineProperty($c,"__esModule",{value:!0});var n=Rv(),e=o(n),s=Dv(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m){var p={};for(var g in i.default)i.default.hasOwnProperty(g)&&(m.hasAttribute("jsbarcode-"+g.toLowerCase())&&(p[g]=m.getAttribute("jsbarcode-"+g.toLowerCase())),m.hasAttribute("data-"+g.toLowerCase())&&(p[g]=m.getAttribute("data-"+g.toLowerCase())));return p.value=m.getAttribute("jsbarcode-value")||m.getAttribute("data-value"),p=(0,e.default)(p),p}return $c.default=c,$c}var Gc={},Vc={},vn={},R1;function Lv(){if(R1)return vn;R1=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.getTotalWidthOfEncodings=vn.calculateEncodingAttributes=vn.getBarcodePadding=vn.getEncodingHeight=vn.getMaximumHeightOfEncodings=void 0;var n=qu(),e=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,d){return d.height+(d.displayValue&&u.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(u,d,b){if(b.displayValue&&d<u){if(b.textAlign=="center")return Math.floor((u-d)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-d)}return 0}function c(u,d,b){for(var x=0;x<u.length;x++){var v=u[x],_=(0,e.default)(d,v.options),S;_.displayValue?S=g(v.text,_,b):S=0;var C=v.data.length*_.width;v.width=Math.ceil(Math.max(S,C)),v.height=i(v,_),v.barcodePadding=o(S,C,_)}}function m(u){for(var d=0,b=0;b<u.length;b++)d+=u[b].width;return d}function p(u){for(var d=0,b=0;b<u.length;b++)u[b].height>d&&(d=u[b].height);return d}function g(u,d,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var v=x.measureText(u);if(!v)return 0;var _=v.width;return _}return vn.getMaximumHeightOfEncodings=p,vn.getEncodingHeight=i,vn.getBarcodePadding=o,vn.calculateEncodingAttributes=c,vn.getTotalWidthOfEncodings=m,vn}var D1;function kN(){if(D1)return Vc;D1=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function p(g,u){for(var d=0;d<u.length;d++){var b=u[d];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,d){return u&&p(g.prototype,u),d&&p(g,d),g}})(),e=qu(),s=o(e),i=Lv();function o(p){return p&&p.__esModule?p:{default:p}}function c(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var m=(function(){function p(g,u,d){c(this,p),this.canvas=g,this.encodings=u,this.options=d}return n(p,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var u=0;u<this.encodings.length;u++){var d=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(d,this.encodings[u]),this.drawCanvasText(d,this.encodings[u]),this.moveCanvasDrawing(this.encodings[u])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var u=this.canvas.getContext("2d");u.save(),(0,i.calculateEncodingAttributes)(this.encodings,this.options,u);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=b,u.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(u.fillStyle=this.options.background,u.fillRect(0,0,this.canvas.width,this.canvas.height)),u.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(u,d){var b=this.canvas.getContext("2d"),x=d.data,v;u.textPosition=="top"?v=u.marginTop+u.fontSize+u.textMargin:v=u.marginTop,b.fillStyle=u.lineColor;for(var _=0;_<x.length;_++){var S=_*u.width+d.barcodePadding;x[_]==="1"?b.fillRect(S,v,u.width,u.height):x[_]&&b.fillRect(S,v,u.width,u.height*x[_])}}},{key:"drawCanvasText",value:function(u,d){var b=this.canvas.getContext("2d"),x=u.fontOptions+" "+u.fontSize+"px "+u.font;if(u.displayValue){var v,_;u.textPosition=="top"?_=u.marginTop+u.fontSize-u.textMargin:_=u.height+u.textMargin+u.marginTop+u.fontSize,b.font=x,u.textAlign=="left"||d.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=d.width-1,b.textAlign="right"):(v=d.width/2,b.textAlign="center"),b.fillText(d.text,v,_)}}},{key:"moveCanvasDrawing",value:function(u){var d=this.canvas.getContext("2d");d.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),p})();return Vc.default=m,Vc}var Yc={},L1;function NN(){if(L1)return Yc;L1=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=qu(),s=o(e),i=Lv();function o(g){return g&&g.__esModule?g:{default:g}}function c(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}var m="http://www.w3.org/2000/svg",p=(function(){function g(u,d,b){c(this,g),this.svg=u,this.encodings=d,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var b=0;b<this.encodings.length;b++){var x=this.encodings[b],v=(0,s.default)(this.options,x.options),_=this.createGroup(d,v.marginTop,this.svg);this.setGroupOptions(_,v),this.drawSvgBarcode(_,v,x),this.drawSVGText(_,v,x),d+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(x,b),this.options.background&&this.drawRect(0,0,x,b,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,b,x){var v=x.data,_;b.textPosition=="top"?_=b.fontSize+b.textMargin:_=0;for(var S=0,C=0,P=0;P<v.length;P++)C=P*b.width+x.barcodePadding,v[P]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,_,b.width*S,b.height,d),S=0);S>0&&this.drawRect(C-b.width*(S-1),_,b.width*S,b.height,d)}},{key:"drawSVGText",value:function(d,b,x){var v=this.document.createElementNS(m,"text");if(b.displayValue){var _,S;v.setAttribute("font-family",b.font),v.setAttribute("font-size",b.fontSize),b.fontOptions.includes("bold")&&v.setAttribute("font-weight","bold"),b.fontOptions.includes("italic")&&v.setAttribute("font-style","italic"),b.textPosition=="top"?S=b.fontSize-b.textMargin:S=b.height+b.textMargin+b.fontSize,b.textAlign=="left"||x.barcodePadding>0?(_=0,v.setAttribute("text-anchor","start")):b.textAlign=="right"?(_=x.width-1,v.setAttribute("text-anchor","end")):(_=x.width/2,v.setAttribute("text-anchor","middle")),v.setAttribute("x",_),v.setAttribute("y",S),v.appendChild(this.document.createTextNode(x.text)),d.appendChild(v)}}},{key:"setSvgAttributes",value:function(d,b){var x=this.svg;x.setAttribute("width",d+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+d+" "+b),x.setAttribute("xmlns",m),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,b,x){var v=this.document.createElementNS(m,"g");return v.setAttribute("transform","translate("+d+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(d,b){d.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(d,b,x,v,_){var S=this.document.createElementNS(m,"rect");return S.setAttribute("x",d),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),_.appendChild(S),S}}]),g})();return Yc.default=p,Yc}var Kc={},q1;function TN(){if(q1)return Kc;q1=1,Object.defineProperty(Kc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,m){e(this,i),this.object=o,this.encodings=c,this.options=m}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Kc.default=s,Kc}var P1;function CN(){if(P1)return Gc;P1=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=kN(),e=m(n),s=NN(),i=m(s),o=TN(),c=m(o);function m(p){return p&&p.__esModule?p:{default:p}}return Gc.default={CanvasRenderer:e.default,SVGRenderer:i.default,ObjectRenderer:c.default},Gc}var Yi={},B1;function qv(){if(B1)return Yi;B1=1,Object.defineProperty(Yi,"__esModule",{value:!0});function n(m,p){if(!(m instanceof p))throw new TypeError("Cannot call a class as a function")}function e(m,p){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:m}function s(m,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);m.prototype=Object.create(p&&p.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(m,p):m.__proto__=p)}var i=(function(m){s(p,m);function p(g,u){n(this,p);var d=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return d.name="InvalidInputException",d.symbology=g,d.input=u,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return p})(Error),o=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return p})(Error),c=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return p})(Error);return Yi.InvalidInputException=i,Yi.InvalidElementException=o,Yi.NoElementException=c,Yi}var U1;function MN(){if(U1)return Ic;U1=1,Object.defineProperty(Ic,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e=jN(),s=m(e),i=CN(),o=m(i),c=qv();function m(d){return d&&d.__esModule?d:{default:d}}function p(d){if(typeof d=="string")return g(d);if(Array.isArray(d)){for(var b=[],x=0;x<d.length;x++)b.push(p(d[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return u(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,s.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,s.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":n(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(d){var b=document.querySelectorAll(d);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(p(b[v]));return x}}function u(d){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",b.toDataURL())}}}return Ic.default=p,Ic}var Jc={},z1;function RN(){if(z1)return Jc;z1=1,Object.defineProperty(Jc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){e(this,i),this.api=o}return n(i,[{key:"handleCatch",value:function(c){if(c.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw c.message;else throw c;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(c){try{var m=c.apply(void 0,arguments);return this.api._options.valid(!0),m}catch(p){return this.handleCatch(p),this.api}}}]),i})();return Jc.default=s,Jc}var hd,I1;function DN(){if(I1)return hd;I1=1;var n=EN(),e=P(n),s=qu(),i=P(s),o=ON(),c=P(o),m=AN(),p=P(m),g=MN(),u=P(g),d=Rv(),b=P(d),x=RN(),v=P(x),_=qv(),S=Dv(),C=P(S);function P(I){return I&&I.__esModule?I:{default:I}}var q=function(){},ne=function(D,X,W){var he=new q;if(typeof D>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(D),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof X<"u"&&(W=W||{},W.format||(W.format=ae()),he.options(W)[W.format](X,W).render()),he};ne.getModule=function(I){return e.default[I]};for(var te in e.default)e.default.hasOwnProperty(te)&&M(e.default,te);function M(I,D){q.prototype[D]=q.prototype[D.toUpperCase()]=q.prototype[D.toLowerCase()]=function(X,W){var he=this;return he._errorHandler.wrapBarcodeCall(function(){W.text=typeof W.text>"u"?void 0:""+W.text;var we=(0,i.default)(he._options,W);we=(0,b.default)(we);var Oe=I[D],F=U(X,Oe,we);return he._encodings.push(F),he})}}function U(I,D,X){I=""+I;var W=new D(I,X);if(!W.valid())throw new _.InvalidInputException(W.constructor.name,I);var he=W.encode();he=(0,c.default)(he);for(var we=0;we<he.length;we++)he[we].options=(0,i.default)(X,he[we].options);return he}function ae(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}q.prototype.options=function(I){return this._options=(0,i.default)(this._options,I),this},q.prototype.blank=function(I){var D=new Array(I+1).join("0");return this._encodings.push({data:D}),this},q.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var I;for(var D in this._renderProperties){I=this._renderProperties[D];var X=(0,i.default)(this._options,I.options);X.format=="auto"&&(X.format=ae()),this._errorHandler.wrapBarcodeCall(function(){var W=X.value,he=e.default[X.format.toUpperCase()],we=U(W,he,X);z(I,we,X)})}}},q.prototype.render=function(){if(!this._renderProperties)throw new _.NoElementException;if(Array.isArray(this._renderProperties))for(var I=0;I<this._renderProperties.length;I++)z(this._renderProperties[I],this._encodings,this._options);else z(this._renderProperties,this._encodings,this._options);return this},q.prototype._defaults=C.default;function z(I,D,X){D=(0,c.default)(D);for(var W=0;W<D.length;W++)D[W].options=(0,i.default)(X,D[W].options),(0,p.default)(D[W].options);(0,p.default)(X);var he=I.renderer,we=new he(I.element,D,X);we.render(),I.afterRender&&I.afterRender()}return typeof window<"u"&&(window.JsBarcode=ne),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(I,D){var X=[];return jQuery(this).each(function(){X.push(this)}),ne(X,I,D)}),hd=ne,hd}var LN=DN();const qN=uS(LN),PN={[je.EXECUTED]:"Executed",[je.MATCHED_LIST]:"Matched list",[je.CONFIRM_REQUIRED]:"Awaiting confirmation",[je.NO_MATCH_FALLBACK]:"No match",[je.UNCONFIGURED]:"Not configured",[je.INVALID_CODE]:"Invalid code",[je.FORBIDDEN]:"Not permitted",[je.CONFLICT]:"Conflict",[je.IDENTITY_PRIMED]:"Identity primed",[je.IDENTITY_UNKNOWN]:"Badge not recognized",[je.NOT_PRIMED]:"Badge required",[je.CHOICES]:"Choices presented",[je.NO_OPEN_CONTAINER]:"Container closing, scan again",[je.HELD]:"Holding",[je.REFUSED]:"Not placed",[je.SUBJECT_STALE]:"Scan it again"},BN={[je.EXECUTED]:"text-status-success",[je.MATCHED_LIST]:"text-status-success",[je.CONFIRM_REQUIRED]:"text-status-warning",[je.NO_MATCH_FALLBACK]:"text-text-secondary",[je.UNCONFIGURED]:"text-status-warning",[je.INVALID_CODE]:"text-status-error",[je.FORBIDDEN]:"text-status-error",[je.CONFLICT]:"text-status-warning",[je.IDENTITY_PRIMED]:"text-status-success",[je.IDENTITY_UNKNOWN]:"text-status-warning",[je.NOT_PRIMED]:"text-status-warning",[je.CHOICES]:"text-status-success",[je.NO_OPEN_CONTAINER]:"text-status-warning",[je.HELD]:"text-status-success",[je.REFUSED]:"text-status-error",[je.SUBJECT_STALE]:"text-status-warning"};function UN(n){return n.outcome===je.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${PN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function zN(n){var e,s,i,o,c,m,p;return n.outcome===je.NO_MATCH_FALLBACK?((e=n.fallback)==null?void 0:e.markdown)??null:n.outcome===je.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===je.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===je.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:n.outcome===je.REFUSED?((c=n.refusal)==null?void 0:c.markdown)??n.error??null:n.outcome===je.HELD?((p=(m=n.subject)==null?void 0:m.expect)==null?void 0:p.prompt)??null:n.outcome===je.SUBJECT_STALE?n.error??null:null}function gs(n){return n.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function IN({content:n,compact:e,inherit:s}){const i=[],o=/^```(\w*)\n([\s\S]*?)^```$/gm;let c=0,m;for(;(m=o.exec(n))!==null;)m.index>c&&i.push({type:"text",text:n.slice(c,m.index)}),i.push({type:"code",lang:m[1],code:m[2].replace(/\n$/,"")}),c=m.index+m[0].length;c<n.length&&i.push({type:"text",text:n.slice(c)});const p=s?{text:"",heading:"",list:"",code:"text-[0.85em]",tone:""}:e?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs",tone:"text-text-secondary"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs",tone:"text-text-secondary"},g=[];for(const u of i){if(u.type==="code"){const d=u.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");g.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${p.code} font-mono text-text-secondary leading-relaxed">${d}</code></pre>`);continue}g.push(...$N(u.text,p))}return h.jsx("div",{className:s?void 0:"prose-sm",dangerouslySetInnerHTML:{__html:g.join(`
55
- `)}})}function $N(n,e){const s=n.split(`
56
- `),i=[];let o=!1,c=!1,m=[];for(const p of s){const g=p.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(d=>d.trim());if(u.every(d=>/^[-:]+$/.test(d)))continue;c||(c=!0,m=[]),m.push(u);continue}if(c){c=!1;const[u,...d]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const b of u)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of d){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),m=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(g)){o&&(i.push("</ul>"),o=!1),i.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(g)){o||(i.push('<ul class="space-y-1 my-1">'),o=!0),i.push(`<li class="${e.list} ${e.tone} flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${gs(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${e.text} ${e.tone} my-1">${gs(g)}</p>`)}if(c&&m.length){const[p,...g]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of p)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const d of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(d)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Hm({result:n,compact:e=!1}){const{response:s}=n,i=e?"text-xs":"text-sm",o=s?zN(s):null,c=s!=null&&s.error&&s.error!==o?s.error:null;return h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:`${i} font-mono text-text-secondary truncate`,children:n.code}),s?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`${i} font-medium ${BN[s.outcome]}`,children:UN(s)}),c&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:c}),o&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(IN,{content:o,compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Pv(n){return n.replace(/[\u2010-\u2015\u2212]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\x00-\x1F\x7F]/g,"").trim()}function HN(n){const e=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&e.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...e]}function FN({value:n}){const e=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!e.current||!n))try{qN(e.current,n,{format:"CODE128",width:2,height:88,margin:12,displayValue:!0,fontSize:13,background:"#ffffff",lineColor:"#000000"}),i(!1)}catch{i(!0)}},[n]),n?h.jsxs("div",{children:[h.jsx("span",{className:"block text-xs uppercase tracking-wide text-text-tertiary mb-1",children:"Barcode"}),s?h.jsxs("p",{className:"text-xs text-status-error",children:["This value has characters Code 128 cannot carry:"," ",h.jsx("span",{className:"font-mono",children:HN(n).join(", ")||"unknown"})]}):h.jsx("div",{className:"bg-white rounded p-1 inline-block max-w-full overflow-hidden",children:h.jsx("svg",{ref:e,className:"max-w-full"})})]}):null}function GN({onClose:n}){const{submitCode:e,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:m,diagnosticsOn:p,setDiagnosticsOn:g}=$m(),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=_=>{_.preventDefault();const S=u.trim();S&&(d(""),e(S))};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[h.jsx(Mo,{className:"w-4 h-4"}),"Scan"]}),h.jsx("button",{type:"button",onClick:n,className:"text-text-tertiary hover:text-text-primary",title:"Close",children:h.jsx(Zt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",children:[h.jsxs("form",{onSubmit:v,className:"space-y-2",children:[h.jsx("label",{className:"block text-xs uppercase tracking-wide text-text-tertiary",children:"Enter a code"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:u,onChange:_=>d(Pv(_.target.value)),placeholder:"10:1:SN-12345",className:"flex-1 px-2 py-1.5 text-sm bg-surface-raised border border-surface-border rounded text-text-primary","data-scan-manual-entry":!0}),h.jsx("button",{type:"submit",disabled:i||!u.trim(),className:"px-3 py-1.5 text-sm rounded bg-accent text-text-inverse disabled:opacity-50",children:"Go"})]}),h.jsx("p",{className:"text-xs text-text-tertiary",children:"Scanning with a connected scanner works from any page — this entry exists for testing and for codes you can read but not scan. Typing here also draws the code below; point the scanner at the screen to fire it for real."})]}),h.jsx(FN,{value:u.trim()}),s&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs uppercase tracking-wide text-text-tertiary",children:"Last scan"}),h.jsx(Hm,{result:s})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{type:"button",onClick:()=>x(_=>!_),className:"text-xs uppercase tracking-wide text-text-tertiary hover:text-text-primary",children:["Capture settings ",b?"▾":"▸"]}),b&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block text-sm text-text-primary",children:[h.jsx("span",{className:"block text-xs text-text-tertiary mb-1",children:"Key gap limit (ms) — a longer pause between keys starts a new capture; raise it for scanners that pace slowly"}),h.jsx("input",{type:"number",min:100,max:2e3,step:50,value:o.maxKeyGapMs,onChange:_=>c({maxKeyGapMs:Number(_.target.value)}),className:"w-24 px-2 py-1 text-sm bg-surface-raised border border-surface-border rounded"})]}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-primary",children:[h.jsx("input",{type:"checkbox",checked:p,onChange:_=>g(_.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),p&&h.jsxs("div",{className:"border border-surface-border rounded",children:[h.jsx("div",{className:"px-2 py-1.5 text-2xs uppercase tracking-wide text-text-tertiary border-b border-surface-border",children:"Keydown trace — scan now, newest last"}),h.jsxs("div",{className:"max-h-64 overflow-y-auto font-mono text-2xs leading-5 px-2 py-1",children:[m.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),m.map(_=>h.jsxs("div",{className:"whitespace-nowrap overflow-hidden text-ellipsis",title:`buffer: ${_.buffer}`,children:[h.jsxs("span",{className:"text-text-tertiary",children:[String(_.deltaMs).padStart(4),"ms "]}),h.jsx("span",{className:"text",children:JSON.stringify(_.key)}),_.code&&h.jsxs("span",{className:"text-text-tertiary",children:[" (",_.code,")"]}),h.jsxs("span",{className:"text-text-tertiary",children:[" — ",_.note]})]},_.seq))]}),h.jsxs("div",{className:"px-2 py-1.5 text-2xs text-text-tertiary border-t border-surface-border",children:["Read it like this: a scan should end with an"," ",h.jsx("span",{className:"font-mono",children:'"Enter"'})," row saying"," ",h.jsx("span",{className:"font-mono",children:"capture → …"}),'. An Enter row saying "no code tail" means the buffer split (raise the gap limit, or a key arrived as something other than one character). No Enter row at all means the scanner sends no suffix — program its Enter/CR suffix. Keys named'," ",h.jsx("span",{className:"font-mono",children:'"Unidentified"'})," mean the decode arrives outside the keydown path."]})]})]})]})]})]})}const Bv=/^\{lt:([A-Za-z0-9_]+)\}$/,$1="me";function RM(n){return`{lt:${n}}`}const Uv="lt:station:link-vars:";function em(n){return`${Uv}${n}`}const tm=new Set;function VN(){for(const n of tm)n()}let wu,Qc={};function zv(n){let e=null;try{e=localStorage.getItem(em(n))}catch{e=null}if(e===wu)return Qc;wu=e;try{const s=e?JSON.parse(e):{};Qc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Qc={}}return Qc}function YN(n,e,s){const i={...zv(n)};s===null||s===""?delete i[e]:i[e]=s;try{Object.keys(i).length===0?localStorage.removeItem(em(n)):localStorage.setItem(em(n),JSON.stringify(i))}catch{}wu=void 0,VN()}function KN(n){tm.add(n);const e=s=>{(s.key===null||s.key.startsWith(Uv))&&(wu=void 0,n())};try{window.addEventListener("storage",e)}catch{}return()=>{tm.delete(n);try{window.removeEventListener("storage",e)}catch{}}}const JN={};function QN(n){return E.useSyncExternalStore(KN,()=>n?zv(n):JN)}function XN(n,e,s,i={}){let o;try{o=new URL(n,"http://local")}catch{return n}const c=o.searchParams.get("facets");if(!c)return n;let m;try{const g=JSON.parse(c);if(!g||typeof g!="object"||Array.isArray(g))return n;m=g}catch{return n}let p=!1;for(const[g,u]of Object.entries(m)){if(typeof u!="string")continue;const d=Bv.exec(u);if(!d)continue;const b=i[d[1]]??e[d[1]]??s[d[1]];typeof b=="string"&&b!==""?m[g]=b:delete m[g],p=!0}return p?(Object.keys(m).length===0?o.searchParams.delete("facets"):o.searchParams.set("facets",JSON.stringify(m)),o.pathname+o.search):n}function DM(n){let e;try{e=new URL(n,"http://local")}catch{return[]}const s=e.searchParams.get("facets");if(!s)return[];try{const i=JSON.parse(s);if(!i||typeof i!="object"||Array.isArray(i))return[];const o=[];for(const c of Object.values(i)){if(typeof c!="string")continue;const m=Bv.exec(c);m&&!o.includes(m[1])&&o.push(m[1])}return o}catch{return[]}}function Fm(){var v;const{user:n,isSuperAdmin:e,hasRoleType:s}=qt(),i=(n==null?void 0:n.userId)??null,o=e||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(_=>_.role)),[n]),{data:m}=Mu({enabled:o||c.size>0}),p=QN(i),g=((v=xA())==null?void 0:v.actorId)??i,u=E.useMemo(()=>{var C;const _=[],S=new Set;for(const P of(m==null?void 0:m.roles)??[]){if(!o&&!c.has(P.role))continue;const q=(C=P.properties)==null?void 0:C.link_variables;if(Array.isArray(q))for(const ne of q){const te=ne==null?void 0:ne.name;if(typeof te!="string"||te===""||te===$1||S.has(te))continue;S.add(te);const M=ne.label,U=ne.default;_.push({name:te,...typeof M=="string"&&M!==""?{label:M}:{},...typeof U=="string"&&U!==""?{default:U}:{},fromRole:P.role})}}return _},[m,c,o]),d=E.useMemo(()=>{const _={};for(const S of u)S.default!==void 0&&(_[S.name]=S.default);return _},[u]),b=E.useCallback(_=>XN(_,p,d,g?{[$1]:g}:{}),[p,d,g]),x=E.useCallback((_,S)=>{i&&YN(i,_,S)},[i]);return{declarations:u,values:p,defaults:d,resolveUrl:b,setValue:x}}function WN({open:n,onClose:e,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const m=p=>{p.key==="Escape"&&e()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,e]),n?sm.createPortal(h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:c?e:void 0}),h.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"lt-modal-title",className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${o??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[h.jsx("h2",{id:"lt-modal-title",className:"text-sm font-medium text-text-primary",children:s}),h.jsx("button",{onClick:e,"aria-label":"Close dialog",className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}function ZN({open:n,onClose:e}){const{declarations:s,values:i,setValue:o}=Fm();return h.jsxs(WN,{open:n,onClose:e,title:"Link Variables",maxWidth:"max-w-lg",children:[h.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed mb-4",children:"Values bound on this device. Pinned links and the Pace Board open scoped to the value applied; an unbound variable falls back to the role's default, or applies no filter at all."}),h.jsx("div",{className:"divide-y divide-surface-border",children:s.map((c,m)=>h.jsx(eT,{declaration:c,value:i[c.name]??"",autoFocus:m===0,onChange:p=>o(c.name,p),onClear:()=>o(c.name,null),onEnter:e},c.name))}),s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary",children:"Your roles declare no link variables."}),s.length>0&&h.jsx("div",{className:"flex justify-end pt-4",children:h.jsx("button",{onClick:e,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function eT({declaration:n,value:e,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const m=E.useId(),{data:p}=rk(n.name),g=(p==null?void 0:p.values)??[];return h.jsxs("div",{className:"py-3 flex items-center gap-3","data-testid":"link-var-row",children:[h.jsxs("div",{className:"w-40 shrink-0 min-w-0",children:[h.jsx("p",{className:"text-xs font-mono text-text-primary truncate",title:n.name,children:n.name}),h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:`declared by ${n.fromRole}`,children:n.label??n.fromRole})]}),h.jsx("input",{type:"text",list:m,autoFocus:s,value:e,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:n.default?`${n.default} (default)`:"no filter","aria-label":`Value for ${n.name}`,className:"input text-xs font-mono flex-1 min-w-0"}),h.jsx("datalist",{id:m,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:e==="",title:`Clear ${n.name}`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors disabled:opacity-30 disabled:cursor-not-allowed shrink-0",children:"×"})]})}const H1=["escalationId","workflowId"],tT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Iv="lt:search:mode",nT="lt:search:facet",Lt={FACET:"facet",COMMAND:"command"};function rT(n,e){return{version:n.version,category:e.category,name:e.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function Co(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function sT(n,e){if(n.encoding==="delimited")return iT(n,e)?{code:e}:{code:`${Co(n)}${e}`};if(!/^[0-9]+$/.test(e))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&e.length!==s&&e.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${Co(n)}${e}`}}function iT(n,e){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(e)}function aT(n,e){return n==="escalationId"||n==="workflowId"?null:Yk(n,e)}function oT(n){return n.kind===Lt.FACET?n.facet:n.command.name}function lT(n){return n.kind===Lt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function cT(n){return n.kind===Lt.FACET?{kind:Lt.FACET,facet:n.facet}:{kind:Lt.COMMAND,version:n.command.version,category:n.command.category}}function uT(n,e,s){if((n==null?void 0:n.kind)===Lt.FACET&&e.includes(n.facet))return{kind:Lt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Lt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Lt.COMMAND,command:i}}return e.length>0?{kind:Lt.FACET,facet:e[0]}:s.length>0?{kind:Lt.COMMAND,command:s[0]}:null}function fT(){try{const n=localStorage.getItem(Iv);if(n){const s=JSON.parse(n);if(s.kind===Lt.FACET&&typeof s.facet=="string"||s.kind===Lt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const e=localStorage.getItem(nT);return e?{kind:Lt.FACET,facet:e}:null}catch{return null}}function hT(n){try{localStorage.setItem(Iv,JSON.stringify(n))}catch{}}const F1=5*6e4,dT=n=>({rules:n.map(e=>{var s;return((s=e.data)==null?void 0:s.rules)??null}),loading:n.some(e=>e.isLoading)});function mT(n){const e=jv({enabled:n,staleTime:F1}),s=E.useMemo(()=>{var m;return(((m=e.data)==null?void 0:m.schemes)??[]).filter(p=>p.enabled&&p.kind===zk.ACTION).sort((p,g)=>p.version-g.version)},[e.data]),{rules:i,loading:o}=fS({queries:s.map(m=>({queryKey:["scan-schemes",m.version,"actions"],queryFn:()=>ue(`/scan-codes/schemes/${m.version}/actions`),enabled:n,staleTime:F1})),combine:dT});return{commands:E.useMemo(()=>s.flatMap((m,p)=>(i[p]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>rT(m,g))),[s,i]),loading:e.isLoading||o}}const pT={escalationId:"opens the item",workflowId:"opens the run"};function yT({mode:n,facets:e,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,m]=E.useState(!1),p=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=_=>{p.current&&!p.current.contains(_.target)&&m(!1)},v=_=>{_.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Lt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${Co(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,d=gT(s),b=x=>{i(x),m(!1)};return h.jsxs("div",{ref:p,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>m(x=>!x),"aria-expanded":c,"aria-haspopup":"listbox","aria-label":"Search or run as",title:u,className:"group flex items-center gap-1 h-full pl-2.5 pr-2 border-l border-surface-field-border hover:bg-surface-hover transition-colors rounded-r-[var(--lt-radius-field)]","data-testid":"search-mode",children:[h.jsx("span",{className:`text-2xs whitespace-nowrap truncate max-w-[9rem] ${g?"font-medium text-accent":"font-mono text-text-tertiary"}`,children:oT(n)}),h.jsx(im,{className:`w-3 h-3 shrink-0 text-text-quaternary group-hover:text-accent transition-transform ${c?"rotate-180":""}`,strokeWidth:1.5})]}),c&&h.jsxs("div",{role:"listbox","aria-label":"Search or run as",className:"absolute z-50 top-full right-0 mt-1.5 min-w-[17rem] max-w-[24rem] max-h-[70vh] overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[e.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(G1,{children:"Find"}),e.map(x=>h.jsx(V1,{label:x,mono:!0,note:pT[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Lt.FACET,facet:x})},x))]}),d.map(({schemeName:x,targetFacet:v,items:_})=>h.jsxs("div",{children:[h.jsxs(G1,{note:v,children:["Run · ",x]}),_.map(S=>h.jsx(V1,{label:S.name,note:Co(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Lt.COMMAND,command:S})},`${S.version}:${S.category}`))]},x)),o&&h.jsxs(h.Fragment,{children:[h.jsx("hr",{className:"border-surface-border/60 my-1"}),h.jsxs("button",{type:"button",onClick:()=>{m(!1),o()},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-accent hover:bg-surface-hover","data-testid":"search-mode-scan-panel",children:[h.jsx(Mo,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function gT(n){const e=[];for(const s of n){const i=e.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):e.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return e}function G1({children:n,note:e}){return h.jsxs("p",{className:"px-3 pt-2 pb-1 flex items-baseline gap-2 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:[h.jsx("span",{className:"truncate",children:n}),e&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:e})]})}function V1({label:n,note:e,active:s,mono:i,noteMono:o,onClick:c}){return h.jsxs("button",{type:"button",role:"option","aria-selected":s,onClick:c,className:`w-full text-left pl-3 pr-3 py-1.5 flex items-baseline gap-3 border-l-2 transition-colors ${s?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[h.jsx("span",{className:`text-xs font-medium truncate ${i?"font-mono":""}`,children:n}),h.jsx("span",{className:`ml-auto text-2xs shrink-0 ${o?"font-mono tabular-nums":""} ${s?"text-accent/70":"text-text-quaternary"}`,children:e})]})}const bT=6e3;function xT({onOpenScanPanel:n}){const e=ni(),{data:s}=er(),i=zm(),{submitCode:o,busy:c,lastResult:m}=$m(),{commands:p}=mT(i),[g,u]=E.useState(""),[d,b]=E.useState(!1),[x,v]=E.useState(null),[_,S]=E.useState(null),[C,P]=E.useState(""),[q,ne]=E.useState(null),[te,M]=E.useState(fT),U=E.useRef(null),ae=E.useMemo(()=>{var le;if(!((le=s==null?void 0:s.search)!=null&&le.enabled))return[];const J=(s.search.facets??[]).filter(pe=>!H1.includes(pe));return[...H1,...J]},[s]),z=E.useMemo(()=>uT(te,ae,p),[te,ae,p]),I=(m==null?void 0:m.source)===To.TOOLBAR&&!m.navigated&&q!==m.at?m:null;E.useEffect(()=>{if(!I)return;const J=setTimeout(()=>ne(I.at),bT);return()=>clearTimeout(J)},[I]);const D=()=>{v(null),S(null),m&&ne(m.at)},X=J=>{var pe;const le=cT(J);M(le),hT(le),D(),(pe=U.current)==null||pe.focus()},W=(J,le)=>{const pe=sT(J.command,Pv(le));if("error"in pe){v(pe.error);return}u(""),o(pe.code,To.TOOLBAR)},he=async(J,le)=>{const pe=aT(J,le);if(pe){u(""),e(pe);return}if(J==="escalationId"&&!tT.test(le)){v("That is not a valid escalation id");return}b(!0);try{if(J==="escalationId")await ue(`/escalations/${encodeURIComponent(le)}`),u(""),e(`/escalations/detail/${encodeURIComponent(le)}`);else{const ye=await ue(`/escalations/by-workflow/${encodeURIComponent(le)}`),Ce=(ye==null?void 0:ye.escalations)??[];Ce.length===1?(u(""),e(`/escalations/detail/${Ce[0].id}`)):(P(le),S(Ce))}}catch{v(`No ${J==="escalationId"?"escalation":"workflow"} found for "${le}"`)}finally{b(!1)}},we=()=>{const J=g.trim();!J||d||c||!z||(D(),z.kind===Lt.COMMAND?W(z,J):he(z.facet,J))};if(!z)return null;const Oe=z.kind===Lt.COMMAND,F=d||c;return h.jsxs("div",{className:"relative w-full max-w-[28rem]","data-testid":"global-search",children:[h.jsxs("div",{className:"flex items-center h-8 bg-surface-field border border-surface-field-border rounded-[var(--lt-radius-field)] focus-within:border-accent focus-within:bg-surface-field-focus transition-colors",children:[h.jsxs("label",{htmlFor:"global-search-input",className:"flex items-center gap-1.5 pl-2.5 shrink-0 cursor-text",children:[Oe?h.jsx(Mo,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(vS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),Oe&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:Co(z.command)})]}),h.jsx("input",{ref:U,id:"global-search-input",type:"text",value:g,onChange:J=>{u(J.target.value),D()},onKeyDown:J=>{J.key==="Enter"&&we(),J.key==="Escape"&&(u(""),D())},placeholder:lT(z),"aria-label":Oe?"Run target":"Global search",autoComplete:"off",spellCheck:!1,className:`flex-1 min-w-0 h-full bg-transparent text-xs text-text-primary placeholder:text-text-quaternary focus:outline-none ${Oe?"pl-0.5 pr-2 font-mono":"px-2"}`}),F&&h.jsx("span",{className:"w-1.5 h-1.5 mr-2 rounded-full bg-accent animate-pulse shrink-0","aria-label":"Working"}),h.jsx(yT,{mode:z,facets:ae,commands:p,onSelect:X,onOpenScanPanel:n})]}),x&&h.jsx("p",{className:"absolute top-full left-0 mt-1 text-2xs text-status-error whitespace-nowrap",role:"alert",children:x}),I&&h.jsx("div",{role:"status",className:"absolute top-full left-0 mt-1.5 z-50 w-full max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg px-3 py-2 animate-fade-in","data-testid":"search-run-outcome",children:h.jsx(Hm,{result:I,compact:!0})}),_!==null&&h.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 min-w-72 max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1","data-testid":"search-workflow-results",children:[_.map(J=>h.jsxs(ar,{to:`/escalations/detail/${J.id}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover truncate",children:[h.jsx("span",{className:"font-medium text-text-primary",children:J.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),J.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:J.type})]},J.id)),_.length===0&&h.jsx("p",{className:"px-3 py-1.5 text-2xs text-text-tertiary",children:"No escalations for this workflow."}),h.jsx("hr",{className:"border-surface-border/60 my-0.5"}),h.jsx(ar,{to:`/workflows/executions/${encodeURIComponent(C)}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-accent hover:bg-surface-hover",children:"Workflow execution →"})]})]})}function vT(){const{identity:n,remainingSeconds:e}=Cu(),[,s]=E.useState(0);return E.useEffect(()=>{if(!(n!=null&&n.expiresAt))return;const i=setInterval(()=>s(o=>o+1),1e3);return()=>clearInterval(i)},[n]),e()}function _T(n){return n>=60?`${Math.floor(n/60)} min`:`${n} s`}function wT(){const{identity:n}=Cu(),e=vT();return n?h.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-secondary whitespace-nowrap min-w-0",title:`Scans act as ${n.displayName}`,"data-testid":"badge-grant-indicator",children:[h.jsx(_S,{className:"w-4 h-4 text-status-success shrink-0",strokeWidth:1.5}),h.jsx("span",{className:"hidden sm:inline",children:"Badged:"}),h.jsx("span",{className:"font-medium text-text-primary truncate max-w-[10rem]",children:n.displayName}),n.expiresAt&&h.jsxs("span",{className:"tabular-nums text-text-tertiary","data-testid":"badge-grant-remaining",children:["· ",_T(e)]})]}):null}function ST(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function nm(n){var e;return((e=n.title)==null?void 0:e.trim())||ST(n.role)}const $v="lt:bookmarks",Xc="scan";function ET(){try{const n=localStorage.getItem($v);if(!n)return[];const e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function Y1(n){try{localStorage.setItem($v,JSON.stringify(n))}catch{}}function OT({onToggleEventFeed:n,onToggleDocs:e,onToggleNav:s}){var Ue,Xe,cn,Mt;const i=ni(),{user:o,logout:c,isSuperAdmin:m,hasRoleType:p}=qt(),{viewAs:g,realIsBuilder:u}=tv(),{available:d,mine:b}=uk();nv();const{connected:x}=qx(),{data:v}=er(),{role:_,targets:S,selectable:C,selectRole:P}=Cm(),{declarations:q,values:ne}=Fm(),[te,M]=E.useState(!1),{data:U}=Mu(),ae=E.useMemo(()=>{const be=(U==null?void 0:U.roles)??[],it=new Set(((o==null?void 0:o.roles)??[]).map(Ot=>Ot.role)),yt=m||p("admin");return be.filter(Ot=>ea(Ot).length>0&&(yt||it.has(Ot.role))).map(Ot=>({role:Ot.role,title:nm(Ot),portals:ea(Ot)}))},[U,o,m,p]),{setPanel:z,closePanel:I,open:D,ownerKey:X}=Lm(),W=zm(),he=en(),we=()=>{D&&X===Xc?I(Xc):z(h.jsx(GN,{onClose:()=>I(Xc)}),{width:360,key:Xc})},[Oe,F]=E.useState(!1),[J,le]=E.useState(!1),[pe,ye]=E.useState(Sv),[Ce,Ne]=E.useState(ET),Me=E.useRef(null),We=(Ue=v==null?void 0:v.branding)==null?void 0:Ue.appName,pt=(Xe=v==null?void 0:v.branding)==null?void 0:Xe.themes,Ct=E.useMemo(()=>(Ak(pt??[]),jk()),[pt]),Se=be=>{kk(be),ye(be)},Re=()=>{const be=window.prompt("Bookmark label:");if(!(be!=null&&be.trim()))return;const it=he.pathname+he.search,yt=[...Ce,{label:be.trim(),url:it}].sort((Ot,Ur)=>Ot.label.localeCompare(Ur.label));Ne(yt),Y1(yt),F(!1)},ce=be=>{const it=Ce.filter(yt=>!(yt.label===be.label&&yt.url===be.url));Ne(it),Y1(it)};return E.useEffect(()=>{if(!Oe)return;const be=it=>{Me.current&&!Me.current.contains(it.target)&&F(!1)};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[Oe]),h.jsxs(h.Fragment,{children:[h.jsxs("header",{className:`h-14 shrink-0 border-b border-surface-border bg-surface-raised flex items-center justify-between pl-2 pr-5 relative ${Oe?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s&&h.jsx("button",{onClick:s,className:"lg:hidden p-2 text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open navigation",children:h.jsx(wS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(ar,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:be=>{(be.ctrlKey||be.metaKey)&&(be.preventDefault(),le(!0))},children:h.jsx(Ru,{appName:We,className:"flex"})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>i(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(cx,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>i(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(gd,{className:"w-5 h-5",strokeWidth:2})})]}),(((cn=v==null?void 0:v.search)==null?void 0:cn.enabled)||W)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx(xT,{onOpenScanPanel:W?we:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsx(wT,{}),h.jsxs(ar,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${d>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),d>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:d})]}),h.jsxs(ar,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${b>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),b>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:b})]}),g&&h.jsx(h.Fragment,{children:h.jsxs("span",{className:"hidden lg:flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-accent/10 border border-accent/25 text-2xs text-accent select-none",children:[h.jsxs("span",{className:"capitalize font-medium tracking-wide",children:[g," View"]}),h.jsx("button",{onClick:Vd,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Zt,{className:"w-2.5 h-2.5"})})]})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),o&&h.jsxs("div",{className:"relative",ref:Me,children:[h.jsxs("button",{onClick:()=>F(be=>!be),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(SS,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),g&&h.jsx("span",{className:"lg:hidden absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"hidden lg:inline whitespace-nowrap",children:o.displayName||o.username||o.userId}),h.jsx("svg",{className:"hidden lg:block w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),Oe&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100]",children:[h.jsx(ar,{to:"/credentials",onClick:()=>F(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),((Mt=v==null?void 0:v.auth)==null?void 0:Mt.oauthServer)&&h.jsx(ar,{to:"/connected-apps",onClick:()=>F(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Connected apps"}),W&&h.jsx("button",{onClick:()=>{F(!1),we()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-scan",children:"Scan a code"}),h.jsx("button",{onClick:()=>{F(!1),x?n==null||n():window.location.reload()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:x?"Events":"Reconnect events"}),u&&h.jsx("button",{onClick:()=>{F(!1),e==null||e()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-docs",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{F(!1),Vd()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",g," view"]}),h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),h.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ct.map(be=>h.jsx("button",{type:"button",onClick:()=>Se(be.id),title:be.label,"aria-label":`${be.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${pe===be.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:be.swatch}},be.id))})]}),C&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Station queue"}),h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("button",{type:"button",onClick:()=>{F(!1),P(null),i("/")},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${_?"text-text-secondary":"text-accent"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_?"bg-surface-border":"bg-accent"}`}),h.jsx("span",{className:"truncate",children:"Full dashboard"})]}),S.map(be=>{var Ot;const it=(Ot=U==null?void 0:U.roles)==null?void 0:Ot.find(Ur=>Ur.role===be),yt=be===_;return h.jsxs("button",{type:"button",onClick:()=>{F(!1),P(be),i(hv(be,ea(it)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${yt?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${yt?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:nm({role:be,title:it==null?void 0:it.title})})]},be)})]})]}),ae.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60","data-testid":"menu-portals",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Portals"}),h.jsx("div",{className:"flex flex-col gap-1.5",children:ae.map(be=>h.jsxs("div",{children:[ae.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:be.role,children:be.title}),be.portals.map(it=>{const yt=Tm(be.role,it.key),Ot=he.pathname===yt;return h.jsxs("button",{type:"button",onClick:()=>{F(!1),i(yt)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${Ot?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${be.role}-${it.key}`,children:[h.jsx(xd,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:it.label})]},it.key)})]},be.role))})]}),q.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Link variables"}),h.jsxs("button",{type:"button",onClick:()=>{F(!1),M(!0)},className:"flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded text-text-secondary hover:bg-surface-hover","data-testid":"link-vars-menu-entry",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Object.keys(ne).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ne).length>0?Object.entries(ne).map(([be,it])=>`${be} = ${it}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{F(!1),c()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"}),h.jsxs("div",{className:"border-t border-surface-border/60 pt-1",children:[Ce.map(be=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(ar,{to:be.url,onClick:()=>F(!1),title:be.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:be.label}),h.jsx("button",{type:"button",onClick:()=>ce(be),title:`Remove "${be.label}"`,className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1 p-0.5 shrink-0 text-text-quaternary hover:text-status-error",children:h.jsx(Zt,{className:"w-3 h-3"})})]},`${be.label}::${be.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:Re,className:"flex items-center gap-1.5 w-full px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:[h.jsx(ES,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),J&&h.jsx(Ok,{onClose:()=>le(!1)}),h.jsx(ZN,{open:te,onClose:()=>M(!1)})]})}function Gm({open:n,children:e}){const[s,i]=E.useState(n);return E.useEffect(()=>{n&&i(!0)},[n]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${n?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{n||i(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?e:null})})}function rm(n){return({isActive:e})=>{const s="flex items-center rounded-md transition-colors duration-150",i="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return n?`${s} justify-center w-10 h-10 mx-auto ${e?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${e?i:o}`}}function AT(){return({isActive:n})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${n?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function jT({group:n,collapsed:e}){const{pathname:s}=en(),i=n.matchPaths.some(p=>s.startsWith(p)),[o,c]=E.useState(i),m=o||i;return e?h.jsx(h.Fragment,{children:n.items.map(p=>h.jsx(Es,{to:p.to,className:rm(!0),title:p.label,children:p.icon&&h.jsx(p.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},p.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(p=>!p),className:"w-full flex items-center justify-between px-4 py-2 text-sm rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",children:[h.jsxs("span",{className:"flex items-center gap-3",children:[n.icon&&h.jsx(n.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:n.label})]}),h.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${m?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),h.jsx(Gm,{open:m,children:n.items.map(p=>h.jsxs(Es,{to:p.to,end:p.end,className:AT(),children:[p.icon&&h.jsx(p.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:p.label})]},p.to))})]})}function kT(n){return n.kind==="group"}function NT({entry:n,collapsed:e}){const{pathname:s,search:i}=en(),o=n.to.includes("?"),c=n.icon&&h.jsx(n.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${n.iconClassName??""}`,strokeWidth:1.5,...n.solid?{fill:"currentColor"}:{}});if(o){const[m,p]=n.to.split("?"),g=s===m&&i===`?${p}`,u=rm(e)({isActive:g});return h.jsxs(Es,{to:n.to,className:u,title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}return h.jsxs(Es,{to:n.to,end:n.end,className:rm(e),title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}function qr({heading:n,entries:e}){const{collapsed:s}=Rm();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:n}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:n}),e.map(i=>kT(i)?h.jsx(jT,{group:i,collapsed:s},i.label):h.jsx(NT,{entry:i,collapsed:s},i.to))]})}function TT({aiEnabled:n=!1,isBuilder:e=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1}){const c=[{to:"/pace",label:"Pace Board",icon:OS},{to:"/trends",label:"Trend Board",icon:AS}];if(!e&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(qr,{heading:"Monitor",entries:c}):null;if(!e)return h.jsx(qr,{heading:"Monitor",entries:o?c:[]});const m=[...o?c:[],{to:"/topics",label:"Event Topics",icon:ux},{to:"/agents",label:n?"Agents":"Automations",icon:jS},{to:"/capabilities",label:"Capabilities",icon:kS}];return h.jsx(qr,{heading:"Monitor",entries:m})}function CT(){return qe({queryKey:["me","preferences"],queryFn:()=>ue("/me/preferences"),staleTime:6e4})}function MT(){const n=Pe();return $e({mutationFn:e=>ue("/me/preferences",{method:"PATCH",body:JSON.stringify(e)}),onSuccess:e=>{n.setQueryData(["me","preferences"],e)}})}const xs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},K1={COMPACT:"compact",CARDS:"cards"},dd={AVAILABLE:"/escalations/available",ALL:"/escalations"},ta={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},RT={[ta.RESOLVED]:"resolved",[ta.CANCELLED]:"cancelled",[ta.EXPIRED]:"expired"};function DT(n){const e=n===ta.CLAIMED;return{available:n===ta.AVAILABLE,claimed:e,apiStatus:e?"pending":RT[n]}}function LT(n){return n===xs.TABLE||n===xs.RICH||n===xs.TIMELINE}function qT(n){return n===K1.COMPACT||n===K1.CARDS}function PT(n,e=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||e,role:n.get("role")||void 0,type:n.get("type")||void 0,subtype:n.get("subtype")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:Vk(n),view:LT(i)?i:null,layout:qT(o)?o:null}}function BT(n){let e;try{e=new URL(n,"http://local")}catch{return null}if(e.pathname!==dd.AVAILABLE&&e.pathname!==dd.ALL)return null;const s=e.pathname===dd.AVAILABLE?ta.AVAILABLE:"";return PT(e.searchParams,s)}function LM(n){var e;return n.role||(((e=n.facets.roles)==null?void 0:e.length)===1?n.facets.roles[0]:null)}function qM(n,e){return n===xs.TIMELINE?xs.TIMELINE:e&&(!n||n===xs.RICH)?xs.RICH:xs.TABLE}function UT(n,e){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(p=>p.label)),c=[...s],m=new Set;for(const{role:p,pins:g}of e)for(const u of g)o.has(u.label)||i.has(u.label)||m.has(u.label)||(m.add(u.label),c.push({...u,id:`role:${p}:${u.label}`,fromRole:p}));return c}function zT(n){const e=BT(n);if(!e)return null;const{available:s,claimed:i,apiStatus:o}=DT(e.statusFilter);return{available:s,params:{...e.facets,role:e.role,type:e.type,subtype:e.subtype,priority:e.priority,status:o,...i?{claimed:!0}:{},search:e.search}}}function IT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function $T(){var I;const{collapsed:n}=Rm(),{user:e}=qt(),s=CT(),i=MT(),o=E.useMemo(()=>new Set(((e==null?void 0:e.roles)??[]).map(D=>D.role)),[e]),{data:c}=Mu({enabled:o.size>0}),m=tn("SUMMARY");js(jm(),()=>{m([["escalations"]])});const p=(I=s.data)==null?void 0:I.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Array.isArray(D.default_pins)&&D.default_pins.length>0).map(D=>({role:D.role,pins:D.default_pins})),[c,o]),{resolveUrl:u}=Fm(),d=E.useMemo(()=>UT(p,g),[p,g]),b=E.useMemo(()=>new Map(d.map(D=>[D.id,D.url])),[d]),x=E.useMemo(()=>d.map(D=>({...D,url:u(D.url)})),[d,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(D=>[D.role,nm(D)])),[c]),_=E.useMemo(()=>x.filter(D=>!D.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Kj(D)).map(D=>D.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>S.has(D.role)||g.some(X=>X.role===D.role)).map(D=>({role:D.role,title:v.get(D.role)??D.role,portals:S.has(D.role)?ea(D):[],pins:x.filter(X=>X.fromRole===D.role)})).filter(D=>D.portals.length>0||D.pins.length>0),[c,g,S,v,x]),P=(p==null?void 0:p.pinnedViews)??[],q=E.useRef(null),ne=D=>i.mutate({pinnedViews:D}),te=D=>ne(P.filter(X=>X.id!==D)),M=D=>ne([...P,{id:IT(),label:D.label,url:b.get(D.id)??D.url,badge:D.badge}]),U=D=>i.mutate({hiddenRolePins:[...(p==null?void 0:p.hiddenRolePins)??[],D]}),ae=(D,X)=>{if(D===X)return;const W=[...P],[he]=W.splice(D,1);W.splice(X,0,he),ne(W)};if(x.length===0&&S.size===0)return null;const z="px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary truncate";return h.jsxs("div",{className:"space-y-1",children:[n&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!n&&_.length>0&&h.jsx("p",{className:z,children:"Pinned"}),_.map(D=>{const X=P.findIndex(W=>W.id===D.id);return h.jsx(J1,{pin:D,collapsed:n,draggable:X!==-1,onDragStart:()=>{q.current=X},onDropOn:()=>{q.current!==null&&X!==-1&&ae(q.current,X),q.current=null},onRemove:()=>te(D.id)},D.id)}),C.map(D=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:z,title:`${D.title} — pins from the ${D.role} role`,"data-testid":"pin-group-label",children:D.title}),D.portals.map(X=>h.jsx(HT,{role:D.role,portal:X,collapsed:n},X.key)),D.pins.map(X=>h.jsx(J1,{pin:X,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>M(X),onHide:()=>U(X.label)},X.id))]},D.role))]})}function HT({role:n,portal:e,collapsed:s}){const i=Tm(n,e.key),o="flex items-center rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",c=`portal-link-${n}-${e.key}`;return s?h.jsx(Es,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:e.label,"data-testid":c,children:h.jsx(xd,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Es,{to:i,title:e.label,className:({isActive:m})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${m?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(xd,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:e.label})]})}function J1({pin:n,collapsed:e,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:m,onHide:p}){const{pathname:g,search:u}=en(),[d,b=""]=n.url.split("?"),x=g===d&&u===(b?`?${b}`:""),v="group flex items-center rounded-md transition-colors duration-150",_=x?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return e?h.jsx(Es,{to:n.url,className:`${v} ${_} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(Mg,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${v} ${_} relative`,draggable:s,onDragStart:i,onDragOver:S=>S.preventDefault(),onDrop:o,children:[h.jsxs(Es,{to:n.url,title:n.label,className:"flex items-center gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] flex-1 min-w-0",children:[h.jsx(Mg,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...n.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:n.label}),n.badge&&h.jsx(FT,{url:n.url})]}),h.jsxs("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 rounded px-0.5 bg-surface-hover opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity",children:[m&&h.jsx("button",{onClick:m,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(fx,{className:"w-3 h-3"})}),p&&h.jsx("button",{onClick:p,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(NS,{className:"w-3 h-3"})}),c&&h.jsx("button",{onClick:c,title:`Remove "${n.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Zt,{className:"w-3 h-3"})})]})]})}function FT({url:n}){var m;const e=E.useMemo(()=>zT(n),[n]),s={limit:1,staleTime:15e3},i=yv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&e.available}),o=pv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&!e.available});if(!e)return null;const c=e.available?i:o;return c.isError||((m=c.data)==null?void 0:m.total)===void 0?null:h.jsx("span",{className:"shrink-0 text-right text-2xs leading-none tabular-nums text-accent/80 relative -top-[0.35em]",title:`${c.data.total} matching now`,children:c.data.total})}function GT(){var c;const{data:n}=er(),e=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=e===!0||e!==!1&&Wx(),i=[{to:"/workflows/registry",label:"Registry",icon:Rg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd},{to:"/workflows/executions",label:"Executions",icon:Dg}],o=s?[{kind:"group",label:"Procedural",icon:TS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:am,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:Rg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:vd},{to:"/mcp/executions",label:"Executions",icon:Dg}]}]:i;return h.jsx(qr,{heading:"Orchestrate",entries:o})}function PM(){return qe({queryKey:["activeWorkers"],queryFn:async()=>(await ue("/workflows/workers")).workers})}function BM(){return qe({queryKey:["discoveredWorkflows"],queryFn:async()=>(await ue("/workflows/discovered")).workflows})}function UM(){return qe({queryKey:["workflowConfigs"],queryFn:async()=>(await ue("/workflows/config")).workflows})}function Hv(){return qe({queryKey:["invocableWorkflows"],queryFn:async()=>(await ue("/workflows/invocable")).workflows})}function zM(n){return Object.fromEntries(n.filter(e=>!e.missing).map(e=>[e.as??e.key,e.data]))}function IM(n,e){return qe({queryKey:["workflows",n,"input-lookups"],queryFn:()=>ue(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function $M(){return qe({queryKey:["cronStatus"],queryFn:async()=>(await ue("/workflows/cron/status")).schedules})}function HM(n){return qe({queryKey:["workflowExecution",n],queryFn:()=>ue(`/workflow-states/${n}/execution`),enabled:!!n})}function FM(n,e){const s=new URLSearchParams;return n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.entity&&s.set("entity",n.entity),n.search&&s.set("search",n.search),n.status&&s.set("status",n.status),n.sort_by&&s.set("sort_by",n.sort_by),n.order&&s.set("order",n.order),n.registered&&s.set("registered",n.registered),n.namespace&&s.set("namespace",n.namespace),qe({queryKey:["jobs",n],queryFn:()=>ue(`/workflow-states/jobs?${s}`),enabled:(e==null?void 0:e.enabled)??!0})}function GM(){const n=Pe();return $e({mutationFn:e=>ue(`/workflows/${e}/terminate`,{method:"POST"}),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function VM(){const n=Pe();return $e({mutationFn:({workflow_type:e,...s})=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function YM(){const n=Pe();return $e({mutationFn:e=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function KM(){const n=Pe();return $e({mutationFn:({workflowType:e,data:s,metadata:i,execute_as:o})=>ue(`/workflows/${e}/invoke`,{method:"POST",body:JSON.stringify({data:s,metadata:i,...o?{execute_as:o}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function VT(){const{data:n}=Hv();return n!=null&&n.length?h.jsx(qr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd}]}):null}const YT=[{to:"/mcp/queries",label:"Designer",icon:CS},{to:"/mcp/servers",label:"Servers & Tools",icon:MS}];function KT(){return h.jsx(qr,{heading:"Design",entries:YT})}const JT=[{to:"/files",label:"Files",icon:RS},{to:"/knowledge",label:"Knowledge Base",icon:hx}];function QT(){return h.jsx(qr,{heading:"Storage",entries:JT})}function XT({isBuilder:n=!1,isOps:e=!1}){var m;const{data:s}=er(),i=((m=s==null?void 0:s.features)==null?void 0:m.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:DS},...n||e?[{to:"/admin/roles",label:"Roles",icon:bd},{to:"/admin/personas",label:"Personas",icon:LS},{to:"/admin/scan-codes",label:"Scan Codes",icon:Mo}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:qS},{to:"/admin/streams",label:"Messages",icon:hx},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:PS}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(qr,{heading:"Identity & Access",entries:o}),n&&Zx()&&h.jsx(qr,{heading:"Infrastructure",entries:c})]})}function Fv({aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(TT,{aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o}),h.jsx($T,{}),!e&&h.jsx(VT,{}),e&&h.jsx(GT,{}),e&&n&&h.jsx(KT,{}),e&&h.jsx(QT,{}),(e||s)&&h.jsx(XT,{isBuilder:e,isOps:s})]})}function WT({open:n,onClose:e,...s}){const i=en();return E.useEffect(()=>{e()},[i.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${n?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:e,"aria-hidden":!0}),h.jsxs("div",{className:`relative w-72 max-w-[85vw] h-full bg-surface-raised border-r border-surface-border shadow-xl flex flex-col transition-transform duration-200 ease-out ${n?"translate-x-0":"-translate-x-full"}`,children:[h.jsx("div",{className:"flex items-center justify-end px-3 pt-3 shrink-0",children:h.jsx("button",{onClick:e,className:"p-1.5 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors","aria-label":"Close navigation",children:h.jsx(Zt,{className:"w-4 h-4"})})}),h.jsx("nav",{className:"flex-1 px-3 pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(ek,{children:h.jsx(Fv,{...s})})})]})]})}const Gv="lt_event_feed_patterns";function ZT(n,e){if(n.startsWith("/topics/")){const m=decodeURIComponent(n.replace("/topics/",""));if(m&&!m.includes("/"))return`lt.events.${m}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const m=new URLSearchParams(e).get("role");return m?`lt.events.system.escalation.${rv(m)}.>`:"lt.events.system.escalation.>"}const i=n.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(i)return`lt.events.system.workflow.${i[1]}.>`;if(n.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=n.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(n.startsWith("/agents"))return"lt.events.system.agent.>";if(n.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(n.startsWith("/files"))return"lt.events.system.file.>";if(n==="/")return"lt.events.system.>";const c=n.match(/^\/mcp\/executions\/(.+)/);return c?`lt.events.system.*.${c[1]}.>`:(n.startsWith("/mcp"),"lt.events.system.>")}function eC(){try{const n=localStorage.getItem(Gv);return n?JSON.parse(n):[]}catch{return[]}}function md(n){try{localStorage.setItem(Gv,JSON.stringify(n))}catch{}}function tC(){const{pathname:n,search:e}=en(),[s,i]=E.useState(eC),o=E.useMemo(()=>ZT(n,e),[n,e]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),m=E.useCallback(u=>{const d=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(d))return b;const x=[...b,d];return md(x),x})},[]),p=E.useCallback(u=>{i(d=>{const b=d.filter(x=>x!==u);return md(b),b})},[]),g=E.useCallback(()=>{i([]),md([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:m,removePattern:p,clearUserPatterns:g}}function nC({children:n,className:e=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${e}`,children:n})}const pd=280,Q1="cubic-bezier(0.4, 0, 0.2, 1)",Wc=40;function rC(n){if(!n)return"scale(0.92)";const e=window.innerWidth,s=window.innerHeight,i=e-Wc*2,o=s-Wc*2,c=n.width/i,m=n.height/o,p=n.left+n.width/2-(Wc+i/2),g=n.top+n.height/2-(Wc+o/2);return`translate(${p}px, ${g}px) scale(${c}, ${m})`}function Vv({open:n,onClose:e,sourceRef:s,children:i}){const[o,c]=E.useState(null),m=E.useRef(null),p=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!p.current?(m.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&p.current&&o==="open"&&(m.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),p.current=n},[n,s,o]),E.useEffect(()=>{if(o!=="entering")return;const x=requestAnimationFrame(()=>{requestAnimationFrame(()=>c("open"))});return()=>cancelAnimationFrame(x)},[o]),E.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),E.useEffect(()=>{if(!o)return;const x=v=>{v.key==="Escape"&&e()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,e]);const g=E.useCallback(x=>{x.propertyName==="transform"&&o==="exiting"&&c(null)},[o]);if(E.useEffect(()=>{if(o!=="exiting")return;const x=setTimeout(()=>c(null),pd+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",d=u?rC(m.current):"none",b=u?0:1;return sm.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${pd}ms ${Q1}, opacity ${pd}ms ${Q1}`,transform:d,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function sC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function iC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function aC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3"})})}function oC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function lC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9L3.5 3.5M9 15v4.5M9 15H4.5M9 15l-5.5 5.5M15 9h4.5M15 9V4.5M15 9l5.5-5.5M15 15h4.5M15 15v4.5m0-4.5l5.5 5.5"})})}function cC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}function uC(n){const e=n.trim().split(`
57
- `);if(e.length<2)return n;const s=p=>p.split("|").map(g=>g.trim()).filter(Boolean),i=s(e[0]),o=e.slice(2),c=i.map(p=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${p}</th>`).join(""),m=o.map(p=>`<tr class="border-t border-surface-border">${s(p).map(d=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${d}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${c}</tr></thead><tbody>${m}</tbody></table>`}function Zc(n){return n.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function fC(n){const e=[];let s=n.replace(/```(\w*)\n([\s\S]*?)```/g,(g,u,d)=>{const b=e.length;return e.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${d}</code></pre>`),`\0CODE${b}\0`});const i=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(i,(g,u,d,b)=>uC(`${u}
53
+ ${p.stack}`),m.reject(u)):m.resolve(d))}});return g.requestSubject=e,this.protocol.publish(e,s,{reply:c,headers:i.headers}),m}else{const c=new Sx(this.protocol.muxSubscriptions,e,i,o);this.protocol.request(c);try{this.publish(e,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(p){c.cancel(p)}const m=Promise.race([c.timer,c.deferred]);return m.catch(()=>{c.cancel()}),m}}flush(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(ge.errorForCode(fe.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Ut;return e.iterClosed.then(()=>{const s=this.listeners.indexOf(e);this.listeners.splice(s,1)}),this.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,i)=>s==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(e={}){const s=new V2(this,e);if(e.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===fe.NoResponders&&(o.code=fe.JetStreamNotEnabled),o}return s}jetstream(e={}){return new pm(this,e)}getServerVersion(){const e=this.info;return e?ti(e.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ge.errorForCode(fe.Disconnect);const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}get services(){return this._services||(this._services=new Q2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(ge.errorForCode(fe.ConnectionDraining)):this.protocol.reconnect()}}class Q2{constructor(e){j(this,"nc");this.nc=e}add(e){try{return new Do(this.nc,e).start()}catch(s){return Promise.reject(s)}}client(e,s){return new N2(this.nc,e,s)}}class X2{constructor(e,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=e,this.prefixLen=s,this.sm=i}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(gu)||"PUT"}get length(){const e=this.sm.header.get(Wt.MessageSizeHdr)||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class W2{constructor(e,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=e,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(um(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var e;return((e=this.sm.headers)==null?void 0:e.get(gu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const e=((s=this.sm.headers)==null?void 0:s.get(Wt.MessageSizeHdr))||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Rx extends IE{constructor(s,i,o){super(s.nc,i,o);j(this,"js");j(this,"monitor");this.js=s,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(s){this.sub.info=s}get info(){return this.sub.info}_resetOrderedConsumer(s){if(this.info===null||this.sub.isClosed())return;const i=Lr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=Os.next(),c.ordered_consumer_sequence.delivery_seq=0,c.flow_control.heartbeat_count=0,c.flow_control.fc_count=0,c.flow_control.consumer_restarts++,c.deliver=i,c.config.deliver_subject=i,c.config.deliver_policy=Et.StartSequence,c.config.opt_start_seq=s;const m={};m.stream_name=this.info.stream,m.config=c.config;const p=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(p,m,{retries:-1}).then(g=>{const u=g,d=this.sub.info;d.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new ge(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,fe.RequestError,g);this.sub.callback(u,{})})}_maybeSetupHbMonitoring(){var i,o;const s=((o=(i=this.info)==null?void 0:i.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(um(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,m=p=>{var d,b,x,v;const g=_E(409,`${In.IdleHeartbeatMissed}: ${p}`,this.sub.subject);if(!((d=this.info)==null?void 0:d.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const _=((x=(b=this.info)==null?void 0:b.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(_+1),(v=this.monitor)==null||v.restart(),!1}return!c.noIterator};this.monitor=new hm(s,m,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Wt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Wt.LastConsumerSeqHdr),10),c=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==c.delivery_seq&&this._resetOrderedConsumer(c.stream_seq+1),!1}_checkOrderedConsumer(s){const i=this.info.ordered_consumer_sequence,o=s.info.streamSequence,c=s.info.deliverySequence;return c!=i.delivery_seq+1?(this._resetOrderedConsumer(i.stream_seq+1),!1):(i.delivery_seq=c,i.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${i}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${i}`,c=await s.api._request(o);return s.last=c,c}}class Z2 extends Rx{constructor(e,s,i){super(e,s,i)}pull(e={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,m={};if(m.batch=e.batch||1,m.no_wait=e.no_wait||!1,(e.max_bytes??0)>0){const u=this.js.nc.features.get(Ye.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);m.max_bytes=e.max_bytes}let p=0;e.expires&&e.expires>0&&(p=e.expires,m.expires=dt(p));let g=0;if(e.idle_heartbeat&&e.idle_heartbeat>0&&(g=e.idle_heartbeat,m.idle_heartbeat=dt(g)),g&&p===0)throw new Error("idle_heartbeat requires expires");if(g>p)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),p&&g&&(this.monitor?this.monitor._change(g,p):this._setupHbMonitoring(g,p));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(d,u.jc.encode(m),{reply:b})}}}function eO(n,e){return n?nO(e):tO(e)}function tO(n){return(e,s)=>e?[e,null]:(e=Xi(s),e?[e,null]:[null,ko(s,n)])}function nO(n){return(e,s)=>{if(e)return[e,null];const i=Xi(s);return i!==null?[Dx(i),null]:[null,ko(s,n)]}}function Dx(n){if(n!==null)switch(n.code){case fe.JetStream404NoMessages:case fe.JetStream408RequestTimeout:return null;case fe.JetStream409:return wE(n)?n:null;default:return n}return null}function rO(n){n&&n.ack()}function sO(n){const e=n.split(".");if(e.length===9&&e.splice(2,0,"_",""),e.length<11||e[0]!=="$JS"||e[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=e[2]==="_"?"":e[2],s.account_hash=e[3],s.stream=e[4],s.consumer=e[5],s.deliveryCount=parseInt(e[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(e[7],10),s.deliverySequence=parseInt(e[8],10),s.timestampNanos=parseInt(e[9],10),s.pending=parseInt(e[10],10),s}class iO{constructor(e,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=e,this.didAck=!1,this.timeout=s}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=sO(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===so[0]&&e[1]===so[1]&&e[2]===so[2]&&e[3]===so[3]}async ackAck(e){var i;e=e||{},e.timeout=e.timeout||this.timeout;const s=mt();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,m=!((i=c.options)!=null&&i.noAsyncTraces),p=new Sx(c.muxSubscriptions,this.msg.reply,{timeout:e.timeout},m);c.request(p);try{c.publish(this.msg.reply,pb,{reply:`${c.muxSubscriptions.baseInbox}${p.token}`})}catch(g){p.cancel(g)}try{await Promise.race([p.timer,p.deferred]),s.resolve(!0)}catch(g){p.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(pb)}nak(e){let s=U2;e&&(s=Ed().encode(`-NAK ${JSON.stringify({delay:dt(e)})}`)),this.doAck(s)}working(){this.doAck(so)}next(e,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=dt(s.expires));const o=Zn().encode(i),c=sa.concat(z2,$2,o),m=e?{reply:e}:void 0;this.msg.respond(c,m)}term(e=""){let s=I2;(e==null?void 0:e.length)>0&&(s=Ed().encode(`+TERM ${e}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const aO="1.30.3",oO="nats.ws";class lO{constructor(){j(this,"version");j(this,"lang");j(this,"closeError");j(this,"connected");j(this,"done");j(this,"socket");j(this,"options");j(this,"socketClosed");j(this,"encrypted");j(this,"peeked");j(this,"yields");j(this,"signal");j(this,"closedNotification");this.version=aO,this.lang=oO,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=mt(),this.closedNotification=mt()}async connect(e,s){const i=mt();if(s.tls)return i.reject(new ge("tls",fe.InvalidOption)),i;this.options=s;const o=e.src;if(s.wsFactory){const{socket:c,encrypted:m}=await s.wsFactory(e.src,s);this.socket=c,this.encrypted=m}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=c=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(c.data)),this.peeked){this.signal.resolve();return}const m=sa.concat(...this.yields),p=YE(m);if(p!==""){const g=_2.exec(p);if(!g){s.debug&&console.error("!!!",ac(m)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);x2(u,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(u){i.reject(u);return}}},this.socket.onclose=c=>{if(this.isDiscarded())return;this.socketClosed=!0;let m;this.done||(c.wasClean||(m=new Error(c.reason)),this._closed(m))},this.socket.onerror=c=>{if(this.isDiscarded())return;const m=c,p=new ge(m.message,fe.Unknown,new Error(m.error));i.reject(p)},i}disconnect(){this._closed(void 0,!0)}async _closed(e,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await ia(100);this.done=!0;try{this.socket.close(e?1002:1e3,e?e.message:void 0)}catch{}s&&this.closedNotification.resolve(e)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let s=0;s<e.length;s++)this.options.debug&&console.info(`> ${ac(e[s])}`),yield e[s];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=mt())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.isDiscarded())try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${ac(e)}`);return}catch(s){this.options.debug&&console.error(`!!! ${ac(e)}: ${s}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var e;this.done=!0;try{(e=this.socket)==null||e.close()}catch{}}}function cO(n,e){/^(.*:\/\/)(.*)/.test(n)||(typeof e=="boolean"?n=`${e===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(e=!1),o==="wss:"&&(e=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,m;const p=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":m=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":m=i.port||"443",c="wss:";break;default:m=i.port||e===!0?"443":"80",c=e===!0?"wss:":"ws:";break}return`${c}//${p}:${m}${g}${u}`}function uO(n={}){return $E({defaultPort:443,urlParseFn:cO,factory:()=>new lO}),ym.connect(n)}const fO=null,hO=null,Xt="lt.events";function Lx(n,e){const s=n.split("."),i=e.split(".");for(let o=0;o<i.length;o++){const c=i[o];if(c===">")return!0;if(o>=s.length||c!=="*"&&c!==s[o])return!1}return s.length===i.length}const aa=E.createContext({connected:!1,subscribe:()=>()=>{}});function qx(){const{connected:n}=E.useContext(aa);return{connected:n}}function An(n,e){const{subscribe:s}=E.useContext(aa),i=E.useRef(e);i.current=e,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function js(n,e){const{subscribe:s}=E.useContext(aa),i=E.useRef(e);i.current=e;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const m=g=>i.current(g),p=c.map(g=>s(g,m));return()=>p.forEach(g=>g())},[s,c])}const Px=E.createContext({connected:!1,unavailable:!1,subscribe:()=>()=>{}});function dO(){const{connected:n,unavailable:e}=E.useContext(Px);return{connected:n,unavailable:e}}const mO=Ed();function pO({children:n,url:e,token:s,resolveCredentials:i,policy:o=yo,onReconnect:c,sessionKey:m}){const p=E.useRef(null),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(!1),_=E.useRef({url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c});_.current={url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c};const S=E.useRef(new Map),C=E.useRef(new Map),P=E.useCallback((te,M)=>{(async()=>{for await(const U of M)try{if(!Lx(U.subject,te))continue;const ae=JSON.parse(mO.decode(U.data)),z=S.current.get(te);if(!z)continue;for(const I of z)try{I(ae)}catch{}}catch{}})()},[]),q=E.useCallback(te=>{var U;const M=p.current;if(!(!M||(U=M.isClosed)!=null&&U.call(M)||C.current.has(te)))try{const ae=M.subscribe(te);C.current.set(te,ae),P(te,ae)}catch{}},[P]),ne=E.useCallback((te,M)=>{const U=S.current;return U.has(te)||U.set(te,new Set),U.get(te).add(M),q(te),()=>{const ae=U.get(te);if(ae&&(ae.delete(M),ae.size===0)){U.delete(te);const z=C.current.get(te);if(z){C.current.delete(te);try{z.unsubscribe()}catch{}}}}},[q]);return E.useEffect(()=>{let te=!1,M=!1,U=!1,ae=!1,z=0,I,D;v(!1);const X=()=>typeof document<"u"&&document.visibilityState==="hidden",W=async()=>{const{url:J,token:le,resolveCredentials:pe}=_.current;if(pe)return pe();const ye=J||fO;return ye?{kind:"ok",url:ye,token:le||hO||null}:{kind:"unavailable"}},he=(J=uE(z++,_.current.policy))=>{te||M||(I=setTimeout(Oe,J))},we=J=>{J.closed().then(()=>{p.current===J&&(p.current=null,C.current.clear(),u(!1),he(Gg(_.current.policy)))})};async function Oe(){if(I=void 0,!(te||M||U||p.current)&&!X()){U=!0;try{const J=await W();if(te)return;if(J.kind==="session-ended"){M=!0,v(!0);return}if(J.kind==="unavailable"){he();return}const le=await uO({servers:J.url,token:J.token??void 0,reconnect:!1});if(te){le.close().catch(()=>{});return}p.current=le,z=0,u(!0),C.current.clear();for(const pe of S.current.keys())q(pe);ae&&(D=setTimeout(()=>{var pe,ye;return(ye=(pe=_.current).onReconnect)==null?void 0:ye.call(pe)},Gg(_.current.policy))),ae=!0,we(le)}catch{te||he()}finally{U=!1}}}const F=()=>{te||M||U||p.current||X()||(I&&clearTimeout(I),z=0,Oe())};return document.addEventListener("visibilitychange",F),window.addEventListener("online",F),Oe(),()=>{te=!0,I&&clearTimeout(I),D&&clearTimeout(D),document.removeEventListener("visibilitychange",F),window.removeEventListener("online",F);for(const J of C.current.values())try{J.unsubscribe()}catch{}C.current.clear(),p.current&&(p.current.close().catch(()=>{}),p.current=null),u(!1)}},[q,m]),E.useEffect(()=>{if(g||x){b(!1);return}const te=setTimeout(()=>b(!0),o.noticeAfterMs);return()=>clearTimeout(te)},[g,x,o.noticeAfterMs]),h.jsx(Px.Provider,{value:{connected:g,unavailable:d,subscribe:ne},children:h.jsx(aa.Provider,{value:{connected:g,subscribe:ne},children:n})})}const ur=Object.create(null);ur.open="0";ur.close="1";ur.ping="2";ur.pong="3";ur.message="4";ur.upgrade="5";ur.noop="6";const iu=Object.create(null);Object.keys(ur).forEach(n=>{iu[ur[n]]=n});const Bd={type:"error",data:"parser error"},Bx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ux=typeof ArrayBuffer=="function",zx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,gm=({type:n,data:e},s,i)=>Bx&&e instanceof Blob?s?i(e):gb(e,i):Ux&&(e instanceof ArrayBuffer||zx(e))?s?i(e):gb(new Blob([e]),i):i(ur[n]+(e||"")),gb=(n,e)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];e("b"+(i||""))},s.readAsDataURL(n)};function bb(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let ad;function yO(n,e){if(Bx&&n.data instanceof Blob)return n.data.arrayBuffer().then(bb).then(e);if(Ux&&(n.data instanceof ArrayBuffer||zx(n.data)))return e(bb(n.data));gm(n,!1,s=>{ad||(ad=new TextEncoder),e(ad.encode(s))})}const xb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<xb.length;n++)xo[xb.charCodeAt(n)]=n;const gO=n=>{let e=n.length*.75,s=n.length,i,o=0,c,m,p,g;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const u=new ArrayBuffer(e),d=new Uint8Array(u);for(i=0;i<s;i+=4)c=xo[n.charCodeAt(i)],m=xo[n.charCodeAt(i+1)],p=xo[n.charCodeAt(i+2)],g=xo[n.charCodeAt(i+3)],d[o++]=c<<2|m>>4,d[o++]=(m&15)<<4|p>>2,d[o++]=(p&3)<<6|g&63;return u},bO=typeof ArrayBuffer=="function",bm=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ix(n,e)};const s=n.charAt(0);return s==="b"?{type:"message",data:xO(n.substring(1),e)}:iu[s]?n.length>1?{type:iu[s],data:n.substring(1)}:{type:iu[s]}:Bd},xO=(n,e)=>{if(bO){const s=gO(n);return Ix(s,e)}else return{base64:!0,data:n}},Ix=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},$x="",vO=(n,e)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,m)=>{gm(c,!1,p=>{i[m]=p,++o===s&&e(i.join($x))})})},_O=(n,e)=>{const s=n.split($x),i=[];for(let o=0;o<s.length;o++){const c=bm(s[o],e);if(i.push(c),c.type==="error")break}return i};function wO(){return new TransformStream({transform(n,e){yO(n,s=>{const i=s.length;let o;if(i<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,i);else if(i<65536){o=new Uint8Array(3);const c=new DataView(o.buffer);c.setUint8(0,126),c.setUint16(1,i)}else{o=new Uint8Array(9);const c=new DataView(o.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(o[0]|=128),e.enqueue(o),e.enqueue(s)})}})}let od;function uc(n){return n.reduce((e,s)=>e+s.length,0)}function fc(n,e){if(n[0].length===e)return n.shift();const s=new Uint8Array(e);let i=0;for(let o=0;o<e;o++)s[o]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),s}function SO(n,e){od||(od=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(m,p){for(s.push(m);;){if(i===0){if(uc(s)<1)break;const g=fc(s,1);c=(g[0]&128)===128,o=g[0]&127,o<126?i=3:o===126?i=1:i=2}else if(i===1){if(uc(s)<2)break;const g=fc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(uc(s)<8)break;const g=fc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){p.enqueue(Bd);break}o=d*Math.pow(2,32)+u.getUint32(4),i=3}else{if(uc(s)<o)break;const g=fc(s,o);p.enqueue(bm(c?g:od.decode(g),e)),i=0}if(o===0||o>n){p.enqueue(Bd);break}}}})}const Hx=4;function Tt(n){if(n)return EO(n)}function EO(n){for(var e in Tt.prototype)n[e]=Tt.prototype[e];return n}Tt.prototype.on=Tt.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};Tt.prototype.once=function(n,e){function s(){this.off(n,s),e.apply(this,arguments)}return s.fn=e,this.on(n,s),this};Tt.prototype.off=Tt.prototype.removeListener=Tt.prototype.removeAllListeners=Tt.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,o=0;o<s.length;o++)if(i=s[o],i===e||i.fn===e){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};Tt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,e)}return this};Tt.prototype.emitReserved=Tt.prototype.emit;Tt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Tt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Nu=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,s)=>s(e,0),$n=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),OO="arraybuffer";function Fx(n,...e){return e.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const AO=$n.setTimeout,jO=$n.clearTimeout;function Tu(n,e){e.useNativeTimers?(n.setTimeoutFn=AO.bind($n),n.clearTimeoutFn=jO.bind($n)):(n.setTimeoutFn=$n.setTimeout.bind($n),n.clearTimeoutFn=$n.clearTimeout.bind($n))}const kO=1.33;function NO(n){return typeof n=="string"?TO(n):Math.ceil((n.byteLength||n.size)*kO)}function TO(n){let e=0,s=0;for(let i=0,o=n.length;i<o;i++)e=n.charCodeAt(i),e<128?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(i++,s+=4);return s}function Gx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function CO(n){let e="";for(let s in n)n.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return e}function MO(n){let e={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");e[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return e}class RO extends Error{constructor(e,s,i){super(e),this.description=s,this.context=i,this.type="TransportError"}}class xm extends Tt{constructor(e){super(),this.writable=!1,Tu(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,s,i){return super.emitReserved("error",new RO(e,s,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const s=bm(e,this.socket.binaryType);this.onPacket(s)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,s={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const s=CO(e);return s.length?"?"+s:""}}class DO extends xm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const s=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||s()})),this.writable||(i++,this.once("drain",function(){--i||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const s=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};_O(e,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,vO(e,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Gx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(e,s)}}let Vx=!1;try{Vx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const LO=Vx;function qO(){}class PO extends DO{constructor(e){if(super(e),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,s){const i=this.request({method:"POST",data:e});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=e}}class cr extends Tt{constructor(e,s,i){super(),this.createRequest=e,Tu(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var e;const s=Fx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&i.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var o;i.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=cr.requestsCount++,cr.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=qO,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete cr.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}cr.requestsCount=0;cr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",vb);else if(typeof addEventListener=="function"){const n="onpagehide"in $n?"pagehide":"unload";addEventListener(n,vb,!1)}}function vb(){for(let n in cr.requests)cr.requests.hasOwnProperty(n)&&cr.requests[n].abort()}const BO=(function(){const n=Yx({xdomain:!1});return n&&n.responseType!==null})();class UO extends PO{constructor(e){super(e);const s=e&&e.forceBase64;this.supportsBinary=BO&&!s}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new cr(Yx,this.uri(),e)}}function Yx(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||LO))return new XMLHttpRequest}catch{}if(!e)try{return new $n[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Kx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class zO extends xm{get name(){return"websocket"}doOpen(){const e=this.uri(),s=this.opts.protocols,i=Kx?{}:Fx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,s,i)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;gm(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Gx()),this.supportsBinary||(s.b64=1),this.createUri(e,s)}}const ld=$n.WebSocket||$n.MozWebSocket;class IO extends zO{createSocket(e,s,i){return Kx?new ld(e,s,i):s?new ld(e,s):new ld(e)}doWrite(e,s){this.ws.send(s)}}class $O extends xm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const s=SO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(s).getReader(),o=wO();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:p,value:g})=>{p||(this.onPacket(g),c())}).catch(p=>{})};c();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;this._writer.write(i).then(()=>{o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const HO={websocket:IO,webtransport:$O,polling:UO},FO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,GO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ud(n){if(n.length>8e3)throw"URI too long";const e=n,s=n.indexOf("["),i=n.indexOf("]");s!=-1&&i!=-1&&(n=n.substring(0,s)+n.substring(s,i).replace(/:/g,";")+n.substring(i,n.length));let o=FO.exec(n||""),c={},m=14;for(;m--;)c[GO[m]]=o[m]||"";return s!=-1&&i!=-1&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=VO(c,c.path),c.queryKey=YO(c,c.query),c}function VO(n,e){const s=/\/{2,9}/g,i=e.replace(s,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function YO(n,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const zd=typeof addEventListener=="function"&&typeof removeEventListener=="function",au=[];zd&&addEventListener("offline",()=>{au.forEach(n=>n())},!1);class Ss extends Tt{constructor(e,s){if(super(),this.binaryType=OO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(s=e,e=null),e){const i=Ud(e);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=Ud(s.host).host);Tu(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(i=>{const o=i.prototype.name;this.transports.push(o),this._transportsByName[o]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=MO(this.opts.query)),zd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},au.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const s=Object.assign({},this.opts.query);s.EIO=Hx,s.transport=e,this.id&&(s.sid=this.id);const i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Ss.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(e);s.open(),this.setTransport(s)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",Ss.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const s=new Error("server error");s.code=e.data,this._onError(s);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){const o=this.writeBuffer[i].data;if(o&&(s+=NO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Nu(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,s,i){return this._sendPacket("message",e,s,i),this}send(e,s,i){return this._sendPacket("message",e,s,i),this}_sendPacket(e,s,i,o){if(typeof s=="function"&&(o=s,s=void 0),typeof i=="function"&&(o=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const c={type:e,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),e()},i=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(Ss.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),zd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=au.indexOf(this._offlineEventListener);i!==-1&&au.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,s),this.writeBuffer=[],this._prevBufferLen=0}}}Ss.protocol=Hx;class KO extends Ss{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let s=this.createTransport(e),i=!1;Ss.priorWebsocketSuccess=!1;const o=()=>{i||(s.send([{type:"ping",data:"probe"}]),s.once("packet",b=>{if(!i)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Ss.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(d(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=s.name,this.emitReserved("upgradeError",x)}}))};function c(){i||(i=!0,d(),s.close(),s=null)}const m=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function p(){m("transport closed")}function g(){m("socket closed")}function u(b){s&&b.name!==s.name&&c()}const d=()=>{s.removeListener("open",o),s.removeListener("error",m),s.removeListener("close",p),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",m),s.once("close",p),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const s=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&s.push(e[i]);return s}}let JO=class extends KO{constructor(e,s={}){const i=typeof e=="object"?e:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>HO[o]).filter(o=>!!o)),super(e,i)}};function QO(n,e="",s){let i=n;s=s||typeof location<"u"&&location,n==null&&(n=s.protocol+"//"+s.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=s.protocol+n:n=s.host+n),/^(https?|wss?):\/\//.test(n)||(typeof s<"u"?n=s.protocol+"//"+n:n="https://"+n),i=Ud(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const c=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+c+":"+i.port+e,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const XO=typeof ArrayBuffer=="function",WO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Jx=Object.prototype.toString,ZO=typeof Blob=="function"||typeof Blob<"u"&&Jx.call(Blob)==="[object BlobConstructor]",eA=typeof File=="function"||typeof File<"u"&&Jx.call(File)==="[object FileConstructor]";function vm(n){return XO&&(n instanceof ArrayBuffer||WO(n))||ZO&&n instanceof Blob||eA&&n instanceof File}function ou(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(ou(n[s]))return!0;return!1}if(vm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return ou(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&ou(n[s]))return!0;return!1}function tA(n){const e=[],s=n.data,i=n;return i.data=Id(s,e),i.attachments=e.length,{packet:i,buffers:e}}function Id(n,e){if(!n)return n;if(vm(n)){const s={_placeholder:!0,num:e.length};return e.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Id(n[i],e);return s}else if(typeof n=="object"&&!(n instanceof Date)){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=Id(n[i],e));return s}return n}function nA(n,e){return n.data=$d(n.data,e),delete n.attachments,n}function $d(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=$d(n[s],e);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=$d(n[s],e));return n}const rA=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ve;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ve||(Ve={}));class sA{constructor(e){this.replacer=e}encode(e){return(e.type===Ve.EVENT||e.type===Ve.ACK)&&ou(e)?this.encodeAsBinary({type:e.type===Ve.EVENT?Ve.BINARY_EVENT:Ve.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let s=""+e.type;return(e.type===Ve.BINARY_EVENT||e.type===Ve.BINARY_ACK)&&(s+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(s+=e.nsp+","),e.id!=null&&(s+=e.id),e.data!=null&&(s+=JSON.stringify(e.data,this.replacer)),s}encodeAsBinary(e){const s=tA(e),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class _m extends Tt{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let s;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(e);const i=s.type===Ve.BINARY_EVENT;i||s.type===Ve.BINARY_ACK?(s.type=i?Ve.EVENT:Ve.ACK,this.reconstructor=new iA(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(vm(e)||e.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(e),s&&(this.reconstructor=null,super.emitReserved("decoded",s));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let s=0;const i={type:Number(e.charAt(0))};if(Ve[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Ve.BINARY_EVENT||i.type===Ve.BINARY_ACK){const c=s+1;for(;e.charAt(++s)!=="-"&&s!=e.length;);const m=e.substring(c,s);if(m!=Number(m)||e.charAt(s)!=="-")throw new Error("Illegal attachments");const p=Number(m);if(!aA(p)||p<0)throw new Error("Illegal attachments");if(p>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=p}if(e.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(e.charAt(s)===","||s===e.length););i.nsp=e.substring(c,s)}else i.nsp="/";const o=e.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const m=e.charAt(s);if(m==null||Number(m)!=m){--s;break}if(s===e.length)break}i.id=Number(e.substring(c,s+1))}if(e.charAt(++s)){const c=this.tryParse(e.substr(s));if(_m.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,s){switch(e){case Ve.CONNECT:return _b(s);case Ve.DISCONNECT:return s===void 0;case Ve.CONNECT_ERROR:return typeof s=="string"||_b(s);case Ve.EVENT:case Ve.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&rA.indexOf(s[0])===-1);case Ve.ACK:case Ve.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class iA{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const s=nA(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const aA=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function _b(n){return Object.prototype.toString.call(n)==="[object Object]"}const oA=Object.freeze(Object.defineProperty({__proto__:null,Decoder:_m,Encoder:sA,get PacketType(){return Ve}},Symbol.toStringTag,{value:"Module"}));function Xn(n,e,s){return n.on(e,s),function(){n.off(e,s)}}const lA=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Qx extends Tt{constructor(e,s,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Xn(e,"open",this.onopen.bind(this)),Xn(e,"packet",this.onpacket.bind(this)),Xn(e,"error",this.onerror.bind(this)),Xn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...s){var i,o,c;if(lA.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(s.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const m={type:Ve.EVENT,data:s};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const d=this.ids++,b=s.pop();this._registerAckCallback(d,b),m.id=d}const p=(o=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!p||(g?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(e,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[e]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===e&&this.sendBuffer.splice(p,1);s.call(this,new Error("operation has timed out"))},o),m=(...p)=>{this.io.clearTimeoutFn(c),s.apply(this,p)};m.withError=!0,this.acks[e]=m}emitWithAck(e,...s){return new Promise((i,o)=>{const c=(m,p)=>m?o(m):i(p);c.withError=!0,s.push(c),this.emit(e,...s)})}_addToQueue(e){let s;typeof e[e.length-1]=="function"&&(s=e.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...c)=>(this._queue[0],o!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!e||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Ve.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(i=>String(i.id)===e)){const i=this.acks[e];delete this.acks[e],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Ve.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ve.EVENT:case Ve.BINARY_EVENT:this.onevent(e);break;case Ve.ACK:case Ve.BINARY_ACK:this.onack(e);break;case Ve.DISCONNECT:this.ondisconnect();break;case Ve.CONNECT_ERROR:this.destroy();const i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){const s=e.data||[];e.id!=null&&s.push(this.ack(e.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:Ve.ACK,id:e,data:o}))}}onack(e){const s=this.acks[e.id];typeof s=="function"&&(delete this.acks[e.id],s.withError&&e.data.unshift(null),s.apply(this,e.data))}onconnect(e,s){this.id=e,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ve.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,e.data)}}}function oa(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}oa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};oa.prototype.reset=function(){this.attempts=0};oa.prototype.setMin=function(n){this.ms=n};oa.prototype.setMax=function(n){this.max=n};oa.prototype.setJitter=function(n){this.jitter=n};class Hd extends Tt{constructor(e,s){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(s=e,e=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,Tu(this,s),this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor((i=s.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new oa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=e;const o=s.parser||oA;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var s;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(s=this.backoff)===null||s===void 0||s.setMin(e),this)}randomizationFactor(e){var s;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(s=this.backoff)===null||s===void 0||s.setJitter(e),this)}reconnectionDelayMax(e){var s;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(s=this.backoff)===null||s===void 0||s.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new JO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Xn(s,"open",function(){i.onopen(),e&&e()}),c=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),e?e(p):this.maybeReconnectOnOpen()},m=Xn(s,"error",c);if(this._timeout!==!1){const p=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},p);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(m),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Xn(e,"ping",this.onping.bind(this)),Xn(e,"data",this.ondata.bind(this)),Xn(e,"error",this.onerror.bind(this)),Xn(e,"close",this.onclose.bind(this)),Xn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(s){this.onclose("parse error",s)}}ondecoded(e){Nu(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,s){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new Qx(this,e,s),this.nsps[e]=i),i}_destroy(e){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(e){const s=this.encoder.encode(e);for(let i=0;i<s.length;i++)this.engine.write(s[i],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const s=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const io={};function lu(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const s=QO(n,e.path||"/socket.io"),i=s.source,o=s.id,c=s.path,m=io[o]&&c in io[o].nsps,p=e.forceNew||e["force new connection"]||e.multiplex===!1||m;let g;return p?g=new Hd(i,e):(io[o]||(io[o]=new Hd(i,e)),g=io[o]),s.query&&!e.query&&(e.query=s.queryKey),g.socket(s.path,e)}Object.assign(lu,{Manager:Hd,Socket:Qx,io:lu,connect:lu});const cA=E.createContext({connected:!1,subscribe:()=>()=>{}});function uA({children:n}){const{isAuthenticated:e}=qt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),m=E.useCallback((g,u)=>{var b;const d=c.current;return d.has(g)||(d.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),d.get(g).add(u),()=>{var v;const x=d.get(g);x&&(x.delete(u),x.size===0&&(d.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),p=E.useCallback((g,u)=>{for(const[d,b]of c.current)if(Lx(g,d))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!e)return;const g=lu({path:`${Vt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const d=wd();u(d?{token:d}:{})}});return s.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),o(!0);for(const u of c.current.keys())g.emit("lt.subscribe",u)}),g.on("disconnect",u=>{console.log("[lt-socketio] disconnected:",u),o(!1)}),g.on("connect_error",u=>{console.warn("[lt-socketio] connect error:",u.message),o(!1)}),g.onAny((u,d)=>{if(u.startsWith("lt."))try{const b=typeof d=="string"?JSON.parse(d):d;p(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[p,e]),h.jsx(cA.Provider,{value:{connected:i,subscribe:m},children:h.jsx(aa.Provider,{value:{connected:i,subscribe:m},children:n})})}function fA({children:n}){const{isAuthenticated:e}=qt(),s=Pe(),[i,o]=E.useState(null),[c,m]=E.useState({url:null,policy:Vg(null)});E.useEffect(()=>{let u=!1;async function d(){var b;try{console.log("[lt-transport] detecting event transport...");const x=await lm(),v=(b=x==null?void 0:x.events)==null?void 0:b.transport;console.log("[lt-transport] server reports:",v),u||(v==="nats"&&m({url:x.events.natsWsUrl??null,policy:Vg(x.events.reconnect)}),o(v==="nats"?"nats":"socketio"))}catch(x){console.warn("[lt-transport] settings fetch error, falling back to socketio",x),u||o("socketio")}}return d(),()=>{u=!0}},[e]);const p=E.useCallback(()=>cE(c.url),[c.url]),g=E.useCallback(()=>{s.invalidateQueries({refetchType:"active"})},[s]);return i==="nats"?h.jsx(pO,{resolveCredentials:p,policy:c.policy,onReconnect:g,sessionKey:e,children:n}):i==="socketio"?h.jsx(uA,{children:n}):h.jsx(h.Fragment,{children:n})}const wm="lt_view_as",Sm="lt_ai_override",Fd="lt_graph_enabled",Gd="lt_infrastructure_enabled",Em="lt_scan_override";function Xx(){try{const n=localStorage.getItem(Sm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function hA(n){try{localStorage.setItem(Sm,String(n))}catch{}}function dA(){try{localStorage.removeItem(Sm)}catch{}}function Om(){try{const n=localStorage.getItem(wm);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function mA(n){try{localStorage.setItem(wm,n)}catch{}window.location.reload()}function Vd(){try{localStorage.removeItem(wm)}catch{}window.location.reload()}function Wx(){try{return localStorage.getItem(Fd)==="true"}catch{return!1}}function pA(n){try{n?localStorage.setItem(Fd,"true"):localStorage.removeItem(Fd)}catch{}}function Zx(){try{return localStorage.getItem(Gd)==="true"}catch{return!1}}function yA(n){try{n?localStorage.setItem(Gd,"true"):localStorage.removeItem(Gd)}catch{}}function ev(){try{const n=localStorage.getItem(Em);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function gA(n){try{localStorage.setItem(Em,String(n))}catch{}}function bA(){try{localStorage.removeItem(Em)}catch{}}function tv(){const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=qt(),i=Om(),o=n||s("engineer"),c=e("admin"),m=n||e("admin");return{isBuilder:i?!1:o,isOps:i?i==="admin"||i==="engineer":c,canBulk:i?i==="admin":m,viewAs:i,realIsBuilder:o}}function nv(){var u;const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=qt(),{data:i}=er(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":e("admin")?"admin":s("engineer")?"engineer":"operator",m=Om(),p=m==="admin"||m==="engineer"||m==="operator"?m:null,g=p??c;return{tier:g,realTier:c,viewAs:p,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}const Am=E.createContext(null);function Cu(){const n=E.useContext(Am);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function xA(){var n;return((n=E.useContext(Am))==null?void 0:n.identity)??null}function vA({children:n}){const[e,s]=E.useState(null),i=E.useRef(e);i.current=e,E.useEffect(()=>{if(!(e!=null&&e.expiresAt))return;const d=new Date(e.expiresAt).getTime()-Date.now();if(d<=0){s(null);return}const b=setTimeout(()=>s(null),d);return()=>clearTimeout(b)},[e]);const o=E.useCallback(d=>{var x;if(!d.actingToken||!d.actor)return null;const b=((x=i.current)==null?void 0:x.actingToken)??null;return s({actingToken:d.actingToken,actorId:d.actor.id,displayName:d.actor.displayName,expiresAt:d.expiresAt??null,subjectScoped:d.grantScope==="subject"}),b},[]),c=E.useCallback(()=>s(null),[]),m=E.useCallback((d,b)=>{const x=i.current;b===0&&(x==null?void 0:x.actingToken)===d&&s(null)},[]),p=E.useCallback((d,b)=>{const x=i.current;if(!x||x.actingToken!==d||!b.acting)return;const{consumed:v,remaining:_,bound:S}=b.acting;(v&&_===0||S&&b.clearSubject)&&s(null)},[]);E.useEffect(()=>(Ig(()=>{var d;return((d=i.current)==null?void 0:d.actingToken)??null}),Hg(c),$g(m),()=>{Ig(null),Hg(null),$g(null)}),[c,m]);const g=E.useCallback(()=>{var b;const d=(b=i.current)==null?void 0:b.expiresAt;return d?Math.max(0,Math.floor((new Date(d).getTime()-Date.now())/1e3)):0},[]),u=E.useMemo(()=>({identity:e,prime:o,clear:c,settle:p,remainingSeconds:g}),[e,o,c,p,g]);return h.jsx(Am.Provider,{value:u,children:n})}function _A(){const{user:n}=qt(),{identity:e}=Cu(),s=n==null?void 0:n.userId,i=e==null?void 0:e.actorId,o=E.useCallback(c=>!!c&&(c===i||c===s),[i,s]);return{viewerId:i??s,isViewer:o}}function rv(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function fr(n={}){const e=n.role?rv(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Xt}.system.escalation.${e}.${s}.${i}`}function Yd(n){return n.verbs.map(e=>fr({role:n.role,verb:e}))}function jm(n){const{user:e,isSuperAdmin:s,hasRoleType:i}=qt(),o=s||i("admin"),c=((e==null?void 0:e.roles)??[]).map(p=>p.role).sort().join(","),m=(n??[]).join(",");return E.useMemo(()=>{const p=m?m.split(","):null;return o||!c?p?Yd({verbs:p}):[fr({})]:c.split(",").flatMap(g=>p?Yd({role:g,verbs:p}):[fr({role:g})])},[o,c,m])}const Kd="/escalations/detail/";function wA(n){return n.startsWith(Kd)&&n.slice(Kd.length).split("/")[0]||void 0}function SA(){const{isViewer:n}=_A(),e=ni(),s=en(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n);o.current=n;const c=E.useCallback(m=>{var b,x,v;if((m==null?void 0:m.assignedAtCreation)!==!0)return;const p=(m==null?void 0:m.escalationId)??((b=m==null?void 0:m.data)==null?void 0:b.id),g=(x=m==null?void 0:m.data)==null?void 0:x.assigned_to,u=(v=m==null?void 0:m.data)==null?void 0:v.parent_id;if(!p||!o.current(g)||!u||u!==wA(i.current))return;const d=`${Kd}${p}`;i.current!==d&&e(d)},[e]);js(jm(["claimed"]),c)}const sv=6048e5,EA=864e5,wb=6e4,Sb=525600,Eb=43200,Ob=1440,Ab=Symbol.for("constructDateFrom");function Br(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&Ab in n?n[Ab](e):n instanceof Date?new n.constructor(e):new Date(e)}function kn(n,e){return Br(e||n,n)}let OA={};function Lo(){return OA}function No(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.weekStartsOn)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=kn(n,e==null?void 0:e.in),c=o.getDay(),m=(c<i?7:0)+c-i;return o.setDate(o.getDate()-m),o.setHours(0,0,0,0),o}function bu(n,e){return No(n,{...e,weekStartsOn:1})}function iv(n,e){const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),m=Br(s,0);m.setFullYear(i,0,4),m.setHours(0,0,0,0);const p=bu(m);return s.getTime()>=c.getTime()?i+1:s.getTime()>=p.getTime()?i:i-1}function xu(n){const e=kn(n),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+n-+s}function av(n,...e){const s=Br.bind(null,n||e.find(i=>typeof i=="object"));return e.map(s)}function jb(n,e){const s=kn(n,e==null?void 0:e.in);return s.setHours(0,0,0,0),s}function AA(n,e,s){const[i,o]=av(s==null?void 0:s.in,n,e),c=jb(i),m=jb(o),p=+c-xu(c),g=+m-xu(m);return Math.round((p-g)/EA)}function jA(n,e){const s=iv(n,e),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function kA(n,e){const s=+kn(n)-+kn(e);return s<0?-1:s>0?1:s}function NA(n){return Br(n,Date.now())}function TA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function CA(n){return!(!TA(n)&&typeof n!="number"||isNaN(+kn(n)))}function MA(n){return e=>{const i=(n?Math[n]:Math.trunc)(e);return i===0?0:i}}function RA(n,e){const s=kn(n,e==null?void 0:e.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const DA={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},LA=(n,e,s)=>{let i;const o=DA[n];return typeof o=="string"?i=o:e===1?i=o.one:i=o.other.replace("{{count}}",e.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function cd(n){return(e={})=>{const s=e.width?String(e.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const qA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},PA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},BA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},UA={date:cd({formats:qA,defaultWidth:"full"}),time:cd({formats:PA,defaultWidth:"full"}),dateTime:cd({formats:BA,defaultWidth:"full"})},zA={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},IA=(n,e,s,i)=>zA[n];function ao(n){return(e,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const m=n.defaultFormattingWidth||n.defaultWidth,p=s!=null&&s.width?String(s.width):m;o=n.formattingValues[p]||n.formattingValues[m]}else{const m=n.defaultWidth,p=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[p]||n.values[m]}const c=n.argumentCallback?n.argumentCallback(e):e;return o[c]}}const $A={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},HA={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},FA={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},GA={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},VA={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},YA={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},KA=(n,e)=>{const s=Number(n),i=s%100;if(i>20||i<10)switch(i%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},JA={ordinalNumber:KA,era:ao({values:$A,defaultWidth:"wide"}),quarter:ao({values:HA,defaultWidth:"wide",argumentCallback:n=>n-1}),month:ao({values:FA,defaultWidth:"wide"}),day:ao({values:GA,defaultWidth:"wide"}),dayPeriod:ao({values:VA,defaultWidth:"wide",formattingValues:YA,defaultFormattingWidth:"wide"})};function oo(n){return(e,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=e.match(o);if(!c)return null;const m=c[0],p=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(p)?XA(p,b=>b.test(m)):QA(p,b=>b.test(m));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const d=e.slice(m.length);return{value:u,rest:d}}}function QA(n,e){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&e(n[s]))return s}function XA(n,e){for(let s=0;s<n.length;s++)if(e(n[s]))return s}function WA(n){return(e,s={})=>{const i=e.match(n.matchPattern);if(!i)return null;const o=i[0],c=e.match(n.parsePattern);if(!c)return null;let m=n.valueCallback?n.valueCallback(c[0]):c[0];m=s.valueCallback?s.valueCallback(m):m;const p=e.slice(o.length);return{value:m,rest:p}}}const ZA=/^(\d+)(th|st|nd|rd)?/i,ej=/\d+/i,tj={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},nj={any:[/^b/i,/^(a|c)/i]},rj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},sj={any:[/1/i,/2/i,/3/i,/4/i]},ij={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},aj={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},oj={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},lj={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},cj={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},uj={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},fj={ordinalNumber:WA({matchPattern:ZA,parsePattern:ej,valueCallback:n=>parseInt(n,10)}),era:oo({matchPatterns:tj,defaultMatchWidth:"wide",parsePatterns:nj,defaultParseWidth:"any"}),quarter:oo({matchPatterns:rj,defaultMatchWidth:"wide",parsePatterns:sj,defaultParseWidth:"any",valueCallback:n=>n+1}),month:oo({matchPatterns:ij,defaultMatchWidth:"wide",parsePatterns:aj,defaultParseWidth:"any"}),day:oo({matchPatterns:oj,defaultMatchWidth:"wide",parsePatterns:lj,defaultParseWidth:"any"}),dayPeriod:oo({matchPatterns:cj,defaultMatchWidth:"any",parsePatterns:uj,defaultParseWidth:"any"})},ov={code:"en-US",formatDistance:LA,formatLong:UA,formatRelative:IA,localize:JA,match:fj,options:{weekStartsOn:0,firstWeekContainsDate:1}};function hj(n,e){const s=kn(n,e==null?void 0:e.in);return AA(s,RA(s))+1}function dj(n,e){const s=kn(n,e==null?void 0:e.in),i=+bu(s)-+jA(s);return Math.round(i/sv)+1}function lv(n,e){var d,b,x,v;const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Lo(),c=(e==null?void 0:e.firstWeekContainsDate)??((b=(d=e==null?void 0:e.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,m=Br((e==null?void 0:e.in)||n,0);m.setFullYear(i+1,0,c),m.setHours(0,0,0,0);const p=No(m,e),g=Br((e==null?void 0:e.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=No(g,e);return+s>=+p?i+1:+s>=+u?i:i-1}function mj(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.firstWeekContainsDate)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=lv(n,e),c=Br((e==null?void 0:e.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),No(c,e)}function pj(n,e){const s=kn(n,e==null?void 0:e.in),i=+No(s,e)-+mj(s,e);return Math.round(i/sv)+1}function tt(n,e){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(e,"0");return s+i}const ys={y(n,e){const s=n.getFullYear(),i=s>0?s:1-s;return tt(e==="yy"?i%100:i,e.length)},M(n,e){const s=n.getMonth();return e==="M"?String(s+1):tt(s+1,2)},d(n,e){return tt(n.getDate(),e.length)},a(n,e){const s=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(n,e){return tt(n.getHours()%12||12,e.length)},H(n,e){return tt(n.getHours(),e.length)},m(n,e){return tt(n.getMinutes(),e.length)},s(n,e){return tt(n.getSeconds(),e.length)},S(n,e){const s=e.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return tt(o,e.length)}},Hi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},kb={G:function(n,e,s){const i=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return s.era(i,{width:"abbreviated"});case"GGGGG":return s.era(i,{width:"narrow"});case"GGGG":default:return s.era(i,{width:"wide"})}},y:function(n,e,s){if(e==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ys.y(n,e)},Y:function(n,e,s,i){const o=lv(n,i),c=o>0?o:1-o;if(e==="YY"){const m=c%100;return tt(m,2)}return e==="Yo"?s.ordinalNumber(c,{unit:"year"}):tt(c,e.length)},R:function(n,e){const s=iv(n);return tt(s,e.length)},u:function(n,e){const s=n.getFullYear();return tt(s,e.length)},Q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(i);case"QQ":return tt(i,2);case"Qo":return s.ordinalNumber(i,{unit:"quarter"});case"QQQ":return s.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(i,{width:"wide",context:"formatting"})}},q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(i);case"qq":return tt(i,2);case"qo":return s.ordinalNumber(i,{unit:"quarter"});case"qqq":return s.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(i,{width:"wide",context:"standalone"})}},M:function(n,e,s){const i=n.getMonth();switch(e){case"M":case"MM":return ys.M(n,e);case"Mo":return s.ordinalNumber(i+1,{unit:"month"});case"MMM":return s.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(i,{width:"wide",context:"formatting"})}},L:function(n,e,s){const i=n.getMonth();switch(e){case"L":return String(i+1);case"LL":return tt(i+1,2);case"Lo":return s.ordinalNumber(i+1,{unit:"month"});case"LLL":return s.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(i,{width:"wide",context:"standalone"})}},w:function(n,e,s,i){const o=pj(n,i);return e==="wo"?s.ordinalNumber(o,{unit:"week"}):tt(o,e.length)},I:function(n,e,s){const i=dj(n);return e==="Io"?s.ordinalNumber(i,{unit:"week"}):tt(i,e.length)},d:function(n,e,s){return e==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ys.d(n,e)},D:function(n,e,s){const i=hj(n);return e==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):tt(i,e.length)},E:function(n,e,s){const i=n.getDay();switch(e){case"E":case"EE":case"EEE":return s.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(i,{width:"short",context:"formatting"});case"EEEE":default:return s.day(i,{width:"wide",context:"formatting"})}},e:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"e":return String(c);case"ee":return tt(c,2);case"eo":return s.ordinalNumber(c,{unit:"day"});case"eee":return s.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(o,{width:"short",context:"formatting"});case"eeee":default:return s.day(o,{width:"wide",context:"formatting"})}},c:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"c":return String(c);case"cc":return tt(c,e.length);case"co":return s.ordinalNumber(c,{unit:"day"});case"ccc":return s.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(o,{width:"narrow",context:"standalone"});case"cccccc":return s.day(o,{width:"short",context:"standalone"});case"cccc":default:return s.day(o,{width:"wide",context:"standalone"})}},i:function(n,e,s){const i=n.getDay(),o=i===0?7:i;switch(e){case"i":return String(o);case"ii":return tt(o,e.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(i,{width:"short",context:"formatting"});case"iiii":default:return s.day(i,{width:"wide",context:"formatting"})}},a:function(n,e,s){const o=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(n,e,s){const i=n.getHours();let o;switch(i===12?o=Hi.noon:i===0?o=Hi.midnight:o=i/12>=1?"pm":"am",e){case"b":case"bb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(n,e,s){const i=n.getHours();let o;switch(i>=17?o=Hi.evening:i>=12?o=Hi.afternoon:i>=4?o=Hi.morning:o=Hi.night,e){case"B":case"BB":case"BBB":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(n,e,s){if(e==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ys.h(n,e)},H:function(n,e,s){return e==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ys.H(n,e)},K:function(n,e,s){const i=n.getHours()%12;return e==="Ko"?s.ordinalNumber(i,{unit:"hour"}):tt(i,e.length)},k:function(n,e,s){let i=n.getHours();return i===0&&(i=24),e==="ko"?s.ordinalNumber(i,{unit:"hour"}):tt(i,e.length)},m:function(n,e,s){return e==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ys.m(n,e)},s:function(n,e,s){return e==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ys.s(n,e)},S:function(n,e){return ys.S(n,e)},X:function(n,e,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(e){case"X":return Tb(i);case"XXXX":case"XX":return Ws(i);case"XXXXX":case"XXX":default:return Ws(i,":")}},x:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"x":return Tb(i);case"xxxx":case"xx":return Ws(i);case"xxxxx":case"xxx":default:return Ws(i,":")}},O:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Nb(i,":");case"OOOO":default:return"GMT"+Ws(i,":")}},z:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Nb(i,":");case"zzzz":default:return"GMT"+Ws(i,":")}},t:function(n,e,s){const i=Math.trunc(+n/1e3);return tt(i,e.length)},T:function(n,e,s){return tt(+n,e.length)}};function Nb(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=Math.trunc(i/60),c=i%60;return c===0?s+String(o):s+String(o)+e+tt(c,2)}function Tb(n,e){return n%60===0?(n>0?"-":"+")+tt(Math.abs(n)/60,2):Ws(n,e)}function Ws(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=tt(Math.trunc(i/60),2),c=tt(i%60,2);return s+o+e+c}const Cb=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},cv=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},yj=(n,e)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return Cb(n,e);let c;switch(i){case"P":c=e.dateTime({width:"short"});break;case"PP":c=e.dateTime({width:"medium"});break;case"PPP":c=e.dateTime({width:"long"});break;case"PPPP":default:c=e.dateTime({width:"full"});break}return c.replace("{{date}}",Cb(i,e)).replace("{{time}}",cv(o,e))},gj={p:cv,P:yj},bj=/^D+$/,xj=/^Y+$/,vj=["D","DD","YY","YYYY"];function _j(n){return bj.test(n)}function wj(n){return xj.test(n)}function Sj(n,e,s){const i=Ej(n,e,s);if(console.warn(i),vj.includes(n))throw new RangeError(i)}function Ej(n,e,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Oj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Aj=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,jj=/^'([^]*?)'?$/,kj=/''/g,Nj=/[a-zA-Z]/;function Tj(n,e,s){var d,b,x,v;const i=Lo(),o=i.locale??ov,c=i.firstWeekContainsDate??((b=(d=i.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??1,m=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,p=kn(n,s==null?void 0:s.in);if(!CA(p))throw new RangeError("Invalid time value");let g=e.match(Aj).map(_=>{const S=_[0];if(S==="p"||S==="P"){const C=gj[S];return C(_,o.formatLong)}return _}).join("").match(Oj).map(_=>{if(_==="''")return{isToken:!1,value:"'"};const S=_[0];if(S==="'")return{isToken:!1,value:Cj(_)};if(kb[S])return{isToken:!0,value:_};if(S.match(Nj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:_}});o.localize.preprocessor&&(g=o.localize.preprocessor(p,g));const u={firstWeekContainsDate:c,weekStartsOn:m,locale:o};return g.map(_=>{if(!_.isToken)return _.value;const S=_.value;(wj(S)||_j(S))&&Sj(S,e,String(n));const C=kb[S[0]];return C(p,S,o.localize,u)}).join("")}function Cj(n){const e=n.match(jj);return e?e[1].replace(kj,"'"):n}function Mj(n,e,s){const i=Lo(),o=(s==null?void 0:s.locale)??i.locale??ov,c=kA(n,e);if(isNaN(c))throw new RangeError("Invalid time value");const m=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[p,g]=av(s==null?void 0:s.in,...c>0?[e,n]:[n,e]),u=MA((s==null?void 0:s.roundingMethod)??"round"),d=g.getTime()-p.getTime(),b=d/wb,x=xu(g)-xu(p),v=(d-x)/wb,_=s==null?void 0:s.unit;let S;if(_?S=_:b<1?S="second":b<60?S="minute":b<Ob?S="hour":v<Eb?S="day":v<Sb?S="month":S="year",S==="second"){const C=u(d/1e3);return o.formatDistance("xSeconds",C,m)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,m)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,m)}else if(S==="day"){const C=u(v/Ob);return o.formatDistance("xDays",C,m)}else if(S==="month"){const C=u(v/Eb);return C===12&&_!=="month"?o.formatDistance("xYears",1,m):o.formatDistance("xMonths",C,m)}else{const C=u(v/Sb);return o.formatDistance("xYears",C,m)}}function Rj(n,e){return Mj(n,NA(n),e)}let vu=null;function Dj(n){vu=n||null}function Lj(){return vu}function qj(n,e,s){const i=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...s?{second:"2-digit"}:{},hour12:!0}).formatToParts(n);return Object.fromEntries(i.map(o=>[o.type,o.value]))}function km(n,e=!1){const s=typeof n=="string"?new Date(n):n;if(Number.isNaN(s.getTime()))return String(n);if(!vu)return Tj(s,e?"MMM d, yyyy h:mm:ss a":"MMM d, yyyy h:mm a");const i=qj(s,vu,e),o=`${i.hour}:${i.minute}${e?`:${i.second}`:""}`;return`${i.month} ${i.day}, ${i.year} ${o} ${i.dayPeriod}`}function uv(n){const e=n??[];return e.length>0&&e.every(s=>s.type==="member"&&s.write_scope==="none")}function y5(n,e,s){return!e||!uv(n)?!0:!!s&&!s.subjectScoped}const Nm={staleTime:5*6e4,refetchOnWindowFocus:!1};function g5(n={},e={}){const s=new URLSearchParams;return n.role&&s.set("role",n.role),n.roleType&&s.set("roleType",n.roleType),n.status&&s.set("status",n.status),n.search&&s.set("search",n.search),n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),qe({queryKey:["users",n],queryFn:()=>ue(`/users?${s}`),enabled:e.enabled??!0,...Nm})}const Mb=200;async function Pj(n){const e=[];for(let s=0;s<n.length;s+=Mb){const i=await ue("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+Mb)})});e.push(...i.users??[])}return e}let Jd=[],Qd=new Map,Xd=!1;function Bj(){const n=Jd,e=Qd;Jd=[],Qd=new Map,Xd=!1,Pj(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of e)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of e.values())i.reject(s)})}function Uj(n){return new Promise((e,s)=>{Jd.push(n),Qd.set(n,{resolve:e,reject:s}),Xd||(Xd=!0,setTimeout(Bj,0))})}function b5(n){return qe({queryKey:["user-name",n],queryFn:()=>Uj(n),enabled:!!n,...Nm})}function zj(n){return qe({queryKey:["users",n,"roles"],queryFn:async()=>(await ue(`/users/${n}/roles`)).roles??[],enabled:!!n,...Nm})}function x5(){const n=Pe();return $e({mutationFn:e=>ue("/users",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function v5(){const n=Pe();return $e({mutationFn:({id:e,...s})=>ue(`/users/${e}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function _5(){const n=Pe();return $e({mutationFn:({id:e,ops:s})=>ue(`/users/${e}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function w5(){return qe({queryKey:["users","system-property-keys"],queryFn:()=>ue("/users/system-property-keys")})}function S5(){const n=Pe();return $e({mutationFn:e=>ue(`/users/${e}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function E5(){const n=Pe();return $e({mutationFn:({userId:e,role:s,type:i,read_scope:o,write_scope:c})=>ue(`/users/${e}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function O5(){const n=Pe();return $e({mutationFn:({userId:e,role:s})=>ue(`/users/${e}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const A5={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function Ij(){return qe({queryKey:["roles"],queryFn:()=>ue("/roles")})}function Mu(n){return qe({queryKey:["roles","details"],queryFn:()=>ue("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function j5(n,e,s=!0){return qe({queryKey:["roles",n,"schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function k5(n){return qe({queryKey:["roles",n,"schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function N5(n,e,s=!0){return qe({queryKey:["roles",n,"list-schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function T5(n){return qe({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function C5(){const n=Pe();return $e({mutationFn:e=>ue("/roles",{method:"POST",body:JSON.stringify({role:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function M5(){const n=Pe();return $e({mutationFn:({role:e,...s})=>ue(`/roles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:e,...s})=>{await n.cancelQueries({queryKey:["roles","details"]});const i=n.getQueryData(["roles","details"]);return i&&n.setQueryData(["roles","details"],{roles:i.roles.map(o=>o.role===e?{...o,...s}:o)}),{previous:i}},onError:(e,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function R5(){const n=Pe();return $e({mutationFn:e=>ue(`/roles/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const fv="lt:station:kiosk-role:";function Wd(n){return`${fv}${n}`}const Zd=new Set;function $j(){for(const n of Zd)n()}function Hj(n){try{return localStorage.getItem(Wd(n))}catch{return null}}function Fj(n,e){try{e===null?localStorage.removeItem(Wd(n)):localStorage.setItem(Wd(n),e)}catch{}$j()}function Gj(n){Zd.add(n);const e=s=>{(s.key===null||s.key.startsWith(fv))&&n()};try{window.addEventListener("storage",e)}catch{}return()=>{Zd.delete(n);try{window.removeEventListener("storage",e)}catch{}}}function Vj(n){return E.useSyncExternalStore(Gj,()=>n?Hj(n):null)}const _u="/portal";function Yj(n){return n===_u||n.startsWith(`${_u}/`)}function Tm(n,e){const s=`${_u}/${encodeURIComponent(n)}`;return e?`${s}/${encodeURIComponent(e)}`:s}function ea(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function Kj(n){return ea(n).length>0}function D5(n,e){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(e);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function hv(n,e){return e.length>0?Tm(n,e[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Cm(){const{user:n}=qt(),e=(n==null?void 0:n.userId)??null,{data:s}=zj(e),{data:i}=Mu(),o=Vj(e),c=E.useCallback(m=>{e&&Fj(e,m)},[e]);return E.useMemo(()=>{const m={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},p=s??[];if(p.length===0||p.some(v=>v.type!=="member"))return m;const g=v=>{var _;return(_=i==null?void 0:i.roles)==null?void 0:_.find(S=>S.role===v)},u=v=>{var _,S;return((S=(_=g(v))==null?void 0:_.properties)==null?void 0:S.kiosk)===!0},d=p.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:hv(v,ea(g(v))),targets:d,selectable:d.length>=2,selectRole:c});if(p.length===1)return d.length===1?b(d[0]):m;if(!uv(p)||d.length===0)return m;const x=o&&d.includes(o)?o:d.length===1?d[0]:null;return x?b(x):{...m,targets:d,selectable:!0}},[s,i,o,c])}const Jj="/escalations/available",Qj=["/escalations",_u,"/scan","/login"];function Xj(n,e=""){if(n===Jj){const s=new URLSearchParams(e);if(!s.get("role")&&!s.get("facets"))return!1}return Qj.some(s=>n===s||n.startsWith(`${s}/`)||n.startsWith(`${s}?`))}const Mm=E.createContext(null),ud="lt_sidebar_collapsed",dv="(max-width: 1023px)";function Wj(){try{return window.matchMedia(dv).matches}catch{return!1}}function Zj({children:n}){const[e,s]=E.useState(()=>{if(Wj())return!0;try{return localStorage.getItem(ud)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(dv)}catch{return}const c=m=>{if(m.matches)s(!0);else try{s(localStorage.getItem(ud)==="true")}catch{s(!1)}};return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[]);const i=E.useCallback(()=>{s(o=>{const c=!o;try{localStorage.setItem(ud,String(c))}catch{}return c})},[]);return h.jsx(Mm.Provider,{value:{collapsed:e,toggle:i},children:n})}function ek({children:n}){return h.jsx(Mm.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Rm(){const n=E.useContext(Mm);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const Rb=380,Dm=E.createContext(null);function tk({children:n}){const[e,s]=E.useState({node:null,width:Rb,open:!1,ownerKey:null}),i=en(),o=E.useRef(i.pathname),c=E.useCallback((p,g)=>{s({node:p,width:(g==null?void 0:g.width)??Rb,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),m=E.useCallback(p=>{s(g=>typeof p=="string"&&g.ownerKey!==p?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(p=>p.open||p.node?{...p,node:null,open:!1,ownerKey:null}:p))},[i.pathname]),h.jsx(Dm.Provider,{value:{...e,setPanel:c,closePanel:m},children:n})}function Lm(){const n=E.useContext(Dm);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function L5(){return E.useContext(Dm)}function nk({open:n,width:e=380,children:s,className:i=""}){const[o,c]=E.useState(n);return E.useEffect(()=>{n&&c(!0)},[n]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${i}`,style:{width:n?e:0,maxWidth:"50%"},onTransitionEnd:m=>{!n&&m.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:e},className:"h-full",children:o?s:null})})}function q5({label:n,children:e}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:n}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:e})]})}function P5({views:n,activeId:e,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:m}){const p=n.find(g=>g.id===e)??n[0];return p?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${c??"sticky top-0 z-10 max-h-[calc(100vh-3.5rem)]"}`,children:[h.jsxs("div",{className:`flex items-center justify-between pl-4 pr-3 shrink-0 ${m?"pt-10 pb-2":"pt-3"}`,children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1 shrink-0",role:"radiogroup","aria-label":"Panel view",children:n.map(g=>{const u=g.icon,d=g.id===p.id;return h.jsx("button",{role:"radio","aria-checked":d,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${d?"bg-accent/10 text-accent":"text-accent/60 hover:text-accent hover:bg-surface-hover"}`,children:h.jsx(u,{className:"w-3.5 h-3.5"})},g.id)})}),m&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:p.label})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o,i&&h.jsx("button",{onClick:i,title:"Close panel",className:"p-1 rounded text-accent/60 hover:text-accent hover:bg-surface-hover transition-colors",children:h.jsx(Zt,{className:"w-3.5 h-3.5"})})]})]}),!m&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:p.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${m?"pt-4 pb-8":"pb-5 pt-1"}`,children:p.content})]})}):null}function mv(n,e){var s,i,o,c,m;e.facets&&Object.keys(e.facets).length&&n.set("facets",JSON.stringify(e.facets)),(s=e.block)!=null&&s.length&&n.set("block",JSON.stringify(e.block)),(i=e.range)!=null&&i.length&&n.set("range",JSON.stringify(e.range)),(o=e.exists)!=null&&o.length&&n.set("exists",JSON.stringify(e.exists)),(c=e.roles)!=null&&c.length&&n.set("roles",JSON.stringify(e.roles)),(m=e.orderBy)!=null&&m.length&&n.set("orderBy",JSON.stringify(e.orderBy)),e.available!==void 0&&n.set("available",String(e.available)),e.jeopardy===!0&&n.set("jeopardy","1"),e.include&&n.set("include",e.include),e.groupBy&&n.set("groupBy",e.groupBy)}function B5(n,e,s){const i=n??"24h",o=e&&Object.keys(e).length?JSON.stringify(e):null;return qe({queryKey:["stationMetrics",i,o],queryFn:()=>ue(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function U5(n){const e=n?`?period=${n}`:"";return qe({queryKey:["escalationStats",n],queryFn:()=>ue(`/escalations/stats${e}`)})}function z5(){return qe({queryKey:["escalationTypes"],queryFn:()=>ue("/escalations/types")})}function I5(n=!0){return qe({queryKey:["escalationFacetKeys"],queryFn:()=>ue("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function rk(n){return qe({queryKey:["escalationFacetValues",n],queryFn:()=>ue(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function sk(n){const e=new URLSearchParams;return n.status&&e.set("status",n.status),n.role&&e.set("role",n.role),n.type&&e.set("type",n.type),n.subtype&&e.set("subtype",n.subtype),n.assigned_to&&e.set("assigned_to",n.assigned_to),n.parent_id&&e.set("parent_id",n.parent_id),n.claimed&&e.set("claimed","true"),n.priority&&e.set("priority",String(n.priority)),n.limit&&e.set("limit",String(n.limit)),n.offset!==void 0&&e.set("offset",String(n.offset)),n.sort_by&&e.set("sort_by",n.sort_by),n.order&&e.set("order",n.order),n.search&&e.set("search",n.search),mv(e,n),e}function ik(n){return{queryKey:["escalations",n],queryFn:()=>ue(`/escalations?${sk(n)}`)}}function pv(n){const{enabled:e=!0,staleTime:s,...i}=n;return qe({...ik(i),enabled:e,...s!==void 0?{staleTime:s}:{}})}function yv(n){const{enabled:e=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),mv(o,i),qe({queryKey:["escalations","available",i],queryFn:()=>ue(`/escalations/available?${o}`),enabled:e,...s!==void 0?{staleTime:s}:{}})}function $5(n){return qe({queryKey:["escalations","by-workflow",n],queryFn:()=>ue(`/escalations/by-workflow/${n}`),enabled:!!n})}function H5(n){return qe({queryKey:["escalations",n],queryFn:()=>ue(`/escalations/${n}`),enabled:!!n})}function F5(n,e){return qe({queryKey:["escalations",n,"lookups"],queryFn:()=>ue(`/escalations/${n}/lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function G5(){const n=Pe();return $e({mutationFn:({id:e,durationMinutes:s})=>ue(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function V5(){const n=Pe();return $e({mutationFn:e=>ue(`/escalations/${e}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function Y5(){const n=Pe();return $e({mutationFn:({id:e,resolverPayload:s})=>ue(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),n.resetQueries({queryKey:["tasks"]}),n.resetQueries({queryKey:["jobs"]})}})}const K5={NEEDS_BADGE:"needs_badge",ROLE_REFUSED:"role_refused"};function J5(){const n=Pe();return $e({mutationFn:({id:e,...s})=>ue(`/escalations/${e}/roster-action`,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]}),n.invalidateQueries({queryKey:["escalationStats"]})}})}function Q5(){const n=Pe();return $e({mutationFn:({id:e,itemKey:s,payload:i})=>ue(`/escalations/${e}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function X5(){const n=Pe();return $e({mutationFn:({id:e,itemKey:s})=>ue(`/escalations/${e}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function W5(){const n=Pe();return $e({mutationFn:({id:e,targetRole:s})=>ue(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function Z5(){const n=Pe();return $e({mutationFn:({ids:e,priority:s})=>ue("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:e,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function eM(){const n=Pe();return $e({mutationFn:({ids:e,durationMinutes:s})=>ue("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:e,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function tM(){const n=Pe();return $e({mutationFn:({ids:e,targetUserId:s,durationMinutes:i,reassign:o})=>ue("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:e,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function nM(){const n=Pe();return $e({mutationFn:({ids:e})=>ue("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function rM(){const n=Pe();return $e({mutationFn:({ids:e,hint:s})=>ue("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:e,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function sM(){const n=Pe();return $e({mutationFn:e=>ue(`/escalations/${e}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function iM(){const n=Pe();return $e({mutationFn:({ids:e})=>ue("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function qm(n){const e=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":e.push(["tasks"]),e.push(["jobs"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),n.originId&&e.push(["processes",n.originId]);break;case"escalation":e.push(["escalations"]),e.push(["escalationStats"]),e.push(["stationMetrics"]),n.workflowId&&e.push(["workflowExecution",n.workflowId]);break;case"workflow":e.push(["jobs"]),e.push(["tasks"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId]),e.push(["mcpQueryResult",n.workflowId]),e.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&e.push(["mcpRunExecution",n.workflowId]),e.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),e.push(["tasks"]);break;case"knowledge":e.push(["knowledge"]);break;case"file":e.push(["files"]);break;case"agent":e.push(["agents"]);break;default:e.push(["jobs"]),e.push(["tasks"]);break}return e}const ak={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},aM=300,Db={DETAIL:0,LIST:1,SUMMARY:2};function ok(n){const e=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function m(d){delete s[d],i[d]=Date.now();const b=[];for(const[v,_]of e)_===d&&b.push(v);for(const v of b)e.delete(v);if(b.length===0)return;const x=c();x&&(o=!0);for(const v of b)n.invalidateQueries({queryKey:JSON.parse(v),...x?{refetchType:"none"}:{}})}function p(d){if(s[d])return;const{coalesceMs:b,minIntervalMs:x}=ak[d],v=i[d],_=v===void 0?0:v+x-Date.now(),S=Math.max(b,_);s[d]=setTimeout(()=>m(d),S)}function g(d,b){for(const x of b){const v=JSON.stringify(x),_=e.get(v);(_===void 0||Db[d]<Db[_])&&e.set(v,d)}p(d)}const u=()=>{typeof document>"u"||document.visibilityState==="visible"&&o&&(o=!1,n.refetchQueries({type:"active",stale:!0}))};return typeof document<"u"&&document.addEventListener("visibilitychange",u),{request:g,dispose(){for(const d of Object.keys(s)){const b=s[d];b&&clearTimeout(b),delete s[d]}e.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const Lb=new WeakMap;function lk(n){let e=Lb.get(n);return e||(e=ok(n),Lb.set(n,e)),e}function tn(n){const e=Pe();return E.useCallback(s=>{lk(e).request(n,s)},[e,n])}function Pm(n){return n?[`${Xt}.system.workflow.>`,`${Xt}.system.activity.>`,`${Xt}.system.milestone.>`,`${Xt}.system.task.>`,`${Xt}.system.escalation.>`]:[]}function oM(){const n=tn("LIST");An(`${Xt}.system.task.>`,()=>{n([["jobs"]])}),An(`${Xt}.system.workflow.>`,()=>{n([["jobs"]])})}function lM(n){const e=tn("DETAIL");js(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function cM(n){const e=tn("DETAIL");js(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function uM(n){const e=tn("DETAIL");js(Pm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=qm(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),e(o)})}function fM(n){const e=tn("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||e([["processes",n]]))},[n,e]);An(`${Xt}.system.task.>`,s),An(`${Xt}.system.workflow.>`,s),An(`${Xt}.system.escalation.>`,s)}function hM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["escalationStats"]])})}function dM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["stationMetrics"]])})}function mM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function pM(n){const e=tn("LIST"),s=(n==null?void 0:n.role)??null,i=((n==null?void 0:n.verbs)??[]).join(","),o=E.useMemo(()=>{const c=i?i.split(","):null;return c?Yd({role:s,verbs:c}):[fr({role:s})]},[s,i]);js(o,()=>{e([["escalations"]])})}const ck=[["escalations","related"],["escalations","related-rows"]];function yM(n){const e=tn("LIST"),s=[...new Set(n)].sort().join(","),i=E.useMemo(()=>s?s.split(",").map(o=>fr({role:o})):[],[s]);js(i,()=>{e(ck)})}function gM(n){const e=tn("DETAIL");An(fr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||e([["escalations",n]])})}function bM(){const n=tn("LIST");An(`${Xt}.system.agent.>`,()=>{n([["agents"]])})}function xM(){const n=tn("LIST");An(`${Xt}.system.task.>`,()=>{n([["processes"]])}),An(`${Xt}.system.workflow.>`,()=>{n([["processes"]])})}function uk(){const{user:n}=qt(),e=n==null?void 0:n.userId,s=tn("SUMMARY");js(jm(),()=>{s([["escalations"]])});const{data:i}=yv({limit:1}),{data:o}=pv({assigned_to:e,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function Ru({size:n="sm",hideLabel:e=!1,className:s="",appName:i="LongTail",variant:o="full"}){const c=n==="lg";if(o==="comet")return h.jsx("div",{className:`relative overflow-visible ${s}`,style:{width:"2.5rem",height:"2.5rem",flexShrink:0},children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Vt}/logo512.png)`,width:"82px",height:"82px",top:"-12px",left:"-80px",transform:"rotate(232deg)",zIndex:-1,opacity:.55}})});if(o==="mark")return h.jsx("div",{className:`flex items-center ${s}`,children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Vt}/logo512.png)`}})});const m=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",p=c?"text-[44px] font-normal text-text-primary tracking-[0.15em] -ml-[12.5rem]":"text-[36px] font-normal text-text-primary tracking-[0.15em] -ml-[9.75rem]";return h.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[h.jsx("span",{role:"img","aria-label":i,className:`logo-mark shrink-0 z-0 ${m}`,style:{"--logo-url":`url(${Vt}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${p} ${e?"opacity-0":""}`,children:i})]})}const fk="system.surfaces.dashboard",hk=`${Xt}.${fk}`;function gv(n=!0){return qe({queryKey:["announcements"],queryFn:()=>ue("/announcements"),enabled:n,staleTime:3e4})}function dk(){const n=Pe();return $e({mutationFn:e=>ue("/announcements",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function mk(){const n=Pe();return $e({mutationFn:e=>ue(`/announcements/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function vM(n){return n.toLocaleString()}function _M(n){return n>=1e9?`${(n/1e9).toFixed(1).replace(/\.0$/,"")}B`:n>=1e6?`${(n/1e6).toFixed(1).replace(/\.0$/,"")}M`:n>=1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}K`:n.toLocaleString()}function pk(n){const e=new Date(n);return e.getTime()>Date.now()?"just now":Rj(e,{addSuffix:!0})}function wM(n){const e=Date.now()-new Date(n).getTime();if(e<0)return"now";const s=Math.floor(e/1e3);if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const o=Math.floor(i/60);if(o<24)return`${o}h`;const c=Math.floor(o/24);return c<7?`${c}d`:c<30?`${Math.floor(c/7)}w`:c<365?`${Math.floor(c/30)}mo`:`${Math.floor(c/365)}y`}function SM(n){return n<=0?"Expired":Bm(n)}function yk(n){return n==null?"--":Bm(n)}function EM(n){return n?km(n):"--"}function Bm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const m=n/1e3;return Number.isInteger(m)?`${m}s`:`${m.toFixed(1)}s`}const e=Math.floor(n/1e3),s=Math.floor(e/86400),i=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),c=e%60;return s>0?i>0?`${s}d ${i}h`:`${s}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:c>0?`${o}m ${c}s`:`${o}m`}function OM(n,e){const s=new Date(n).getTime(),i=e?new Date(e).getTime():Date.now();return Bm(i-s)}function bv({options:n,children:e,className:s=""}){const[i,o]=E.useState(!1),[c,m]=E.useState(null),[p,g]=E.useState(null),u=E.useRef(null),d=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const P=u.current.getBoundingClientRect(),q=window.innerWidth-x-8,ne=Math.max(8,Math.min(P.left,q));g({top:P.bottom+4,left:ne})},[]),_=E.useCallback(async(P,q)=>{try{await navigator.clipboard.writeText(P),m(q),clearTimeout(d.current),d.current=setTimeout(()=>m(null),1200)}catch{}},[]),S=E.useCallback(()=>{clearTimeout(b.current),v(),o(!0)},[v]),C=E.useCallback(()=>{b.current=setTimeout(()=>o(!1),150)},[]);return E.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[e,i&&p&&sm.createPortal(h.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:p.top,left:p.left},onMouseEnter:S,onMouseLeave:C,children:n.map(P=>h.jsxs("button",{onClick:q=>{q.stopPropagation(),_(P.value,P.label)},className:"flex items-center justify-between w-full px-2.5 py-1 text-left hover:bg-surface-hover transition-colors",children:[h.jsx("span",{className:"text-2xs font-medium uppercase tracking-wider text-text-tertiary w-10 shrink-0",children:P.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===P.label?"✓":P.value})]},P.label))}),document.body)]})}function gk(n,e){const s=new Date(n);switch(e){case"relative":return pk(n);case"datetime":return km(s);case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:Lj()??void 0})}}function bk(n){const e=new Date(n);return[{label:"ms",value:String(e.getTime())},{label:"utc",value:e.toISOString()},{label:"local",value:km(e,!0)}]}function xv({date:n,format:e="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(e!=="relative")return;const c=setInterval(()=>i(m=>m+1),3e4);return()=>clearInterval(c)},[e]);const o=E.useMemo(()=>bk(n),[n]);return h.jsx(bv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:gk(n,e)})})}function xk({values:n,options:e,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const m=e.filter(p=>!n.includes(p));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(p=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==p)),className:"inline-flex items-center gap-1 text-2xs font-mono text-text-primary border border-surface-border px-1.5 py-0.5 hover:text-status-error hover:border-status-error/50 transition-colors",title:`Remove ${p}`,children:[p,h.jsx(Zt,{className:"w-3 h-3",strokeWidth:1.5})]},p)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),m.length>0&&h.jsxs("select",{value:"",onChange:p=>p.target.value&&s([...n,p.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),m.map(p=>h.jsx("option",{value:p,children:p},p))]})]})}const vk=[{minutes:1,label:"1 minute"},{minutes:15,label:"15 minutes"},{minutes:30,label:"30 minutes"},{minutes:60,label:"1 hour"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:4320,label:"3 days"},{minutes:10080,label:"7 days"}];function _k(){const{data:n}=gv(),{data:e}=Ij(),s=dk(),i=mk(),[o,c]=E.useState(""),[m,p]=E.useState(""),[g,u]=E.useState(1440),[d,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{m.trim()&&s.mutate({body:m.trim(),...o.trim()?{title:o.trim()}:{},...d.length?{roles:d}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),p(""),b([])}})};return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Alerts"}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Title"}),h.jsx("input",{type:"text",value:o,onChange:_=>c(_.target.value),placeholder:"Optional headline",className:"input text-xs w-full"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Summary"}),h.jsx("textarea",{value:m,onChange:_=>p(_.target.value),placeholder:"What everyone should know (markdown supported)",rows:3,className:"input text-xs w-full resize-y"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible for"}),h.jsx("select",{value:g,onChange:_=>u(Number(_.target.value)),className:"select text-xs w-full",children:vk.map(_=>h.jsx("option",{value:_.minutes,children:_.label},_.minutes))})]}),h.jsxs("div",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible to"}),h.jsx(xk,{values:d,options:(e==null?void 0:e.roles)??[],onChange:b,addLabel:"Add a role…",emptyText:"Everyone",ariaLabel:"Add a role"})]}),s.error&&h.jsx("p",{className:"text-xs text-status-error",children:s.error.message}),h.jsx("button",{onClick:v,disabled:!m.trim()||s.isPending,className:"btn-primary text-xs w-full disabled:opacity-50",children:s.isPending?"Publishing…":"Publish alert"})]}),x.length>0&&h.jsxs("div",{className:"mt-6",children:[h.jsx("p",{className:"text-2xs text-text-tertiary mb-2",children:"Active now — stacked as banner rows, newest first"}),h.jsx("div",{className:"space-y-1",children:x.map(_=>h.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-surface-border/40 last:border-b-0",children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block text-xs text-text-primary truncate",children:_.title??_.body.split(`
54
+ `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(xv,{date:_.expires_at,format:"relative"})]})]}),h.jsx("button",{onClick:()=>i.mutate(_.id),disabled:i.isPending,className:"icon-link shrink-0 mt-0.5",title:"Remove for everyone","aria-label":`Remove ${_.title??"announcement"}`,children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},_.id))})]})]})}const wk=[{id:null,label:"Your view",description:"Full access based on your account role",minTier:"operator"},{id:"admin",label:"Admin",description:"Pace Board + identity management",minTier:"superadmin"},{id:"engineer",label:"Engineer",description:"Work queue + identity management",minTier:"admin"},{id:"operator",label:"Operator",description:"Escalation queue only",minTier:"engineer"}],Sk=["operator","engineer","admin","superadmin"];function qb(n){return Sk.indexOf(n)}function Ek(n,e){return qb(n)>=qb(e)}function Ok({onClose:n}){var Ne,Me,We,pt,Ct,Se,Re;const{isSuperAdmin:e,hasRoleType:s,hasRole:i}=qt(),{data:o}=er(),c=Om(),m=!!((Ne=o==null?void 0:o.ai)!=null&&Ne.enabled),p=Xx(),g=p!==null?p:m,[u,d]=E.useState(g),b=(Me=o==null?void 0:o.features)==null?void 0:Me.graphWorkflows,x=b==null,[v,_]=E.useState(b===!0||x&&Wx()),S=e||i("engineer"),[C,P]=E.useState(Zx()),q=!!((We=o==null?void 0:o.features)!=null&&We.scanCodes),ne=ev(),[te,M]=E.useState(ne!==null?ne:q),U=e?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ae=((pt=o==null?void 0:o.branding)==null?void 0:pt.appName)??"LongTail",z=(Ct=o==null?void 0:o.environment)==null?void 0:Ct.longTailVersion,I=(Se=o==null?void 0:o.environment)==null?void 0:Se.hotmeshVersion,D=(Re=o==null?void 0:o.environment)==null?void 0:Re.nodeEnv;E.useEffect(()=>{const ce=Ue=>{Ue.key==="Escape"&&n()};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[n]);const X=wk.filter(ce=>Ek(U,ce.minTier)),W=X.length>1,he=U!=="operator",we=[...W?[{id:"viewas",label:"View As",icon:gS}]:[],{id:"features",label:"Features",icon:bS},...he?[{id:"alerts",label:"Alerts",icon:xS}]:[]],[Oe,F]=E.useState(we[0].id),J=ce=>{ce===null?Vd():mA(ce)},le=()=>{const ce=!u;d(ce),ce===m?dA():hA(ce),window.location.reload()},pe=()=>{const ce=!v;_(ce),pA(ce),window.location.reload()},ye=()=>{const ce=!C;P(ce),yA(ce),window.location.reload()},Ce=()=>{const ce=!te;M(ce),ce===q?bA():gA(ce),window.location.reload()};return h.jsx("div",{className:"fixed inset-0 z-[100] bg-surface-sunken/75 backdrop-blur-sm flex items-center justify-center",onClick:n,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:ce=>ce.stopPropagation(),children:[h.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Zt,{className:"w-4 h-4",strokeWidth:1.5})}),h.jsxs("div",{className:"flex flex-col items-center gap-3 pb-8",children:[h.jsx("span",{className:"logo-mark block w-20 h-20 opacity-50",style:{"--logo-url":`url(${Vt}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ae}),z&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",z,I&&h.jsxs(h.Fragment,{children:[" · HotMesh v",I]}),D&&D!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:D})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),we.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:we.map(ce=>{const Ue=Oe===ce.id;return h.jsxs("button",{role:"tab","aria-selected":Ue,onClick:()=>F(ce.id),title:ce.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Ue?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(ce.icon,{className:"w-5 h-5",strokeWidth:1.5,...Ue?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:ce.label})]},ce.id)})}),Oe==="viewas"&&W&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"View As"}),X.map(ce=>{const Ue=c===ce.id,Xe=ce.id===null?`Your view · ${U}`:ce.label;return h.jsxs("button",{onClick:()=>J(ce.id),className:"w-full text-left flex items-start gap-3 py-2.5 px-1 group",children:[h.jsx("span",{className:`mt-0.5 w-4 h-4 rounded-full border shrink-0 flex items-center justify-center transition-colors ${Ue?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Ue&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"})}),h.jsxs("span",{children:[h.jsx("span",{className:`block text-sm font-medium transition-colors ${Ue?"text-accent":"text-text-primary group-hover:text-accent"}`,children:Xe}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:ce.description})]})]},String(ce.id))})]}),Oe==="features"&&h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Features"}),h.jsxs("button",{onClick:le,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"AI features"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:u?"Enabled — AI assist, agent labels, bulk AI actions":"Hidden — automation labels, no AI surfaces"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${u?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${u?"translate-x-4":"translate-x-0"}`})})]}),x&&h.jsxs("button",{onClick:pe,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Graph workflows"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:v?"Visible — Graph section shown in Orchestrate sidebar":"Hidden — use Procedural workflows instead"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${v?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${v?"translate-x-4":"translate-x-0"}`})})]}),S&&h.jsxs("button",{onClick:ye,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group","data-testid":"feature-infrastructure",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Infrastructure"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:C?"Visible — Routers, Messages, and DB Maintenance in the sidebar":"Hidden — routers, message streams, and database maintenance"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${C?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${C?"translate-x-4":"translate-x-0"}`})})]}),h.jsxs("button",{onClick:Ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Scan input"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:te?"Enabled — header scan affordance, panel, and keyboard-wedge capture":"Hidden — the deployment opts in with features.scanCodes"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${te?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${te?"translate-x-4":"translate-x-0"}`})})]})]}),Oe==="alerts"&&he&&h.jsx(_k,{}),h.jsx("hr",{className:"border-surface-border/50 mt-8"}),h.jsx("p",{className:"mt-4 text-2xs text-text-quaternary text-center",children:"Esc or click outside to close"})]})})}const vv=[{id:"violet",label:"Violet",swatch:"#7B3BE0"},{id:"red",label:"Brick",swatch:"#DC382D"},{id:"green",label:"Emerald",swatch:"#059669"},{id:"blue",label:"Electric",swatch:"#2563EB"},{id:"rose",label:"Raspberry",swatch:"#D6246E"},{id:"orange",label:"Harvest",swatch:"#E85D04"}],Pb="blue",_v="lt.theme";let wv=[];function Ak(n){const e=new Set(vv.map(i=>i.id)),s=new Set;wv=n.filter(i=>!(i!=null&&i.id)||e.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function jk(){return[...vv,...wv]}function Sv(){try{return localStorage.getItem(_v)||Pb}catch{return Pb}}function Ev(n){document.documentElement.dataset.theme=n}function kk(n){try{localStorage.setItem(_v,n)}catch{}Ev(n)}const Nk=[8,12,13,14];function Tk(n){if(!/^[0-9]+$/.test(n)||!Nk.includes(n.length))return!1;const e=n.split("").map(Number),s=e.pop();let i=0;for(let o=e.length-1,c=3;o>=0;o--,c=c===3?1:3)i+=e[o]*c;return(10-i%10)%10===s}function AM(n){return n.padStart(14,"0")}const cu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},Ov="lt_scan_wedge_config";function Av(){try{const n=localStorage.getItem(Ov);return n?{...cu,...JSON.parse(n)}:cu}catch{return cu}}function Ck(n){const e={...Av(),...n};return localStorage.setItem(Ov,JSON.stringify(e)),e}const Um=[{pattern:/(?:^|[^0-9])([1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+)$/,digitsOnly:!1},{pattern:/(?:^|[^0-9])([1-9][0-9]{7,})$/,digitsOnly:!0}];function Mk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rk(n){const e=[];for(const s of n.filter(i=>i.enabled))if(s.encoding==="delimited"){const i=Mk(s.delimiter);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}${i}[0-9]${i}[a-zA-Z0-9._-]+)$`),digitsOnly:!1})}else if(s.encoding==="fixed"){const i=1+(s.target_length??0);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}[0-9]{${i},${i+1}})$`),digitsOnly:!0})}else s.encoding==="gtin"&&e.push({pattern:/(?:^|[^0-9])([0-9]{8}|[0-9]{12,14})$/,digitsOnly:!0,accept:Tk});return e.length?e:Um}function Dk(n,e=Um){var i;let s=null;for(const o of e){const c=(i=n.match(o.pattern))==null?void 0:i[1];!c||o.accept&&!o.accept(c)||(!s||c.length>s.code.length)&&(s={code:c,shape:o})}return s}const Lk=new Set(["Shift","CapsLock"]),hc={suppress:!1,emit:null};function qk(n=cu,e=Um){let s={buffer:"",times:[],lastKeyMs:0};function i(u){const d=s.times.slice(-u.length);return d.length<2?!1:(d[d.length-1]-d[0])/(d.length-1)<=n.autoFireMaxAvgKeyMs}function o(){const u=Dk(s.buffer,e);return!u||u.code.length<n.minLength||u.shape.digitsOnly&&!i(u.code)?null:u.code}function c(){s={buffer:"",times:[],lastKeyMs:0}}function m(u){const{key:d,timeMs:b,hasModifier:x,isRepeat:v}=u;if(Lk.has(d))return hc;if(n.terminators.includes(d)){const q=o();return c(),q?{suppress:!0,emit:q,consumedLength:q.length}:hc}if(x||v||d.length!==1)return c(),hc;const _=b-s.lastKeyMs,S=s.lastKeyMs>0&&_<=n.maxKeyGapMs,C=(S?s.buffer+d:d).slice(-128),P=(S?[...s.times,b]:[b]).slice(-128);return s={buffer:C,times:P,lastKeyMs:b},hc}function p(){return{buffer:s.buffer}}function g(){const u=o();return!u||!i(u)?null:{code:u,consumedLength:u.length}}return{step:m,reset:c,snapshot:p,pendingAutoFire:g}}function Pk(){const n=document.activeElement;return n instanceof HTMLInputElement?["text","search","tel","url","email","password","number"].includes(n.type)?n:null:n instanceof HTMLTextAreaElement?n:null}function Bk(n,e,s){var c;const i=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,o=(c=Object.getOwnPropertyDescriptor(i,"value"))==null?void 0:c.set;o?o.call(n,e):n.value=e;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function Bb(n){if(n<=0)return;const e=Pk();if(!e)return;const s=e.selectionStart??e.value.length,i=Math.max(0,s-n);Bk(e,e.value.slice(0,i)+e.value.slice(s),i)}const To={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar"},Uk="data-lt-scan-capture",zk="off";function Ik(n){return n instanceof Element&&!!n.closest(`[${Uk}="${zk}"]`)}function $k({active:n,wedgeConfig:e,tailShapes:s,diagnosticsOn:i,onScan:o,onDiag:c}){const m=E.useRef({diagnosticsOn:i,onScan:o,onDiag:c});m.current={diagnosticsOn:i,onScan:o,onDiag:c};const p=E.useRef(0),g=E.useRef(0);E.useEffect(()=>{if(!n)return;const u=qk(e,s);let d=null;const b=()=>{d&&(clearTimeout(d),d=null)},x=(S,C,P)=>{C&&Bb(C),m.current.diagnosticsOn&&(console.debug("[scan]",P),m.current.onDiag({seq:++p.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:P})),m.current.onScan(S)},v=()=>{b(),u.pendingAutoFire()&&(d=setTimeout(()=>{d=null;const S=u.pendingAutoFire();S&&(u.reset(),x(S.code,S.consumedLength,`capture → ${S.code} (quiet period — no suffix)`))},e.autoFireQuietMs))},_=S=>{if(Ik(S.target)){u.reset(),b();return}const C=u.snapshot().buffer,{suppress:P,emit:q,consumedLength:ne}=u.step({key:S.key,timeMs:S.timeStamp,hasModifier:S.ctrlKey||S.metaKey||S.altKey,isRepeat:S.repeat});if(P&&(S.preventDefault(),S.stopPropagation()),m.current.diagnosticsOn){const te=u.snapshot().buffer,M=e.terminators.includes(S.key),U=q?`capture → ${q}`:M?`terminator — no code tail in "${C.slice(-24)}"`:te===C?C?"neutral (chord key)":"ignored":te===""?"reset (edit/chord/non-printable)":te.length<=1&&C.length>1?"gap — new episode":"accumulate",ae=g.current?Math.round(S.timeStamp-g.current):0,z={seq:++p.current,key:S.key,code:S.code!==S.key?S.code:"",deltaMs:ae,buffer:te.slice(-24),note:U};console.debug("[scan]",z.key,z.code,`${z.deltaMs}ms`,z.note),m.current.onDiag(z)}g.current=S.timeStamp,q?(b(),ne&&Bb(ne),m.current.onScan(q)):v()};return window.addEventListener("keydown",_,{capture:!0}),()=>{b(),window.removeEventListener("keydown",_,{capture:!0})}},[n,e,s])}const je={EXECUTED:"executed",MATCHED_LIST:"matched_list",CONFIRM_REQUIRED:"confirm_required",NO_MATCH_FALLBACK:"no_match_fallback",UNCONFIGURED:"unconfigured",INVALID_CODE:"invalid_code",FORBIDDEN:"forbidden",CONFLICT:"conflict",IDENTITY_PRIMED:"identity_primed",IDENTITY_UNKNOWN:"identity_unknown",NOT_PRIMED:"not_primed",CHOICES:"choices",NO_OPEN_CONTAINER:"no_open_container",HELD:"held",REFUSED:"refused",SUBJECT_STALE:"subject_stale"},dc={SHOW_DETAIL:"show-detail",SHOW_LIST:"show-list",CLAIM:"claim",CLAIM_SHOW_DETAIL:"claim-show-detail",RELEASE:"release",RESOLVE:"resolve",ESCALATE:"escalate",CANCEL:"cancel",ACCUMULATE:"accumulate",PRESENT:"present",HOLD:"hold",FILL:"fill"},Hk={ACTION:"action",IDENTITY:"identity"};function Fk(n,e){return ue("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...e!=null&&e.actingToken?{actingToken:e.actingToken}:{},...e!=null&&e.previousActingToken?{previousActingToken:e.previousActingToken}:{},...e!=null&&e.subject?{subject:e.subject}:{},...e!=null&&e.stationRole?{stationRole:e.stationRole}:{}})})}function jM(n){return ue("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function jv(n){return qe({queryKey:["scan-schemes"],queryFn:()=>ue("/scan-codes/schemes"),...n})}function kM(n){return qe({queryKey:["scan-schemes",n],queryFn:()=>ue(`/scan-codes/schemes/${n}`),enabled:n!=null})}function NM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.version}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function TM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function CM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function MM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"DELETE"}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const Gk=3e4;function Vk(n,e=Date.now()){if(!(!n||Date.parse(n.expiresAt)<=e))return{code:n.code,escalationId:n.escalationId}}function Ub(n,e,s=Date.now()){if(e.outcome===je.HELD&&e.subject){const i=Math.max(0,Date.parse(e.subject.expiresAt)-s);return{...e.subject,ttlMs:i}}return e.clearSubject||!n?null:e.outcome===je.EXECUTED&&e.progress&&e.progress.remaining>0?{...n,expiresAt:new Date(s+n.ttlMs).toISOString()}:n}function zb(n){return n.outcome===je.NOT_PRIMED&&n.replayable===!0}function Yk(n,e=Date.now()){return n&&e-n.at<=Gk?n:null}const Kk=[je.HELD,je.REFUSED,je.SUBJECT_STALE],Fi=n=>{if(n)try{return JSON.parse(n)}catch{return}},Zs=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function Jk(n){const e={},s=Fi(n.get("facets"));Zs(s)||(e.facets=s);const i=Fi(n.get("block"));Zs(i)||(e.block=i);const o=Fi(n.get("range"));Zs(o)||(e.range=o);const c=Fi(n.get("exists"));Zs(c)||(e.exists=c);const m=Fi(n.get("roles"));Zs(m)||(e.roles=m);const p=Fi(n.get("orderBy"));Zs(p)||(e.orderBy=p),n.get("available")!=null&&(e.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(e.jeopardy=!0),e}function RM(n,e){const s=(i,o)=>Zs(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",e.facets),s("block",e.block),s("range",e.range),s("exists",e.exists),s("roles",e.roles),s("orderBy",e.orderBy),e.available==null?n.delete("available"):n.set("available",String(e.available)),e.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const Ib=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function kv(n,e){const s={};for(const[o,c]of Object.entries(n))s[o]=typeof c=="object"&&c!==null?JSON.stringify(c):c;const i=encodeURIComponent(JSON.stringify(s));return e?`/escalations/available?role=${encodeURIComponent(e)}&facets=${i}${Ib}`:`/escalations/available?facets=${i}${Ib}`}function Qk(n,e,s){return kv({[n]:e},s)}function DM(n){var e,s,i;return Object.keys(n.facets??{}).length+(((e=n.block)==null?void 0:e.length)??0)+(((s=n.range)==null?void 0:s.length)??0)+(((i=n.exists)==null?void 0:i.length)??0)+(n.available!=null?1:0)+(n.jeopardy===!0?1:0)}function zm(){var s;const{data:n}=er(),e=ev();return e!==null?e:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const Im=E.createContext(null);function $m(){const n=E.useContext(Im);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}function LM(){return E.useContext(Im)}const Xk="scanPendingAction",Wk="scanChoices",fd="/scan/station";function Zk({children:n}){const{user:e}=qt(),s=zm(),i=ni(),o=en(),{identity:c,prime:m,clear:p,settle:g}=Cu(),[u,d]=E.useState(null),[b,x]=E.useState(null),[v,_]=E.useState(null),{data:S}=jv({enabled:!!e&&s,staleTime:6e4}),C=E.useRef(null);C.current=Cm().role;const P=E.useMemo(()=>Rk((S==null?void 0:S.schemes)??[]),[S]),[q,ne]=E.useState(!1),[te,M]=E.useState(()=>Av()),[U,ae]=E.useState([]),[z,I]=E.useState(!1),D=E.useCallback(Se=>{var Ue;const{outcome:Re}=Se;if(Re===je.CONFIRM_REQUIRED&&Se.pendingAction)return i(`/escalations/detail/${Se.pendingAction.escalationId}`,{state:{[Xk]:Se.pendingAction}}),!0;const ce=Re===je.EXECUTED&&!!F.current;if(Kk.includes(Re)||zb(Se)||ce)return le.current!==fd&&i(fd),!0;if(Re===je.EXECUTED&&Se.escalation){const Xe=[dc.SHOW_DETAIL,dc.CLAIM_SHOW_DETAIL,dc.CLAIM,dc.ESCALATE];return Se.verb&&Xe.includes(Se.verb)?(i(`/escalations/detail/${Se.escalation.id}`),!0):!1}if(Re===je.MATCHED_LIST&&Se.listQuery){const{targetFacet:Xe,target:cn,roles:Mt}=Se.listQuery;return i(kv({[Xe]:cn},(Mt==null?void 0:Mt[0])??null)),!0}return Re===je.CHOICES&&Se.choices?(i(fd,{state:{[Wk]:Se}}),!0):Re===je.NO_MATCH_FALLBACK&&((Ue=Se.fallback)!=null&&Ue.route)?(i(Se.fallback.route),!0):!1},[i]),X=E.useRef(null);X.current=(c==null?void 0:c.actingToken)??null;const W=E.useRef(null),he=E.useRef([]),we=E.useCallback(Se=>(he.current=[Se,...he.current],()=>{he.current=he.current.filter(Re=>Re!==Se)}),[]),Oe=E.useRef(null);Oe.current=b;const F=E.useRef(void 0),J=E.useRef(null);J.current=v;const le=E.useRef(o.pathname);le.current=o.pathname,E.useEffect(()=>{if(!b)return;const Se=Date.parse(b.expiresAt)-Date.now();if(Se<=0){x(null);return}const Re=setTimeout(()=>x(null),Se);return()=>clearTimeout(Re)},[b]);const pe=E.useCallback(async(Se,Re,ce)=>{ne(!0);const Ue=Date.now();try{F.current=Vk(Oe.current);const Xe=await Fk(Se,{actingToken:ce??void 0,previousActingToken:W.current??void 0,subject:F.current,stationRole:C.current??void 0});if(ce&&g(ce,Xe),x(Mt=>Ub(Mt,Xe)),Xe.outcome===je.IDENTITY_PRIMED){W.current=m(Xe);const Mt=Yk(J.current);if(_(null),Mt&&Xe.actingToken){d({code:Se,source:Re,at:Ue,response:Xe,error:null,navigated:!1}),await pe(Mt.code,Re,Xe.actingToken);return}}else zb(Xe)?_({code:Se,at:Ue}):_(null);Xe.outcome===je.NOT_PRIMED&&ce&&p();const cn=D(Xe);d({code:Se,source:Re,at:Ue,response:Xe,error:null,navigated:cn})}catch(Xe){d({code:Se,source:Re,at:Ue,response:null,error:Xe.message,navigated:!1})}finally{ne(!1)}},[D,m,p,g]),ye=E.useCallback(async(Se,Re=To.MANUAL)=>{for(const ce of he.current)if(ce(Se))return;await pe(Se,Re,X.current)},[pe]),Ce=E.useCallback(()=>x(null),[]),Ne=E.useCallback(Se=>{x(Re=>Ub(Re,Se))},[]),Me=E.useCallback(()=>_(null),[]),We=E.useRef(ye);We.current=ye,$k({active:!!e&&s,wedgeConfig:te,tailShapes:P,diagnosticsOn:z,onScan:Se=>void We.current(Se,To.KEYBOARD_WEDGE),onDiag:Se=>ae(Re=>[...Re.slice(-29),Se])});const pt=E.useCallback(Se=>{M(Ck(Se))},[]),Ct=E.useMemo(()=>({submitCode:ye,pushCodeInterceptor:we,lastResult:u,subject:b,dropSubject:Ce,adoptResponse:Ne,pendingScan:v,dropPendingScan:Me,busy:q,wedgeConfig:te,updateWedgeConfig:pt,diagnostics:U,diagnosticsOn:z,setDiagnosticsOn:I}),[ye,we,u,b,Ce,Ne,v,Me,q,te,pt,U,z]);return h.jsx(Im.Provider,{value:Ct,children:n})}var mc={},lo={},pc={},$b;function Nn(){if($b)return pc;$b=1,Object.defineProperty(pc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var e=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return pc.default=e,pc}var Hb;function eN(){if(Hb)return lo;Hb=1,Object.defineProperty(lo,"__esModule",{value:!0}),lo.CODE39=void 0;var n=(function(){function S(C,P){for(var q=0;q<P.length;q++){var ne=P[q];ne.enumerable=ne.enumerable||!1,ne.configurable=!0,"value"in ne&&(ne.writable=!0),Object.defineProperty(C,ne.key,ne)}}return function(C,P,q){return P&&S(C.prototype,P),q&&S(C,q),C}})(),e=Nn(),s=i(e);function i(S){return S&&S.__esModule?S:{default:S}}function o(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function c(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function m(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var p=(function(S){m(C,S);function C(P,q){return o(this,C),P=P.toUpperCase(),q.mod43&&(P+=x(_(P))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,P,q))}return n(C,[{key:"encode",value:function(){for(var q=d("*"),ne=0;ne<this.data.length;ne++)q+=d(this.data[ne])+"0";return q+=d("*"),{data:q,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),C})(s.default),g=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],u=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(S){return b(v(S))}function b(S){return u[S].toString(2)}function x(S){return g[S]}function v(S){return g.indexOf(S)}function _(S){for(var C=0,P=0;P<S.length;P++)C+=v(S[P]);return C=C%43,C}return lo.CODE39=p,lo}var Jn={},yc={},gc={},vt={},Fb;function qo(){if(Fb)return vt;Fb=1,Object.defineProperty(vt,"__esModule",{value:!0});var n;function e(g,u,d){return u in g?Object.defineProperty(g,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):g[u]=d,g}var s=vt.SET_A=0,i=vt.SET_B=1,o=vt.SET_C=2;vt.SHIFT=98;var c=vt.START_A=103,m=vt.START_B=104,p=vt.START_C=105;return vt.MODULO=103,vt.STOP=106,vt.FNC1=207,vt.SET_BY_CODE=(n={},e(n,c,s),e(n,m,i),e(n,p,o),n),vt.SWAP={101:s,100:i,99:o},vt.A_START_CHAR="Ð",vt.B_START_CHAR="Ñ",vt.C_START_CHAR="Ò",vt.A_CHARS="[\0-_È-Ï]",vt.B_CHARS="[ -È-Ï]",vt.C_CHARS="(Ï*[0-9]{2}Ï*)",vt.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],vt}var Gb;function Du(){if(Gb)return gc;Gb=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){c(this,d);var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(_){return _.charCodeAt(0)}),v}return n(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.bytes,v=x.shift()-105,_=i.SET_BY_CODE[v];if(_===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&x.unshift(i.FNC1);var S=d.next(x,1,_);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(v)+S.result+d.getBar((S.checksum+v)%i.MODULO)+d.getBar(i.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var x=this.options.ean128||!1;return typeof x=="string"&&(x=x.toLowerCase()==="true"),x}}],[{key:"getBar",value:function(x){return i.BARS[x]?i.BARS[x].toString():""}},{key:"correctIndex",value:function(x,v){if(v===i.SET_A){var _=x.shift();return _<32?_+64:_-32}else return v===i.SET_B?x.shift()-32:(x.shift()-48)*10+x.shift()-48}},{key:"next",value:function(x,v,_){if(!x.length)return{result:"",checksum:0};var S=void 0,C=void 0;if(x[0]>=200){C=x.shift()-105;var P=i.SWAP[C];P!==void 0?S=d.next(x,v+1,P):((_===i.SET_A||_===i.SET_B)&&C===i.SHIFT&&(x[0]=_===i.SET_A?x[0]>95?x[0]-96:x[0]:x[0]<32?x[0]+96:x[0]),S=d.next(x,v+1,_))}else C=d.correctIndex(x,_),S=d.next(x,v+1,_);var q=d.getBar(C),ne=C*v;return{result:q+S.result,checksum:ne+S.checksum}}}]),d})(s.default);return gc.default=g,gc}var bc={},Vb;function tN(){if(Vb)return bc;Vb=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=qo(),e=function(p){return p.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(p){return p.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(p){return p.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(m,p){var g=p?n.A_CHARS:n.B_CHARS,u=m.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(m.substring(u[1].length));var d=m.match(new RegExp("^"+g+"+"))[0];return d.length===m.length?m:d+String.fromCharCode(p?205:206)+o(m.substring(d.length),!p)}function c(m){var p=i(m),g=p.length;if(g===m.length)return m;m=m.substring(g);var u=e(m)>=s(m);return p+String.fromCharCode(u?206:205)+o(m,u)}return bc.default=function(m){var p=void 0,g=i(m).length;if(g>=2)p=n.C_START_CHAR+c(m);else{var u=e(m)>s(m);p=(u?n.A_START_CHAR:n.B_START_CHAR)+o(m,u)}return p.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,b){return"Ë"+b})},bc}var Yb;function nN(){if(Yb)return yc;Yb=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Du(),e=o(n),s=tN(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){if(c(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,i.default)(b),x));else var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x));return m(v)}return d})(e.default);return yc.default=g,yc}var xc={},Kb;function rN(){if(Kb)return xc;Kb=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.A_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),d})(s.default);return xc.default=g,xc}var vc={},Jb;function sN(){if(Jb)return vc;Jb=1,Object.defineProperty(vc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.B_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),d})(s.default);return vc.default=g,vc}var _c={},Qb;function iN(){if(Qb)return _c;Qb=1,Object.defineProperty(_c,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.C_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),d})(s.default);return _c.default=g,_c}var Xb;function aN(){if(Xb)return Jn;Xb=1,Object.defineProperty(Jn,"__esModule",{value:!0}),Jn.CODE128C=Jn.CODE128B=Jn.CODE128A=Jn.CODE128=void 0;var n=nN(),e=g(n),s=rN(),i=g(s),o=sN(),c=g(o),m=iN(),p=g(m);function g(u){return u&&u.__esModule?u:{default:u}}return Jn.CODE128=e.default,Jn.CODE128A=i.default,Jn.CODE128B=c.default,Jn.CODE128C=p.default,Jn}var Kt={},wc={},Rr={},Wb;function Po(){return Wb||(Wb=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.SIDE_BIN="101",Rr.MIDDLE_BIN="01010",Rr.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},Rr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Rr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Rr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Rr}var Sc={},Ec={},Zb;function Bo(){if(Zb)return Ec;Zb=1,Object.defineProperty(Ec,"__esModule",{value:!0});var n=Po(),e=function(i,o,c){var m=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var p=i.length-1;m=m.map(function(g,u){return u<p?g+c:g})}return m.join("")};return Ec.default=e,Ec}var e1;function Nv(){if(e1)return Sc;e1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){p(this,x);var S=g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.fontSize=!_.flat&&_.fontSize>_.width*10?_.width*10:_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(_,S){return this.text.substr(_,S)}},{key:"leftEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"rightText",value:function(_,S){return this.text.substr(_,S)}},{key:"rightEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"encodeGuarded",value:function(){var _={fontSize:this.fontSize},S={height:this.guardHeight};return[{data:e.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:_},{data:e.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:_},{data:e.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var _=[e.SIDE_BIN,this.leftEncode(),e.MIDDLE_BIN,this.rightEncode(),e.SIDE_BIN];return{data:_.join(""),text:this.text}}}]),x})(c.default);return Sc.default=d,Sc}var t1;function oN(){if(t1)return wc;t1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=function b(x,v,_){x===null&&(x=Function.prototype);var S=Object.getOwnPropertyDescriptor(x,v);if(S===void 0){var C=Object.getPrototypeOf(x);return C===null?void 0:b(C,v,_)}else{if("value"in S)return S.value;var P=S.get;return P===void 0?void 0:P.call(_)}},s=Po(),i=Nv(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=function(x){var v=x.substr(0,12).split("").map(function(_){return+_}).reduce(function(_,S,C){return C%2?_+S*3:_+S},0);return(10-v%10)%10},d=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.lastChar=_.lastChar,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===u(this.data)}},{key:"leftText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var _=this.data.substr(1,6),S=s.EAN13_STRUCTURE[this.data[0]];return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,_,S)}},{key:"rightText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var _=this.data.substr(7,6);return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,_,"RRRRRR")}},{key:"encodeGuarded",value:function(){var _=e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(_.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(_.push({data:"00"}),_.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),_}}]),x})(o.default);return wc.default=d,wc}var Oc={},n1;function lN(){if(n1)return Oc;n1=1,Object.defineProperty(Oc,"__esModule",{value:!0});var n=(function(){function d(b,x){for(var v=0;v<x.length;v++){var _=x[v];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,x,v){return x&&d(b.prototype,x),v&&d(b,v),b}})(),e=function d(b,x,v){b===null&&(b=Function.prototype);var _=Object.getOwnPropertyDescriptor(b,x);if(_===void 0){var S=Object.getPrototypeOf(b);return S===null?void 0:d(S,x,v)}else{if("value"in _)return _.value;var C=_.get;return C===void 0?void 0:C.call(v)}},s=Nv(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d,b){if(!(d instanceof b))throw new TypeError("Cannot call a class as a function")}function m(d,b){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:d}function p(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);d.prototype=Object.create(b&&b.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(d,b):d.__proto__=b)}var g=function(b){var x=b.substr(0,7).split("").map(function(v){return+v}).reduce(function(v,_,S){return S%2?v+_:v+_*3},0);return(10-x%10)%10},u=(function(d){p(b,d);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),m(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,x,v))}return n(b,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===g(this.data)}},{key:"leftText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var v=this.data.substr(0,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var v=this.data.substr(4,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Oc.default=u,Oc}var Ac={},r1;function cN(){if(r1)return Ac;r1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function x(v,_){for(var S=0;S<_.length;S++){var C=_[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}return function(v,_,S){return _&&x(v.prototype,_),S&&x(v,S),v}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(x){return x&&x.__esModule?x:{default:x}}function p(x,v){if(!(x instanceof v))throw new TypeError("Cannot call a class as a function")}function g(x,v){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:x}function u(x,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);x.prototype=Object.create(v&&v.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(x,v):x.__proto__=v)}var d=function(v){var _=v.split("").map(function(S){return+S}).reduce(function(S,C,P){return P%2?S+C*9:S+C*3},0);return _%10},b=(function(x){u(v,x);function v(_,S){return p(this,v),g(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,_,S))}return n(v,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var S=e.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ac.default=b,Ac}var jc={},s1;function uN(){if(s1)return jc;s1=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){return p(this,x),g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_))}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var _=e.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,_,"01"),text:this.text}}}]),x})(c.default);return jc.default=d,jc}var co={},i1;function Tv(){if(i1)return co;i1=1,Object.defineProperty(co,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})();co.checksum=d;var e=Bo(),s=c(e),i=Nn(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=d(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.displayValue=_.displayValue,_.fontSize>_.width*10?S.fontSize=_.width*10:S.fontSize=_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var _="";return _+="101",_+=(0,s.default)(this.data.substr(0,6),"LLLLLL"),_+="01010",_+=(0,s.default)(this.data.substr(6,6),"RRRRRR"),_+="101",{data:_,text:this.text}}},{key:"guardedEncoding",value:function(){var _=[];return this.displayValue&&_.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),_.push({data:"101"+(0,s.default)(this.data[0],"L"),options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),_.push({data:"01010",options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),_.push({data:(0,s.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&_.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),_}}]),x})(o.default);function d(b){var x=0,v;for(v=1;v<11;v+=2)x+=parseInt(b[v]);for(v=0;v<11;v+=2)x+=parseInt(b[v])*3;return(10-x%10)%10}return co.default=u,co}var kc={},a1;function fN(){if(a1)return kc;a1=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function _(S,C){for(var P=0;P<C.length;P++){var q=C[P];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(S,q.key,q)}}return function(S,C,P){return C&&_(S.prototype,C),P&&_(S,P),S}})(),e=Bo(),s=m(e),i=Nn(),o=m(i),c=Tv();function m(_){return _&&_.__esModule?_:{default:_}}function p(_,S){if(!(_ instanceof S))throw new TypeError("Cannot call a class as a function")}function g(_,S){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:_}function u(_,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);_.prototype=Object.create(S&&S.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(_,S):_.__proto__=S)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],b=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],x=(function(_){u(S,_);function S(C,P){p(this,S);var q=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,P));if(q.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)q.middleDigits=C,q.upcA=v(C,"0"),q.text=P.text||""+q.upcA[0]+C+q.upcA[q.upcA.length-1],q.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(q.middleDigits=C.substring(1,C.length-1),q.upcA=v(q.middleDigits,C[0]),q.upcA[q.upcA.length-1]===C[C.length-1])q.isValid=!0;else return g(q);else return g(q);return q.displayValue=P.displayValue,P.fontSize>P.width*10?q.fontSize=P.width*10:q.fontSize=P.fontSize,q.guardHeight=P.height+q.fontSize/2+P.textMargin,q}return n(S,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var P="";return P+="101",P+=this.encodeMiddleDigits(),P+="010101",{data:P,text:this.text}}},{key:"guardedEncoding",value:function(){var P=[];return this.displayValue&&P.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),P.push({data:"101",options:{height:this.guardHeight}}),P.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),P.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&P.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),P}},{key:"encodeMiddleDigits",value:function(){var P=this.upcA[0],q=this.upcA[this.upcA.length-1],ne=b[parseInt(q)][parseInt(P)];return(0,s.default)(this.middleDigits,ne)}}]),S})(o.default);function v(_,S){for(var C=parseInt(_[_.length-1]),P=d[C],q="",ne=0,te=0;te<P.length;te++){var M=P[te];M==="X"?q+=_[ne++]:q+=M}return q=""+S+q,""+q+(0,c.checksum)(q)}return kc.default=x,kc}var o1;function hN(){if(o1)return Kt;o1=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.UPCE=Kt.UPC=Kt.EAN2=Kt.EAN5=Kt.EAN8=Kt.EAN13=void 0;var n=oN(),e=x(n),s=lN(),i=x(s),o=cN(),c=x(o),m=uN(),p=x(m),g=Tv(),u=x(g),d=fN(),b=x(d);function x(v){return v&&v.__esModule?v:{default:v}}return Kt.EAN13=e.default,Kt.EAN8=i.default,Kt.EAN5=c.default,Kt.EAN2=p.default,Kt.UPC=u.default,Kt.UPCE=b.default,Kt}var Qs={},Nc={},Gi={},l1;function dN(){return l1||(l1=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.START_BIN="1010",Gi.END_BIN="11101",Gi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Gi}var c1;function Cv(){if(c1)return Nc;c1=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=dN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return n(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var x=this,v=this.data.match(/.{2}/g).map(function(_){return x.encodePair(_)}).join("");return{data:e.START_BIN+v+e.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=e.BINARIES[x[1]];return e.BINARIES[x[0]].split("").map(function(_,S){return(_==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),d})(i.default);return Nc.default=g,Nc}var Tc={},u1;function mN(){if(u1)return Tc;u1=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Cv(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=function(d){var b=d.substr(0,13).split("").map(function(x){return parseInt(x,10)}).reduce(function(x,v,_){return x+v*(3-_%2*2)},0);return Math.ceil(b/10)*10-b},g=(function(u){m(d,u);function d(b,x){return o(this,d),b.search(/^[0-9]{13}$/)!==-1&&(b+=p(b)),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===p(this.data)}}]),d})(s.default);return Tc.default=g,Tc}var f1;function pN(){if(f1)return Qs;f1=1,Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.ITF14=Qs.ITF=void 0;var n=Cv(),e=o(n),s=mN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Qs.ITF=e.default,Qs.ITF14=i.default,Qs}var xn={},Cc={},h1;function Uo(){if(h1)return Cc;h1=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=(function(u){m(d,u);function d(b,x){return o(this,d),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"encode",value:function(){for(var x="110",v=0;v<this.data.length;v++){var _=parseInt(this.data[v]),S=_.toString(2);S=g(S,4-S.length);for(var C=0;C<S.length;C++)x+=S[C]=="0"?"100":"110"}return x+="1001",{data:x,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(s.default);function g(u,d){for(var b=0;b<d;b++)u="0"+u;return u}return Cc.default=p,Cc}var Mc={},uo={},d1;function Lu(){if(d1)return uo;d1=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.mod10=n,uo.mod11=e;function n(s){for(var i=0,o=0;o<s.length;o++){var c=parseInt(s[o]);(o+s.length)%2===0?i+=c:i+=c*2%10+Math.floor(c*2/10)}return(10-i%10)%10}function e(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var m=parseInt(s[s.length-1-c]);i+=o[c%o.length]*m}return(11-i%11)%11}return uo}var m1;function yN(){if(m1)return Mc;m1=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod10)(d),b))}return u})(e.default);return Mc.default=p,Mc}var Rc={},p1;function gN(){if(p1)return Rc;p1=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod11)(d),b))}return u})(e.default);return Rc.default=p,Rc}var Dc={},y1;function bN(){if(y1)return Dc;y1=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod10)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Dc.default=p,Dc}var Lc={},g1;function xN(){if(g1)return Lc;g1=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod11)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Lc.default=p,Lc}var b1;function vN(){if(b1)return xn;b1=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.MSI1110=xn.MSI1010=xn.MSI11=xn.MSI10=xn.MSI=void 0;var n=Uo(),e=d(n),s=yN(),i=d(s),o=gN(),c=d(o),m=bN(),p=d(m),g=xN(),u=d(g);function d(b){return b&&b.__esModule?b:{default:b}}return xn.MSI=e.default,xn.MSI10=i.default,xn.MSI11=c.default,xn.MSI1010=p.default,xn.MSI1110=u.default,xn}var fo={},x1;function _N(){if(x1)return fo;x1=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.pharmacode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b));return x.number=parseInt(d,10),x}return n(u,[{key:"encode",value:function(){for(var b=this.number,x="";!isNaN(b)&&b!=0;)b%2===0?(x="11100"+x,b=(b-2)/2):(x="100"+x,b=(b-1)/2);return x=x.slice(0,-2),{data:x,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),u})(s.default);return fo.pharmacode=p,fo}var ho={},v1;function wN(){if(v1)return ho;v1=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.codabar=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d.toUpperCase(),b));return x.text=x.options.text||x.text.replace(/[A-D]/g,""),x}return n(u,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var b=[],x=this.getEncodings(),v=0;v<this.data.length;v++)b.push(x[this.data.charAt(v)]),v!==this.data.length-1&&b.push("0");return{text:this.text,data:b.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),u})(s.default);return ho.codabar=p,ho}var Xs={},qc={},Vi={},_1;function SN(){return _1||(_1=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Vi.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],Vi.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),Vi}var w1;function Mv(){if(w1)return qc;w1=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=SN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return e.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return d.getEncoding(C)}).join(""),_=d.checksum(x,20),S=d.checksum(x.concat(_),15);return{text:this.text,data:d.getEncoding("ÿ")+v+d.getEncoding(_)+d.getEncoding(S)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return e.BINARIES[d.symbolValue(x)]}},{key:"getSymbol",value:function(x){return e.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return e.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var _=x.slice().reverse().reduce(function(S,C,P){var q=P%v+1;return S+d.symbolValue(C)*q},0);return d.getSymbol(_%47)}}]),d})(i.default);return qc.default=g,qc}var Pc={},S1;function EN(){if(S1)return Pc;S1=1,Object.defineProperty(Pc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Mv(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return Pc.default=p,Pc}var E1;function ON(){if(E1)return Xs;E1=1,Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.CODE93FullASCII=Xs.CODE93=void 0;var n=Mv(),e=o(n),s=EN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Xs.CODE93=e.default,Xs.CODE93FullASCII=i.default,Xs}var mo={},O1;function AN(){if(O1)return mo;O1=1,Object.defineProperty(mo,"__esModule",{value:!0}),mo.GenericBarcode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return mo.GenericBarcode=p,mo}var A1;function jN(){if(A1)return mc;A1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=eN(),e=aN(),s=hN(),i=pN(),o=vN(),c=_N(),m=wN(),p=ON(),g=AN();return mc.default={CODE39:n.CODE39,CODE128:e.CODE128,CODE128A:e.CODE128A,CODE128B:e.CODE128B,CODE128C:e.CODE128C,EAN13:s.EAN13,EAN8:s.EAN8,EAN5:s.EAN5,EAN2:s.EAN2,UPC:s.UPC,UPCE:s.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:c.pharmacode,codabar:m.codabar,CODE93:p.CODE93,CODE93FullASCII:p.CODE93FullASCII,GenericBarcode:g.GenericBarcode},mc}var Bc={},j1;function qu(){if(j1)return Bc;j1=1,Object.defineProperty(Bc,"__esModule",{value:!0});var n=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e};return Bc.default=function(e,s){return n({},e,s)},Bc}var Uc={},k1;function kN(){if(k1)return Uc;k1=1,Object.defineProperty(Uc,"__esModule",{value:!0}),Uc.default=n;function n(e){var s=[];function i(o){if(Array.isArray(o))for(var c=0;c<o.length;c++)i(o[c]);else o.text=o.text||"",o.data=o.data||"",s.push(o)}return i(e),s}return Uc}var zc={},N1;function NN(){if(N1)return zc;N1=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.default=n;function n(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}return zc}var Ic={},$c={},Hc={},T1;function Rv(){if(T1)return Hc;T1=1,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.default=n;function n(e){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof e[i]=="string"&&(e[i]=parseInt(e[i],10)));return typeof e.displayValue=="string"&&(e.displayValue=e.displayValue!="false"),e}return Hc}var Fc={},C1;function Dv(){if(C1)return Fc;C1=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Fc.default=n,Fc}var M1;function TN(){if(M1)return $c;M1=1,Object.defineProperty($c,"__esModule",{value:!0});var n=Rv(),e=o(n),s=Dv(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m){var p={};for(var g in i.default)i.default.hasOwnProperty(g)&&(m.hasAttribute("jsbarcode-"+g.toLowerCase())&&(p[g]=m.getAttribute("jsbarcode-"+g.toLowerCase())),m.hasAttribute("data-"+g.toLowerCase())&&(p[g]=m.getAttribute("data-"+g.toLowerCase())));return p.value=m.getAttribute("jsbarcode-value")||m.getAttribute("data-value"),p=(0,e.default)(p),p}return $c.default=c,$c}var Gc={},Vc={},vn={},R1;function Lv(){if(R1)return vn;R1=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.getTotalWidthOfEncodings=vn.calculateEncodingAttributes=vn.getBarcodePadding=vn.getEncodingHeight=vn.getMaximumHeightOfEncodings=void 0;var n=qu(),e=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,d){return d.height+(d.displayValue&&u.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(u,d,b){if(b.displayValue&&d<u){if(b.textAlign=="center")return Math.floor((u-d)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-d)}return 0}function c(u,d,b){for(var x=0;x<u.length;x++){var v=u[x],_=(0,e.default)(d,v.options),S;_.displayValue?S=g(v.text,_,b):S=0;var C=v.data.length*_.width;v.width=Math.ceil(Math.max(S,C)),v.height=i(v,_),v.barcodePadding=o(S,C,_)}}function m(u){for(var d=0,b=0;b<u.length;b++)d+=u[b].width;return d}function p(u){for(var d=0,b=0;b<u.length;b++)u[b].height>d&&(d=u[b].height);return d}function g(u,d,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var v=x.measureText(u);if(!v)return 0;var _=v.width;return _}return vn.getMaximumHeightOfEncodings=p,vn.getEncodingHeight=i,vn.getBarcodePadding=o,vn.calculateEncodingAttributes=c,vn.getTotalWidthOfEncodings=m,vn}var D1;function CN(){if(D1)return Vc;D1=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function p(g,u){for(var d=0;d<u.length;d++){var b=u[d];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,d){return u&&p(g.prototype,u),d&&p(g,d),g}})(),e=qu(),s=o(e),i=Lv();function o(p){return p&&p.__esModule?p:{default:p}}function c(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var m=(function(){function p(g,u,d){c(this,p),this.canvas=g,this.encodings=u,this.options=d}return n(p,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var u=0;u<this.encodings.length;u++){var d=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(d,this.encodings[u]),this.drawCanvasText(d,this.encodings[u]),this.moveCanvasDrawing(this.encodings[u])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var u=this.canvas.getContext("2d");u.save(),(0,i.calculateEncodingAttributes)(this.encodings,this.options,u);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=b,u.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(u.fillStyle=this.options.background,u.fillRect(0,0,this.canvas.width,this.canvas.height)),u.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(u,d){var b=this.canvas.getContext("2d"),x=d.data,v;u.textPosition=="top"?v=u.marginTop+u.fontSize+u.textMargin:v=u.marginTop,b.fillStyle=u.lineColor;for(var _=0;_<x.length;_++){var S=_*u.width+d.barcodePadding;x[_]==="1"?b.fillRect(S,v,u.width,u.height):x[_]&&b.fillRect(S,v,u.width,u.height*x[_])}}},{key:"drawCanvasText",value:function(u,d){var b=this.canvas.getContext("2d"),x=u.fontOptions+" "+u.fontSize+"px "+u.font;if(u.displayValue){var v,_;u.textPosition=="top"?_=u.marginTop+u.fontSize-u.textMargin:_=u.height+u.textMargin+u.marginTop+u.fontSize,b.font=x,u.textAlign=="left"||d.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=d.width-1,b.textAlign="right"):(v=d.width/2,b.textAlign="center"),b.fillText(d.text,v,_)}}},{key:"moveCanvasDrawing",value:function(u){var d=this.canvas.getContext("2d");d.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),p})();return Vc.default=m,Vc}var Yc={},L1;function MN(){if(L1)return Yc;L1=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=qu(),s=o(e),i=Lv();function o(g){return g&&g.__esModule?g:{default:g}}function c(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}var m="http://www.w3.org/2000/svg",p=(function(){function g(u,d,b){c(this,g),this.svg=u,this.encodings=d,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var b=0;b<this.encodings.length;b++){var x=this.encodings[b],v=(0,s.default)(this.options,x.options),_=this.createGroup(d,v.marginTop,this.svg);this.setGroupOptions(_,v),this.drawSvgBarcode(_,v,x),this.drawSVGText(_,v,x),d+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(x,b),this.options.background&&this.drawRect(0,0,x,b,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,b,x){var v=x.data,_;b.textPosition=="top"?_=b.fontSize+b.textMargin:_=0;for(var S=0,C=0,P=0;P<v.length;P++)C=P*b.width+x.barcodePadding,v[P]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,_,b.width*S,b.height,d),S=0);S>0&&this.drawRect(C-b.width*(S-1),_,b.width*S,b.height,d)}},{key:"drawSVGText",value:function(d,b,x){var v=this.document.createElementNS(m,"text");if(b.displayValue){var _,S;v.setAttribute("font-family",b.font),v.setAttribute("font-size",b.fontSize),b.fontOptions.includes("bold")&&v.setAttribute("font-weight","bold"),b.fontOptions.includes("italic")&&v.setAttribute("font-style","italic"),b.textPosition=="top"?S=b.fontSize-b.textMargin:S=b.height+b.textMargin+b.fontSize,b.textAlign=="left"||x.barcodePadding>0?(_=0,v.setAttribute("text-anchor","start")):b.textAlign=="right"?(_=x.width-1,v.setAttribute("text-anchor","end")):(_=x.width/2,v.setAttribute("text-anchor","middle")),v.setAttribute("x",_),v.setAttribute("y",S),v.appendChild(this.document.createTextNode(x.text)),d.appendChild(v)}}},{key:"setSvgAttributes",value:function(d,b){var x=this.svg;x.setAttribute("width",d+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+d+" "+b),x.setAttribute("xmlns",m),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,b,x){var v=this.document.createElementNS(m,"g");return v.setAttribute("transform","translate("+d+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(d,b){d.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(d,b,x,v,_){var S=this.document.createElementNS(m,"rect");return S.setAttribute("x",d),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),_.appendChild(S),S}}]),g})();return Yc.default=p,Yc}var Kc={},q1;function RN(){if(q1)return Kc;q1=1,Object.defineProperty(Kc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,m){e(this,i),this.object=o,this.encodings=c,this.options=m}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Kc.default=s,Kc}var P1;function DN(){if(P1)return Gc;P1=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=CN(),e=m(n),s=MN(),i=m(s),o=RN(),c=m(o);function m(p){return p&&p.__esModule?p:{default:p}}return Gc.default={CanvasRenderer:e.default,SVGRenderer:i.default,ObjectRenderer:c.default},Gc}var Yi={},B1;function qv(){if(B1)return Yi;B1=1,Object.defineProperty(Yi,"__esModule",{value:!0});function n(m,p){if(!(m instanceof p))throw new TypeError("Cannot call a class as a function")}function e(m,p){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:m}function s(m,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);m.prototype=Object.create(p&&p.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(m,p):m.__proto__=p)}var i=(function(m){s(p,m);function p(g,u){n(this,p);var d=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return d.name="InvalidInputException",d.symbology=g,d.input=u,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return p})(Error),o=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return p})(Error),c=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return p})(Error);return Yi.InvalidInputException=i,Yi.InvalidElementException=o,Yi.NoElementException=c,Yi}var U1;function LN(){if(U1)return Ic;U1=1,Object.defineProperty(Ic,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e=TN(),s=m(e),i=DN(),o=m(i),c=qv();function m(d){return d&&d.__esModule?d:{default:d}}function p(d){if(typeof d=="string")return g(d);if(Array.isArray(d)){for(var b=[],x=0;x<d.length;x++)b.push(p(d[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return u(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,s.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,s.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":n(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(d){var b=document.querySelectorAll(d);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(p(b[v]));return x}}function u(d){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",b.toDataURL())}}}return Ic.default=p,Ic}var Jc={},z1;function qN(){if(z1)return Jc;z1=1,Object.defineProperty(Jc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){e(this,i),this.api=o}return n(i,[{key:"handleCatch",value:function(c){if(c.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw c.message;else throw c;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(c){try{var m=c.apply(void 0,arguments);return this.api._options.valid(!0),m}catch(p){return this.handleCatch(p),this.api}}}]),i})();return Jc.default=s,Jc}var hd,I1;function PN(){if(I1)return hd;I1=1;var n=jN(),e=P(n),s=qu(),i=P(s),o=kN(),c=P(o),m=NN(),p=P(m),g=LN(),u=P(g),d=Rv(),b=P(d),x=qN(),v=P(x),_=qv(),S=Dv(),C=P(S);function P(I){return I&&I.__esModule?I:{default:I}}var q=function(){},ne=function(D,X,W){var he=new q;if(typeof D>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(D),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof X<"u"&&(W=W||{},W.format||(W.format=ae()),he.options(W)[W.format](X,W).render()),he};ne.getModule=function(I){return e.default[I]};for(var te in e.default)e.default.hasOwnProperty(te)&&M(e.default,te);function M(I,D){q.prototype[D]=q.prototype[D.toUpperCase()]=q.prototype[D.toLowerCase()]=function(X,W){var he=this;return he._errorHandler.wrapBarcodeCall(function(){W.text=typeof W.text>"u"?void 0:""+W.text;var we=(0,i.default)(he._options,W);we=(0,b.default)(we);var Oe=I[D],F=U(X,Oe,we);return he._encodings.push(F),he})}}function U(I,D,X){I=""+I;var W=new D(I,X);if(!W.valid())throw new _.InvalidInputException(W.constructor.name,I);var he=W.encode();he=(0,c.default)(he);for(var we=0;we<he.length;we++)he[we].options=(0,i.default)(X,he[we].options);return he}function ae(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}q.prototype.options=function(I){return this._options=(0,i.default)(this._options,I),this},q.prototype.blank=function(I){var D=new Array(I+1).join("0");return this._encodings.push({data:D}),this},q.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var I;for(var D in this._renderProperties){I=this._renderProperties[D];var X=(0,i.default)(this._options,I.options);X.format=="auto"&&(X.format=ae()),this._errorHandler.wrapBarcodeCall(function(){var W=X.value,he=e.default[X.format.toUpperCase()],we=U(W,he,X);z(I,we,X)})}}},q.prototype.render=function(){if(!this._renderProperties)throw new _.NoElementException;if(Array.isArray(this._renderProperties))for(var I=0;I<this._renderProperties.length;I++)z(this._renderProperties[I],this._encodings,this._options);else z(this._renderProperties,this._encodings,this._options);return this},q.prototype._defaults=C.default;function z(I,D,X){D=(0,c.default)(D);for(var W=0;W<D.length;W++)D[W].options=(0,i.default)(X,D[W].options),(0,p.default)(D[W].options);(0,p.default)(X);var he=I.renderer,we=new he(I.element,D,X);we.render(),I.afterRender&&I.afterRender()}return typeof window<"u"&&(window.JsBarcode=ne),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(I,D){var X=[];return jQuery(this).each(function(){X.push(this)}),ne(X,I,D)}),hd=ne,hd}var BN=PN();const UN=uS(BN),zN={[je.EXECUTED]:"Executed",[je.MATCHED_LIST]:"Matched list",[je.CONFIRM_REQUIRED]:"Awaiting confirmation",[je.NO_MATCH_FALLBACK]:"No match",[je.UNCONFIGURED]:"Not configured",[je.INVALID_CODE]:"Invalid code",[je.FORBIDDEN]:"Not permitted",[je.CONFLICT]:"Conflict",[je.IDENTITY_PRIMED]:"Identity primed",[je.IDENTITY_UNKNOWN]:"Badge not recognized",[je.NOT_PRIMED]:"Badge required",[je.CHOICES]:"Choices presented",[je.NO_OPEN_CONTAINER]:"Container closing, scan again",[je.HELD]:"Holding",[je.REFUSED]:"Not placed",[je.SUBJECT_STALE]:"Scan it again"},IN={[je.EXECUTED]:"text-status-success",[je.MATCHED_LIST]:"text-status-success",[je.CONFIRM_REQUIRED]:"text-status-warning",[je.NO_MATCH_FALLBACK]:"text-text-secondary",[je.UNCONFIGURED]:"text-status-warning",[je.INVALID_CODE]:"text-status-error",[je.FORBIDDEN]:"text-status-error",[je.CONFLICT]:"text-status-warning",[je.IDENTITY_PRIMED]:"text-status-success",[je.IDENTITY_UNKNOWN]:"text-status-warning",[je.NOT_PRIMED]:"text-status-warning",[je.CHOICES]:"text-status-success",[je.NO_OPEN_CONTAINER]:"text-status-warning",[je.HELD]:"text-status-success",[je.REFUSED]:"text-status-error",[je.SUBJECT_STALE]:"text-status-warning"};function $N(n){return n.outcome===je.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${zN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function HN(n){var e,s,i,o,c,m,p;return n.outcome===je.NO_MATCH_FALLBACK?((e=n.fallback)==null?void 0:e.markdown)??null:n.outcome===je.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===je.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===je.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:n.outcome===je.REFUSED?((c=n.refusal)==null?void 0:c.markdown)??n.error??null:n.outcome===je.HELD?((p=(m=n.subject)==null?void 0:m.expect)==null?void 0:p.prompt)??null:n.outcome===je.SUBJECT_STALE?n.error??null:null}function gs(n){return n.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function FN({content:n,compact:e,inherit:s}){const i=[],o=/^```(\w*)\n([\s\S]*?)^```$/gm;let c=0,m;for(;(m=o.exec(n))!==null;)m.index>c&&i.push({type:"text",text:n.slice(c,m.index)}),i.push({type:"code",lang:m[1],code:m[2].replace(/\n$/,"")}),c=m.index+m[0].length;c<n.length&&i.push({type:"text",text:n.slice(c)});const p=s?{text:"",heading:"",list:"",code:"text-[0.85em]",tone:""}:e?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs",tone:"text-text-secondary"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs",tone:"text-text-secondary"},g=[];for(const u of i){if(u.type==="code"){const d=u.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");g.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${p.code} font-mono text-text-secondary leading-relaxed">${d}</code></pre>`);continue}g.push(...GN(u.text,p))}return h.jsx("div",{className:s?void 0:"prose-sm",dangerouslySetInnerHTML:{__html:g.join(`
55
+ `)}})}function GN(n,e){const s=n.split(`
56
+ `),i=[];let o=!1,c=!1,m=[];for(const p of s){const g=p.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(d=>d.trim());if(u.every(d=>/^[-:]+$/.test(d)))continue;c||(c=!0,m=[]),m.push(u);continue}if(c){c=!1;const[u,...d]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const b of u)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of d){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),m=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(g)){o&&(i.push("</ul>"),o=!1),i.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(g)){o||(i.push('<ul class="space-y-1 my-1">'),o=!0),i.push(`<li class="${e.list} ${e.tone} flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${gs(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${e.text} ${e.tone} my-1">${gs(g)}</p>`)}if(c&&m.length){const[p,...g]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of p)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const d of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(d)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Hm({result:n,compact:e=!1}){const{response:s}=n,i=e?"text-xs":"text-sm",o=s?HN(s):null,c=s!=null&&s.error&&s.error!==o?s.error:null;return h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:`${i} font-mono text-text-secondary truncate`,children:n.code}),s?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`${i} font-medium ${IN[s.outcome]}`,children:$N(s)}),c&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:c}),o&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(FN,{content:o,compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Pv(n){return n.replace(/[\u2010-\u2015\u2212]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\x00-\x1F\x7F]/g,"").trim()}function VN(n){const e=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&e.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...e]}function YN({value:n}){const e=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!e.current||!n))try{UN(e.current,n,{format:"CODE128",width:2,height:88,margin:12,displayValue:!0,fontSize:13,background:"#ffffff",lineColor:"#000000"}),i(!1)}catch{i(!0)}},[n]),n?h.jsxs("div",{children:[h.jsx("span",{className:"block text-xs uppercase tracking-wide text-text-tertiary mb-1",children:"Barcode"}),s?h.jsxs("p",{className:"text-xs text-status-error",children:["This value has characters Code 128 cannot carry:"," ",h.jsx("span",{className:"font-mono",children:VN(n).join(", ")||"unknown"})]}):h.jsx("div",{className:"bg-white rounded p-1 inline-block max-w-full overflow-hidden",children:h.jsx("svg",{ref:e,className:"max-w-full"})})]}):null}function KN({onClose:n}){const{submitCode:e,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:m,diagnosticsOn:p,setDiagnosticsOn:g}=$m(),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=_=>{_.preventDefault();const S=u.trim();S&&(d(""),e(S))};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[h.jsx(Mo,{className:"w-4 h-4"}),"Scan"]}),h.jsx("button",{type:"button",onClick:n,className:"text-text-tertiary hover:text-text-primary",title:"Close",children:h.jsx(Zt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",children:[h.jsxs("form",{onSubmit:v,className:"space-y-2",children:[h.jsx("label",{className:"block text-xs uppercase tracking-wide text-text-tertiary",children:"Enter a code"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:u,onChange:_=>d(Pv(_.target.value)),placeholder:"10:1:SN-12345",className:"flex-1 px-2 py-1.5 text-sm bg-surface-raised border border-surface-border rounded text-text-primary","data-scan-manual-entry":!0}),h.jsx("button",{type:"submit",disabled:i||!u.trim(),className:"px-3 py-1.5 text-sm rounded bg-accent text-text-inverse disabled:opacity-50",children:"Go"})]}),h.jsx("p",{className:"text-xs text-text-tertiary",children:"Scanning with a connected scanner works from any page — this entry exists for testing and for codes you can read but not scan. Typing here also draws the code below; point the scanner at the screen to fire it for real."})]}),h.jsx(YN,{value:u.trim()}),s&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs uppercase tracking-wide text-text-tertiary",children:"Last scan"}),h.jsx(Hm,{result:s})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{type:"button",onClick:()=>x(_=>!_),className:"text-xs uppercase tracking-wide text-text-tertiary hover:text-text-primary",children:["Capture settings ",b?"▾":"▸"]}),b&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block text-sm text-text-primary",children:[h.jsx("span",{className:"block text-xs text-text-tertiary mb-1",children:"Key gap limit (ms) — a longer pause between keys starts a new capture; raise it for scanners that pace slowly"}),h.jsx("input",{type:"number",min:100,max:2e3,step:50,value:o.maxKeyGapMs,onChange:_=>c({maxKeyGapMs:Number(_.target.value)}),className:"w-24 px-2 py-1 text-sm bg-surface-raised border border-surface-border rounded"})]}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-primary",children:[h.jsx("input",{type:"checkbox",checked:p,onChange:_=>g(_.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),p&&h.jsxs("div",{className:"border border-surface-border rounded",children:[h.jsx("div",{className:"px-2 py-1.5 text-2xs uppercase tracking-wide text-text-tertiary border-b border-surface-border",children:"Keydown trace — scan now, newest last"}),h.jsxs("div",{className:"max-h-64 overflow-y-auto font-mono text-2xs leading-5 px-2 py-1",children:[m.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),m.map(_=>h.jsxs("div",{className:"whitespace-nowrap overflow-hidden text-ellipsis",title:`buffer: ${_.buffer}`,children:[h.jsxs("span",{className:"text-text-tertiary",children:[String(_.deltaMs).padStart(4),"ms "]}),h.jsx("span",{className:"text",children:JSON.stringify(_.key)}),_.code&&h.jsxs("span",{className:"text-text-tertiary",children:[" (",_.code,")"]}),h.jsxs("span",{className:"text-text-tertiary",children:[" — ",_.note]})]},_.seq))]}),h.jsxs("div",{className:"px-2 py-1.5 text-2xs text-text-tertiary border-t border-surface-border",children:["Read it like this: a scan should end with an"," ",h.jsx("span",{className:"font-mono",children:'"Enter"'})," row saying"," ",h.jsx("span",{className:"font-mono",children:"capture → …"}),'. An Enter row saying "no code tail" means the buffer split (raise the gap limit, or a key arrived as something other than one character). No Enter row at all means the scanner sends no suffix — program its Enter/CR suffix. Keys named'," ",h.jsx("span",{className:"font-mono",children:'"Unidentified"'})," mean the decode arrives outside the keydown path."]})]})]})]})]})]})}const Bv=/^\{lt:([A-Za-z0-9_]+)\}$/,$1="me";function qM(n){return`{lt:${n}}`}const Uv="lt:station:link-vars:";function em(n){return`${Uv}${n}`}const tm=new Set;function JN(){for(const n of tm)n()}let wu,Qc={};function zv(n){let e=null;try{e=localStorage.getItem(em(n))}catch{e=null}if(e===wu)return Qc;wu=e;try{const s=e?JSON.parse(e):{};Qc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Qc={}}return Qc}function QN(n,e,s){const i={...zv(n)};s===null||s===""?delete i[e]:i[e]=s;try{Object.keys(i).length===0?localStorage.removeItem(em(n)):localStorage.setItem(em(n),JSON.stringify(i))}catch{}wu=void 0,JN()}function XN(n){tm.add(n);const e=s=>{(s.key===null||s.key.startsWith(Uv))&&(wu=void 0,n())};try{window.addEventListener("storage",e)}catch{}return()=>{tm.delete(n);try{window.removeEventListener("storage",e)}catch{}}}const WN={};function ZN(n){return E.useSyncExternalStore(XN,()=>n?zv(n):WN)}function eT(n,e,s,i={}){let o;try{o=new URL(n,"http://local")}catch{return n}const c=o.searchParams.get("facets");if(!c)return n;let m;try{const g=JSON.parse(c);if(!g||typeof g!="object"||Array.isArray(g))return n;m=g}catch{return n}let p=!1;for(const[g,u]of Object.entries(m)){if(typeof u!="string")continue;const d=Bv.exec(u);if(!d)continue;const b=i[d[1]]??e[d[1]]??s[d[1]];typeof b=="string"&&b!==""?m[g]=b:delete m[g],p=!0}return p?(Object.keys(m).length===0?o.searchParams.delete("facets"):o.searchParams.set("facets",JSON.stringify(m)),o.pathname+o.search):n}function PM(n){let e;try{e=new URL(n,"http://local")}catch{return[]}const s=e.searchParams.get("facets");if(!s)return[];try{const i=JSON.parse(s);if(!i||typeof i!="object"||Array.isArray(i))return[];const o=[];for(const c of Object.values(i)){if(typeof c!="string")continue;const m=Bv.exec(c);m&&!o.includes(m[1])&&o.push(m[1])}return o}catch{return[]}}function Fm(){var v;const{user:n,isSuperAdmin:e,hasRoleType:s}=qt(),i=(n==null?void 0:n.userId)??null,o=e||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(_=>_.role)),[n]),{data:m}=Mu({enabled:o||c.size>0}),p=ZN(i),g=((v=xA())==null?void 0:v.actorId)??i,u=E.useMemo(()=>{var C;const _=[],S=new Set;for(const P of(m==null?void 0:m.roles)??[]){if(!o&&!c.has(P.role))continue;const q=(C=P.properties)==null?void 0:C.link_variables;if(Array.isArray(q))for(const ne of q){const te=ne==null?void 0:ne.name;if(typeof te!="string"||te===""||te===$1||S.has(te))continue;S.add(te);const M=ne.label,U=ne.default;_.push({name:te,...typeof M=="string"&&M!==""?{label:M}:{},...typeof U=="string"&&U!==""?{default:U}:{},fromRole:P.role})}}return _},[m,c,o]),d=E.useMemo(()=>{const _={};for(const S of u)S.default!==void 0&&(_[S.name]=S.default);return _},[u]),b=E.useCallback(_=>eT(_,p,d,g?{[$1]:g}:{}),[p,d,g]),x=E.useCallback((_,S)=>{i&&QN(i,_,S)},[i]);return{declarations:u,values:p,defaults:d,resolveUrl:b,setValue:x}}function tT({open:n,onClose:e,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const m=p=>{p.key==="Escape"&&e()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,e]),n?sm.createPortal(h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:c?e:void 0}),h.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"lt-modal-title",className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${o??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[h.jsx("h2",{id:"lt-modal-title",className:"text-sm font-medium text-text-primary",children:s}),h.jsx("button",{onClick:e,"aria-label":"Close dialog",className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}function nT({open:n,onClose:e}){const{declarations:s,values:i,setValue:o}=Fm();return h.jsxs(tT,{open:n,onClose:e,title:"Link Variables",maxWidth:"max-w-lg",children:[h.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed mb-4",children:"Values bound on this device. Pinned links and the Pace Board open scoped to the value applied; an unbound variable falls back to the role's default, or applies no filter at all."}),h.jsx("div",{className:"divide-y divide-surface-border",children:s.map((c,m)=>h.jsx(rT,{declaration:c,value:i[c.name]??"",autoFocus:m===0,onChange:p=>o(c.name,p),onClear:()=>o(c.name,null),onEnter:e},c.name))}),s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary",children:"Your roles declare no link variables."}),s.length>0&&h.jsx("div",{className:"flex justify-end pt-4",children:h.jsx("button",{onClick:e,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function rT({declaration:n,value:e,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const m=E.useId(),{data:p}=rk(n.name),g=(p==null?void 0:p.values)??[];return h.jsxs("div",{className:"py-3 flex items-center gap-3","data-testid":"link-var-row",children:[h.jsxs("div",{className:"w-40 shrink-0 min-w-0",children:[h.jsx("p",{className:"text-xs font-mono text-text-primary truncate",title:n.name,children:n.name}),h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:`declared by ${n.fromRole}`,children:n.label??n.fromRole})]}),h.jsx("input",{type:"text",list:m,autoFocus:s,value:e,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:n.default?`${n.default} (default)`:"no filter","aria-label":`Value for ${n.name}`,className:"input text-xs font-mono flex-1 min-w-0"}),h.jsx("datalist",{id:m,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:e==="",title:`Clear ${n.name}`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors disabled:opacity-30 disabled:cursor-not-allowed shrink-0",children:"×"})]})}const H1=["escalationId","workflowId"],sT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Iv="lt:search:mode",iT="lt:search:facet",Lt={FACET:"facet",COMMAND:"command"};function aT(n,e){return{version:n.version,category:e.category,name:e.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function Co(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function oT(n,e){if(n.encoding==="delimited")return lT(n,e)?{code:e}:{code:`${Co(n)}${e}`};if(!/^[0-9]+$/.test(e))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&e.length!==s&&e.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${Co(n)}${e}`}}function lT(n,e){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(e)}function cT(n,e){return n==="escalationId"||n==="workflowId"?null:Qk(n,e)}function uT(n){return n.kind===Lt.FACET?n.facet:n.command.name}function fT(n){return n.kind===Lt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function hT(n){return n.kind===Lt.FACET?{kind:Lt.FACET,facet:n.facet}:{kind:Lt.COMMAND,version:n.command.version,category:n.command.category}}function dT(n,e,s){if((n==null?void 0:n.kind)===Lt.FACET&&e.includes(n.facet))return{kind:Lt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Lt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Lt.COMMAND,command:i}}return e.length>0?{kind:Lt.FACET,facet:e[0]}:s.length>0?{kind:Lt.COMMAND,command:s[0]}:null}function mT(){try{const n=localStorage.getItem(Iv);if(n){const s=JSON.parse(n);if(s.kind===Lt.FACET&&typeof s.facet=="string"||s.kind===Lt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const e=localStorage.getItem(iT);return e?{kind:Lt.FACET,facet:e}:null}catch{return null}}function pT(n){try{localStorage.setItem(Iv,JSON.stringify(n))}catch{}}const F1=5*6e4,yT=n=>({rules:n.map(e=>{var s;return((s=e.data)==null?void 0:s.rules)??null}),loading:n.some(e=>e.isLoading)});function gT(n){const e=jv({enabled:n,staleTime:F1}),s=E.useMemo(()=>{var m;return(((m=e.data)==null?void 0:m.schemes)??[]).filter(p=>p.enabled&&p.kind===Hk.ACTION).sort((p,g)=>p.version-g.version)},[e.data]),{rules:i,loading:o}=fS({queries:s.map(m=>({queryKey:["scan-schemes",m.version,"actions"],queryFn:()=>ue(`/scan-codes/schemes/${m.version}/actions`),enabled:n,staleTime:F1})),combine:yT});return{commands:E.useMemo(()=>s.flatMap((m,p)=>(i[p]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>aT(m,g))),[s,i]),loading:e.isLoading||o}}const bT={escalationId:"opens the item",workflowId:"opens the run"};function xT({mode:n,facets:e,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,m]=E.useState(!1),p=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=_=>{p.current&&!p.current.contains(_.target)&&m(!1)},v=_=>{_.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Lt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${Co(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,d=vT(s),b=x=>{i(x),m(!1)};return h.jsxs("div",{ref:p,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>m(x=>!x),"aria-expanded":c,"aria-haspopup":"listbox","aria-label":"Search or run as",title:u,className:"group flex items-center gap-1 h-full pl-2.5 pr-2 border-l border-surface-field-border hover:bg-surface-hover transition-colors rounded-r-[var(--lt-radius-field)]","data-testid":"search-mode",children:[h.jsx("span",{className:`text-2xs whitespace-nowrap truncate max-w-[9rem] ${g?"font-medium text-accent":"font-mono text-text-tertiary"}`,children:uT(n)}),h.jsx(im,{className:`w-3 h-3 shrink-0 text-text-quaternary group-hover:text-accent transition-transform ${c?"rotate-180":""}`,strokeWidth:1.5})]}),c&&h.jsxs("div",{role:"listbox","aria-label":"Search or run as",className:"absolute z-50 top-full right-0 mt-1.5 min-w-[17rem] max-w-[24rem] max-h-[70vh] overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[e.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(G1,{children:"Find"}),e.map(x=>h.jsx(V1,{label:x,mono:!0,note:bT[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Lt.FACET,facet:x})},x))]}),d.map(({schemeName:x,targetFacet:v,items:_})=>h.jsxs("div",{children:[h.jsxs(G1,{note:v,children:["Run · ",x]}),_.map(S=>h.jsx(V1,{label:S.name,note:Co(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Lt.COMMAND,command:S})},`${S.version}:${S.category}`))]},x)),o&&h.jsxs(h.Fragment,{children:[h.jsx("hr",{className:"border-surface-border/60 my-1"}),h.jsxs("button",{type:"button",onClick:()=>{m(!1),o()},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-accent hover:bg-surface-hover","data-testid":"search-mode-scan-panel",children:[h.jsx(Mo,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function vT(n){const e=[];for(const s of n){const i=e.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):e.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return e}function G1({children:n,note:e}){return h.jsxs("p",{className:"px-3 pt-2 pb-1 flex items-baseline gap-2 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:[h.jsx("span",{className:"truncate",children:n}),e&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:e})]})}function V1({label:n,note:e,active:s,mono:i,noteMono:o,onClick:c}){return h.jsxs("button",{type:"button",role:"option","aria-selected":s,onClick:c,className:`w-full text-left pl-3 pr-3 py-1.5 flex items-baseline gap-3 border-l-2 transition-colors ${s?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[h.jsx("span",{className:`text-xs font-medium truncate ${i?"font-mono":""}`,children:n}),h.jsx("span",{className:`ml-auto text-2xs shrink-0 ${o?"font-mono tabular-nums":""} ${s?"text-accent/70":"text-text-quaternary"}`,children:e})]})}const _T=6e3;function wT({onOpenScanPanel:n}){const e=ni(),{data:s}=er(),i=zm(),{submitCode:o,busy:c,lastResult:m}=$m(),{commands:p}=gT(i),[g,u]=E.useState(""),[d,b]=E.useState(!1),[x,v]=E.useState(null),[_,S]=E.useState(null),[C,P]=E.useState(""),[q,ne]=E.useState(null),[te,M]=E.useState(mT),U=E.useRef(null),ae=E.useMemo(()=>{var le;if(!((le=s==null?void 0:s.search)!=null&&le.enabled))return[];const J=(s.search.facets??[]).filter(pe=>!H1.includes(pe));return[...H1,...J]},[s]),z=E.useMemo(()=>dT(te,ae,p),[te,ae,p]),I=(m==null?void 0:m.source)===To.TOOLBAR&&!m.navigated&&q!==m.at?m:null;E.useEffect(()=>{if(!I)return;const J=setTimeout(()=>ne(I.at),_T);return()=>clearTimeout(J)},[I]);const D=()=>{v(null),S(null),m&&ne(m.at)},X=J=>{var pe;const le=hT(J);M(le),pT(le),D(),(pe=U.current)==null||pe.focus()},W=(J,le)=>{const pe=oT(J.command,Pv(le));if("error"in pe){v(pe.error);return}u(""),o(pe.code,To.TOOLBAR)},he=async(J,le)=>{const pe=cT(J,le);if(pe){u(""),e(pe);return}if(J==="escalationId"&&!sT.test(le)){v("That is not a valid escalation id");return}b(!0);try{if(J==="escalationId")await ue(`/escalations/${encodeURIComponent(le)}`),u(""),e(`/escalations/detail/${encodeURIComponent(le)}`);else{const ye=await ue(`/escalations/by-workflow/${encodeURIComponent(le)}`),Ce=(ye==null?void 0:ye.escalations)??[];Ce.length===1?(u(""),e(`/escalations/detail/${Ce[0].id}`)):(P(le),S(Ce))}}catch{v(`No ${J==="escalationId"?"escalation":"workflow"} found for "${le}"`)}finally{b(!1)}},we=()=>{const J=g.trim();!J||d||c||!z||(D(),z.kind===Lt.COMMAND?W(z,J):he(z.facet,J))};if(!z)return null;const Oe=z.kind===Lt.COMMAND,F=d||c;return h.jsxs("div",{className:"relative w-full max-w-[28rem]","data-testid":"global-search",children:[h.jsxs("div",{className:"flex items-center h-8 bg-surface-field border border-surface-field-border rounded-[var(--lt-radius-field)] focus-within:border-accent focus-within:bg-surface-field-focus transition-colors",children:[h.jsxs("label",{htmlFor:"global-search-input",className:"flex items-center gap-1.5 pl-2.5 shrink-0 cursor-text",children:[Oe?h.jsx(Mo,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(vS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),Oe&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:Co(z.command)})]}),h.jsx("input",{ref:U,id:"global-search-input",type:"text",value:g,onChange:J=>{u(J.target.value),D()},onKeyDown:J=>{J.key==="Enter"&&we(),J.key==="Escape"&&(u(""),D())},placeholder:fT(z),"aria-label":Oe?"Run target":"Global search",autoComplete:"off",spellCheck:!1,className:`flex-1 min-w-0 h-full bg-transparent text-xs text-text-primary placeholder:text-text-quaternary focus:outline-none ${Oe?"pl-0.5 pr-2 font-mono":"px-2"}`}),F&&h.jsx("span",{className:"w-1.5 h-1.5 mr-2 rounded-full bg-accent animate-pulse shrink-0","aria-label":"Working"}),h.jsx(xT,{mode:z,facets:ae,commands:p,onSelect:X,onOpenScanPanel:n})]}),x&&h.jsx("p",{className:"absolute top-full left-0 mt-1 text-2xs text-status-error whitespace-nowrap",role:"alert",children:x}),I&&h.jsx("div",{role:"status",className:"absolute top-full left-0 mt-1.5 z-50 w-full max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg px-3 py-2 animate-fade-in","data-testid":"search-run-outcome",children:h.jsx(Hm,{result:I,compact:!0})}),_!==null&&h.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 min-w-72 max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1","data-testid":"search-workflow-results",children:[_.map(J=>h.jsxs(ar,{to:`/escalations/detail/${J.id}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover truncate",children:[h.jsx("span",{className:"font-medium text-text-primary",children:J.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),J.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:J.type})]},J.id)),_.length===0&&h.jsx("p",{className:"px-3 py-1.5 text-2xs text-text-tertiary",children:"No escalations for this workflow."}),h.jsx("hr",{className:"border-surface-border/60 my-0.5"}),h.jsx(ar,{to:`/workflows/executions/${encodeURIComponent(C)}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-accent hover:bg-surface-hover",children:"Workflow execution →"})]})]})}function ST(){const{identity:n,remainingSeconds:e}=Cu(),[,s]=E.useState(0);return E.useEffect(()=>{if(!(n!=null&&n.expiresAt))return;const i=setInterval(()=>s(o=>o+1),1e3);return()=>clearInterval(i)},[n]),e()}function ET(n){return n>=60?`${Math.floor(n/60)} min`:`${n} s`}function OT(){const{identity:n}=Cu(),e=ST();return n?h.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-secondary whitespace-nowrap min-w-0",title:`Scans act as ${n.displayName}`,"data-testid":"badge-grant-indicator",children:[h.jsx(_S,{className:"w-4 h-4 text-status-success shrink-0",strokeWidth:1.5}),h.jsx("span",{className:"hidden sm:inline",children:"Badged:"}),h.jsx("span",{className:"font-medium text-text-primary truncate max-w-[10rem]",children:n.displayName}),n.expiresAt&&h.jsxs("span",{className:"tabular-nums text-text-tertiary","data-testid":"badge-grant-remaining",children:["· ",ET(e)]})]}):null}function AT(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function nm(n){var e;return((e=n.title)==null?void 0:e.trim())||AT(n.role)}const $v="lt:bookmarks",Xc="scan";function jT(){try{const n=localStorage.getItem($v);if(!n)return[];const e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function Y1(n){try{localStorage.setItem($v,JSON.stringify(n))}catch{}}function kT({onToggleEventFeed:n,onToggleDocs:e,onToggleNav:s}){var Ue,Xe,cn,Mt;const i=ni(),{user:o,logout:c,isSuperAdmin:m,hasRoleType:p}=qt(),{viewAs:g,realIsBuilder:u}=tv(),{available:d,mine:b}=uk();nv();const{connected:x}=qx(),{data:v}=er(),{role:_,targets:S,selectable:C,selectRole:P}=Cm(),{declarations:q,values:ne}=Fm(),[te,M]=E.useState(!1),{data:U}=Mu(),ae=E.useMemo(()=>{const be=(U==null?void 0:U.roles)??[],it=new Set(((o==null?void 0:o.roles)??[]).map(Ot=>Ot.role)),yt=m||p("admin");return be.filter(Ot=>ea(Ot).length>0&&(yt||it.has(Ot.role))).map(Ot=>({role:Ot.role,title:nm(Ot),portals:ea(Ot)}))},[U,o,m,p]),{setPanel:z,closePanel:I,open:D,ownerKey:X}=Lm(),W=zm(),he=en(),we=()=>{D&&X===Xc?I(Xc):z(h.jsx(KN,{onClose:()=>I(Xc)}),{width:360,key:Xc})},[Oe,F]=E.useState(!1),[J,le]=E.useState(!1),[pe,ye]=E.useState(Sv),[Ce,Ne]=E.useState(jT),Me=E.useRef(null),We=(Ue=v==null?void 0:v.branding)==null?void 0:Ue.appName,pt=(Xe=v==null?void 0:v.branding)==null?void 0:Xe.themes,Ct=E.useMemo(()=>(Ak(pt??[]),jk()),[pt]),Se=be=>{kk(be),ye(be)},Re=()=>{const be=window.prompt("Bookmark label:");if(!(be!=null&&be.trim()))return;const it=he.pathname+he.search,yt=[...Ce,{label:be.trim(),url:it}].sort((Ot,Ur)=>Ot.label.localeCompare(Ur.label));Ne(yt),Y1(yt),F(!1)},ce=be=>{const it=Ce.filter(yt=>!(yt.label===be.label&&yt.url===be.url));Ne(it),Y1(it)};return E.useEffect(()=>{if(!Oe)return;const be=it=>{Me.current&&!Me.current.contains(it.target)&&F(!1)};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[Oe]),h.jsxs(h.Fragment,{children:[h.jsxs("header",{className:`h-14 shrink-0 border-b border-surface-border bg-surface-raised flex items-center justify-between pl-2 pr-5 relative ${Oe?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s&&h.jsx("button",{onClick:s,className:"lg:hidden p-2 text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open navigation",children:h.jsx(wS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(ar,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:be=>{(be.ctrlKey||be.metaKey)&&(be.preventDefault(),le(!0))},children:h.jsx(Ru,{appName:We,className:"flex"})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>i(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(cx,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>i(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(gd,{className:"w-5 h-5",strokeWidth:2})})]}),(((cn=v==null?void 0:v.search)==null?void 0:cn.enabled)||W)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx(wT,{onOpenScanPanel:W?we:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsx(OT,{}),h.jsxs(ar,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${d>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),d>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:d})]}),h.jsxs(ar,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${b>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),b>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:b})]}),g&&h.jsx(h.Fragment,{children:h.jsxs("span",{className:"hidden lg:flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-accent/10 border border-accent/25 text-2xs text-accent select-none",children:[h.jsxs("span",{className:"capitalize font-medium tracking-wide",children:[g," View"]}),h.jsx("button",{onClick:Vd,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Zt,{className:"w-2.5 h-2.5"})})]})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),o&&h.jsxs("div",{className:"relative",ref:Me,children:[h.jsxs("button",{onClick:()=>F(be=>!be),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(SS,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),g&&h.jsx("span",{className:"lg:hidden absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"hidden lg:inline whitespace-nowrap",children:o.displayName||o.username||o.userId}),h.jsx("svg",{className:"hidden lg:block w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),Oe&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100]",children:[h.jsx(ar,{to:"/credentials",onClick:()=>F(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),((Mt=v==null?void 0:v.auth)==null?void 0:Mt.oauthServer)&&h.jsx(ar,{to:"/connected-apps",onClick:()=>F(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Connected apps"}),W&&h.jsx("button",{onClick:()=>{F(!1),we()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-scan",children:"Scan a code"}),h.jsx("button",{onClick:()=>{F(!1),x?n==null||n():window.location.reload()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:x?"Events":"Reconnect events"}),u&&h.jsx("button",{onClick:()=>{F(!1),e==null||e()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-docs",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{F(!1),Vd()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",g," view"]}),h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),h.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ct.map(be=>h.jsx("button",{type:"button",onClick:()=>Se(be.id),title:be.label,"aria-label":`${be.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${pe===be.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:be.swatch}},be.id))})]}),C&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Station queue"}),h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("button",{type:"button",onClick:()=>{F(!1),P(null),i("/")},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${_?"text-text-secondary":"text-accent"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_?"bg-surface-border":"bg-accent"}`}),h.jsx("span",{className:"truncate",children:"Full dashboard"})]}),S.map(be=>{var Ot;const it=(Ot=U==null?void 0:U.roles)==null?void 0:Ot.find(Ur=>Ur.role===be),yt=be===_;return h.jsxs("button",{type:"button",onClick:()=>{F(!1),P(be),i(hv(be,ea(it)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${yt?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${yt?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:nm({role:be,title:it==null?void 0:it.title})})]},be)})]})]}),ae.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60","data-testid":"menu-portals",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Portals"}),h.jsx("div",{className:"flex flex-col gap-1.5",children:ae.map(be=>h.jsxs("div",{children:[ae.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:be.role,children:be.title}),be.portals.map(it=>{const yt=Tm(be.role,it.key),Ot=he.pathname===yt;return h.jsxs("button",{type:"button",onClick:()=>{F(!1),i(yt)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${Ot?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${be.role}-${it.key}`,children:[h.jsx(xd,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:it.label})]},it.key)})]},be.role))})]}),q.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Link variables"}),h.jsxs("button",{type:"button",onClick:()=>{F(!1),M(!0)},className:"flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded text-text-secondary hover:bg-surface-hover","data-testid":"link-vars-menu-entry",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Object.keys(ne).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ne).length>0?Object.entries(ne).map(([be,it])=>`${be} = ${it}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{F(!1),c()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"}),h.jsxs("div",{className:"border-t border-surface-border/60 pt-1",children:[Ce.map(be=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(ar,{to:be.url,onClick:()=>F(!1),title:be.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:be.label}),h.jsx("button",{type:"button",onClick:()=>ce(be),title:`Remove "${be.label}"`,className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1 p-0.5 shrink-0 text-text-quaternary hover:text-status-error",children:h.jsx(Zt,{className:"w-3 h-3"})})]},`${be.label}::${be.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:Re,className:"flex items-center gap-1.5 w-full px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:[h.jsx(ES,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),J&&h.jsx(Ok,{onClose:()=>le(!1)}),h.jsx(nT,{open:te,onClose:()=>M(!1)})]})}function Gm({open:n,children:e}){const[s,i]=E.useState(n);return E.useEffect(()=>{n&&i(!0)},[n]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${n?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{n||i(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?e:null})})}function rm(n){return({isActive:e})=>{const s="flex items-center rounded-md transition-colors duration-150",i="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return n?`${s} justify-center w-10 h-10 mx-auto ${e?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${e?i:o}`}}function NT(){return({isActive:n})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${n?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function TT({group:n,collapsed:e}){const{pathname:s}=en(),i=n.matchPaths.some(p=>s.startsWith(p)),[o,c]=E.useState(i),m=o||i;return e?h.jsx(h.Fragment,{children:n.items.map(p=>h.jsx(Es,{to:p.to,className:rm(!0),title:p.label,children:p.icon&&h.jsx(p.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},p.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(p=>!p),className:"w-full flex items-center justify-between px-4 py-2 text-sm rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",children:[h.jsxs("span",{className:"flex items-center gap-3",children:[n.icon&&h.jsx(n.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:n.label})]}),h.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${m?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),h.jsx(Gm,{open:m,children:n.items.map(p=>h.jsxs(Es,{to:p.to,end:p.end,className:NT(),children:[p.icon&&h.jsx(p.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:p.label})]},p.to))})]})}function CT(n){return n.kind==="group"}function MT({entry:n,collapsed:e}){const{pathname:s,search:i}=en(),o=n.to.includes("?"),c=n.icon&&h.jsx(n.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${n.iconClassName??""}`,strokeWidth:1.5,...n.solid?{fill:"currentColor"}:{}});if(o){const[m,p]=n.to.split("?"),g=s===m&&i===`?${p}`,u=rm(e)({isActive:g});return h.jsxs(Es,{to:n.to,className:u,title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}return h.jsxs(Es,{to:n.to,end:n.end,className:rm(e),title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}function qr({heading:n,entries:e}){const{collapsed:s}=Rm();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:n}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:n}),e.map(i=>CT(i)?h.jsx(TT,{group:i,collapsed:s},i.label):h.jsx(MT,{entry:i,collapsed:s},i.to))]})}function RT({aiEnabled:n=!1,isBuilder:e=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1}){const c=[{to:"/pace",label:"Pace Board",icon:OS},{to:"/trends",label:"Trend Board",icon:AS}];if(!e&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(qr,{heading:"Monitor",entries:c}):null;if(!e)return h.jsx(qr,{heading:"Monitor",entries:o?c:[]});const m=[...o?c:[],{to:"/topics",label:"Event Topics",icon:ux},{to:"/agents",label:n?"Agents":"Automations",icon:jS},{to:"/capabilities",label:"Capabilities",icon:kS}];return h.jsx(qr,{heading:"Monitor",entries:m})}function DT(){return qe({queryKey:["me","preferences"],queryFn:()=>ue("/me/preferences"),staleTime:6e4})}function LT(){const n=Pe();return $e({mutationFn:e=>ue("/me/preferences",{method:"PATCH",body:JSON.stringify(e)}),onSuccess:e=>{n.setQueryData(["me","preferences"],e)}})}const xs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},K1={COMPACT:"compact",CARDS:"cards"},dd={AVAILABLE:"/escalations/available",ALL:"/escalations"},ta={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},qT={[ta.RESOLVED]:"resolved",[ta.CANCELLED]:"cancelled",[ta.EXPIRED]:"expired"};function PT(n){const e=n===ta.CLAIMED;return{available:n===ta.AVAILABLE,claimed:e,apiStatus:e?"pending":qT[n]}}function BT(n){return n===xs.TABLE||n===xs.RICH||n===xs.TIMELINE}function UT(n){return n===K1.COMPACT||n===K1.CARDS}function zT(n,e=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||e,role:n.get("role")||void 0,type:n.get("type")||void 0,subtype:n.get("subtype")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:Jk(n),view:BT(i)?i:null,layout:UT(o)?o:null}}function IT(n){let e;try{e=new URL(n,"http://local")}catch{return null}if(e.pathname!==dd.AVAILABLE&&e.pathname!==dd.ALL)return null;const s=e.pathname===dd.AVAILABLE?ta.AVAILABLE:"";return zT(e.searchParams,s)}function BM(n){var e;return n.role||(((e=n.facets.roles)==null?void 0:e.length)===1?n.facets.roles[0]:null)}function UM(n,e){return n===xs.TIMELINE?xs.TIMELINE:e&&(!n||n===xs.RICH)?xs.RICH:xs.TABLE}function $T(n,e){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(p=>p.label)),c=[...s],m=new Set;for(const{role:p,pins:g}of e)for(const u of g)o.has(u.label)||i.has(u.label)||m.has(u.label)||(m.add(u.label),c.push({...u,id:`role:${p}:${u.label}`,fromRole:p}));return c}function HT(n){const e=IT(n);if(!e)return null;const{available:s,claimed:i,apiStatus:o}=PT(e.statusFilter);return{available:s,params:{...e.facets,role:e.role,type:e.type,subtype:e.subtype,priority:e.priority,status:o,...i?{claimed:!0}:{},search:e.search}}}function FT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function GT(){var I;const{collapsed:n}=Rm(),{user:e}=qt(),s=DT(),i=LT(),o=E.useMemo(()=>new Set(((e==null?void 0:e.roles)??[]).map(D=>D.role)),[e]),{data:c}=Mu({enabled:o.size>0}),m=tn("SUMMARY");js(jm(),()=>{m([["escalations"]])});const p=(I=s.data)==null?void 0:I.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Array.isArray(D.default_pins)&&D.default_pins.length>0).map(D=>({role:D.role,pins:D.default_pins})),[c,o]),{resolveUrl:u}=Fm(),d=E.useMemo(()=>$T(p,g),[p,g]),b=E.useMemo(()=>new Map(d.map(D=>[D.id,D.url])),[d]),x=E.useMemo(()=>d.map(D=>({...D,url:u(D.url)})),[d,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(D=>[D.role,nm(D)])),[c]),_=E.useMemo(()=>x.filter(D=>!D.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Kj(D)).map(D=>D.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>S.has(D.role)||g.some(X=>X.role===D.role)).map(D=>({role:D.role,title:v.get(D.role)??D.role,portals:S.has(D.role)?ea(D):[],pins:x.filter(X=>X.fromRole===D.role)})).filter(D=>D.portals.length>0||D.pins.length>0),[c,g,S,v,x]),P=(p==null?void 0:p.pinnedViews)??[],q=E.useRef(null),ne=D=>i.mutate({pinnedViews:D}),te=D=>ne(P.filter(X=>X.id!==D)),M=D=>ne([...P,{id:FT(),label:D.label,url:b.get(D.id)??D.url,badge:D.badge}]),U=D=>i.mutate({hiddenRolePins:[...(p==null?void 0:p.hiddenRolePins)??[],D]}),ae=(D,X)=>{if(D===X)return;const W=[...P],[he]=W.splice(D,1);W.splice(X,0,he),ne(W)};if(x.length===0&&S.size===0)return null;const z="px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary truncate";return h.jsxs("div",{className:"space-y-1",children:[n&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!n&&_.length>0&&h.jsx("p",{className:z,children:"Pinned"}),_.map(D=>{const X=P.findIndex(W=>W.id===D.id);return h.jsx(J1,{pin:D,collapsed:n,draggable:X!==-1,onDragStart:()=>{q.current=X},onDropOn:()=>{q.current!==null&&X!==-1&&ae(q.current,X),q.current=null},onRemove:()=>te(D.id)},D.id)}),C.map(D=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:z,title:`${D.title} — pins from the ${D.role} role`,"data-testid":"pin-group-label",children:D.title}),D.portals.map(X=>h.jsx(VT,{role:D.role,portal:X,collapsed:n},X.key)),D.pins.map(X=>h.jsx(J1,{pin:X,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>M(X),onHide:()=>U(X.label)},X.id))]},D.role))]})}function VT({role:n,portal:e,collapsed:s}){const i=Tm(n,e.key),o="flex items-center rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",c=`portal-link-${n}-${e.key}`;return s?h.jsx(Es,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:e.label,"data-testid":c,children:h.jsx(xd,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Es,{to:i,title:e.label,className:({isActive:m})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${m?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(xd,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:e.label})]})}function J1({pin:n,collapsed:e,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:m,onHide:p}){const{pathname:g,search:u}=en(),[d,b=""]=n.url.split("?"),x=g===d&&u===(b?`?${b}`:""),v="group flex items-center rounded-md transition-colors duration-150",_=x?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return e?h.jsx(Es,{to:n.url,className:`${v} ${_} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(Mg,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${v} ${_} relative`,draggable:s,onDragStart:i,onDragOver:S=>S.preventDefault(),onDrop:o,children:[h.jsxs(Es,{to:n.url,title:n.label,className:"flex items-center gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] flex-1 min-w-0",children:[h.jsx(Mg,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...n.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:n.label}),n.badge&&h.jsx(YT,{url:n.url})]}),h.jsxs("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 rounded px-0.5 bg-surface-hover opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity",children:[m&&h.jsx("button",{onClick:m,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(fx,{className:"w-3 h-3"})}),p&&h.jsx("button",{onClick:p,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(NS,{className:"w-3 h-3"})}),c&&h.jsx("button",{onClick:c,title:`Remove "${n.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Zt,{className:"w-3 h-3"})})]})]})}function YT({url:n}){var m;const e=E.useMemo(()=>HT(n),[n]),s={limit:1,staleTime:15e3},i=yv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&e.available}),o=pv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&!e.available});if(!e)return null;const c=e.available?i:o;return c.isError||((m=c.data)==null?void 0:m.total)===void 0?null:h.jsx("span",{className:"shrink-0 text-right text-2xs leading-none tabular-nums text-accent/80 relative -top-[0.35em]",title:`${c.data.total} matching now`,children:c.data.total})}function KT(){var c;const{data:n}=er(),e=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=e===!0||e!==!1&&Wx(),i=[{to:"/workflows/registry",label:"Registry",icon:Rg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd},{to:"/workflows/executions",label:"Executions",icon:Dg}],o=s?[{kind:"group",label:"Procedural",icon:TS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:am,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:Rg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:vd},{to:"/mcp/executions",label:"Executions",icon:Dg}]}]:i;return h.jsx(qr,{heading:"Orchestrate",entries:o})}function zM(){return qe({queryKey:["activeWorkers"],queryFn:async()=>(await ue("/workflows/workers")).workers})}function IM(){return qe({queryKey:["discoveredWorkflows"],queryFn:async()=>(await ue("/workflows/discovered")).workflows})}function $M(){return qe({queryKey:["workflowConfigs"],queryFn:async()=>(await ue("/workflows/config")).workflows})}function Hv(){return qe({queryKey:["invocableWorkflows"],queryFn:async()=>(await ue("/workflows/invocable")).workflows})}function HM(n){return Object.fromEntries(n.filter(e=>!e.missing).map(e=>[e.as??e.key,e.data]))}function FM(n,e){return qe({queryKey:["workflows",n,"input-lookups"],queryFn:()=>ue(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function GM(){return qe({queryKey:["cronStatus"],queryFn:async()=>(await ue("/workflows/cron/status")).schedules})}function VM(n){return qe({queryKey:["workflowExecution",n],queryFn:()=>ue(`/workflow-states/${n}/execution`),enabled:!!n})}function YM(n,e){const s=new URLSearchParams;return n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.entity&&s.set("entity",n.entity),n.search&&s.set("search",n.search),n.status&&s.set("status",n.status),n.sort_by&&s.set("sort_by",n.sort_by),n.order&&s.set("order",n.order),n.registered&&s.set("registered",n.registered),n.namespace&&s.set("namespace",n.namespace),qe({queryKey:["jobs",n],queryFn:()=>ue(`/workflow-states/jobs?${s}`),enabled:(e==null?void 0:e.enabled)??!0})}function KM(){const n=Pe();return $e({mutationFn:e=>ue(`/workflows/${e}/terminate`,{method:"POST"}),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function JM(){const n=Pe();return $e({mutationFn:({workflow_type:e,...s})=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function QM(){const n=Pe();return $e({mutationFn:e=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function XM(){const n=Pe();return $e({mutationFn:({workflowType:e,data:s,metadata:i,execute_as:o})=>ue(`/workflows/${e}/invoke`,{method:"POST",body:JSON.stringify({data:s,metadata:i,...o?{execute_as:o}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function JT(){const{data:n}=Hv();return n!=null&&n.length?h.jsx(qr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd}]}):null}const QT=[{to:"/mcp/queries",label:"Designer",icon:CS},{to:"/mcp/servers",label:"Servers & Tools",icon:MS}];function XT(){return h.jsx(qr,{heading:"Design",entries:QT})}const WT=[{to:"/files",label:"Files",icon:RS},{to:"/knowledge",label:"Knowledge Base",icon:hx}];function ZT(){return h.jsx(qr,{heading:"Storage",entries:WT})}function eC({isBuilder:n=!1,isOps:e=!1}){var m;const{data:s}=er(),i=((m=s==null?void 0:s.features)==null?void 0:m.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:DS},...n||e?[{to:"/admin/roles",label:"Roles",icon:bd},{to:"/admin/personas",label:"Personas",icon:LS},{to:"/admin/scan-codes",label:"Scan Codes",icon:Mo}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:qS},{to:"/admin/streams",label:"Messages",icon:hx},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:PS}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(qr,{heading:"Identity & Access",entries:o}),n&&Zx()&&h.jsx(qr,{heading:"Infrastructure",entries:c})]})}function Fv({aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(RT,{aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o}),h.jsx(GT,{}),!e&&h.jsx(JT,{}),e&&h.jsx(KT,{}),e&&n&&h.jsx(XT,{}),e&&h.jsx(ZT,{}),(e||s)&&h.jsx(eC,{isBuilder:e,isOps:s})]})}function tC({open:n,onClose:e,...s}){const i=en();return E.useEffect(()=>{e()},[i.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${n?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:e,"aria-hidden":!0}),h.jsxs("div",{className:`relative w-72 max-w-[85vw] h-full bg-surface-raised border-r border-surface-border shadow-xl flex flex-col transition-transform duration-200 ease-out ${n?"translate-x-0":"-translate-x-full"}`,children:[h.jsx("div",{className:"flex items-center justify-end px-3 pt-3 shrink-0",children:h.jsx("button",{onClick:e,className:"p-1.5 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors","aria-label":"Close navigation",children:h.jsx(Zt,{className:"w-4 h-4"})})}),h.jsx("nav",{className:"flex-1 px-3 pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(ek,{children:h.jsx(Fv,{...s})})})]})]})}const Gv="lt_event_feed_patterns";function nC(n,e){if(n.startsWith("/topics/")){const m=decodeURIComponent(n.replace("/topics/",""));if(m&&!m.includes("/"))return`lt.events.${m}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const m=new URLSearchParams(e).get("role");return m?`lt.events.system.escalation.${rv(m)}.>`:"lt.events.system.escalation.>"}const i=n.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(i)return`lt.events.system.workflow.${i[1]}.>`;if(n.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=n.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(n.startsWith("/agents"))return"lt.events.system.agent.>";if(n.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(n.startsWith("/files"))return"lt.events.system.file.>";if(n==="/")return"lt.events.system.>";const c=n.match(/^\/mcp\/executions\/(.+)/);return c?`lt.events.system.*.${c[1]}.>`:(n.startsWith("/mcp"),"lt.events.system.>")}function rC(){try{const n=localStorage.getItem(Gv);return n?JSON.parse(n):[]}catch{return[]}}function md(n){try{localStorage.setItem(Gv,JSON.stringify(n))}catch{}}function sC(){const{pathname:n,search:e}=en(),[s,i]=E.useState(rC),o=E.useMemo(()=>nC(n,e),[n,e]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),m=E.useCallback(u=>{const d=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(d))return b;const x=[...b,d];return md(x),x})},[]),p=E.useCallback(u=>{i(d=>{const b=d.filter(x=>x!==u);return md(b),b})},[]),g=E.useCallback(()=>{i([]),md([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:m,removePattern:p,clearUserPatterns:g}}function iC({children:n,className:e=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${e}`,children:n})}const pd=280,Q1="cubic-bezier(0.4, 0, 0.2, 1)",Wc=40;function aC(n){if(!n)return"scale(0.92)";const e=window.innerWidth,s=window.innerHeight,i=e-Wc*2,o=s-Wc*2,c=n.width/i,m=n.height/o,p=n.left+n.width/2-(Wc+i/2),g=n.top+n.height/2-(Wc+o/2);return`translate(${p}px, ${g}px) scale(${c}, ${m})`}function Vv({open:n,onClose:e,sourceRef:s,children:i}){const[o,c]=E.useState(null),m=E.useRef(null),p=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!p.current?(m.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&p.current&&o==="open"&&(m.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),p.current=n},[n,s,o]),E.useEffect(()=>{if(o!=="entering")return;const x=requestAnimationFrame(()=>{requestAnimationFrame(()=>c("open"))});return()=>cancelAnimationFrame(x)},[o]),E.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),E.useEffect(()=>{if(!o)return;const x=v=>{v.key==="Escape"&&e()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,e]);const g=E.useCallback(x=>{x.propertyName==="transform"&&o==="exiting"&&c(null)},[o]);if(E.useEffect(()=>{if(o!=="exiting")return;const x=setTimeout(()=>c(null),pd+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",d=u?aC(m.current):"none",b=u?0:1;return sm.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${pd}ms ${Q1}, opacity ${pd}ms ${Q1}`,transform:d,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function oC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function lC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function cC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3"})})}function uC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function fC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9L3.5 3.5M9 15v4.5M9 15H4.5M9 15l-5.5 5.5M15 9h4.5M15 9V4.5M15 9l5.5-5.5M15 15h4.5M15 15v4.5m0-4.5l5.5 5.5"})})}function hC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}function dC(n){const e=n.trim().split(`
57
+ `);if(e.length<2)return n;const s=p=>p.split("|").map(g=>g.trim()).filter(Boolean),i=s(e[0]),o=e.slice(2),c=i.map(p=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${p}</th>`).join(""),m=o.map(p=>`<tr class="border-t border-surface-border">${s(p).map(d=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${d}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${c}</tr></thead><tbody>${m}</tbody></table>`}function Zc(n){return n.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function mC(n){const e=[];let s=n.replace(/```(\w*)\n([\s\S]*?)```/g,(g,u,d)=>{const b=e.length;return e.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${d}</code></pre>`),`\0CODE${b}\0`});const i=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(i,(g,u,d,b)=>dC(`${u}
58
58
  ${d}
59
- ${b.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-2xs">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,u)=>`<h4 id="${Zc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Zc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Zc(u)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${u}</h2>`).replace(/^# (.+)$/gm,(g,u)=>`<h1 id="${Zc(u)}" class="text-lg font-bold text-text-primary mb-3">${u}</h1>`),s=s.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(#([^)]+)\)/g,'<a data-anchor="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]*\.md(?:#[^)]*)?)\)/g,'<a data-doc-link="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent hover:underline">$1</a>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^- (.+)$/gm,'<li class="ml-4 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^---+$/gm,'<hr class="border-surface-border my-4" />').replace(/(?:^> (.+)$\n?)+/gm,g=>{const u=g.replace(/^> /gm,"").trim(),d=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${d?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${d?"border-status-warning":b?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${u}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(c('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,u)=>e[parseInt(u,10)]);const m="text-xs leading-relaxed text-text-secondary mb-2",p=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const u=g.trim();if(!u)return"";const d=[];let b=u,x;for(;(x=p.exec(b))!==null;){const v=x.index+x[0].length;d.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),p.lastIndex=0}return b&&d.push(b),d.map(v=>{const _=v.trim();return _?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(_)?_:`<p class="${m}">${_}</p>`:""}).join("")}).join(""),s}const hC=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function dC(n){return hC.test(n)}function Pu({content:n,className:e,onClick:s}){const i=E.useMemo(()=>fC(n),[n]);return h.jsx("div",{className:e,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function Su({data:n,depth:e=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:e>0,[c,m]=E.useState(o),[p,g]=E.useState(s);if(s!==void 0&&s!==p&&(g(s),m(s%2===0&&e>0)),n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',n,'"']});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:n.map((u,d)=>h.jsxs("div",{children:[h.jsx(Su,{data:u,depth:e+1,generation:s}),d<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof n=="object"){const u=Object.entries(n);return u.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:u.map(([d,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:d}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(Su,{data:b,depth:e+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function Eo({data:n,depth:e=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&dC(n)?h.jsx(Pu,{content:n}):h.jsx("span",{className:"text-text-primary",children:n});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:n.map((s,i)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[i+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(Eo,{data:s,depth:e+1})})]},i))});if(typeof n=="object"){const s=Object.entries(n);return s.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):h.jsx("div",{className:e>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([i,o])=>{const c=o===null||typeof o!="object";return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:i.replace(/[_-]/g," ")}),c?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(Eo,{data:o,depth:e+1})}):h.jsx(Eo,{data:o,depth:e+1})]},i)})})}return h.jsx("span",{children:String(n)})}function X1({mode:n,setMode:e,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:m,onClose:p,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",d=`${g?"p-2":"p-1.5"} rounded text-accent/60 hover:text-accent hover:bg-surface-raised transition-colors duration-150`;return h.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[n==="json"&&h.jsx("button",{onClick:i,className:d,title:s?"Expand all":"Collapse all",children:s?h.jsx(cC,{className:u}):h.jsx(lC,{className:u})}),h.jsx("button",{onClick:()=>e(n==="json"?"tree":"json"),className:d,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(sC,{className:u}):h.jsx(iC,{className:u})}),h.jsx("button",{onClick:o,className:d,title:"Copy to clipboard",children:c?h.jsx(oC,{className:`${u} text-status-success`}):h.jsx(aC,{className:u})}),m&&h.jsx("button",{onClick:m,className:d,title:"Fullscreen",children:h.jsx(dx,{className:u})}),p&&h.jsx("button",{onClick:p,className:d,title:"Close (Esc)",children:h.jsx(mx,{className:u})})]})}function mC({data:n,label:e,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[m,p]=E.useState(o??"json"),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[_,S]=E.useState(1),C=x%2===0,P=_%2===0,q=E.useCallback(()=>v(D=>D+1),[]),ne=E.useCallback(()=>S(D=>D+1),[]);let te=n;if(typeof n=="string")try{te=JSON.parse(n)}catch{}const M=async()=>{const D=typeof n=="string"?n:JSON.stringify(te,null,2);await navigator.clipboard.writeText(D),u(!0),setTimeout(()=>u(!1),2e3)},U=E.useCallback(()=>{S(1),b(!0)},[]),ae=s==="panel",z=ae?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",I=ae?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken border border-surface-border rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:z,children:[e&&h.jsx(nC,{children:e}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:C,onToggleCollapse:q,onCopy:M,copied:g,onFullscreen:U})}),h.jsx("div",{className:I,children:m==="json"?h.jsx(Su,{data:te,generation:x}):h.jsx(Eo,{data:te})})]}),h.jsxs(Vv,{open:d,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:P,onToggleCollapse:ne,onCopy:M,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:m==="json"?h.jsx(Su,{data:te,generation:_}):h.jsx(Eo,{data:te})})]})]})}const pC=100,W1=500;let yC=0;const Yv={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function Kv(n){const e=n.split(".");return e[0]==="system"&&e.length>=3?`${e[1]}.${e[e.length-1]}`:n}function Z1({event:n,forceExpanded:e=!1}){var x,v;const[s,i]=E.useState(e),o=Yv[Kv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(e)},[e]);const c=e,m=c?"text-xs":"text-2xs",p=c?"text-xs":"text-2xs",g=c?"text-xs":"text-2xs",u=c?"w-3.5 h-3.5":"w-2.5 h-2.5",d=c?"py-2 px-4":"py-1 px-3",b=c?"pb-4 px-4":"pb-2 px-3";return h.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[h.jsxs("button",{onClick:()=>i(!s),className:`flex items-center gap-2 ${d} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${m} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${p} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:n.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(x=n.data)!=null&&x.workflowId?String(n.data.workflowId):"",(v=n.data)!=null&&v.escalationId?` esc:${String(n.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${u} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),h.jsx(Gm,{open:s,children:h.jsx("div",{className:b,children:h.jsx(mC,{data:n.data})})})]})}function gC({open:n,onToggle:e,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[m,p]=E.useState(!1),[g,u]=E.useState(""),d=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(aa),{connected:v}=qx(),{patterns:_,pagePattern:S,userPatterns:C,addPattern:P,removePattern:q}=tC(),ne=E.useCallback(U=>{const ae=String(U.type||"unknown");if(ae.startsWith("mesh."))return;const z=`${ae}:${U.timestamp||""}:${U.escalationId||U.workflowId||U.taskId||""}`,I=Date.now(),D=b.current.get(z);if(!(D&&I-D<W1)){if(b.current.set(z,I),b.current.size>200)for(const[X,W]of b.current)I-W>W1*2&&b.current.delete(X);c(X=>[{id:++yC,type:ae,timestamp:U.timestamp||new Date().toISOString(),data:U},...X].slice(0,pC))}},[]),te=E.useRef(ne);te.current=ne;const M=n||m||s;return E.useEffect(()=>{if(!M)return;const U=_.map(ae=>x(ae,z=>te.current(z)));return()=>U.forEach(ae=>ae())},[x,_.join(","),M]),E.useEffect(()=>{n&&d.current&&(d.current.scrollTop=0)},[o.length,n]),h.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[h.jsxs("button",{onClick:e,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[n?h.jsx(im,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(px,{className:"w-3 h-3 text-text-tertiary"}),h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&h.jsxs("span",{className:"text-2xs text-text-tertiary",children:[o.length," events"]}),o.length>0&&!n&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Yv[Kv(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx("span",{className:`p-0.5 ${v?"text-status-success":"text-status-warning hover:text-text-primary cursor-pointer"}`,title:v?"Live events connected":"Events disconnected — click to reconnect",onClick:U=>{U.stopPropagation(),v||window.location.reload()},children:h.jsx(ux,{className:"w-3 h-3"})}),h.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:U=>{U.stopPropagation(),i()},children:h.jsx(BS,{className:"w-3 h-3"})}),o.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Fullscreen",onClick:U=>{U.stopPropagation(),p(!0)},children:h.jsx(dx,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:U=>{U.stopPropagation(),c([])},children:h.jsx(US,{className:"w-3 h-3"})})]})]})]}),s&&h.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[h.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),h.jsx("span",{className:"text-2xs font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:S.replace("lt.events.","")}),C.map(U=>h.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-mono text-text-secondary px-1.5 py-0.5 bg-surface-sunken rounded",children:[U.replace("lt.events.",""),h.jsx("button",{onClick:()=>q(U),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Zt,{className:"w-2 h-2"})})]},U))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:U=>u(U.target.value),onKeyDown:U=>{U.key==="Enter"&&g.trim()&&(P(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(P(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(fx,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Gm,{open:n,children:h.jsx("div",{ref:d,className:"h-48 overflow-y-auto",children:o.length===0?h.jsx("p",{className:"text-2xs text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map(U=>h.jsx(Z1,{event:U},U.id))})}),h.jsxs(Vv,{open:m,onClose:()=>p(!1),sourceRef:d,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>p(!1),className:"p-2 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150 bg-surface-sunken/80 backdrop-blur-sm",title:"Close (Esc)",children:h.jsx(mx,{className:"w-5 h-5"})})}),o.length===0?h.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map(U=>h.jsx(Z1,{event:U,forceExpanded:!0},U.id))]})]})}function bC(){return qe({queryKey:["docs"],queryFn:()=>ue("/docs"),staleTime:5*6e4})}function xC(n){return qe({queryKey:["docs",n],queryFn:()=>ue(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function vC(){const[n,e]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),m=E.useRef(o),p=E.useRef(n),g=E.useRef(s);m.current=o,p.current=n,g.current=s;const u=E.useCallback((_,S)=>{var P;const C=m.current;if(C){const q=((P=S==null?void 0:S.current)==null?void 0:P.scrollTop)??0;e([...p.current,{...C,scrollTop:q}])}i([]),c({path:_,scrollTop:0})},[]),d=E.useCallback(_=>{var q;const S=p.current;if(S.length===0)return;const C=S[S.length-1],P=m.current;if(P){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;i([...g.current,{...P,scrollTop:ne}])}e(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(_=>{var q;const S=g.current;if(S.length===0)return;const C=S[S.length-1],P=m.current;if(P){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;e([...p.current,{...P,scrollTop:ne}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(_=>{var P,q;const S=m.current;if(!S)return;const C=((P=_==null?void 0:_.current)==null?void 0:P.scrollTop)??0;e([...p.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0})},[]),v=E.useCallback(()=>{e([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:d,goForward:b,pushScrollPosition:x,reset:v}}function _C(n,e){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const m=((e?e.replace(/[^/]+$/,""):"")+o).split("/"),p=[];for(const g of m)g===".."?p.pop():g&&g!=="."&&p.push(g);o=p.join("/")}return{path:o,anchor:i}}function wC(n){if(!n.startsWith("#docs"))return null;const e=n.slice(1).split(":"),s=e[1]||"README.md",i=e[2]||void 0;return{path:s,anchor:i}}function SC(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function EC({content:n,currentPath:e,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const m=c.target,p=m.closest("[data-anchor]");if(p){c.preventDefault(),i();const d=p.dataset.anchor,b=(u=p.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(d)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=m.closest("[data-doc-link]");if(g){c.preventDefault();const{path:d,anchor:b}=_C(g.dataset.docLink,e);s(d,b);return}};return h.jsx(Pu,{content:n,className:"docs-content",onClick:o})}function OC(n){const e=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){e.push(i);continue}let c=s;for(let m=0;m<o.length-1;m++){const p=o[m];c.has(p)||c.set(p,{label:p,children:[],subdirs:new Map});const g=c.get(p);m===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:e,dirs:s}}function AC({docs:n,selected:e,onSelect:s}){const{topLevel:i,dirs:o}=OC(n),c=p=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${e===p?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function m(p,g){return h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[h.jsx(zS,{className:"w-3 h-3",strokeWidth:1.5}),p.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...p.subdirs.values()].map(u=>m(u)),p.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},p.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(p=>h.jsx("button",{className:c(p.path),onClick:()=>s(p.path),children:p.title},p.path)),[...o.values()].map(p=>m(p))]})}function jC({open:n,onClose:e}){var ae,z,I;const[s,i]=E.useState(!1),{data:o}=bC(),c=vC(),{data:m,isLoading:p}=xC(((ae=c.current)==null?void 0:ae.path)??null),g=E.useRef(null),[u,d]=E.useState(null);E.useEffect(()=>{u&&(m!=null&&m.content)&&g.current&&requestAnimationFrame(()=>{var X;const D=(X=g.current)==null?void 0:X.querySelector(`#${CSS.escape(u)}`);D==null||D.scrollIntoView({behavior:"smooth",block:"start"}),d(null)})},[u,m]);const b=E.useCallback(()=>{var W;const D=wC(window.location.hash),X=(D==null?void 0:D.path)??"README.md";((W=c.current)==null?void 0:W.path)!==X&&c.navigate(X,g),D!=null&&D.anchor&&d(D.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const D=SC(c.current.path);window.location.hash!==D&&window.history.replaceState(null,"",window.location.pathname+window.location.search+D)},[n,(z=c.current)==null?void 0:z.path]),E.useEffect(()=>{if(!n)return;const D=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[n,b]);const v=E.useCallback((D,X)=>{X&&d(X),c.navigate(D,g)},[c]),_=E.useCallback(D=>{c.navigate(D,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),P=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const D=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(D)}},[n]),!(n||s))return null;const ne=()=>{i(!1),setTimeout(()=>{e(),c.reset()},200)},te=((I=c.current)==null?void 0:I.path)??null,M=c.backStack.length>0,U=c.forwardStack.length>0;return h.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&n?"opacity-100":"opacity-0"}`,onClick:ne}),h.jsxs("div",{className:`relative ml-auto w-[40vw] min-w-[800px] max-w-[90vw] h-full bg-surface-raised border-l border-surface-border flex flex-col shadow-xl transition-transform duration-200 ease-out ${s&&n?"translate-x-0":"translate-x-full"}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:S,disabled:!M,className:`p-0.5 transition-colors ${M?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(cx,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!U,className:`p-0.5 transition-colors ${U?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(gd,{className:"w-4 h-4"})}),h.jsx(IS,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),h.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),h.jsx("button",{onClick:ne,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Zt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsx("div",{className:"w-48 shrink-0 border-r border-surface-border overflow-y-auto py-2",children:o!=null&&o.docs?h.jsx(AC,{docs:o.docs,selected:te,onSelect:_}):h.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),h.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:te?p?h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):m!=null&&m.content?h.jsx(EC,{content:m.content,currentPath:te,onNavigate:v,onAnchorClick:P}):h.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[h.jsx(gd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function kC(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const ex=2e3;function NC(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
59
+ ${b.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-2xs">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,u)=>`<h4 id="${Zc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Zc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Zc(u)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${u}</h2>`).replace(/^# (.+)$/gm,(g,u)=>`<h1 id="${Zc(u)}" class="text-lg font-bold text-text-primary mb-3">${u}</h1>`),s=s.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(#([^)]+)\)/g,'<a data-anchor="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]*\.md(?:#[^)]*)?)\)/g,'<a data-doc-link="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent hover:underline">$1</a>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^- (.+)$/gm,'<li class="ml-4 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^---+$/gm,'<hr class="border-surface-border my-4" />').replace(/(?:^> (.+)$\n?)+/gm,g=>{const u=g.replace(/^> /gm,"").trim(),d=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${d?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${d?"border-status-warning":b?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${u}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(c('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,u)=>e[parseInt(u,10)]);const m="text-xs leading-relaxed text-text-secondary mb-2",p=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const u=g.trim();if(!u)return"";const d=[];let b=u,x;for(;(x=p.exec(b))!==null;){const v=x.index+x[0].length;d.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),p.lastIndex=0}return b&&d.push(b),d.map(v=>{const _=v.trim();return _?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(_)?_:`<p class="${m}">${_}</p>`:""}).join("")}).join(""),s}const pC=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function yC(n){return pC.test(n)}function Pu({content:n,className:e,onClick:s}){const i=E.useMemo(()=>mC(n),[n]);return h.jsx("div",{className:e,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function Su({data:n,depth:e=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:e>0,[c,m]=E.useState(o),[p,g]=E.useState(s);if(s!==void 0&&s!==p&&(g(s),m(s%2===0&&e>0)),n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',n,'"']});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:n.map((u,d)=>h.jsxs("div",{children:[h.jsx(Su,{data:u,depth:e+1,generation:s}),d<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof n=="object"){const u=Object.entries(n);return u.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:u.map(([d,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:d}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(Su,{data:b,depth:e+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function Eo({data:n,depth:e=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&yC(n)?h.jsx(Pu,{content:n}):h.jsx("span",{className:"text-text-primary",children:n});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:n.map((s,i)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[i+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(Eo,{data:s,depth:e+1})})]},i))});if(typeof n=="object"){const s=Object.entries(n);return s.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):h.jsx("div",{className:e>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([i,o])=>{const c=o===null||typeof o!="object";return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:i.replace(/[_-]/g," ")}),c?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(Eo,{data:o,depth:e+1})}):h.jsx(Eo,{data:o,depth:e+1})]},i)})})}return h.jsx("span",{children:String(n)})}function X1({mode:n,setMode:e,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:m,onClose:p,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",d=`${g?"p-2":"p-1.5"} rounded text-accent/60 hover:text-accent hover:bg-surface-raised transition-colors duration-150`;return h.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[n==="json"&&h.jsx("button",{onClick:i,className:d,title:s?"Expand all":"Collapse all",children:s?h.jsx(hC,{className:u}):h.jsx(fC,{className:u})}),h.jsx("button",{onClick:()=>e(n==="json"?"tree":"json"),className:d,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(oC,{className:u}):h.jsx(lC,{className:u})}),h.jsx("button",{onClick:o,className:d,title:"Copy to clipboard",children:c?h.jsx(uC,{className:`${u} text-status-success`}):h.jsx(cC,{className:u})}),m&&h.jsx("button",{onClick:m,className:d,title:"Fullscreen",children:h.jsx(dx,{className:u})}),p&&h.jsx("button",{onClick:p,className:d,title:"Close (Esc)",children:h.jsx(mx,{className:u})})]})}function gC({data:n,label:e,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[m,p]=E.useState(o??"json"),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[_,S]=E.useState(1),C=x%2===0,P=_%2===0,q=E.useCallback(()=>v(D=>D+1),[]),ne=E.useCallback(()=>S(D=>D+1),[]);let te=n;if(typeof n=="string")try{te=JSON.parse(n)}catch{}const M=async()=>{const D=typeof n=="string"?n:JSON.stringify(te,null,2);await navigator.clipboard.writeText(D),u(!0),setTimeout(()=>u(!1),2e3)},U=E.useCallback(()=>{S(1),b(!0)},[]),ae=s==="panel",z=ae?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",I=ae?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken border border-surface-border rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:z,children:[e&&h.jsx(iC,{children:e}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:C,onToggleCollapse:q,onCopy:M,copied:g,onFullscreen:U})}),h.jsx("div",{className:I,children:m==="json"?h.jsx(Su,{data:te,generation:x}):h.jsx(Eo,{data:te})})]}),h.jsxs(Vv,{open:d,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:P,onToggleCollapse:ne,onCopy:M,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:m==="json"?h.jsx(Su,{data:te,generation:_}):h.jsx(Eo,{data:te})})]})]})}const bC=100,W1=500;let xC=0;const Yv={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function Kv(n){const e=n.split(".");return e[0]==="system"&&e.length>=3?`${e[1]}.${e[e.length-1]}`:n}function Z1({event:n,forceExpanded:e=!1}){var x,v;const[s,i]=E.useState(e),o=Yv[Kv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(e)},[e]);const c=e,m=c?"text-xs":"text-2xs",p=c?"text-xs":"text-2xs",g=c?"text-xs":"text-2xs",u=c?"w-3.5 h-3.5":"w-2.5 h-2.5",d=c?"py-2 px-4":"py-1 px-3",b=c?"pb-4 px-4":"pb-2 px-3";return h.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[h.jsxs("button",{onClick:()=>i(!s),className:`flex items-center gap-2 ${d} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${m} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${p} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:n.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(x=n.data)!=null&&x.workflowId?String(n.data.workflowId):"",(v=n.data)!=null&&v.escalationId?` esc:${String(n.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${u} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),h.jsx(Gm,{open:s,children:h.jsx("div",{className:b,children:h.jsx(gC,{data:n.data})})})]})}function vC({open:n,onToggle:e,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[m,p]=E.useState(!1),[g,u]=E.useState(""),d=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(aa),{connected:v}=qx(),{patterns:_,pagePattern:S,userPatterns:C,addPattern:P,removePattern:q}=sC(),ne=E.useCallback(U=>{const ae=String(U.type||"unknown");if(ae.startsWith("mesh."))return;const z=`${ae}:${U.timestamp||""}:${U.escalationId||U.workflowId||U.taskId||""}`,I=Date.now(),D=b.current.get(z);if(!(D&&I-D<W1)){if(b.current.set(z,I),b.current.size>200)for(const[X,W]of b.current)I-W>W1*2&&b.current.delete(X);c(X=>[{id:++xC,type:ae,timestamp:U.timestamp||new Date().toISOString(),data:U},...X].slice(0,bC))}},[]),te=E.useRef(ne);te.current=ne;const M=n||m||s;return E.useEffect(()=>{if(!M)return;const U=_.map(ae=>x(ae,z=>te.current(z)));return()=>U.forEach(ae=>ae())},[x,_.join(","),M]),E.useEffect(()=>{n&&d.current&&(d.current.scrollTop=0)},[o.length,n]),h.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[h.jsxs("button",{onClick:e,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[n?h.jsx(im,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(px,{className:"w-3 h-3 text-text-tertiary"}),h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&h.jsxs("span",{className:"text-2xs text-text-tertiary",children:[o.length," events"]}),o.length>0&&!n&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Yv[Kv(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx("span",{className:`p-0.5 ${v?"text-status-success":"text-status-warning hover:text-text-primary cursor-pointer"}`,title:v?"Live events connected":"Events disconnected — click to reconnect",onClick:U=>{U.stopPropagation(),v||window.location.reload()},children:h.jsx(ux,{className:"w-3 h-3"})}),h.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:U=>{U.stopPropagation(),i()},children:h.jsx(BS,{className:"w-3 h-3"})}),o.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Fullscreen",onClick:U=>{U.stopPropagation(),p(!0)},children:h.jsx(dx,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:U=>{U.stopPropagation(),c([])},children:h.jsx(US,{className:"w-3 h-3"})})]})]})]}),s&&h.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[h.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),h.jsx("span",{className:"text-2xs font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:S.replace("lt.events.","")}),C.map(U=>h.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-mono text-text-secondary px-1.5 py-0.5 bg-surface-sunken rounded",children:[U.replace("lt.events.",""),h.jsx("button",{onClick:()=>q(U),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Zt,{className:"w-2 h-2"})})]},U))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:U=>u(U.target.value),onKeyDown:U=>{U.key==="Enter"&&g.trim()&&(P(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(P(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(fx,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Gm,{open:n,children:h.jsx("div",{ref:d,className:"h-48 overflow-y-auto",children:o.length===0?h.jsx("p",{className:"text-2xs text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map(U=>h.jsx(Z1,{event:U},U.id))})}),h.jsxs(Vv,{open:m,onClose:()=>p(!1),sourceRef:d,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>p(!1),className:"p-2 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150 bg-surface-sunken/80 backdrop-blur-sm",title:"Close (Esc)",children:h.jsx(mx,{className:"w-5 h-5"})})}),o.length===0?h.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map(U=>h.jsx(Z1,{event:U,forceExpanded:!0},U.id))]})]})}function _C(){return qe({queryKey:["docs"],queryFn:()=>ue("/docs"),staleTime:5*6e4})}function wC(n){return qe({queryKey:["docs",n],queryFn:()=>ue(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function SC(){const[n,e]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),m=E.useRef(o),p=E.useRef(n),g=E.useRef(s);m.current=o,p.current=n,g.current=s;const u=E.useCallback((_,S)=>{var P;const C=m.current;if(C){const q=((P=S==null?void 0:S.current)==null?void 0:P.scrollTop)??0;e([...p.current,{...C,scrollTop:q}])}i([]),c({path:_,scrollTop:0})},[]),d=E.useCallback(_=>{var q;const S=p.current;if(S.length===0)return;const C=S[S.length-1],P=m.current;if(P){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;i([...g.current,{...P,scrollTop:ne}])}e(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(_=>{var q;const S=g.current;if(S.length===0)return;const C=S[S.length-1],P=m.current;if(P){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;e([...p.current,{...P,scrollTop:ne}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(_=>{var P,q;const S=m.current;if(!S)return;const C=((P=_==null?void 0:_.current)==null?void 0:P.scrollTop)??0;e([...p.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0})},[]),v=E.useCallback(()=>{e([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:d,goForward:b,pushScrollPosition:x,reset:v}}function EC(n,e){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const m=((e?e.replace(/[^/]+$/,""):"")+o).split("/"),p=[];for(const g of m)g===".."?p.pop():g&&g!=="."&&p.push(g);o=p.join("/")}return{path:o,anchor:i}}function OC(n){if(!n.startsWith("#docs"))return null;const e=n.slice(1).split(":"),s=e[1]||"README.md",i=e[2]||void 0;return{path:s,anchor:i}}function AC(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function jC({content:n,currentPath:e,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const m=c.target,p=m.closest("[data-anchor]");if(p){c.preventDefault(),i();const d=p.dataset.anchor,b=(u=p.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(d)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=m.closest("[data-doc-link]");if(g){c.preventDefault();const{path:d,anchor:b}=EC(g.dataset.docLink,e);s(d,b);return}};return h.jsx(Pu,{content:n,className:"docs-content",onClick:o})}function kC(n){const e=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){e.push(i);continue}let c=s;for(let m=0;m<o.length-1;m++){const p=o[m];c.has(p)||c.set(p,{label:p,children:[],subdirs:new Map});const g=c.get(p);m===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:e,dirs:s}}function NC({docs:n,selected:e,onSelect:s}){const{topLevel:i,dirs:o}=kC(n),c=p=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${e===p?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function m(p,g){return h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[h.jsx(zS,{className:"w-3 h-3",strokeWidth:1.5}),p.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...p.subdirs.values()].map(u=>m(u)),p.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},p.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(p=>h.jsx("button",{className:c(p.path),onClick:()=>s(p.path),children:p.title},p.path)),[...o.values()].map(p=>m(p))]})}function TC({open:n,onClose:e}){var ae,z,I;const[s,i]=E.useState(!1),{data:o}=_C(),c=SC(),{data:m,isLoading:p}=wC(((ae=c.current)==null?void 0:ae.path)??null),g=E.useRef(null),[u,d]=E.useState(null);E.useEffect(()=>{u&&(m!=null&&m.content)&&g.current&&requestAnimationFrame(()=>{var X;const D=(X=g.current)==null?void 0:X.querySelector(`#${CSS.escape(u)}`);D==null||D.scrollIntoView({behavior:"smooth",block:"start"}),d(null)})},[u,m]);const b=E.useCallback(()=>{var W;const D=OC(window.location.hash),X=(D==null?void 0:D.path)??"README.md";((W=c.current)==null?void 0:W.path)!==X&&c.navigate(X,g),D!=null&&D.anchor&&d(D.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const D=AC(c.current.path);window.location.hash!==D&&window.history.replaceState(null,"",window.location.pathname+window.location.search+D)},[n,(z=c.current)==null?void 0:z.path]),E.useEffect(()=>{if(!n)return;const D=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[n,b]);const v=E.useCallback((D,X)=>{X&&d(X),c.navigate(D,g)},[c]),_=E.useCallback(D=>{c.navigate(D,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),P=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const D=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(D)}},[n]),!(n||s))return null;const ne=()=>{i(!1),setTimeout(()=>{e(),c.reset()},200)},te=((I=c.current)==null?void 0:I.path)??null,M=c.backStack.length>0,U=c.forwardStack.length>0;return h.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&n?"opacity-100":"opacity-0"}`,onClick:ne}),h.jsxs("div",{className:`relative ml-auto w-[40vw] min-w-[800px] max-w-[90vw] h-full bg-surface-raised border-l border-surface-border flex flex-col shadow-xl transition-transform duration-200 ease-out ${s&&n?"translate-x-0":"translate-x-full"}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:S,disabled:!M,className:`p-0.5 transition-colors ${M?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(cx,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!U,className:`p-0.5 transition-colors ${U?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(gd,{className:"w-4 h-4"})}),h.jsx(IS,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),h.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),h.jsx("button",{onClick:ne,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Zt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsx("div",{className:"w-48 shrink-0 border-r border-surface-border overflow-y-auto py-2",children:o!=null&&o.docs?h.jsx(NC,{docs:o.docs,selected:te,onSelect:_}):h.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),h.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:te?p?h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):m!=null&&m.content?h.jsx(jC,{content:m.content,currentPath:te,onNavigate:v,onAnchorClick:P}):h.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[h.jsx(gd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function CC(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const ex=2e3;function MC(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
60
60
  ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
61
61
  `)}
62
62
  [End prior conversation]
63
63
 
64
- `}function TC(n){const e=n.summary,s=n.title;if(e){const i=e.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?e.slice(0,i).trim():e}return s||(typeof n=="string"?n:"Query completed.")}const Jv=E.createContext(null);function CC({children:n}){const e=en(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[m,p]=E.useState(null),[g,u]=E.useState({}),d=E.useRef(null),b={page:e.pathname.split("/").filter(Boolean).join("-")||"home",route:e.pathname,params:{},...g,suggestedTags:g.suggestedTags??kC(e.pathname)};E.useEffect(()=>()=>{d.current&&clearInterval(d.current)},[]);const x=E.useCallback(()=>i(P=>!P),[]),v=E.useCallback(P=>{u(P)},[]),_=E.useCallback(()=>{c([]),p(null)},[]),S=E.useCallback(async P=>{var z;const q=new Date().toISOString(),ne={id:`user-${Date.now()}`,role:"user",content:P,timestamp:q},te={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:q,pending:!0};c(I=>[...I,ne,te]);const M={...b};(z=M.entities)!=null&&z.yamlContent&&M.entities.yamlContent.length>ex&&(M.entities={...M.entities,yamlContent:M.entities.yamlContent.slice(0,ex)+`
65
- ... (truncated)`});const ae=`${NC(o.concat(ne))}${P}`;try{const D=(await ue("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ae,tags:M.suggestedTags,context:M,wait:!1,direct:!0})})).workflow_id;p(D),c(X=>X.map(W=>W.id===te.id?{...W,workflowId:D}:W)),d.current&&clearInterval(d.current),d.current=setInterval(async()=>{var X;try{const W=await ue(`/workflows/${D}/result`),he=(X=W==null?void 0:W.result)==null?void 0:X.data;if(he){d.current&&clearInterval(d.current),d.current=null,p(null);const we=TC(he);let Oe;try{Oe=(await ue(`/workflow-states/${D}/execution`)).duration_ms}catch{}c(F=>F.map(J=>J.id===te.id?{...J,content:we,timestamp:new Date().toISOString(),pending:!1,durationMs:Oe}:J))}}catch{}},3e3)}catch{c(I=>I.map(D=>D.id===te.id?{...D,content:"Failed to submit query. Please try again.",pending:!1}:D))}},[o,b]),C=E.useCallback(async P=>{const q=o.find(M=>M.id===P);if(!(q!=null&&q.workflowId)||q.compilationStatus==="compiling"||q.compilationStatus==="done")return;const ne=o.indexOf(q),te=o.slice(0,ne).reverse().find(M=>M.role==="user");if(te){c(M=>M.map(U=>U.id===P?{...U,compilationStatus:"compiling"}:U));try{const M=await ue("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:te.content,summary:q.content})}),U=await ue("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:q.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:M.tool_name,description:M.description,tags:M.tags,app_id:""})});await ue(`/yaml-workflows/${U.id}/deploy`,{method:"POST"}),c(ae=>ae.map(z=>z.id===P?{...z,compilationStatus:"done"}:z))}catch(M){const U=M instanceof Error?M.message:"Compilation failed";c(ae=>ae.map(z=>z.id===P?{...z,compilationStatus:"error",compilationError:U}:z))}}},[o]);return h.jsx(Jv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:m,clearMessages:_,compileMessage:C},children:n})}function Qv(){const n=E.useContext(Jv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function MC(){const{helpOpen:n,toggleHelp:e}=Qv();return h.jsx("button",{onClick:e,className:"fixed right-3 z-[45] flex items-center justify-center w-10 h-10 rounded-full bg-surface-raised shadow-lg hover:scale-110 transition-transform duration-150 border border-accent/30",style:{bottom:"44px"},"aria-label":n?"Close help":"Ask for help",children:n?h.jsx(Zt,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):h.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Vt}/logo512.png)`}})})}function RC({ms:n,className:e=""}){const s=yk(n),i=E.useMemo(()=>n==null?[]:[{label:"ms",value:String(n)},{label:"sec",value:`${(n/1e3).toFixed(3)}s`},{label:"text",value:s}],[n,s]);return n==null?h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:"--"}):h.jsx(bv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:s})})}const DC=["sm","md","lg","full"],tx={sm:"w-[28rem] max-h-[40vh]",md:"w-[36rem] max-h-[60vh]",lg:"w-[48rem] max-h-[80vh]",full:"inset-4 w-auto max-h-none"},nx={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function LC({which:n}){const e="stroke-current";switch(n){case"sm":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:e,strokeWidth:"1.5"})});case"md":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:e,strokeWidth:"1.5"})});case"lg":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:e,strokeWidth:"1.5"})});case"full":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:e,strokeWidth:"1.5"})})}}function qC({msg:n}){const[e,s]=E.useState(0);E.useEffect(()=>{const m=new Date(n.timestamp).getTime(),p=()=>s(Math.floor((Date.now()-m)/1e3));p();const g=setInterval(p,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(e/60),o=e%60,c=i>0?`${i}m ${o}s`:`${o}s`;return h.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),h.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:c})]}),n.workflowId&&h.jsxs(ar,{to:`/workflows/executions/${n.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function PC({msg:n,compileMessage:e}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(xv,{date:n.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),n.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(RC,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(ar,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>e(n.id),disabled:n.compilationStatus==="compiling"||n.compilationStatus==="done",className:"transition-colors",title:n.compilationStatus==="done"?"Compiled — future queries will match this pipeline":n.compilationStatus==="error"?n.compilationError??"Compilation failed":n.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx($S,{className:`w-2.5 h-2.5 ${n.compilationStatus==="done"?"text-status-success":n.compilationStatus==="error"?"text-status-error":n.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function BC(){const{helpOpen:n,setHelpOpen:e,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:m,compileMessage:p}=Qv(),[g,u]=E.useState(""),[d,b]=E.useState("md"),[x,v]=E.useState(!0),_=E.useRef(null),S=E.useRef(null);if(E.useEffect(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[s]),E.useEffect(()=>{n&&S.current&&S.current.focus()},[n]),E.useEffect(()=>{if(!n)return;const M=U=>{U.key==="Escape"&&(d==="full"?b("lg"):d==="lg"?b("md"):d==="md"?b("sm"):e(!1))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n,d,e]),!n)return null;const C=()=>{const M=g.trim();!M||c||(i(M),u(""),S.current&&(S.current.style.height="auto"))},P=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),C())},q=d==="full",ne=o.page.replace(/-/g," "),te=q?{}:{bottom:"108px"};return h.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${q?tx.full:`right-6 ${tx[d]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:te,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[h.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),h.jsx("p",{className:"text-2xs text-text-tertiary truncate",children:ne})]}),h.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[h.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:DC.map(M=>h.jsx("button",{onClick:()=>b(M),className:`p-1 rounded transition-colors ${M===d?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":M===d,"aria-label":nx[M],title:nx[M],children:h.jsx(LC,{which:M})},M))}),s.length>0&&h.jsx("button",{onClick:m,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(HS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>e(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:_,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(M=>h.jsxs("div",{className:`text-xs leading-relaxed ${M.role==="user"?"text-right":"text-left"}`,children:[h.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${M.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:M.pending?h.jsx(qC,{msg:M}):M.role==="assistant"?h.jsx(Pu,{content:M.content}):M.content}),!M.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(PC,{msg:M,compileMessage:p})})]},M.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:S,value:g,onChange:M=>{u(M.target.value);const U=M.target;U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,120)}px`},onKeyDown:P,placeholder:"Ask a question...",rows:2,className:"flex-1 resize-none bg-surface text-xs text-text-primary placeholder:text-text-tertiary rounded px-2.5 py-1.5 border border-surface-border focus:outline-none focus:border-accent",style:{minHeight:"2.5rem"},disabled:!!c}),h.jsx("button",{onClick:C,disabled:!g.trim()||!!c,className:"px-2.5 py-1.5 text-accent hover:text-accent-hover disabled:text-text-muted transition-colors self-end","aria-label":"Send",children:h.jsx(FS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const UC=6e3,zC="scan";function IC(){const{lastResult:n}=$m(),{open:e,ownerKey:s}=Lm(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),UC);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||e&&s===zC||n.source===To.TOOLBAR?null:h.jsx("div",{role:"status",className:"fixed bottom-14 right-4 z-[60] w-80 max-w-[calc(100vw-2rem)] bg-surface-raised border border-surface-border shadow-lg rounded-md animate-page-in",children:h.jsxs("div",{className:"flex items-start gap-2.5 px-3.5 py-3",children:[h.jsx(Mo,{className:"w-4 h-4 mt-0.5 text-accent-muted shrink-0",strokeWidth:1.5}),h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx(Hm,{result:n})}),h.jsx("button",{type:"button",onClick:()=>o(n.at),className:"text-text-tertiary hover:text-text-primary shrink-0",title:"Dismiss",children:h.jsx(Zt,{className:"w-3.5 h-3.5"})})]})})}const Xv="lt-announcement-dismissed:",$C="Live updates unavailable. Reconnecting… Refresh if this persists.";function HC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function FC(n){try{return localStorage.getItem(`${Xv}${n}`)==="1"}catch{return!1}}function GC(){const{isAuthenticated:n,userRoleNames:e}=qt(),{data:s}=gv(n),i=Pe(),[o,c]=E.useState(null),[m,p]=E.useState(0),{unavailable:g}=dO();An(hk,()=>{i.invalidateQueries({queryKey:["announcements"]})});const u=Date.now(),d=((s==null?void 0:s.announcements)??[]).filter(x=>!FC(x.id)&&new Date(x.expires_at).getTime()>u&&(x.roles.length===0||x.roles.some(v=>e.includes(v))));if(E.useEffect(()=>{const x=((s==null?void 0:s.announcements)??[]).map(_=>new Date(_.expires_at).getTime()-Date.now()).filter(_=>_>0);if(x.length===0)return;const v=setTimeout(()=>p(_=>_+1),Math.min(...x)+250);return()=>clearTimeout(v)},[s,m]),d.length===0&&!g)return null;const b=x=>{try{localStorage.setItem(`${Xv}${x}`,"1")}catch{}p(v=>v+1)};return h.jsxs("div",{"data-testid":"announcement-banner",className:"relative z-40",children:[g&&h.jsx("div",{"data-testid":"live-updates-notice",role:"status",className:"border-b border-status-warning/25 bg-status-warning/10",children:h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-status-warning",children:"Notice"}),h.jsx("span",{className:"truncate text-xs text-text-primary",children:$C})]})}),d.map(x=>{const v=o===x.id,_=x.title??x.body.split(`
66
- `)[0];return h.jsxs("div",{className:"border-b border-accent/25 bg-accent/10",children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-accent",children:"Notice"}),h.jsxs("button",{type:"button",onClick:()=>c(v?null:x.id),className:"flex items-center gap-1.5 text-xs text-text-primary hover:text-accent transition-colors min-w-0",children:[h.jsx("span",{className:"truncate",children:_}),v?h.jsx(px,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(im,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>b(x.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${_}`,children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),v&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Pu,{content:HC(x.body)})})]},x.id)})]})}function VC(){var U,ae;const{isBuilder:n,isOps:e,viewAs:s}=tv(),{canSeePaceBoard:i}=nv();SA();const{data:o}=er();Dj((U=o==null?void 0:o.display)==null?void 0:U.timeZone);const c=Xx(),m=c!==null?c:!!((ae=o==null?void 0:o.ai)!=null&&ae.enabled),{collapsed:p,toggle:g}=Rm(),[u,d]=E.useState(!1),[b,x]=E.useState(!1),[v,_]=E.useState(!1),[S,C]=E.useState(()=>window.location.hash.startsWith("#docs")),P=en(),q=E.useRef(null),{kiosk:ne,homePath:te}=Cm(),M=ne||Yj(P.pathname);return E.useEffect(()=>{const z=q.current;z&&(z.classList.remove("animate-page-in"),z.offsetWidth,z.classList.add("animate-page-in"))},[P.pathname]),E.useEffect(()=>{const z=()=>{window.location.hash.startsWith("#docs")&&C(!0)};return window.addEventListener("hashchange",z),()=>window.removeEventListener("hashchange",z)},[]),ne&&te&&!Xj(P.pathname,P.search)?h.jsx(Sn,{to:te,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(OT,{onToggleEventFeed:()=>d(z=>!z),onToggleDocs:()=>C(z=>!z),onToggleNav:M?void 0:()=>x(z=>!z)}),h.jsx(GC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!M&&h.jsxs("aside",{className:`${p?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border hidden lg:flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[h.jsx("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(Fv,{aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i})}),h.jsx("button",{onClick:g,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${p?"flex justify-center":"flex items-center px-7"}`,"aria-label":p?"Expand sidebar":"Collapse sidebar",children:p?h.jsx(GS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(VS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!p&&(o==null?void 0:o.environment)&&h.jsxs("div",{className:"shrink-0 px-5 pb-3 text-2xs leading-tight text-text-tertiary whitespace-nowrap overflow-hidden text-ellipsis",title:`long-tail v${o.environment.longTailVersion} · HotMesh v${o.environment.hotmeshVersion} · Node ${o.environment.nodeVersion} · ${o.environment.nodeEnv}`,children:["long-tail v",o.environment.longTailVersion,h.jsx("span",{className:"mx-1 text-surface-border",children:"·"}),"HotMesh v",o.environment.hotmeshVersion]})]}),h.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto",children:h.jsx("div",{ref:q,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(ei,{})})}),h.jsx(YC,{})]}),!M&&h.jsx(WT,{open:b,onClose:()=>x(!1),aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i}),h.jsx(gC,{open:u,onToggle:()=>d(z=>!z),configOpen:v,onToggleConfig:()=>_(z=>!z)}),h.jsx(jC,{open:S,onClose:()=>{C(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),m&&h.jsx(MC,{}),m&&h.jsx(BC,{}),h.jsx(IC,{})]})}function YC(){const{node:n,width:e,open:s}=Lm();return h.jsx(nk,{open:s,width:e,className:"border-l border-surface-border bg-surface-raised",children:n})}function KC(){const{isAuthenticated:n}=qt(),e=en();return n?h.jsx(Zj,{children:h.jsx(tk,{children:h.jsx(CC,{children:h.jsx(vA,{children:h.jsx(Qk,{children:h.jsx(VC,{})})})})})}):h.jsx(Sn,{to:"/login",state:{from:e.pathname},replace:!0})}function Wv({provider:n,className:e="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),h.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),h.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),h.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]});case"github":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})});case"microsoft":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),h.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),h.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),h.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M13.827 3.52h3.603L24 20.48h-3.603l-6.57-16.96zm-7.258 0h3.767L16.906 20.48h-3.674l-1.343-3.461H6.396l-1.34 3.461H1.5l5.07-16.96zm2.327 5.14l-2.065 5.326h4.108l-2.043-5.326z"})});default:return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M12 8v4l3 3"})]})}}async function JC(){return ue("/auth/oauth/providers")}async function QC(n,e){const s=e?`?label=${encodeURIComponent(e)}`:"";return ue(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function JM(){return qe({queryKey:["oauth-connections"],queryFn:()=>ue("/auth/oauth/connections")})}function QM(){const n=Pe();return $e({mutationFn:({provider:e,label:s})=>QC(e,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function XC(){var ae;const{login:n,isAuthenticated:e}=qt(),s=ni(),i=en(),o=new URLSearchParams(i.search),c=o.get("token"),m=o.get("error"),p=((ae=i.state)==null?void 0:ae.from)??o.get("returnTo")??"/",g=E.useRef(!1);c&&!g.current&&(g.current=!0,n(c,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[u,d]=E.useState(""),[b,x]=E.useState(""),[v,_]=E.useState(m||""),[S,C]=E.useState(!1),[P,q]=E.useState(!!c),[ne,te]=E.useState([]),M=E.useRef(!1);if(E.useEffect(()=>{c||M.current||(M.current=!0,(async()=>{var z,I,D,X;try{const W=await lm().catch(()=>null);if(!((z=W==null?void 0:W.auth)!=null&&z.sso))return;const he=await fetch(`${Vt}/api/auth/sso`,{method:"POST"});if(!he.ok){_("Host authentication required — please log in to your organization first");return}const we=await he.json();we.token&&((I=W.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",W.auth.ssoLogoutUrl),q(!0),n(we.token,void 0,{displayName:(D=we.user)==null?void 0:D.display_name,username:(X=we.user)==null?void 0:X.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||JC().then(te).catch(()=>{})},[]),E.useEffect(()=>{if(!P)return;const z=setTimeout(()=>s(p,{replace:!0}),1500);return()=>clearTimeout(z)},[P]),e&&!P)return h.jsx(Sn,{to:p,replace:!0});const U=async z=>{var I,D;if(z.preventDefault(),_(""),!u.trim()||!b){_("Username and password are required");return}C(!0);try{const X=await fetch(`${Vt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),W=await X.json();if(!X.ok){_(W.error||"Login failed");return}q(!0),n(W.token,{username:u.trim(),password:b},{displayName:(I=W.user)==null?void 0:I.display_name,username:(D=W.user)==null?void 0:D.external_id})}catch{_("Unable to connect to server")}finally{C(!1)}};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${P?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Ru,{size:"lg",hideLabel:P})}),h.jsxs("form",{onSubmit:U,className:`space-y-5 transition-opacity duration-300 ${P?"opacity-0":""}`,children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),h.jsx("input",{id:"username",type:"text",value:u,onChange:z=>d(z.target.value),className:"input",placeholder:"Enter your username",autoFocus:!P,autoComplete:"username"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:b,onChange:z=>x(z.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),v&&h.jsx("p",{className:"text-sm text-status-error",children:v}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:S||P,children:S?"Signing in...":"Sign In"}),ne.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[h.jsx("div",{className:"flex-1 h-px bg-border"}),h.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),h.jsx("div",{className:"flex-1 h-px bg-border"})]}),h.jsx("div",{className:"space-y-2",children:ne.filter(z=>z.provider!=="anthropic").map(z=>h.jsxs("a",{href:`${Vt}/api/auth/oauth/${z.provider}?returnTo=${encodeURIComponent(p)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Wv,{provider:z.provider}),"Sign in with ",z.name]},z.provider))})]})]})]})})}function rx(){const{isAuthenticated:n}=qt(),e=ni(),s=en(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||e(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,m]=E.useState(""),[p,g]=E.useState(i.get("label")||"default"),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=c.trim().startsWith("sk-ant-oat"),_=c.trim().startsWith("sk-ant-api"),S=C=>{C.preventDefault();const P=c.trim();if(!P){d("A token or API key is required");return}if(!P.startsWith("sk-ant-")){d('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),d("");const q=`${Vt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(P)}&state=${encodeURIComponent(o)}`;window.location.href=q};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Wv,{provider:"anthropic",className:"w-6 h-6"}),h.jsx("h2",{className:"heading-3",children:"Connect Anthropic"})]}),h.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Connect your Anthropic account so Claude Code tasks run under your credentials. Your token is encrypted at rest."}),h.jsxs("form",{onSubmit:S,className:"space-y-5",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),h.jsx("input",{id:"token",type:"password",value:c,onChange:C=>m(C.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),v&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),_&&h.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),h.jsx("input",{id:"label",type:"text",value:p,onChange:C=>g(C.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),h.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:'A name for this credential. Use different labels to store multiple credentials (e.g., "subscription", "api-batch").'})]}),u&&h.jsx("p",{className:"text-sm text-status-error",children:u}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:b,children:b?"Validating...":"Connect"}),h.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),h.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",h.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-2xs",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",h.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent-secondary hover:underline",children:"console.anthropic.com"})," ","(billed per-token)."]})]})]})})}function WC({items:n,columns:e=1}){if(n.length===0)return null;const s=e>=2&&n.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return h.jsx("div",{className:"@container",children:h.jsx("dl",{className:`grid ${s} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:n.map(({key:i,label:o,value:c})=>h.jsxs(E.Fragment,{children:[h.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:o}),h.jsx("dd",{className:"text-sm text-text-primary break-words whitespace-pre-wrap min-w-0","data-field-key":i,children:ZC(c)})]},i))})})}function ZC(n){return n==null||n===""?"—":typeof n=="boolean"?n?"Yes":"No":typeof n=="object"?JSON.stringify(n):String(n)}function e3(n){return qe({queryKey:["oauth-client",n],queryFn:()=>ue(`/oauth/clients/${encodeURIComponent(n)}`),enabled:!!n,retry:!1})}function t3(n){return qe({queryKey:["oauth-presets"],queryFn:()=>ue("/oauth/presets"),enabled:n})}function n3(){return $e({mutationFn:n=>ue(n.preset?"/oauth/authorize":"/oauth/deny",{method:"POST",body:JSON.stringify(n.preset?{...n.request,preset:n.preset}:n.request)})})}function XM(){return qe({queryKey:["oauth-grants"],queryFn:()=>ue("/oauth/grants")})}function WM(){const n=Pe();return $e({mutationFn:e=>ue(`/oauth/grants/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["oauth-grants"]})})}const r3=["client_id","redirect_uri","code_challenge","code_challenge_method","response_type","state","scope","resource"],yd={read_only:{action:"Allow read-only",effect:"Reads what you can read and runs workflows marked read-safe."},just_me:{action:"Allow as me",effect:"Acts with your full rights: claims, resolves, invokes, and administers wherever you may."}};function s3(n){const e=new URLSearchParams(n),s=r3.map(o=>[o,e.get(o)??void 0]),i=Object.fromEntries(s);return!i.client_id||!i.redirect_uri||!i.code_challenge?null:i}function i3(n){try{return new URL(n).host}catch{return n}}function a3(){var b,x,v;const{isAuthenticated:n,user:e}=qt(),s=ni(),i=en(),o=E.useMemo(()=>s3(i.search),[i.search]);E.useEffect(()=>{n||s(`/login?returnTo=${encodeURIComponent(i.pathname+i.search)}`,{replace:!0})},[n]);const c=e3(n&&o?o.client_id:null),m=t3(n&&!!o),p=n3(),g=_=>{o&&p.mutate({request:o,preset:_},{onSuccess:({redirect:S})=>window.location.assign(S)})};if(!n)return null;const u=!o||c.isError,d=((b=c.data)==null?void 0:b.client_name)||"An app";return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-lg p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),u?h.jsxs("div",{role:"alert",children:[h.jsx("h2",{className:"heading-3 mb-3",children:"Sign-in link not valid"}),h.jsx("p",{className:"text-sm text-text-secondary",children:"Start the connection again from the app."})]}):h.jsxs(h.Fragment,{children:[h.jsxs("h2",{className:"heading-2 mb-2",children:["Connect ",d]}),h.jsxs("p",{className:"text-sm text-text-secondary mb-6",children:["Pick how much ",d," may do as you. Disconnect it any time under Connected apps."]}),h.jsx("div",{className:"mb-8",children:h.jsx(WC,{items:[{key:"app",label:"App",value:d},{key:"account",label:"Account",value:(e==null?void 0:e.displayName)||(e==null?void 0:e.username)||(e==null?void 0:e.userId)||null},{key:"returns-to",label:"Returns to",value:i3(o.redirect_uri)},{key:"deployment",label:"Deployment",value:window.location.host}]})}),h.jsx("dl",{className:"space-y-3 mb-8",children:(((x=m.data)==null?void 0:x.presets)??[]).map(_=>h.jsxs("div",{children:[h.jsx("dt",{className:"text-sm font-medium text-text-primary",children:yd[_].action}),h.jsx("dd",{className:"text-sm text-text-secondary",children:yd[_].effect})]},_))}),p.isError&&h.jsx("p",{className:"text-sm text-status-error mb-4",role:"alert",children:p.error.message}),h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[(((v=m.data)==null?void 0:v.presets)??[]).map(_=>h.jsx("button",{type:"button",className:_==="read_only"?"btn-primary":"btn-secondary",disabled:p.isPending||c.isLoading,onClick:()=>g(_),children:yd[_].action},_)),h.jsx("button",{type:"button",className:"btn-ghost",disabled:p.isPending,onClick:()=>g(null),children:"Deny"})]})]})]})})}function po({roleTypes:n,roleNames:e,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=qt();return i?h.jsx(ei,{}):n&&n.some(m=>c(m))?h.jsx(ei,{}):e&&e.some(m=>o(m))?h.jsx(ei,{}):h.jsx(Sn,{to:s,replace:!0})}function o3(){const{data:n,isSuccess:e}=Hv();return e&&n.length===0?h.jsx(Sn,{to:"/",replace:!0}):h.jsx(ei,{})}function l3({redirectTo:n="/"}){var i;const{data:e,isLoading:s}=er();return s||!e?null:(i=e.ai)!=null&&i.enabled?h.jsx(ei,{}):h.jsx(Sn,{to:n,replace:!0})}function c3({flag:n,redirectTo:e="/"}){var o;const{data:s,isLoading:i}=er();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(Sn,{to:e,replace:!0}):h.jsx(ei,{})}const u3=E.lazy(()=>ke(()=>import("./ProcessesListPage-DO5A-OfZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url).then(n=>({default:n.ProcessesListPage}))),f3=E.lazy(()=>ke(()=>import("./ProcessDetailPage-BdkacBrD.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),h3=E.lazy(()=>ke(()=>import("./McpOverview-H61XQRji.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),d3=E.lazy(()=>ke(()=>import("./McpRunsPage-Cu91Mh52.js"),__vite__mapDeps([28,1,24,25,3,4,29,26,6,7,8,9,16,13,30,14,12,11,15,31]),import.meta.url).then(n=>({default:n.McpRunsPage}))),m3=E.lazy(()=>ke(()=>import("./McpRunDetailPage-TZBX68i4.js"),__vite__mapDeps([32,1,24,14,13,33,34,12,35,19,4,36,15,37]),import.meta.url).then(n=>({default:n.McpRunDetailPage}))),p3=E.lazy(()=>ke(()=>import("./McpQueryPage-CYvVEk3G.js"),__vite__mapDeps([38,1,14,13,7,8,9,12,11,15,6,10,30,16,31,3,4,39]),import.meta.url).then(n=>({default:n.McpQueryPage}))),y3=E.lazy(()=>ke(()=>import("./McpQueryDetailPage-wbwK8WWq.js"),__vite__mapDeps([40,1,14,13,19,39,4,25,41,42,24,2,43,44,45,46,47,48,37,49,35,36]),import.meta.url).then(n=>({default:n.McpQueryDetailPage}))),g3=E.lazy(()=>ke(()=>import("./EscalationsOverview-ChuKh02E.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),b3=E.lazy(()=>ke(()=>import("./AvailableEscalationsPage-BVtpc4xO.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,21,58,19,7,8,9,59,11,60,12,61,20,16,62,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),x3=E.lazy(()=>ke(()=>import("./OperatorDashboard-DD8JUU3L.js"),__vite__mapDeps([63,1,3,4,5,6,52,7,8,9,11,31,59,57,21,13,58,19,60,12,61,20,16,62,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),v3=E.lazy(()=>ke(()=>import("./index-CvKegIVe.js"),__vite__mapDeps([64,1,65,13,66,4,57,21,58,19,54,16,53,5,14,15,20,62,37,67]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),_3=E.lazy(()=>ke(()=>import("./WorkflowsOverview-BPUHAj8T.js"),__vite__mapDeps([68,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),w3=E.lazy(()=>ke(()=>import("./index-Dafrbwk_.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),S3=E.lazy(()=>ke(()=>import("./index-Dafrbwk_.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),E3=E.lazy(()=>ke(()=>import("./WorkflowsDashboard-CABuRCXp.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"durable"})}))),O3=E.lazy(()=>ke(()=>import("./WorkflowsDashboard-CABuRCXp.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"all"})}))),A3=E.lazy(()=>ke(()=>import("./YamlWorkflowsPage-DIxHURlM.js"),__vite__mapDeps([72,1,25,3,4,14,13,12,8,48,70,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),j3=E.lazy(()=>ke(()=>import("./GraphInvokePage-_fB7mtBU.js"),__vite__mapDeps([73,1,25,14,13,43,45,46,47,44,4,48,70]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),k3=E.lazy(()=>ke(()=>import("./YamlWorkflowDetailPage-DZGjT-Tl.js"),__vite__mapDeps([74,1,25,19,70,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),N3=E.lazy(()=>ke(()=>import("./TasksListPage-KaUSoqos.js"),__vite__mapDeps([75,1,2,3,4,7,8,9,19,61,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),T3=E.lazy(()=>ke(()=>import("./TaskDetailPage-VuaIXISy.js"),__vite__mapDeps([76,1,2,19,61,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),sx=E.lazy(()=>ke(()=>import("./WorkflowExecutionPage-B2S5ODie.js"),__vite__mapDeps([77,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),C3=E.lazy(()=>ke(()=>import("./AdminDashboard-B8MqNLiB.js"),__vite__mapDeps([78,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),M3=E.lazy(()=>ke(()=>import("./index-CR9rhAvN.js"),__vite__mapDeps([79,1,7,8,9,12,13,31,3,4,14,80,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),R3=E.lazy(()=>ke(()=>import("./index-CWKs10VQ.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),ix=E.lazy(()=>ke(()=>import("./index-CWKs10VQ.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),D3=E.lazy(()=>ke(()=>import("./index-BTm3-qwq.js"),__vite__mapDeps([83,1,23,8,82,14,13,12,11,3,4,84,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),ax=E.lazy(()=>ke(()=>import("./index-BIfY4mR2.js"),__vite__mapDeps([85,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),L3=E.lazy(()=>ke(()=>import("./index-YGTGxcTF.js"),__vite__mapDeps([86,1,3,4,7,8,9,11,12,13,82,31,14,20,47,49,87,88,33]),import.meta.url).then(n=>({default:n.UsersPage}))),q3=E.lazy(()=>ke(()=>import("./RolesPage-BmsWq83e.js"),__vite__mapDeps([89,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),P3=E.lazy(()=>ke(()=>import("./RoleDetailPage-DgVp0Hih.js"),__vite__mapDeps([90,1,91,82,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),B3=E.lazy(()=>ke(()=>import("./PersonasPage-DtHW6-Qx.js"),__vite__mapDeps([92,1,87,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),U3=E.lazy(()=>ke(()=>import("./PersonaDetailPage-CGri6okV.js"),__vite__mapDeps([93,1,87,20,13,88,91,82,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),z3=E.lazy(()=>ke(()=>import("./EscalationSchemaPage-BsYdNVN7.js"),__vite__mapDeps([94,1,65,13,66,4,57,21,58,19,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),I3=E.lazy(()=>ke(()=>import("./PortalPage-Dgbk_mzr.js"),__vite__mapDeps([95,1,9,56,13,57,21,58,19,4,7,8,59,11,60,12,61,20,16,62]),import.meta.url).then(n=>({default:n.PortalPage}))),$3=E.lazy(()=>ke(()=>import("./EscalationListSchemaPage-CPcbC1-9.js"),__vite__mapDeps([96,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),H3=E.lazy(()=>ke(()=>import("./ScanCodesPage-Cy05JOt4.js"),__vite__mapDeps([97,1,98,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),F3=E.lazy(()=>ke(()=>import("./ScanSchemeDetailPage-BX1afzOg.js"),__vite__mapDeps([99,1,82,14,13,98,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),G3=E.lazy(()=>ke(()=>import("./ScanStationPage-DLAB41tb.js"),__vite__mapDeps([100,1,13,67,57,21,66,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),V3=E.lazy(()=>ke(()=>import("./index-Dk7nwVpm.js"),__vite__mapDeps([101,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),ox=E.lazy(()=>ke(()=>import("./OperationsPage-D-6sKw6y.js").then(n=>n.O),__vite__mapDeps([102,1,60,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),Y3=E.lazy(()=>ke(()=>import("./index-vgHzaGmW.js"),__vite__mapDeps([103,1,18,13,12,3,4,29,26,42,80,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),K3=E.lazy(()=>ke(()=>import("./index-WPVpyoD3.js"),__vite__mapDeps([104,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),J3=E.lazy(()=>ke(()=>import("./CredentialsPage-CTtUkvoD.js"),__vite__mapDeps([105,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),Q3=E.lazy(()=>ke(()=>import("./ConnectedAppsPage-CIM9gzHj.js"),__vite__mapDeps([106,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.ConnectedAppsPage}))),X3=E.lazy(()=>ke(()=>import("./index-DvkcyTE2.js"),__vite__mapDeps([107,1,4,14,13,12,15,6,8,108,49]),import.meta.url).then(n=>({default:n.FilesPage}))),W3=E.lazy(()=>ke(()=>import("./index-D_ojXTgO.js"),__vite__mapDeps([109,1,14,13,12,15,11,8,108,49,110,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),Z3=E.lazy(()=>ke(()=>import("./HomePage-BXA0Cz0F.js"),__vite__mapDeps([111,1,24,26,20,13,16,15,102,60,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),e5=E.lazy(()=>ke(()=>import("./AgentsPage-CZIWMwak.js"),__vite__mapDeps([112,1,113,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),t5=E.lazy(()=>ke(()=>import("./AgentDetailPage-ZUGYEONO.js"),__vite__mapDeps([114,1,113,115,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),lx=E.lazy(()=>ke(()=>import("./AgentConfigPage-Yg81Eiuo.js"),__vite__mapDeps([116,1,113,115,13,14,110,45,46,47,25,117,118,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),n5=E.lazy(()=>ke(()=>import("./CapabilitiesPage-BQQBR2sj.js"),__vite__mapDeps([119,1,117,84,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),r5=E.lazy(()=>ke(()=>import("./TopicsPage-8SmCnQ-E.js"),__vite__mapDeps([120,1,118,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),s5=E.lazy(()=>ke(()=>import("./TopicDetailPage-BprToO7w.js"),__vite__mapDeps([121,1,118,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function i5(){return h.jsxs("div",{className:"animate-pulse space-y-4",children:[h.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function Ee({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(i5,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Zv=new hS({defaultOptions:{queries:{staleTime:1e4,retry:(n,e)=>e instanceof Error&&e.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Zv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",e=`${n}/login`;if(window.location.pathname!==e){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${e}?returnTo=${encodeURIComponent(i)}`}});const a5=pS([{path:"/login",element:h.jsx(XC,{})},{path:"/connect/anthropic",element:h.jsx(rx,{})},{path:"/connect/:provider",element:h.jsx(rx,{})},{path:"/oauth/consent",element:h.jsx(a3,{})},{path:"/",element:h.jsx(KC,{}),children:[{index:!0,element:h.jsx(Ee,{children:h.jsx(Z3,{})})},{path:"processes/all",element:h.jsx(Ee,{children:h.jsx(u3,{})})},{path:"processes/detail/:originId",element:h.jsx(Ee,{children:h.jsx(f3,{})})},{path:"credentials",element:h.jsx(Ee,{children:h.jsx(J3,{})})},{path:"connected-apps",element:h.jsx(Ee,{children:h.jsx(Q3,{})})},{path:"connections",element:h.jsx(Sn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Ee,{children:h.jsx(g3,{})})},{path:"escalations/available",element:h.jsx(Ee,{children:h.jsx(b3,{})})},{path:"escalations/queue",element:h.jsx(Ee,{children:h.jsx(x3,{})})},{path:"escalations/detail/:id",element:h.jsx(Ee,{children:h.jsx(v3,{})})},{path:"portal/:role/:portal?",element:h.jsx(Ee,{children:h.jsx(I3,{})})},{path:"scan/station",element:h.jsx(Ee,{children:h.jsx(G3,{})})},{path:"capabilities",element:h.jsx(Ee,{children:h.jsx(n5,{})})},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"agents",element:h.jsx(Ee,{children:h.jsx(e5,{})})},{path:"agents/new",element:h.jsx(Ee,{children:h.jsx(lx,{})})},{path:"agents/:id",element:h.jsx(Ee,{children:h.jsx(t5,{})})},{path:"agents/:id/edit",element:h.jsx(Ee,{children:h.jsx(lx,{})})},{path:"topics",element:h.jsx(Ee,{children:h.jsx(r5,{})})},{path:"topics/:topic",element:h.jsx(Ee,{children:h.jsx(s5,{})})}]},{element:h.jsx(o3,{}),children:[{path:"workflows/start",element:h.jsx(Ee,{children:h.jsx(w3,{})})},{path:"workflows/durable/invoke",element:h.jsx(Ee,{children:h.jsx(S3,{})})}]},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Ee,{children:h.jsx(_3,{})})},{path:"workflows/executions",element:h.jsx(Ee,{children:h.jsx(O3,{})})},{path:"workflows/durable/executions",element:h.jsx(Ee,{children:h.jsx(E3,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(sx,{})})},{path:"workflows/tasks",element:h.jsx(Ee,{children:h.jsx(N3,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Ee,{children:h.jsx(T3,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(sx,{})})},{path:"workflows/cron",element:h.jsx(Sn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Ee,{children:h.jsx(M3,{})})},{path:"workflows/registry",element:h.jsx(Ee,{children:h.jsx(R3,{})})},{path:"workflows/registry/new",element:h.jsx(Ee,{children:h.jsx(ix,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Ee,{children:h.jsx(ix,{})})}]},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Ee,{children:h.jsx(A3,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Ee,{children:h.jsx(j3,{})})},{path:"mcp/workflows/:id",element:h.jsx(Ee,{children:h.jsx(k3,{})})},{path:"mcp/executions",element:h.jsx(Ee,{children:h.jsx(d3,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Ee,{children:h.jsx(m3,{})})},{path:"files",element:h.jsx(Ee,{children:h.jsx(X3,{})})},{path:"knowledge",element:h.jsx(Ee,{children:h.jsx(W3,{})})},{element:h.jsx(l3,{}),children:[{path:"mcp",element:h.jsx(Ee,{children:h.jsx(h3,{})})},{path:"mcp/queries",element:h.jsx(Ee,{children:h.jsx(p3,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Ee,{children:h.jsx(y3,{})})},{path:"mcp/tools",element:h.jsx(Sn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Ee,{children:h.jsx(D3,{})})},{path:"mcp/servers/new",element:h.jsx(Ee,{children:h.jsx(ax,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Ee,{children:h.jsx(ax,{})})}]}]},{path:"pace",element:h.jsx(Ee,{children:h.jsx(ox,{})})},{path:"trends",element:h.jsx(Ee,{children:h.jsx(ox,{})})},{path:"operations",element:h.jsx(Sn,{to:"/pace",replace:!0})},{element:h.jsx(po,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Ee,{children:h.jsx(C3,{})})},{path:"admin/users",element:h.jsx(Ee,{children:h.jsx(L3,{})})},{path:"admin/escalation-chains",element:h.jsx(Sn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Ee,{children:h.jsx(q3,{})})},{path:"admin/roles/:role",element:h.jsx(Ee,{children:h.jsx(P3,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Ee,{children:h.jsx(z3,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Ee,{children:h.jsx($3,{})})},{path:"admin/scan-codes",element:h.jsx(Ee,{children:h.jsx(H3,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Ee,{children:h.jsx(F3,{})})},{path:"admin/personas",element:h.jsx(Ee,{children:h.jsx(B3,{})})},{path:"admin/personas/:key",element:h.jsx(Ee,{children:h.jsx(U3,{})})}]},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(Sn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(c3,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Ee,{children:h.jsx(V3,{})})}]},{path:"admin/controlplane",element:h.jsx(Ee,{children:h.jsx(Y3,{})})},{path:"admin/streams",element:h.jsx(Ee,{children:h.jsx(K3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function o5(){return h.jsx(dS,{client:Zv,children:h.jsx(oE,{children:h.jsx(fA,{children:h.jsx(yS,{router:a5})})})})}Ev(Sv());const Vm=document.createElement("link");Vm.rel="stylesheet";Vm.href=`${Vt}/api/settings/custom.css`;document.head.appendChild(Vm);XS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(o5,{})}));export{qt as $,Vk as A,TM as B,Gm as C,RC as D,B5 as E,Vv as F,CM as G,Lm as H,CT as I,mC as J,MT as K,IT as L,WN as M,Xt as N,tv as O,R5 as P,Cm as Q,Q5 as R,nC as S,X5 as T,W5 as U,Z5 as V,eM as W,nM as X,Ij as Y,Mu as Z,P5 as _,UM as a,O5 as a$,nm as a0,PT as a1,E5 as a2,qM as a3,Bm as a4,ta as a5,xs as a6,H5 as a7,A5 as a8,pv as a9,IM as aA,zM as aB,Hv as aC,$M as aD,BM as aE,bv as aF,iM as aG,GM as aH,PM as aI,YM as aJ,VM as aK,y5 as aL,g5 as aM,_5 as aN,w5 as aO,b5 as aP,x5 as aQ,v5 as aR,k5 as aS,T5 as aT,N5 as aU,RM as aV,S5 as aW,Tm as aX,C5 as aY,BT as aZ,M5 as a_,ST as aa,Tk as ab,SM as ac,Kk as ad,dc as ae,Y5 as af,K5 as ag,Pu as ah,Yk as ai,IN as aj,MM as ak,jv as al,Cu as am,zm as an,zj as ao,_A as ap,z5 as aq,mM as ar,I5 as as,J5 as at,tM as au,uv as av,d5 as aw,zg as ax,m5 as ay,FM as az,lM as b,xM as b0,js as b1,Eo as b2,KM as b3,qx as b4,WC as b5,gM as b6,Vt as b7,wd as b8,p5 as b9,vT as bA,$m as bB,pk as bC,Jk as bD,je as bE,EM as bF,L5 as bG,uM as bH,ZN as bI,JM as bJ,QM as bK,Wv as bL,XM as bM,WM as bN,jm as bO,nv as bP,pM as bQ,DT as ba,LM as bb,yv as bc,K1 as bd,kv as be,dM as bf,km as bg,fM as bh,_M as bi,Tj as bj,vM as bk,ik as bl,V5 as bm,G5 as bn,fr as bo,rv as bp,bM as bq,ea as br,j5 as bs,zk as bt,AM as bu,xk as bv,kM as bw,NM as bx,OM as by,jM as bz,er as c,wM as d,rM as e,yk as f,xv as g,nk as h,D5 as i,tn as j,An as k,sM as l,ue as m,HM as n,aM as o,oM as p,U5 as q,$5 as r,F5 as s,cM as t,yM as u,q5 as v,Fm as w,DM as x,Xx as y,hM as z};
67
- //# sourceMappingURL=index-D7peGNN0.js.map
64
+ `}function RC(n){const e=n.summary,s=n.title;if(e){const i=e.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?e.slice(0,i).trim():e}return s||(typeof n=="string"?n:"Query completed.")}const Jv=E.createContext(null);function DC({children:n}){const e=en(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[m,p]=E.useState(null),[g,u]=E.useState({}),d=E.useRef(null),b={page:e.pathname.split("/").filter(Boolean).join("-")||"home",route:e.pathname,params:{},...g,suggestedTags:g.suggestedTags??CC(e.pathname)};E.useEffect(()=>()=>{d.current&&clearInterval(d.current)},[]);const x=E.useCallback(()=>i(P=>!P),[]),v=E.useCallback(P=>{u(P)},[]),_=E.useCallback(()=>{c([]),p(null)},[]),S=E.useCallback(async P=>{var z;const q=new Date().toISOString(),ne={id:`user-${Date.now()}`,role:"user",content:P,timestamp:q},te={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:q,pending:!0};c(I=>[...I,ne,te]);const M={...b};(z=M.entities)!=null&&z.yamlContent&&M.entities.yamlContent.length>ex&&(M.entities={...M.entities,yamlContent:M.entities.yamlContent.slice(0,ex)+`
65
+ ... (truncated)`});const ae=`${MC(o.concat(ne))}${P}`;try{const D=(await ue("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ae,tags:M.suggestedTags,context:M,wait:!1,direct:!0})})).workflow_id;p(D),c(X=>X.map(W=>W.id===te.id?{...W,workflowId:D}:W)),d.current&&clearInterval(d.current),d.current=setInterval(async()=>{var X;try{const W=await ue(`/workflows/${D}/result`),he=(X=W==null?void 0:W.result)==null?void 0:X.data;if(he){d.current&&clearInterval(d.current),d.current=null,p(null);const we=RC(he);let Oe;try{Oe=(await ue(`/workflow-states/${D}/execution`)).duration_ms}catch{}c(F=>F.map(J=>J.id===te.id?{...J,content:we,timestamp:new Date().toISOString(),pending:!1,durationMs:Oe}:J))}}catch{}},3e3)}catch{c(I=>I.map(D=>D.id===te.id?{...D,content:"Failed to submit query. Please try again.",pending:!1}:D))}},[o,b]),C=E.useCallback(async P=>{const q=o.find(M=>M.id===P);if(!(q!=null&&q.workflowId)||q.compilationStatus==="compiling"||q.compilationStatus==="done")return;const ne=o.indexOf(q),te=o.slice(0,ne).reverse().find(M=>M.role==="user");if(te){c(M=>M.map(U=>U.id===P?{...U,compilationStatus:"compiling"}:U));try{const M=await ue("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:te.content,summary:q.content})}),U=await ue("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:q.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:M.tool_name,description:M.description,tags:M.tags,app_id:""})});await ue(`/yaml-workflows/${U.id}/deploy`,{method:"POST"}),c(ae=>ae.map(z=>z.id===P?{...z,compilationStatus:"done"}:z))}catch(M){const U=M instanceof Error?M.message:"Compilation failed";c(ae=>ae.map(z=>z.id===P?{...z,compilationStatus:"error",compilationError:U}:z))}}},[o]);return h.jsx(Jv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:m,clearMessages:_,compileMessage:C},children:n})}function Qv(){const n=E.useContext(Jv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function LC(){const{helpOpen:n,toggleHelp:e}=Qv();return h.jsx("button",{onClick:e,className:"fixed right-3 z-[45] flex items-center justify-center w-10 h-10 rounded-full bg-surface-raised shadow-lg hover:scale-110 transition-transform duration-150 border border-accent/30",style:{bottom:"44px"},"aria-label":n?"Close help":"Ask for help",children:n?h.jsx(Zt,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):h.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Vt}/logo512.png)`}})})}function qC({ms:n,className:e=""}){const s=yk(n),i=E.useMemo(()=>n==null?[]:[{label:"ms",value:String(n)},{label:"sec",value:`${(n/1e3).toFixed(3)}s`},{label:"text",value:s}],[n,s]);return n==null?h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:"--"}):h.jsx(bv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:s})})}const PC=["sm","md","lg","full"],tx={sm:"w-[28rem] max-h-[40vh]",md:"w-[36rem] max-h-[60vh]",lg:"w-[48rem] max-h-[80vh]",full:"inset-4 w-auto max-h-none"},nx={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function BC({which:n}){const e="stroke-current";switch(n){case"sm":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:e,strokeWidth:"1.5"})});case"md":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:e,strokeWidth:"1.5"})});case"lg":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:e,strokeWidth:"1.5"})});case"full":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:e,strokeWidth:"1.5"})})}}function UC({msg:n}){const[e,s]=E.useState(0);E.useEffect(()=>{const m=new Date(n.timestamp).getTime(),p=()=>s(Math.floor((Date.now()-m)/1e3));p();const g=setInterval(p,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(e/60),o=e%60,c=i>0?`${i}m ${o}s`:`${o}s`;return h.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),h.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:c})]}),n.workflowId&&h.jsxs(ar,{to:`/workflows/executions/${n.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function zC({msg:n,compileMessage:e}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(xv,{date:n.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),n.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(qC,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(ar,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>e(n.id),disabled:n.compilationStatus==="compiling"||n.compilationStatus==="done",className:"transition-colors",title:n.compilationStatus==="done"?"Compiled — future queries will match this pipeline":n.compilationStatus==="error"?n.compilationError??"Compilation failed":n.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx($S,{className:`w-2.5 h-2.5 ${n.compilationStatus==="done"?"text-status-success":n.compilationStatus==="error"?"text-status-error":n.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function IC(){const{helpOpen:n,setHelpOpen:e,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:m,compileMessage:p}=Qv(),[g,u]=E.useState(""),[d,b]=E.useState("md"),[x,v]=E.useState(!0),_=E.useRef(null),S=E.useRef(null);if(E.useEffect(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[s]),E.useEffect(()=>{n&&S.current&&S.current.focus()},[n]),E.useEffect(()=>{if(!n)return;const M=U=>{U.key==="Escape"&&(d==="full"?b("lg"):d==="lg"?b("md"):d==="md"?b("sm"):e(!1))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n,d,e]),!n)return null;const C=()=>{const M=g.trim();!M||c||(i(M),u(""),S.current&&(S.current.style.height="auto"))},P=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),C())},q=d==="full",ne=o.page.replace(/-/g," "),te=q?{}:{bottom:"108px"};return h.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${q?tx.full:`right-6 ${tx[d]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:te,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[h.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),h.jsx("p",{className:"text-2xs text-text-tertiary truncate",children:ne})]}),h.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[h.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:PC.map(M=>h.jsx("button",{onClick:()=>b(M),className:`p-1 rounded transition-colors ${M===d?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":M===d,"aria-label":nx[M],title:nx[M],children:h.jsx(BC,{which:M})},M))}),s.length>0&&h.jsx("button",{onClick:m,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(HS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>e(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:_,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(M=>h.jsxs("div",{className:`text-xs leading-relaxed ${M.role==="user"?"text-right":"text-left"}`,children:[h.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${M.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:M.pending?h.jsx(UC,{msg:M}):M.role==="assistant"?h.jsx(Pu,{content:M.content}):M.content}),!M.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(zC,{msg:M,compileMessage:p})})]},M.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:S,value:g,onChange:M=>{u(M.target.value);const U=M.target;U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,120)}px`},onKeyDown:P,placeholder:"Ask a question...",rows:2,className:"flex-1 resize-none bg-surface text-xs text-text-primary placeholder:text-text-tertiary rounded px-2.5 py-1.5 border border-surface-border focus:outline-none focus:border-accent",style:{minHeight:"2.5rem"},disabled:!!c}),h.jsx("button",{onClick:C,disabled:!g.trim()||!!c,className:"px-2.5 py-1.5 text-accent hover:text-accent-hover disabled:text-text-muted transition-colors self-end","aria-label":"Send",children:h.jsx(FS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const $C=6e3,HC="scan";function FC(){const{lastResult:n}=$m(),{open:e,ownerKey:s}=Lm(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),$C);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||e&&s===HC||n.source===To.TOOLBAR?null:h.jsx("div",{role:"status",className:"fixed bottom-14 right-4 z-[60] w-80 max-w-[calc(100vw-2rem)] bg-surface-raised border border-surface-border shadow-lg rounded-md animate-page-in",children:h.jsxs("div",{className:"flex items-start gap-2.5 px-3.5 py-3",children:[h.jsx(Mo,{className:"w-4 h-4 mt-0.5 text-accent-muted shrink-0",strokeWidth:1.5}),h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx(Hm,{result:n})}),h.jsx("button",{type:"button",onClick:()=>o(n.at),className:"text-text-tertiary hover:text-text-primary shrink-0",title:"Dismiss",children:h.jsx(Zt,{className:"w-3.5 h-3.5"})})]})})}const Xv="lt-announcement-dismissed:",GC="Live updates unavailable. Reconnecting… Refresh if this persists.";function VC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YC(n){try{return localStorage.getItem(`${Xv}${n}`)==="1"}catch{return!1}}function KC(){const{isAuthenticated:n,userRoleNames:e}=qt(),{data:s}=gv(n),i=Pe(),[o,c]=E.useState(null),[m,p]=E.useState(0),{unavailable:g}=dO();An(hk,()=>{i.invalidateQueries({queryKey:["announcements"]})});const u=Date.now(),d=((s==null?void 0:s.announcements)??[]).filter(x=>!YC(x.id)&&new Date(x.expires_at).getTime()>u&&(x.roles.length===0||x.roles.some(v=>e.includes(v))));if(E.useEffect(()=>{const x=((s==null?void 0:s.announcements)??[]).map(_=>new Date(_.expires_at).getTime()-Date.now()).filter(_=>_>0);if(x.length===0)return;const v=setTimeout(()=>p(_=>_+1),Math.min(...x)+250);return()=>clearTimeout(v)},[s,m]),d.length===0&&!g)return null;const b=x=>{try{localStorage.setItem(`${Xv}${x}`,"1")}catch{}p(v=>v+1)};return h.jsxs("div",{"data-testid":"announcement-banner",className:"relative z-40",children:[g&&h.jsx("div",{"data-testid":"live-updates-notice",role:"status",className:"border-b border-status-warning/25 bg-status-warning/10",children:h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-status-warning",children:"Notice"}),h.jsx("span",{className:"truncate text-xs text-text-primary",children:GC})]})}),d.map(x=>{const v=o===x.id,_=x.title??x.body.split(`
66
+ `)[0];return h.jsxs("div",{className:"border-b border-accent/25 bg-accent/10",children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-accent",children:"Notice"}),h.jsxs("button",{type:"button",onClick:()=>c(v?null:x.id),className:"flex items-center gap-1.5 text-xs text-text-primary hover:text-accent transition-colors min-w-0",children:[h.jsx("span",{className:"truncate",children:_}),v?h.jsx(px,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(im,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>b(x.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${_}`,children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),v&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Pu,{content:VC(x.body)})})]},x.id)})]})}function JC(){var U,ae;const{isBuilder:n,isOps:e,viewAs:s}=tv(),{canSeePaceBoard:i}=nv();SA();const{data:o}=er();Dj((U=o==null?void 0:o.display)==null?void 0:U.timeZone);const c=Xx(),m=c!==null?c:!!((ae=o==null?void 0:o.ai)!=null&&ae.enabled),{collapsed:p,toggle:g}=Rm(),[u,d]=E.useState(!1),[b,x]=E.useState(!1),[v,_]=E.useState(!1),[S,C]=E.useState(()=>window.location.hash.startsWith("#docs")),P=en(),q=E.useRef(null),{kiosk:ne,homePath:te}=Cm(),M=ne||Yj(P.pathname);return E.useEffect(()=>{const z=q.current;z&&(z.classList.remove("animate-page-in"),z.offsetWidth,z.classList.add("animate-page-in"))},[P.pathname]),E.useEffect(()=>{const z=()=>{window.location.hash.startsWith("#docs")&&C(!0)};return window.addEventListener("hashchange",z),()=>window.removeEventListener("hashchange",z)},[]),ne&&te&&!Xj(P.pathname,P.search)?h.jsx(Sn,{to:te,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(kT,{onToggleEventFeed:()=>d(z=>!z),onToggleDocs:()=>C(z=>!z),onToggleNav:M?void 0:()=>x(z=>!z)}),h.jsx(KC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!M&&h.jsxs("aside",{className:`${p?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border hidden lg:flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[h.jsx("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(Fv,{aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i})}),h.jsx("button",{onClick:g,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${p?"flex justify-center":"flex items-center px-7"}`,"aria-label":p?"Expand sidebar":"Collapse sidebar",children:p?h.jsx(GS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(VS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!p&&(o==null?void 0:o.environment)&&h.jsxs("div",{className:"shrink-0 px-5 pb-3 text-2xs leading-tight text-text-tertiary whitespace-nowrap overflow-hidden text-ellipsis",title:`long-tail v${o.environment.longTailVersion} · HotMesh v${o.environment.hotmeshVersion} · Node ${o.environment.nodeVersion} · ${o.environment.nodeEnv}`,children:["long-tail v",o.environment.longTailVersion,h.jsx("span",{className:"mx-1 text-surface-border",children:"·"}),"HotMesh v",o.environment.hotmeshVersion]})]}),h.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto",children:h.jsx("div",{ref:q,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(ei,{})})}),h.jsx(QC,{})]}),!M&&h.jsx(tC,{open:b,onClose:()=>x(!1),aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i}),h.jsx(vC,{open:u,onToggle:()=>d(z=>!z),configOpen:v,onToggleConfig:()=>_(z=>!z)}),h.jsx(TC,{open:S,onClose:()=>{C(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),m&&h.jsx(LC,{}),m&&h.jsx(IC,{}),h.jsx(FC,{})]})}function QC(){const{node:n,width:e,open:s}=Lm();return h.jsx(nk,{open:s,width:e,className:"border-l border-surface-border bg-surface-raised",children:n})}function XC(){const{isAuthenticated:n}=qt(),e=en();return n?h.jsx(Zj,{children:h.jsx(tk,{children:h.jsx(DC,{children:h.jsx(vA,{children:h.jsx(Zk,{children:h.jsx(JC,{})})})})})}):h.jsx(Sn,{to:"/login",state:{from:e.pathname},replace:!0})}function Wv({provider:n,className:e="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),h.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),h.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),h.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]});case"github":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})});case"microsoft":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),h.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),h.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),h.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M13.827 3.52h3.603L24 20.48h-3.603l-6.57-16.96zm-7.258 0h3.767L16.906 20.48h-3.674l-1.343-3.461H6.396l-1.34 3.461H1.5l5.07-16.96zm2.327 5.14l-2.065 5.326h4.108l-2.043-5.326z"})});default:return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M12 8v4l3 3"})]})}}async function WC(){return ue("/auth/oauth/providers")}async function ZC(n,e){const s=e?`?label=${encodeURIComponent(e)}`:"";return ue(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function WM(){return qe({queryKey:["oauth-connections"],queryFn:()=>ue("/auth/oauth/connections")})}function ZM(){const n=Pe();return $e({mutationFn:({provider:e,label:s})=>ZC(e,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function e3(){var ae;const{login:n,isAuthenticated:e}=qt(),s=ni(),i=en(),o=new URLSearchParams(i.search),c=o.get("token"),m=o.get("error"),p=((ae=i.state)==null?void 0:ae.from)??o.get("returnTo")??"/",g=E.useRef(!1);c&&!g.current&&(g.current=!0,n(c,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[u,d]=E.useState(""),[b,x]=E.useState(""),[v,_]=E.useState(m||""),[S,C]=E.useState(!1),[P,q]=E.useState(!!c),[ne,te]=E.useState([]),M=E.useRef(!1);if(E.useEffect(()=>{c||M.current||(M.current=!0,(async()=>{var z,I,D,X;try{const W=await lm().catch(()=>null);if(!((z=W==null?void 0:W.auth)!=null&&z.sso))return;const he=await fetch(`${Vt}/api/auth/sso`,{method:"POST"});if(!he.ok){_("Host authentication required — please log in to your organization first");return}const we=await he.json();we.token&&((I=W.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",W.auth.ssoLogoutUrl),q(!0),n(we.token,void 0,{displayName:(D=we.user)==null?void 0:D.display_name,username:(X=we.user)==null?void 0:X.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||WC().then(te).catch(()=>{})},[]),E.useEffect(()=>{if(!P)return;const z=setTimeout(()=>s(p,{replace:!0}),1500);return()=>clearTimeout(z)},[P]),e&&!P)return h.jsx(Sn,{to:p,replace:!0});const U=async z=>{var I,D;if(z.preventDefault(),_(""),!u.trim()||!b){_("Username and password are required");return}C(!0);try{const X=await fetch(`${Vt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),W=await X.json();if(!X.ok){_(W.error||"Login failed");return}q(!0),n(W.token,{username:u.trim(),password:b},{displayName:(I=W.user)==null?void 0:I.display_name,username:(D=W.user)==null?void 0:D.external_id})}catch{_("Unable to connect to server")}finally{C(!1)}};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${P?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Ru,{size:"lg",hideLabel:P})}),h.jsxs("form",{onSubmit:U,className:`space-y-5 transition-opacity duration-300 ${P?"opacity-0":""}`,children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),h.jsx("input",{id:"username",type:"text",value:u,onChange:z=>d(z.target.value),className:"input",placeholder:"Enter your username",autoFocus:!P,autoComplete:"username"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:b,onChange:z=>x(z.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),v&&h.jsx("p",{className:"text-sm text-status-error",children:v}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:S||P,children:S?"Signing in...":"Sign In"}),ne.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[h.jsx("div",{className:"flex-1 h-px bg-border"}),h.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),h.jsx("div",{className:"flex-1 h-px bg-border"})]}),h.jsx("div",{className:"space-y-2",children:ne.filter(z=>z.provider!=="anthropic").map(z=>h.jsxs("a",{href:`${Vt}/api/auth/oauth/${z.provider}?returnTo=${encodeURIComponent(p)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Wv,{provider:z.provider}),"Sign in with ",z.name]},z.provider))})]})]})]})})}function rx(){const{isAuthenticated:n}=qt(),e=ni(),s=en(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||e(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,m]=E.useState(""),[p,g]=E.useState(i.get("label")||"default"),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=c.trim().startsWith("sk-ant-oat"),_=c.trim().startsWith("sk-ant-api"),S=C=>{C.preventDefault();const P=c.trim();if(!P){d("A token or API key is required");return}if(!P.startsWith("sk-ant-")){d('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),d("");const q=`${Vt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(P)}&state=${encodeURIComponent(o)}`;window.location.href=q};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Wv,{provider:"anthropic",className:"w-6 h-6"}),h.jsx("h2",{className:"heading-3",children:"Connect Anthropic"})]}),h.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Connect your Anthropic account so Claude Code tasks run under your credentials. Your token is encrypted at rest."}),h.jsxs("form",{onSubmit:S,className:"space-y-5",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),h.jsx("input",{id:"token",type:"password",value:c,onChange:C=>m(C.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),v&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),_&&h.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),h.jsx("input",{id:"label",type:"text",value:p,onChange:C=>g(C.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),h.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:'A name for this credential. Use different labels to store multiple credentials (e.g., "subscription", "api-batch").'})]}),u&&h.jsx("p",{className:"text-sm text-status-error",children:u}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:b,children:b?"Validating...":"Connect"}),h.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),h.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",h.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-2xs",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",h.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent-secondary hover:underline",children:"console.anthropic.com"})," ","(billed per-token)."]})]})]})})}function t3({items:n,columns:e=1}){if(n.length===0)return null;const s=e>=2&&n.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return h.jsx("div",{className:"@container",children:h.jsx("dl",{className:`grid ${s} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:n.map(({key:i,label:o,value:c})=>h.jsxs(E.Fragment,{children:[h.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:o}),h.jsx("dd",{className:"text-sm text-text-primary break-words whitespace-pre-wrap min-w-0","data-field-key":i,children:n3(c)})]},i))})})}function n3(n){return n==null||n===""?"—":typeof n=="boolean"?n?"Yes":"No":typeof n=="object"?JSON.stringify(n):String(n)}function r3(n){return qe({queryKey:["oauth-client",n],queryFn:()=>ue(`/oauth/clients/${encodeURIComponent(n)}`),enabled:!!n,retry:!1})}function s3(n){return qe({queryKey:["oauth-presets"],queryFn:()=>ue("/oauth/presets"),enabled:n})}function i3(){return $e({mutationFn:n=>ue(n.preset?"/oauth/authorize":"/oauth/deny",{method:"POST",body:JSON.stringify(n.preset?{...n.request,preset:n.preset}:n.request)})})}function eR(){return qe({queryKey:["oauth-grants"],queryFn:()=>ue("/oauth/grants")})}function tR(){const n=Pe();return $e({mutationFn:e=>ue(`/oauth/grants/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["oauth-grants"]})})}const a3=["client_id","redirect_uri","code_challenge","code_challenge_method","response_type","state","scope","resource"],yd={read_only:{action:"Allow read-only",effect:"Reads what you can read and runs workflows marked read-safe."},just_me:{action:"Allow as me",effect:"Acts with your full rights: claims, resolves, invokes, and administers wherever you may."}};function o3(n){const e=new URLSearchParams(n),s=a3.map(o=>[o,e.get(o)??void 0]),i=Object.fromEntries(s);return!i.client_id||!i.redirect_uri||!i.code_challenge?null:i}function l3(n){try{return new URL(n).host}catch{return n}}function c3(){var b,x,v;const{isAuthenticated:n,user:e}=qt(),s=ni(),i=en(),o=E.useMemo(()=>o3(i.search),[i.search]);E.useEffect(()=>{n||s(`/login?returnTo=${encodeURIComponent(i.pathname+i.search)}`,{replace:!0})},[n]);const c=r3(n&&o?o.client_id:null),m=s3(n&&!!o),p=i3(),g=_=>{o&&p.mutate({request:o,preset:_},{onSuccess:({redirect:S})=>window.location.assign(S)})};if(!n)return null;const u=!o||c.isError,d=((b=c.data)==null?void 0:b.client_name)||"An app";return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-lg p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),u?h.jsxs("div",{role:"alert",children:[h.jsx("h2",{className:"heading-3 mb-3",children:"Sign-in link not valid"}),h.jsx("p",{className:"text-sm text-text-secondary",children:"Start the connection again from the app."})]}):h.jsxs(h.Fragment,{children:[h.jsxs("h2",{className:"heading-2 mb-2",children:["Connect ",d]}),h.jsxs("p",{className:"text-sm text-text-secondary mb-6",children:["Pick how much ",d," may do as you. Disconnect it any time under Connected apps."]}),h.jsx("div",{className:"mb-8",children:h.jsx(t3,{items:[{key:"app",label:"App",value:d},{key:"account",label:"Account",value:(e==null?void 0:e.displayName)||(e==null?void 0:e.username)||(e==null?void 0:e.userId)||null},{key:"returns-to",label:"Returns to",value:l3(o.redirect_uri)},{key:"deployment",label:"Deployment",value:window.location.host}]})}),h.jsx("dl",{className:"space-y-3 mb-8",children:(((x=m.data)==null?void 0:x.presets)??[]).map(_=>h.jsxs("div",{children:[h.jsx("dt",{className:"text-sm font-medium text-text-primary",children:yd[_].action}),h.jsx("dd",{className:"text-sm text-text-secondary",children:yd[_].effect})]},_))}),p.isError&&h.jsx("p",{className:"text-sm text-status-error mb-4",role:"alert",children:p.error.message}),h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[(((v=m.data)==null?void 0:v.presets)??[]).map(_=>h.jsx("button",{type:"button",className:_==="read_only"?"btn-primary":"btn-secondary",disabled:p.isPending||c.isLoading,onClick:()=>g(_),children:yd[_].action},_)),h.jsx("button",{type:"button",className:"btn-ghost",disabled:p.isPending,onClick:()=>g(null),children:"Deny"})]})]})]})})}function po({roleTypes:n,roleNames:e,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=qt();return i?h.jsx(ei,{}):n&&n.some(m=>c(m))?h.jsx(ei,{}):e&&e.some(m=>o(m))?h.jsx(ei,{}):h.jsx(Sn,{to:s,replace:!0})}function u3(){const{data:n,isSuccess:e}=Hv();return e&&n.length===0?h.jsx(Sn,{to:"/",replace:!0}):h.jsx(ei,{})}function f3({redirectTo:n="/"}){var i;const{data:e,isLoading:s}=er();return s||!e?null:(i=e.ai)!=null&&i.enabled?h.jsx(ei,{}):h.jsx(Sn,{to:n,replace:!0})}function h3({flag:n,redirectTo:e="/"}){var o;const{data:s,isLoading:i}=er();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(Sn,{to:e,replace:!0}):h.jsx(ei,{})}const d3=E.lazy(()=>ke(()=>import("./ProcessesListPage-B6k4RpmR.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url).then(n=>({default:n.ProcessesListPage}))),m3=E.lazy(()=>ke(()=>import("./ProcessDetailPage-B9wMw0RV.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),p3=E.lazy(()=>ke(()=>import("./McpOverview-8gqiL3Vj.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),y3=E.lazy(()=>ke(()=>import("./McpRunsPage-DaSsI-EM.js"),__vite__mapDeps([28,1,24,25,3,4,29,26,6,7,8,9,16,13,30,14,12,11,15,31]),import.meta.url).then(n=>({default:n.McpRunsPage}))),g3=E.lazy(()=>ke(()=>import("./McpRunDetailPage-80fQn9iX.js"),__vite__mapDeps([32,1,24,14,13,33,34,12,35,19,4,36,15,37]),import.meta.url).then(n=>({default:n.McpRunDetailPage}))),b3=E.lazy(()=>ke(()=>import("./McpQueryPage-Dj6Qj72w.js"),__vite__mapDeps([38,1,14,13,7,8,9,12,11,15,6,10,30,16,31,3,4,39]),import.meta.url).then(n=>({default:n.McpQueryPage}))),x3=E.lazy(()=>ke(()=>import("./McpQueryDetailPage-COyn6Ak5.js"),__vite__mapDeps([40,1,14,13,19,39,4,25,41,42,24,2,43,44,45,46,47,48,37,49,35,36]),import.meta.url).then(n=>({default:n.McpQueryDetailPage}))),v3=E.lazy(()=>ke(()=>import("./EscalationsOverview-Qaov-uML.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),_3=E.lazy(()=>ke(()=>import("./AvailableEscalationsPage-DrvfXz70.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,21,58,19,7,8,9,59,11,60,12,61,20,16,62,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),w3=E.lazy(()=>ke(()=>import("./OperatorDashboard-HFI4WGIV.js"),__vite__mapDeps([63,1,3,4,5,6,52,7,8,9,11,31,59,57,21,13,58,19,60,12,61,20,16,62,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),S3=E.lazy(()=>ke(()=>import("./index-CfP2nKRc.js"),__vite__mapDeps([64,1,65,13,66,4,57,21,58,19,54,16,53,5,14,15,20,62,37,67]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),E3=E.lazy(()=>ke(()=>import("./WorkflowsOverview-Dta1kurk.js"),__vite__mapDeps([68,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),O3=E.lazy(()=>ke(()=>import("./index-DhSCCpqM.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),A3=E.lazy(()=>ke(()=>import("./index-DhSCCpqM.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),j3=E.lazy(()=>ke(()=>import("./WorkflowsDashboard-Bb8HlrTJ.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"durable"})}))),k3=E.lazy(()=>ke(()=>import("./WorkflowsDashboard-Bb8HlrTJ.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"all"})}))),N3=E.lazy(()=>ke(()=>import("./YamlWorkflowsPage-CQFUzT4t.js"),__vite__mapDeps([72,1,25,3,4,14,13,12,8,48,70,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),T3=E.lazy(()=>ke(()=>import("./GraphInvokePage-Djslhf96.js"),__vite__mapDeps([73,1,25,14,13,43,45,46,47,44,4,48,70]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),C3=E.lazy(()=>ke(()=>import("./YamlWorkflowDetailPage-CfAajg68.js"),__vite__mapDeps([74,1,25,19,70,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),M3=E.lazy(()=>ke(()=>import("./TasksListPage-OIcFFp1C.js"),__vite__mapDeps([75,1,2,3,4,7,8,9,19,61,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),R3=E.lazy(()=>ke(()=>import("./TaskDetailPage-HycMx3O9.js"),__vite__mapDeps([76,1,2,19,61,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),sx=E.lazy(()=>ke(()=>import("./WorkflowExecutionPage-Di08wCbs.js"),__vite__mapDeps([77,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),D3=E.lazy(()=>ke(()=>import("./AdminDashboard-DlItqxFS.js"),__vite__mapDeps([78,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),L3=E.lazy(()=>ke(()=>import("./index-Cga5IW3D.js"),__vite__mapDeps([79,1,7,8,9,12,13,31,3,4,14,80,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),q3=E.lazy(()=>ke(()=>import("./index-jL2K6us4.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),ix=E.lazy(()=>ke(()=>import("./index-jL2K6us4.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),P3=E.lazy(()=>ke(()=>import("./index-Cx8xb-oU.js"),__vite__mapDeps([83,1,23,8,82,14,13,12,11,3,4,84,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),ax=E.lazy(()=>ke(()=>import("./index-2SM2_onB.js"),__vite__mapDeps([85,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),B3=E.lazy(()=>ke(()=>import("./index-CL_1VpGb.js"),__vite__mapDeps([86,1,3,4,7,8,9,11,12,13,82,31,14,20,47,49,87,88,33]),import.meta.url).then(n=>({default:n.UsersPage}))),U3=E.lazy(()=>ke(()=>import("./RolesPage-DBKxeam4.js"),__vite__mapDeps([89,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),z3=E.lazy(()=>ke(()=>import("./RoleDetailPage-CTbq0mz4.js"),__vite__mapDeps([90,1,91,82,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),I3=E.lazy(()=>ke(()=>import("./PersonasPage-BJClu-5H.js"),__vite__mapDeps([92,1,87,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),$3=E.lazy(()=>ke(()=>import("./PersonaDetailPage-D0qlBuGi.js"),__vite__mapDeps([93,1,87,20,13,88,91,82,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),H3=E.lazy(()=>ke(()=>import("./EscalationSchemaPage-BKi_npI9.js"),__vite__mapDeps([94,1,65,13,66,4,57,21,58,19,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),F3=E.lazy(()=>ke(()=>import("./PortalPage-CucNZn_w.js"),__vite__mapDeps([95,1,9,56,13,57,21,58,19,4,7,8,59,11,60,12,61,20,16,62]),import.meta.url).then(n=>({default:n.PortalPage}))),G3=E.lazy(()=>ke(()=>import("./EscalationListSchemaPage-Bad6Jrmr.js"),__vite__mapDeps([96,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),V3=E.lazy(()=>ke(()=>import("./ScanCodesPage-BlKleaT0.js"),__vite__mapDeps([97,1,98,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),Y3=E.lazy(()=>ke(()=>import("./ScanSchemeDetailPage-CTW6gofi.js"),__vite__mapDeps([99,1,82,14,13,98,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),K3=E.lazy(()=>ke(()=>import("./ScanStationPage-DPRjSPyT.js"),__vite__mapDeps([100,1,13,67,57,21,66,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),J3=E.lazy(()=>ke(()=>import("./index-CZ7A3AcD.js"),__vite__mapDeps([101,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),ox=E.lazy(()=>ke(()=>import("./OperationsPage-BSu1o2gB.js").then(n=>n.O),__vite__mapDeps([102,1,60,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),Q3=E.lazy(()=>ke(()=>import("./index-4YaDUcKd.js"),__vite__mapDeps([103,1,18,13,12,3,4,29,26,42,80,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),X3=E.lazy(()=>ke(()=>import("./index-DiaRlFYI.js"),__vite__mapDeps([104,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),W3=E.lazy(()=>ke(()=>import("./CredentialsPage-bLYydwqa.js"),__vite__mapDeps([105,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),Z3=E.lazy(()=>ke(()=>import("./ConnectedAppsPage-DlMzE5a-.js"),__vite__mapDeps([106,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.ConnectedAppsPage}))),e5=E.lazy(()=>ke(()=>import("./index-XntldBd0.js"),__vite__mapDeps([107,1,4,14,13,12,15,6,8,108,49]),import.meta.url).then(n=>({default:n.FilesPage}))),t5=E.lazy(()=>ke(()=>import("./index-Rwqrflm-.js"),__vite__mapDeps([109,1,14,13,12,15,11,8,108,49,110,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),n5=E.lazy(()=>ke(()=>import("./HomePage-EjcNxlKx.js"),__vite__mapDeps([111,1,24,26,20,13,16,15,102,60,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),r5=E.lazy(()=>ke(()=>import("./AgentsPage-C9UuUKhr.js"),__vite__mapDeps([112,1,113,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),s5=E.lazy(()=>ke(()=>import("./AgentDetailPage-Cww8rlBi.js"),__vite__mapDeps([114,1,113,115,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),lx=E.lazy(()=>ke(()=>import("./AgentConfigPage-BUmT4a7n.js"),__vite__mapDeps([116,1,113,115,13,14,110,45,46,47,25,117,118,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),i5=E.lazy(()=>ke(()=>import("./CapabilitiesPage-CSCrI6B1.js"),__vite__mapDeps([119,1,117,84,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),a5=E.lazy(()=>ke(()=>import("./TopicsPage-CqiEcj-W.js"),__vite__mapDeps([120,1,118,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),o5=E.lazy(()=>ke(()=>import("./TopicDetailPage-iZW8rK9L.js"),__vite__mapDeps([121,1,118,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function l5(){return h.jsxs("div",{className:"animate-pulse space-y-4",children:[h.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function Ee({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(l5,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Zv=new hS({defaultOptions:{queries:{staleTime:1e4,retry:(n,e)=>e instanceof Error&&e.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Zv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",e=`${n}/login`;if(window.location.pathname!==e){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${e}?returnTo=${encodeURIComponent(i)}`}});const c5=pS([{path:"/login",element:h.jsx(e3,{})},{path:"/connect/anthropic",element:h.jsx(rx,{})},{path:"/connect/:provider",element:h.jsx(rx,{})},{path:"/oauth/consent",element:h.jsx(c3,{})},{path:"/",element:h.jsx(XC,{}),children:[{index:!0,element:h.jsx(Ee,{children:h.jsx(n5,{})})},{path:"processes/all",element:h.jsx(Ee,{children:h.jsx(d3,{})})},{path:"processes/detail/:originId",element:h.jsx(Ee,{children:h.jsx(m3,{})})},{path:"credentials",element:h.jsx(Ee,{children:h.jsx(W3,{})})},{path:"connected-apps",element:h.jsx(Ee,{children:h.jsx(Z3,{})})},{path:"connections",element:h.jsx(Sn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Ee,{children:h.jsx(v3,{})})},{path:"escalations/available",element:h.jsx(Ee,{children:h.jsx(_3,{})})},{path:"escalations/queue",element:h.jsx(Ee,{children:h.jsx(w3,{})})},{path:"escalations/detail/:id",element:h.jsx(Ee,{children:h.jsx(S3,{})})},{path:"portal/:role/:portal?",element:h.jsx(Ee,{children:h.jsx(F3,{})})},{path:"scan/station",element:h.jsx(Ee,{children:h.jsx(K3,{})})},{path:"capabilities",element:h.jsx(Ee,{children:h.jsx(i5,{})})},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"agents",element:h.jsx(Ee,{children:h.jsx(r5,{})})},{path:"agents/new",element:h.jsx(Ee,{children:h.jsx(lx,{})})},{path:"agents/:id",element:h.jsx(Ee,{children:h.jsx(s5,{})})},{path:"agents/:id/edit",element:h.jsx(Ee,{children:h.jsx(lx,{})})},{path:"topics",element:h.jsx(Ee,{children:h.jsx(a5,{})})},{path:"topics/:topic",element:h.jsx(Ee,{children:h.jsx(o5,{})})}]},{element:h.jsx(u3,{}),children:[{path:"workflows/start",element:h.jsx(Ee,{children:h.jsx(O3,{})})},{path:"workflows/durable/invoke",element:h.jsx(Ee,{children:h.jsx(A3,{})})}]},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Ee,{children:h.jsx(E3,{})})},{path:"workflows/executions",element:h.jsx(Ee,{children:h.jsx(k3,{})})},{path:"workflows/durable/executions",element:h.jsx(Ee,{children:h.jsx(j3,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(sx,{})})},{path:"workflows/tasks",element:h.jsx(Ee,{children:h.jsx(M3,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Ee,{children:h.jsx(R3,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Ee,{children:h.jsx(sx,{})})},{path:"workflows/cron",element:h.jsx(Sn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Ee,{children:h.jsx(L3,{})})},{path:"workflows/registry",element:h.jsx(Ee,{children:h.jsx(q3,{})})},{path:"workflows/registry/new",element:h.jsx(Ee,{children:h.jsx(ix,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Ee,{children:h.jsx(ix,{})})}]},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Ee,{children:h.jsx(N3,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Ee,{children:h.jsx(T3,{})})},{path:"mcp/workflows/:id",element:h.jsx(Ee,{children:h.jsx(C3,{})})},{path:"mcp/executions",element:h.jsx(Ee,{children:h.jsx(y3,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Ee,{children:h.jsx(g3,{})})},{path:"files",element:h.jsx(Ee,{children:h.jsx(e5,{})})},{path:"knowledge",element:h.jsx(Ee,{children:h.jsx(t5,{})})},{element:h.jsx(f3,{}),children:[{path:"mcp",element:h.jsx(Ee,{children:h.jsx(p3,{})})},{path:"mcp/queries",element:h.jsx(Ee,{children:h.jsx(b3,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Ee,{children:h.jsx(x3,{})})},{path:"mcp/tools",element:h.jsx(Sn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Ee,{children:h.jsx(P3,{})})},{path:"mcp/servers/new",element:h.jsx(Ee,{children:h.jsx(ax,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Ee,{children:h.jsx(ax,{})})}]}]},{path:"pace",element:h.jsx(Ee,{children:h.jsx(ox,{})})},{path:"trends",element:h.jsx(Ee,{children:h.jsx(ox,{})})},{path:"operations",element:h.jsx(Sn,{to:"/pace",replace:!0})},{element:h.jsx(po,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Ee,{children:h.jsx(D3,{})})},{path:"admin/users",element:h.jsx(Ee,{children:h.jsx(B3,{})})},{path:"admin/escalation-chains",element:h.jsx(Sn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Ee,{children:h.jsx(U3,{})})},{path:"admin/roles/:role",element:h.jsx(Ee,{children:h.jsx(z3,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Ee,{children:h.jsx(H3,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Ee,{children:h.jsx(G3,{})})},{path:"admin/scan-codes",element:h.jsx(Ee,{children:h.jsx(V3,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Ee,{children:h.jsx(Y3,{})})},{path:"admin/personas",element:h.jsx(Ee,{children:h.jsx(I3,{})})},{path:"admin/personas/:key",element:h.jsx(Ee,{children:h.jsx($3,{})})}]},{element:h.jsx(po,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(Sn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(h3,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Ee,{children:h.jsx(J3,{})})}]},{path:"admin/controlplane",element:h.jsx(Ee,{children:h.jsx(Q3,{})})},{path:"admin/streams",element:h.jsx(Ee,{children:h.jsx(X3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function u5(){return h.jsx(dS,{client:Zv,children:h.jsx(oE,{children:h.jsx(fA,{children:h.jsx(yS,{router:c5})})})})}Ev(Sv());const Vm=document.createElement("link");Vm.rel="stylesheet";Vm.href=`${Vt}/api/settings/custom.css`;document.head.appendChild(Vm);XS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(u5,{})}));export{qt as $,Jk as A,RM as B,Gm as C,qC as D,I5 as E,Vv as F,DM as G,Lm as H,DT as I,gC as J,LT as K,FT as L,tT as M,Xt as N,tv as O,q5 as P,Cm as Q,Z5 as R,iC as S,eM as T,tM as U,nM as V,rM as W,iM as X,Ij as Y,Mu as Z,z5 as _,$M as a,k5 as a$,nm as a0,zT as a1,j5 as a2,UM as a3,Bm as a4,ta as a5,xs as a6,V5 as a7,N5 as a8,pv as a9,FM as aA,HM as aB,Hv as aC,GM as aD,IM as aE,bv as aF,lM as aG,KM as aH,zM as aI,QM as aJ,JM as aK,x5 as aL,v5 as aM,E5 as aN,O5 as aO,_5 as aP,w5 as aQ,S5 as aR,C5 as aS,R5 as aT,M5 as aU,qM as aV,A5 as aW,Tm as aX,D5 as aY,IT as aZ,L5 as a_,AT as aa,Tk as ab,AM as ac,Xk as ad,dc as ae,Q5 as af,X5 as ag,Pu as ah,Qk as ai,FN as aj,LM as ak,jv as al,Cu as am,zm as an,zj as ao,_A as ap,H5 as aq,gM as ar,F5 as as,W5 as at,sM as au,uv as av,y5 as aw,zg as ax,g5 as ay,YM as az,fM as b,wM as b0,js as b1,Eo as b2,XM as b3,qx as b4,t3 as b5,vM as b6,Vt as b7,wd as b8,b5 as b9,kM as bA,TM as bB,ST as bC,$m as bD,pk as bE,Wk as bF,je as bG,jM as bH,B5 as bI,dM as bJ,nT as bK,WM as bL,ZM as bM,Wv as bN,eR as bO,tR as bP,jm as bQ,nv as bR,bM as bS,PT as ba,BM as bb,yv as bc,K1 as bd,kv as be,yM as bf,km as bg,mM as bh,EM as bi,Tj as bj,SM as bk,zk as bl,Uk as bm,ik as bn,J5 as bo,K5 as bp,fr as bq,rv as br,_M as bs,ea as bt,T5 as bu,Hk as bv,NM as bw,xk as bx,CM as by,MM as bz,er as c,OM as d,aM as e,yk as f,xv as g,nk as h,P5 as i,tn as j,An as k,oM as l,ue as m,VM as n,cM as o,uM as p,$5 as q,G5 as r,Y5 as s,hM as t,xM as u,U5 as v,Fm as w,PM as x,Xx as y,pM as z};
67
+ //# sourceMappingURL=index-Dz6R8-Dw.js.map