@hotmeshio/long-tail 0.21.2 → 0.22.1

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 (268) hide show
  1. package/build/api/escalations/accumulate.d.ts +10 -1
  2. package/build/api/escalations/accumulate.js +83 -15
  3. package/build/api/escalations/metadata.d.ts +5 -0
  4. package/build/api/escalations/metadata.js +6 -2
  5. package/build/api/scan-codes/choice.js +3 -2
  6. package/build/api/scan-codes/verbs.d.ts +6 -1
  7. package/build/api/scan-codes/verbs.js +13 -3
  8. package/build/api/workflows/invocation.d.ts +8 -4
  9. package/build/api/workflows/invocation.js +26 -9
  10. package/build/lib/cli/commands/workflows.js +9 -4
  11. package/build/lib/db/index.d.ts +8 -3
  12. package/build/lib/db/index.js +24 -2
  13. package/build/routes/escalations/accumulate.js +13 -6
  14. package/build/sdk/index.d.ts +3 -0
  15. package/build/services/escalation/crud.d.ts +2 -2
  16. package/build/services/escalation/crud.js +4 -2
  17. package/build/services/escalation/facet-sql.js +8 -0
  18. package/build/services/escalation/facets.js +4 -1
  19. package/build/services/escalation/sql.d.ts +4 -2
  20. package/build/services/escalation/sql.js +10 -2
  21. package/build/services/export/index.d.ts +8 -3
  22. package/build/services/export/index.js +15 -21
  23. package/build/services/pipelines/events.js +2 -1
  24. package/build/services/pipelines/execution-builder.js +2 -1
  25. package/build/services/pipelines/queries.js +2 -1
  26. package/build/services/scan-code/validate.js +19 -0
  27. package/build/services/workflow-state.d.ts +21 -0
  28. package/build/services/workflow-state.js +39 -0
  29. package/build/shared/workflow-state.d.ts +17 -0
  30. package/build/shared/workflow-state.js +29 -0
  31. package/build/system/mcp-servers/admin/escalations.js +8 -4
  32. package/build/system/mcp-servers/admin/schemas.d.ts +40 -2
  33. package/build/system/mcp-servers/admin/schemas.js +4 -0
  34. package/build/system/mcp-servers/admin/workflows.js +20 -31
  35. package/build/system/seed/tool-manifests-admin.d.ts +94 -0
  36. package/build/system/seed/tool-manifests-admin.js +3 -3
  37. package/build/tsconfig.tsbuildinfo +1 -1
  38. package/build/types/facets.d.ts +14 -0
  39. package/build/types/index.d.ts +1 -1
  40. package/build/types/scan-code.d.ts +10 -1
  41. package/build/types/scan-code.js +0 -11
  42. package/dashboard/dist/assets/{AdminDashboard-Covdam48.js → AdminDashboard-BbWve-Ax.js} +2 -2
  43. package/dashboard/dist/assets/{AdminDashboard-Covdam48.js.map → AdminDashboard-BbWve-Ax.js.map} +1 -1
  44. package/dashboard/dist/assets/{AgentConfigPage-CE1k6J5r.js → AgentConfigPage-M-9eTKhP.js} +2 -2
  45. package/dashboard/dist/assets/{AgentConfigPage-CE1k6J5r.js.map → AgentConfigPage-M-9eTKhP.js.map} +1 -1
  46. package/dashboard/dist/assets/{AgentDetailPage-CWJZIZP1.js → AgentDetailPage-CsakSlx5.js} +3 -3
  47. package/dashboard/dist/assets/{AgentDetailPage-CWJZIZP1.js.map → AgentDetailPage-CsakSlx5.js.map} +1 -1
  48. package/dashboard/dist/assets/{AgentsPage---Dg5ufF.js → AgentsPage-Cj_cRTT1.js} +2 -2
  49. package/dashboard/dist/assets/{AgentsPage---Dg5ufF.js.map → AgentsPage-Cj_cRTT1.js.map} +1 -1
  50. package/dashboard/dist/assets/AvailableEscalationsPage-BXJmMBM1.js +2 -0
  51. package/dashboard/dist/assets/AvailableEscalationsPage-BXJmMBM1.js.map +1 -0
  52. package/dashboard/dist/assets/{BotPicker-D3drO3-T.js → BotPicker-CGB16rYU.js} +2 -2
  53. package/dashboard/dist/assets/{BotPicker-D3drO3-T.js.map → BotPicker-CGB16rYU.js.map} +1 -1
  54. package/dashboard/dist/assets/{BulkAssignModal-BOAWsViq.js → BulkAssignModal-MjxcU7N1.js} +2 -2
  55. package/dashboard/dist/assets/{BulkAssignModal-BOAWsViq.js.map → BulkAssignModal-MjxcU7N1.js.map} +1 -1
  56. package/dashboard/dist/assets/{CapabilitiesPage-RGgD3YZO.js → CapabilitiesPage-BxadotXn.js} +2 -2
  57. package/dashboard/dist/assets/{CapabilitiesPage-RGgD3YZO.js.map → CapabilitiesPage-BxadotXn.js.map} +1 -1
  58. package/dashboard/dist/assets/{CollapsibleSection-DNkZn87n.js → CollapsibleSection-BBNpP-6h.js} +2 -2
  59. package/dashboard/dist/assets/{CollapsibleSection-DNkZn87n.js.map → CollapsibleSection-BBNpP-6h.js.map} +1 -1
  60. package/dashboard/dist/assets/{ConfirmDeleteModal-BqzOwhPr.js → ConfirmDeleteModal-D_kAbT_D.js} +2 -2
  61. package/dashboard/dist/assets/{ConfirmDeleteModal-BqzOwhPr.js.map → ConfirmDeleteModal-D_kAbT_D.js.map} +1 -1
  62. package/dashboard/dist/assets/{CountdownTimer-BaexQMK6.js → CountdownTimer-CI_JOAvk.js} +2 -2
  63. package/dashboard/dist/assets/{CountdownTimer-BaexQMK6.js.map → CountdownTimer-CI_JOAvk.js.map} +1 -1
  64. package/dashboard/dist/assets/{CredentialsPage-D7abp0aS.js → CredentialsPage-C9OA1Q2J.js} +2 -2
  65. package/dashboard/dist/assets/{CredentialsPage-D7abp0aS.js.map → CredentialsPage-C9OA1Q2J.js.map} +1 -1
  66. package/dashboard/dist/assets/{CronLabel-DZiWmTwJ.js → CronLabel-sxLLBf2I.js} +2 -2
  67. package/dashboard/dist/assets/{CronLabel-DZiWmTwJ.js.map → CronLabel-sxLLBf2I.js.map} +1 -1
  68. package/dashboard/dist/assets/{DropZone-f1o-GLM8.js → DropZone-B1Tdfddc.js} +2 -2
  69. package/dashboard/dist/assets/{DropZone-f1o-GLM8.js.map → DropZone-B1Tdfddc.js.map} +1 -1
  70. package/dashboard/dist/assets/{ElapsedCell-BdGO_w4v.js → ElapsedCell-jH9m8Dgl.js} +2 -2
  71. package/dashboard/dist/assets/{ElapsedCell-BdGO_w4v.js.map → ElapsedCell-jH9m8Dgl.js.map} +1 -1
  72. package/dashboard/dist/assets/{EntityTimelinePanel-DIDcF5Yu.js → EntityTimelinePanel-Dl3Nr2kk.js} +2 -2
  73. package/dashboard/dist/assets/{EntityTimelinePanel-DIDcF5Yu.js.map → EntityTimelinePanel-Dl3Nr2kk.js.map} +1 -1
  74. package/dashboard/dist/assets/{EscalationListSchemaPage-C28rn9XC.js → EscalationListSchemaPage-DAK6It5J.js} +3 -3
  75. package/dashboard/dist/assets/{EscalationListSchemaPage-C28rn9XC.js.map → EscalationListSchemaPage-DAK6It5J.js.map} +1 -1
  76. package/dashboard/dist/assets/{EscalationListView-CkBnkpDJ.js → EscalationListView-CAHbdxKR.js} +2 -2
  77. package/dashboard/dist/assets/{EscalationListView-CkBnkpDJ.js.map → EscalationListView-CAHbdxKR.js.map} +1 -1
  78. package/dashboard/dist/assets/EscalationSchemaPage-DotfAMCL.js +9 -0
  79. package/dashboard/dist/assets/EscalationSchemaPage-DotfAMCL.js.map +1 -0
  80. package/dashboard/dist/assets/EscalationTimeline-DqmFydnU.js +2 -0
  81. package/dashboard/dist/assets/EscalationTimeline-DqmFydnU.js.map +1 -0
  82. package/dashboard/dist/assets/{EscalationTitleSelect-CzKfavri.js → EscalationTitleSelect-BpRquguO.js} +2 -2
  83. package/dashboard/dist/assets/{EscalationTitleSelect-CzKfavri.js.map → EscalationTitleSelect-BpRquguO.js.map} +1 -1
  84. package/dashboard/dist/assets/{EscalationsOverview-Tdu3Yx2c.js → EscalationsOverview-DtGOqnP4.js} +2 -2
  85. package/dashboard/dist/assets/{EscalationsOverview-Tdu3Yx2c.js.map → EscalationsOverview-DtGOqnP4.js.map} +1 -1
  86. package/dashboard/dist/assets/{EventTable-DiIxOJwO.js → EventTable-DSHqKyX2.js} +2 -2
  87. package/dashboard/dist/assets/{EventTable-DiIxOJwO.js.map → EventTable-DSHqKyX2.js.map} +1 -1
  88. package/dashboard/dist/assets/{FilterBar-CvMBCVIo.js → FilterBar-Dxd0wNSW.js} +2 -2
  89. package/dashboard/dist/assets/{FilterBar-CvMBCVIo.js.map → FilterBar-Dxd0wNSW.js.map} +1 -1
  90. package/dashboard/dist/assets/{GraphInvokePage-DO-yyhi6.js → GraphInvokePage-ChqqGkro.js} +2 -2
  91. package/dashboard/dist/assets/{GraphInvokePage-DO-yyhi6.js.map → GraphInvokePage-ChqqGkro.js.map} +1 -1
  92. package/dashboard/dist/assets/{HomePage-DSS3eHR2.js → HomePage-ByKesG8w.js} +2 -2
  93. package/dashboard/dist/assets/{HomePage-DSS3eHR2.js.map → HomePage-ByKesG8w.js.map} +1 -1
  94. package/dashboard/dist/assets/{ListToolbar-C3-Tqqub.js → ListToolbar-Ddz_S2av.js} +2 -2
  95. package/dashboard/dist/assets/{ListToolbar-C3-Tqqub.js.map → ListToolbar-Ddz_S2av.js.map} +1 -1
  96. package/dashboard/dist/assets/{McpOverview-DEJmsdVi.js → McpOverview-CVe13tEv.js} +2 -2
  97. package/dashboard/dist/assets/{McpOverview-DEJmsdVi.js.map → McpOverview-CVe13tEv.js.map} +1 -1
  98. package/dashboard/dist/assets/McpQueryDetailPage-BQYF2Mjq.js +5 -0
  99. package/dashboard/dist/assets/McpQueryDetailPage-BQYF2Mjq.js.map +1 -0
  100. package/dashboard/dist/assets/{McpQueryPage-BBcG_UuU.js → McpQueryPage-DZi5lm7s.js} +2 -2
  101. package/dashboard/dist/assets/{McpQueryPage-BBcG_UuU.js.map → McpQueryPage-DZi5lm7s.js.map} +1 -1
  102. package/dashboard/dist/assets/{McpRunDetailPage-C6xw0kBg.js → McpRunDetailPage-DreARTE1.js} +2 -2
  103. package/dashboard/dist/assets/{McpRunDetailPage-C6xw0kBg.js.map → McpRunDetailPage-DreARTE1.js.map} +1 -1
  104. package/dashboard/dist/assets/{McpRunsPage-CRQqrF4Q.js → McpRunsPage-DmO0YVhT.js} +2 -2
  105. package/dashboard/dist/assets/{McpRunsPage-CRQqrF4Q.js.map → McpRunsPage-DmO0YVhT.js.map} +1 -1
  106. package/dashboard/dist/assets/{NamespacePill-DADRJOUl.js → NamespacePill-DwM5pNA4.js} +2 -2
  107. package/dashboard/dist/assets/{NamespacePill-DADRJOUl.js.map → NamespacePill-DwM5pNA4.js.map} +1 -1
  108. package/dashboard/dist/assets/{OperationsPage-Dlfwzf-0.js → OperationsPage-DpjCO85T.js} +2 -2
  109. package/dashboard/dist/assets/{OperationsPage-Dlfwzf-0.js.map → OperationsPage-DpjCO85T.js.map} +1 -1
  110. package/dashboard/dist/assets/{OperatorDashboard-DoiDGZ9R.js → OperatorDashboard-Vv_MEBkv.js} +2 -2
  111. package/dashboard/dist/assets/{OperatorDashboard-DoiDGZ9R.js.map → OperatorDashboard-Vv_MEBkv.js.map} +1 -1
  112. package/dashboard/dist/assets/{PageHeader-Csq434-v.js → PageHeader-CMd3f4bz.js} +2 -2
  113. package/dashboard/dist/assets/{PageHeader-Csq434-v.js.map → PageHeader-CMd3f4bz.js.map} +1 -1
  114. package/dashboard/dist/assets/{PageHeaderWithStats-CSnk1p5A.js → PageHeaderWithStats-DHj8Mqox.js} +2 -2
  115. package/dashboard/dist/assets/{PageHeaderWithStats-CSnk1p5A.js.map → PageHeaderWithStats-DHj8Mqox.js.map} +1 -1
  116. package/dashboard/dist/assets/{PersonaDetailPage-BzbA4Prr.js → PersonaDetailPage-CW-2uBHY.js} +2 -2
  117. package/dashboard/dist/assets/{PersonaDetailPage-BzbA4Prr.js.map → PersonaDetailPage-CW-2uBHY.js.map} +1 -1
  118. package/dashboard/dist/assets/{PersonasPage-B36yn4hU.js → PersonasPage-CO6yYQdm.js} +2 -2
  119. package/dashboard/dist/assets/{PersonasPage-B36yn4hU.js.map → PersonasPage-CO6yYQdm.js.map} +1 -1
  120. package/dashboard/dist/assets/{PortalPage-BkD4YfDf.js → PortalPage-DcNqhBlg.js} +2 -2
  121. package/dashboard/dist/assets/{PortalPage-BkD4YfDf.js.map → PortalPage-DcNqhBlg.js.map} +1 -1
  122. package/dashboard/dist/assets/{ProcessDetailPage-BT0eiBWY.js → ProcessDetailPage-BuipGZcC.js} +2 -2
  123. package/dashboard/dist/assets/{ProcessDetailPage-BT0eiBWY.js.map → ProcessDetailPage-BuipGZcC.js.map} +1 -1
  124. package/dashboard/dist/assets/{ProcessesListPage-BEqeeNae.js → ProcessesListPage-D9DYntvl.js} +2 -2
  125. package/dashboard/dist/assets/{ProcessesListPage-BEqeeNae.js.map → ProcessesListPage-D9DYntvl.js.map} +1 -1
  126. package/dashboard/dist/assets/ResolverForm-BVG8X0sS.js +8 -0
  127. package/dashboard/dist/assets/ResolverForm-BVG8X0sS.js.map +1 -0
  128. package/dashboard/dist/assets/{RoleDetailPage-BFuLNJXa.js → RoleDetailPage-KCXDqoJz.js} +3 -3
  129. package/dashboard/dist/assets/{RoleDetailPage-BFuLNJXa.js.map → RoleDetailPage-KCXDqoJz.js.map} +1 -1
  130. package/dashboard/dist/assets/{RolePill-BafrASDX.js → RolePill-Di2CAHuD.js} +2 -2
  131. package/dashboard/dist/assets/{RolePill-BafrASDX.js.map → RolePill-Di2CAHuD.js.map} +1 -1
  132. package/dashboard/dist/assets/{RolesPage-80quJU5-.js → RolesPage-0QJOBSzF.js} +2 -2
  133. package/dashboard/dist/assets/{RolesPage-80quJU5-.js.map → RolesPage-0QJOBSzF.js.map} +1 -1
  134. package/dashboard/dist/assets/{RunAsSelector-BoePhWVD.js → RunAsSelector-Dh4lyyRo.js} +2 -2
  135. package/dashboard/dist/assets/{RunAsSelector-BoePhWVD.js.map → RunAsSelector-Dh4lyyRo.js.map} +1 -1
  136. package/dashboard/dist/assets/{ScanCodesPage-Cu1bKEix.js → ScanCodesPage-CUhCz-Yr.js} +2 -2
  137. package/dashboard/dist/assets/{ScanCodesPage-Cu1bKEix.js.map → ScanCodesPage-CUhCz-Yr.js.map} +1 -1
  138. package/dashboard/dist/assets/{ScanSchemeDetailPage-D9AbS6UY.js → ScanSchemeDetailPage-qzXKNqJK.js} +2 -2
  139. package/dashboard/dist/assets/{ScanSchemeDetailPage-D9AbS6UY.js.map → ScanSchemeDetailPage-qzXKNqJK.js.map} +1 -1
  140. package/dashboard/dist/assets/{ScanStationPage-gcZGefvT.js → ScanStationPage-D8e8cG3t.js} +2 -2
  141. package/dashboard/dist/assets/{ScanStationPage-gcZGefvT.js.map → ScanStationPage-D8e8cG3t.js.map} +1 -1
  142. package/dashboard/dist/assets/{ScopeBadge-b6MIBiYD.js → ScopeBadge-CSItPVOH.js} +2 -2
  143. package/dashboard/dist/assets/{ScopeBadge-b6MIBiYD.js.map → ScopeBadge-CSItPVOH.js.map} +1 -1
  144. package/dashboard/dist/assets/{StickyPagination-9ITrei_d.js → StickyPagination-BSUyf5ja.js} +2 -2
  145. package/dashboard/dist/assets/{StickyPagination-9ITrei_d.js.map → StickyPagination-BSUyf5ja.js.map} +1 -1
  146. package/dashboard/dist/assets/{StreamMessageDetail-BkYvEHFY.js → StreamMessageDetail--tp7l2Sd.js} +2 -2
  147. package/dashboard/dist/assets/{StreamMessageDetail-BkYvEHFY.js.map → StreamMessageDetail--tp7l2Sd.js.map} +1 -1
  148. package/dashboard/dist/assets/{SwimlaneTimeline-B1rotFix.js → SwimlaneTimeline-CxBZ2THh.js} +2 -2
  149. package/dashboard/dist/assets/{SwimlaneTimeline-B1rotFix.js.map → SwimlaneTimeline-CxBZ2THh.js.map} +1 -1
  150. package/dashboard/dist/assets/{TagInput-ZrIIrEUP.js → TagInput-CAgdLN_b.js} +2 -2
  151. package/dashboard/dist/assets/{TagInput-ZrIIrEUP.js.map → TagInput-CAgdLN_b.js.map} +1 -1
  152. package/dashboard/dist/assets/{TaskDetailPage-zhn_U_eC.js → TaskDetailPage-BJ1QrmPH.js} +2 -2
  153. package/dashboard/dist/assets/{TaskDetailPage-zhn_U_eC.js.map → TaskDetailPage-BJ1QrmPH.js.map} +1 -1
  154. package/dashboard/dist/assets/{TaskQueuePill-DkQ1uc6y.js → TaskQueuePill-h0oorVMe.js} +2 -2
  155. package/dashboard/dist/assets/{TaskQueuePill-DkQ1uc6y.js.map → TaskQueuePill-h0oorVMe.js.map} +1 -1
  156. package/dashboard/dist/assets/{TasksListPage-CNbNeagx.js → TasksListPage-5BydGWmt.js} +2 -2
  157. package/dashboard/dist/assets/{TasksListPage-CNbNeagx.js.map → TasksListPage-5BydGWmt.js.map} +1 -1
  158. package/dashboard/dist/assets/{TimeAgo-0YVMBwls.js → TimeAgo-CCnz84Y4.js} +2 -2
  159. package/dashboard/dist/assets/{TimeAgo-0YVMBwls.js.map → TimeAgo-CCnz84Y4.js.map} +1 -1
  160. package/dashboard/dist/assets/{TimestampCell-DB7r3np8.js → TimestampCell-D0ru7Lya.js} +2 -2
  161. package/dashboard/dist/assets/{TimestampCell-DB7r3np8.js.map → TimestampCell-D0ru7Lya.js.map} +1 -1
  162. package/dashboard/dist/assets/{ToolPill-Baxm02L6.js → ToolPill-CQCsVdzD.js} +2 -2
  163. package/dashboard/dist/assets/{ToolPill-Baxm02L6.js.map → ToolPill-CQCsVdzD.js.map} +1 -1
  164. package/dashboard/dist/assets/{ToolTestPanel-BLfA02wv.js → ToolTestPanel-3Kpofmen.js} +2 -2
  165. package/dashboard/dist/assets/{ToolTestPanel-BLfA02wv.js.map → ToolTestPanel-3Kpofmen.js.map} +1 -1
  166. package/dashboard/dist/assets/{TopicDetailPage-eAqPKShq.js → TopicDetailPage-BaBXD_AK.js} +4 -4
  167. package/dashboard/dist/assets/{TopicDetailPage-eAqPKShq.js.map → TopicDetailPage-BaBXD_AK.js.map} +1 -1
  168. package/dashboard/dist/assets/{TopicsPage-BNNWD-zl.js → TopicsPage-Cnm1AAjh.js} +2 -2
  169. package/dashboard/dist/assets/{TopicsPage-BNNWD-zl.js.map → TopicsPage-Cnm1AAjh.js.map} +1 -1
  170. package/dashboard/dist/assets/{UserName-Pw46tO_k.js → UserName-CXsdPiMZ.js} +2 -2
  171. package/dashboard/dist/assets/{UserName-Pw46tO_k.js.map → UserName-CXsdPiMZ.js.map} +1 -1
  172. package/dashboard/dist/assets/{WorkflowExecutionPage-DvA51lT3.js → WorkflowExecutionPage-zx3AUJFd.js} +2 -2
  173. package/dashboard/dist/assets/{WorkflowExecutionPage-DvA51lT3.js.map → WorkflowExecutionPage-zx3AUJFd.js.map} +1 -1
  174. package/dashboard/dist/assets/{WorkflowPill-ZepbO_ny.js → WorkflowPill-Dg7BDTyM.js} +2 -2
  175. package/dashboard/dist/assets/{WorkflowPill-ZepbO_ny.js.map → WorkflowPill-Dg7BDTyM.js.map} +1 -1
  176. package/dashboard/dist/assets/{WorkflowsDashboard-DFDTwnhn.js → WorkflowsDashboard-DfAGK1l7.js} +2 -2
  177. package/dashboard/dist/assets/{WorkflowsDashboard-DFDTwnhn.js.map → WorkflowsDashboard-DfAGK1l7.js.map} +1 -1
  178. package/dashboard/dist/assets/{WorkflowsOverview-5i2Tcy-p.js → WorkflowsOverview-QIYvoa13.js} +2 -2
  179. package/dashboard/dist/assets/{WorkflowsOverview-5i2Tcy-p.js.map → WorkflowsOverview-QIYvoa13.js.map} +1 -1
  180. package/dashboard/dist/assets/{YamlWorkflowDetailPage-p4VEYZS0.js → YamlWorkflowDetailPage-DGgO3hyB.js} +2 -2
  181. package/dashboard/dist/assets/{YamlWorkflowDetailPage-p4VEYZS0.js.map → YamlWorkflowDetailPage-DGgO3hyB.js.map} +1 -1
  182. package/dashboard/dist/assets/{YamlWorkflowsPage-Cq-hMVxl.js → YamlWorkflowsPage-CEsHm0B9.js} +2 -2
  183. package/dashboard/dist/assets/{YamlWorkflowsPage-Cq-hMVxl.js.map → YamlWorkflowsPage-CEsHm0B9.js.map} +1 -1
  184. package/dashboard/dist/assets/{agents-EyBPJMYa.js → agents-v_HH3Rji.js} +2 -2
  185. package/dashboard/dist/assets/{agents-EyBPJMYa.js.map → agents-v_HH3Rji.js.map} +1 -1
  186. package/dashboard/dist/assets/{bots-DX6jjqtF.js → bots-bwvWYrXz.js} +2 -2
  187. package/dashboard/dist/assets/{bots-DX6jjqtF.js.map → bots-bwvWYrXz.js.map} +1 -1
  188. package/dashboard/dist/assets/{capabilities-ZdLv9xBQ.js → capabilities-D4vaw_nQ.js} +2 -2
  189. package/dashboard/dist/assets/{capabilities-ZdLv9xBQ.js.map → capabilities-D4vaw_nQ.js.map} +1 -1
  190. package/dashboard/dist/assets/{controlplane-CpvZaJuw.js → controlplane-CiiZ6LJF.js} +2 -2
  191. package/dashboard/dist/assets/{controlplane-CpvZaJuw.js.map → controlplane-CiiZ6LJF.js.map} +1 -1
  192. package/dashboard/dist/assets/{escalation-columns-Mvsze5eV.js → escalation-columns-Dv-MB3eC.js} +2 -2
  193. package/dashboard/dist/assets/{escalation-columns-Mvsze5eV.js.map → escalation-columns-Dv-MB3eC.js.map} +1 -1
  194. package/dashboard/dist/assets/{index-oFKUFGQL.js → index-2tzsxFat.js} +2 -2
  195. package/dashboard/dist/assets/{index-oFKUFGQL.js.map → index-2tzsxFat.js.map} +1 -1
  196. package/dashboard/dist/assets/{index-DZhtP2Ok.js → index-BLB77tc8.js} +2 -2
  197. package/dashboard/dist/assets/{index-DZhtP2Ok.js.map → index-BLB77tc8.js.map} +1 -1
  198. package/dashboard/dist/assets/{index-PfSRKerc.js → index-C3WutFpT.js} +2 -2
  199. package/dashboard/dist/assets/{index-PfSRKerc.js.map → index-C3WutFpT.js.map} +1 -1
  200. package/dashboard/dist/assets/{index-DkrBFFSO.js → index-C4Lce2ET.js} +2 -2
  201. package/dashboard/dist/assets/{index-DkrBFFSO.js.map → index-C4Lce2ET.js.map} +1 -1
  202. package/dashboard/dist/assets/index-CT-FN6CW.js +3 -0
  203. package/dashboard/dist/assets/index-CT-FN6CW.js.map +1 -0
  204. package/dashboard/dist/assets/{index-Eo-l3Lqo.js → index-C_ISDOWJ.js} +2 -2
  205. package/dashboard/dist/assets/{index-Eo-l3Lqo.js.map → index-C_ISDOWJ.js.map} +1 -1
  206. package/dashboard/dist/assets/{index-Bhb89oHH.js → index-CcuvGdvf.js} +2 -2
  207. package/dashboard/dist/assets/{index-Bhb89oHH.js.map → index-CcuvGdvf.js.map} +1 -1
  208. package/dashboard/dist/assets/{index-BbCjGO3M.js → index-CjenRVX_.js} +2 -2
  209. package/dashboard/dist/assets/{index-BbCjGO3M.js.map → index-CjenRVX_.js.map} +1 -1
  210. package/dashboard/dist/assets/{index-DGmzBY9D.js → index-CzjUgFt_.js} +2 -2
  211. package/dashboard/dist/assets/{index-DGmzBY9D.js.map → index-CzjUgFt_.js.map} +1 -1
  212. package/dashboard/dist/assets/{index-D-Xs4rAW.js → index-D2VKBMng.js} +2 -2
  213. package/dashboard/dist/assets/{index-D-Xs4rAW.js.map → index-D2VKBMng.js.map} +1 -1
  214. package/dashboard/dist/assets/{index-z5Hpeidu.js → index-D6pBLZFu.js} +2 -2
  215. package/dashboard/dist/assets/{index-z5Hpeidu.js.map → index-D6pBLZFu.js.map} +1 -1
  216. package/dashboard/dist/assets/{index-Cn8uJsd7.js → index-IJmtbuLh.js} +2 -2
  217. package/dashboard/dist/assets/{index-Cn8uJsd7.js.map → index-IJmtbuLh.js.map} +1 -1
  218. package/dashboard/dist/assets/{index-CgUcYveM.js → index-N71QQ3J5.js} +5 -5
  219. package/dashboard/dist/assets/index-N71QQ3J5.js.map +1 -0
  220. package/dashboard/dist/assets/{knowledge-CgloEkaf.js → knowledge-D1YP2NzS.js} +2 -2
  221. package/dashboard/dist/assets/{knowledge-CgloEkaf.js.map → knowledge-D1YP2NzS.js.map} +1 -1
  222. package/dashboard/dist/assets/{mcp-Bix7QYO7.js → mcp-Bb5psC61.js} +2 -2
  223. package/dashboard/dist/assets/{mcp-Bix7QYO7.js.map → mcp-Bb5psC61.js.map} +1 -1
  224. package/dashboard/dist/assets/{mcp-query-o-sGX2ST.js → mcp-query-D5jUdZwN.js} +2 -2
  225. package/dashboard/dist/assets/{mcp-query-o-sGX2ST.js.map → mcp-query-D5jUdZwN.js.map} +1 -1
  226. package/dashboard/dist/assets/{personas-30azkJ_s.js → personas-CDndbkp4.js} +2 -2
  227. package/dashboard/dist/assets/{personas-30azkJ_s.js.map → personas-CDndbkp4.js.map} +1 -1
  228. package/dashboard/dist/assets/{pipelines-Bfk2GFK7.js → pipelines-Dq3kNhKu.js} +2 -2
  229. package/dashboard/dist/assets/{pipelines-Bfk2GFK7.js.map → pipelines-Dq3kNhKu.js.map} +1 -1
  230. package/dashboard/dist/assets/{tasks-CpdopewW.js → tasks-BlpDsWCy.js} +2 -2
  231. package/dashboard/dist/assets/{tasks-CpdopewW.js.map → tasks-BlpDsWCy.js.map} +1 -1
  232. package/dashboard/dist/assets/{topics--bvCV9Yp.js → topics-C0YaR9fu.js} +2 -2
  233. package/dashboard/dist/assets/{topics--bvCV9Yp.js.map → topics-C0YaR9fu.js.map} +1 -1
  234. package/dashboard/dist/assets/{useDebouncedValue-Da0lPmj3.js → useDebouncedValue-B-KC5ba3.js} +2 -2
  235. package/dashboard/dist/assets/{useDebouncedValue-Da0lPmj3.js.map → useDebouncedValue-B-KC5ba3.js.map} +1 -1
  236. package/dashboard/dist/assets/{useNamespace-DD_Esl6n.js → useNamespace-Dkr5g2Ac.js} +2 -2
  237. package/dashboard/dist/assets/{useNamespace-DD_Esl6n.js.map → useNamespace-Dkr5g2Ac.js.map} +1 -1
  238. package/dashboard/dist/assets/{useYamlActivityEvents-AeAhZJJk.js → useYamlActivityEvents-BANBOshA.js} +2 -2
  239. package/dashboard/dist/assets/{useYamlActivityEvents-AeAhZJJk.js.map → useYamlActivityEvents-BANBOshA.js.map} +1 -1
  240. package/dashboard/dist/assets/{vendor-icons-B7OcUM6b.js → vendor-icons-CeVtUKyP.js} +2 -2
  241. package/dashboard/dist/assets/{vendor-icons-B7OcUM6b.js.map → vendor-icons-CeVtUKyP.js.map} +1 -1
  242. package/dashboard/dist/assets/{yaml-workflows-BHAOOGvn.js → yaml-workflows-BLYoJfmB.js} +2 -2
  243. package/dashboard/dist/assets/{yaml-workflows-BHAOOGvn.js.map → yaml-workflows-BLYoJfmB.js.map} +1 -1
  244. package/dashboard/dist/index.html +2 -2
  245. package/docs/accumulator.md +37 -1
  246. package/docs/api/mcp/admin.md +3 -2
  247. package/docs/api/sdk/escalations.md +6 -0
  248. package/docs/api/sdk/exports.md +1 -1
  249. package/docs/api/sdk/workflows.md +23 -4
  250. package/docs/cli.md +1 -1
  251. package/docs/dashboard.md +1 -1
  252. package/docs/faceted-routing.md +2 -0
  253. package/docs/hitl/x-lt-widget.md +5 -0
  254. package/docs/scan-codes.md +40 -7
  255. package/package.json +2 -2
  256. package/dashboard/dist/assets/AvailableEscalationsPage-CpbC8oTN.js +0 -2
  257. package/dashboard/dist/assets/AvailableEscalationsPage-CpbC8oTN.js.map +0 -1
  258. package/dashboard/dist/assets/EscalationSchemaPage-W5r0A1kj.js +0 -9
  259. package/dashboard/dist/assets/EscalationSchemaPage-W5r0A1kj.js.map +0 -1
  260. package/dashboard/dist/assets/EscalationTimeline-DKyTz6sM.js +0 -2
  261. package/dashboard/dist/assets/EscalationTimeline-DKyTz6sM.js.map +0 -1
  262. package/dashboard/dist/assets/McpQueryDetailPage-DYJr16l7.js +0 -5
  263. package/dashboard/dist/assets/McpQueryDetailPage-DYJr16l7.js.map +0 -1
  264. package/dashboard/dist/assets/ResolverForm-BwgjIX97.js +0 -7
  265. package/dashboard/dist/assets/ResolverForm-BwgjIX97.js.map +0 -1
  266. package/dashboard/dist/assets/index-B_GT23TE.js +0 -3
  267. package/dashboard/dist/assets/index-B_GT23TE.js.map +0 -1
  268. package/dashboard/dist/assets/index-CgUcYveM.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-BEqeeNae.js","./vendor-query-DvWWuNIB.js","./tasks-CpdopewW.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-Da0lPmj3.js","./api-path-u2Jf9QXS.js","./DataTable-spX1dFyb.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-DB7r3np8.js","./StickyPagination-9ITrei_d.js","./FilterBar-CvMBCVIo.js","./vendor-icons-B7OcUM6b.js","./PageHeader-Csq434-v.js","./ListToolbar-C3-Tqqub.js","./WorkflowPill-ZepbO_ny.js","./ProcessDetailPage-BT0eiBWY.js","./PageHeaderWithStats-CSnk1p5A.js","./StatusBadge-DHVwxre2.js","./RolePill-BafrASDX.js","./UserName-Pw46tO_k.js","./McpOverview-DEJmsdVi.js","./mcp-Bix7QYO7.js","./pipelines-Bfk2GFK7.js","./yaml-workflows-BHAOOGvn.js","./controlplane-CpvZaJuw.js","./StatCard-nWY4sndl.js","./McpRunsPage-CRQqrF4Q.js","./useNamespace-DD_Esl6n.js","./ElapsedCell-BdGO_w4v.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-C6xw0kBg.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-DiIxOJwO.js","./SwimlaneTimeline-B1rotFix.js","./StreamMessageDetail-BkYvEHFY.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-BBcG_UuU.js","./mcp-query-o-sGX2ST.js","./McpQueryDetailPage-DYJr16l7.js","./TagInput-ZrIIrEUP.js","./CollapsibleSection-DNkZn87n.js","./useYamlActivityEvents-AeAhZJJk.js","./helpers-DzO-OGPe.js","./RunAsSelector-BoePhWVD.js","./BotPicker-D3drO3-T.js","./bots-DX6jjqtF.js","./ToolPill-Baxm02L6.js","./TimeAgo-0YVMBwls.js","./EscalationsOverview-Tdu3Yx2c.js","./AvailableEscalationsPage-CpbC8oTN.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-BOAWsViq.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-CzKfavri.js","./EscalationTimeline-DKyTz6sM.js","./EscalationListView-CkBnkpDJ.js","./escalation-columns-Mvsze5eV.js","./EntityTimelinePanel-DIDcF5Yu.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-BaexQMK6.js","./OperatorDashboard-DoiDGZ9R.js","./index-B_GT23TE.js","./ResolverForm-BwgjIX97.js","./metadata-display-COo3mMCr.js","./WorkflowsOverview-5i2Tcy-p.js","./index-z5Hpeidu.js","./NamespacePill-DADRJOUl.js","./WorkflowsDashboard-DFDTwnhn.js","./YamlWorkflowsPage-Cq-hMVxl.js","./GraphInvokePage-DO-yyhi6.js","./YamlWorkflowDetailPage-p4VEYZS0.js","./TasksListPage-CNbNeagx.js","./TaskDetailPage-zhn_U_eC.js","./WorkflowExecutionPage-DvA51lT3.js","./AdminDashboard-Covdam48.js","./index-D-Xs4rAW.js","./TaskQueuePill-DkQ1uc6y.js","./index-DkrBFFSO.js","./ConfirmDeleteModal-BqzOwhPr.js","./index-Bhb89oHH.js","./ToolTestPanel-BLfA02wv.js","./index-DZhtP2Ok.js","./index-Cn8uJsd7.js","./personas-30azkJ_s.js","./ScopeBadge-b6MIBiYD.js","./RolesPage-80quJU5-.js","./RoleDetailPage-BFuLNJXa.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-B36yn4hU.js","./PersonaDetailPage-BzbA4Prr.js","./EscalationSchemaPage-W5r0A1kj.js","./PortalPage-BkD4YfDf.js","./EscalationListSchemaPage-C28rn9XC.js","./ScanCodesPage-Cu1bKEix.js","./ScanSchemeDetailPage-D9AbS6UY.js","./ScanStationPage-gcZGefvT.js","./index-Eo-l3Lqo.js","./OperationsPage-Dlfwzf-0.js","./index-PfSRKerc.js","./index-BbCjGO3M.js","./CredentialsPage-D7abp0aS.js","./index-DGmzBY9D.js","./DropZone-f1o-GLM8.js","./index-oFKUFGQL.js","./knowledge-CgloEkaf.js","./HomePage-DSS3eHR2.js","./AgentsPage---Dg5ufF.js","./agents-EyBPJMYa.js","./AgentDetailPage-CWJZIZP1.js","./CronLabel-DZiWmTwJ.js","./AgentConfigPage-CE1k6J5r.js","./capabilities-ZdLv9xBQ.js","./topics--bvCV9Yp.js","./CapabilitiesPage-RGgD3YZO.js","./TopicsPage-BNNWD-zl.js","./TopicDetailPage-eAqPKShq.js"])))=>i.map(i=>d[i]);
2
- var Jw=Object.defineProperty;var Qw=(n,t,s)=>t in n?Jw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var j=(n,t,s)=>Qw(n,typeof t!="symbol"?t+"":t,s);import{r as Xw,u as Ue,a as E,j as h,b as ze,c as He,g as Ww,d as Zw,Q as eS,e as tS}from"./vendor-query-DvWWuNIB.js";import{r as nS,u as ra,a as On,b as Xd,L as Cr,N as Ss,c as xn,O as Ws,d as rS,R as sS}from"./vendor-react-_9U4mKFr.js";import{X as Xt,E as iS,S as aS,M as oS,a as No,C as Wd,b as lS,c as cS,d as Qb,e as fd,I as hd,U as uS,L as dd,B as fS,G as hS,T as dS,R as Xb,f as mS,Z as pS,P as wg,g as Wb,h as yS,i as Sg,j as md,k as Eg,l as gS,W as Zd,m as bS,n as xS,F as vS,o as Zb,p as _S,D as wS,N as SS,q as ES,r as ex,s as tx,t as nx,u as OS,v as AS,w as jS,x as kS,y as NS,z as TS,A as CS,H as MS,J as RS}from"./vendor-icons-B7OcUM6b.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).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 Gh={exports:{}},to={},Vh={exports:{}},Yh={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-D9DYntvl.js","./vendor-query-DvWWuNIB.js","./tasks-BlpDsWCy.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-B-KC5ba3.js","./api-path-u2Jf9QXS.js","./DataTable-spX1dFyb.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-D0ru7Lya.js","./StickyPagination-BSUyf5ja.js","./FilterBar-Dxd0wNSW.js","./vendor-icons-CeVtUKyP.js","./PageHeader-CMd3f4bz.js","./ListToolbar-Ddz_S2av.js","./WorkflowPill-Dg7BDTyM.js","./ProcessDetailPage-BuipGZcC.js","./PageHeaderWithStats-DHj8Mqox.js","./StatusBadge-DHVwxre2.js","./RolePill-Di2CAHuD.js","./UserName-CXsdPiMZ.js","./McpOverview-CVe13tEv.js","./mcp-Bb5psC61.js","./pipelines-Dq3kNhKu.js","./yaml-workflows-BLYoJfmB.js","./controlplane-CiiZ6LJF.js","./StatCard-nWY4sndl.js","./McpRunsPage-DmO0YVhT.js","./useNamespace-Dkr5g2Ac.js","./ElapsedCell-jH9m8Dgl.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-DreARTE1.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-DSHqKyX2.js","./SwimlaneTimeline-CxBZ2THh.js","./StreamMessageDetail--tp7l2Sd.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-DZi5lm7s.js","./mcp-query-D5jUdZwN.js","./McpQueryDetailPage-BQYF2Mjq.js","./TagInput-CAgdLN_b.js","./CollapsibleSection-BBNpP-6h.js","./useYamlActivityEvents-BANBOshA.js","./helpers-DzO-OGPe.js","./RunAsSelector-Dh4lyyRo.js","./BotPicker-CGB16rYU.js","./bots-bwvWYrXz.js","./ToolPill-CQCsVdzD.js","./TimeAgo-CCnz84Y4.js","./EscalationsOverview-DtGOqnP4.js","./AvailableEscalationsPage-BXJmMBM1.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-MjxcU7N1.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-BpRquguO.js","./EscalationTimeline-DqmFydnU.js","./EscalationListView-CAHbdxKR.js","./escalation-columns-Dv-MB3eC.js","./EntityTimelinePanel-Dl3Nr2kk.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-CI_JOAvk.js","./OperatorDashboard-Vv_MEBkv.js","./index-CT-FN6CW.js","./ResolverForm-BVG8X0sS.js","./metadata-display-COo3mMCr.js","./WorkflowsOverview-QIYvoa13.js","./index-D6pBLZFu.js","./NamespacePill-DwM5pNA4.js","./WorkflowsDashboard-DfAGK1l7.js","./YamlWorkflowsPage-CEsHm0B9.js","./GraphInvokePage-ChqqGkro.js","./YamlWorkflowDetailPage-DGgO3hyB.js","./TasksListPage-5BydGWmt.js","./TaskDetailPage-BJ1QrmPH.js","./WorkflowExecutionPage-zx3AUJFd.js","./AdminDashboard-BbWve-Ax.js","./index-D2VKBMng.js","./TaskQueuePill-h0oorVMe.js","./index-C4Lce2ET.js","./ConfirmDeleteModal-D_kAbT_D.js","./index-CcuvGdvf.js","./ToolTestPanel-3Kpofmen.js","./index-BLB77tc8.js","./index-IJmtbuLh.js","./personas-CDndbkp4.js","./ScopeBadge-CSItPVOH.js","./RolesPage-0QJOBSzF.js","./RoleDetailPage-KCXDqoJz.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-CO6yYQdm.js","./PersonaDetailPage-CW-2uBHY.js","./EscalationSchemaPage-DotfAMCL.js","./PortalPage-DcNqhBlg.js","./EscalationListSchemaPage-DAK6It5J.js","./ScanCodesPage-CUhCz-Yr.js","./ScanSchemeDetailPage-qzXKNqJK.js","./ScanStationPage-D8e8cG3t.js","./index-C_ISDOWJ.js","./OperationsPage-DpjCO85T.js","./index-C3WutFpT.js","./index-CjenRVX_.js","./CredentialsPage-C9OA1Q2J.js","./index-CzjUgFt_.js","./DropZone-B1Tdfddc.js","./index-2tzsxFat.js","./knowledge-D1YP2NzS.js","./HomePage-ByKesG8w.js","./AgentsPage-Cj_cRTT1.js","./agents-v_HH3Rji.js","./AgentDetailPage-CsakSlx5.js","./CronLabel-sxLLBf2I.js","./AgentConfigPage-M-9eTKhP.js","./capabilities-D4vaw_nQ.js","./topics-C0YaR9fu.js","./CapabilitiesPage-BxadotXn.js","./TopicsPage-Cnm1AAjh.js","./TopicDetailPage-BaBXD_AK.js"])))=>i.map(i=>d[i]);
2
+ var Jw=Object.defineProperty;var Qw=(n,t,s)=>t in n?Jw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var j=(n,t,s)=>Qw(n,typeof t!="symbol"?t+"":t,s);import{r as Xw,u as Ue,a as E,j as h,b as ze,c as He,g as Ww,d as Zw,Q as eS,e as tS}from"./vendor-query-DvWWuNIB.js";import{r as nS,u as ra,a as On,b as Xd,L as Cr,N as Ss,c as xn,O as Ws,d as rS,R as sS}from"./vendor-react-_9U4mKFr.js";import{X as Xt,E as iS,S as aS,M as oS,a as No,C as Wd,b as lS,c as cS,d as Qb,e as fd,I as hd,U as uS,L as dd,B as fS,G as hS,T as dS,R as Xb,f as mS,Z as pS,P as wg,g as Wb,h as yS,i as Sg,j as md,k as Eg,l as gS,W as Zd,m as bS,n as xS,F as vS,o as Zb,p as _S,D as wS,N as SS,q as ES,r as ex,s as tx,t as nx,u as OS,v as AS,w as jS,x as kS,y as NS,z as TS,A as CS,H as MS,J as RS}from"./vendor-icons-CeVtUKyP.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).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 Gh={exports:{}},to={},Vh={exports:{}},Yh={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -53,7 +53,7 @@ ${y.stack}`),g.unsubscribe(),d.reject(u)):(u=lx(m),u?(y&&(u.stack+=`
53
53
  ${y.stack}`),d.reject(u)):d.resolve(m))}});return g.requestSubject=t,this.protocol.publish(t,s,{reply:c,headers:i.headers}),d}else{const c=new fx(this.protocol.muxSubscriptions,t,i,o);this.protocol.request(c);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(y){c.cancel(y)}const d=Promise.race([c.timer,c.deferred]);return d.catch(()=>{c.cancel()}),d}}flush(){return this.isClosed()?Promise.reject(pe.errorForCode(ce.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(pe.errorForCode(ce.ConnectionClosed)):this.isDraining()?Promise.reject(pe.errorForCode(ce.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const t=this.protocol.getServer();return t?t.listen:""}status(){const t=new qt;return t.iterClosed.then(()=>{const s=this.listeners.indexOf(t);this.listeners.splice(s,1)}),this.listeners.push(t),t}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(t={}){const s=new T2(this,t);if(t.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===ce.NoResponders&&(o.code=ce.JetStreamNotEnabled),o}return s}jetstream(t={}){return new lm(this,t)}getServerVersion(){const t=this.info;return t?Zs(t.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw pe.errorForCode(ce.Disconnect);const t=Date.now();return await this.flush(),Date.now()-t}get features(){return this.protocol.features}get services(){return this._services||(this._services=new D2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(pe.errorForCode(ce.ConnectionClosed)):this.isDraining()?Promise.reject(pe.errorForCode(ce.ConnectionDraining)):this.protocol.reconnect()}}class D2{constructor(t){j(this,"nc");this.nc=t}add(t){try{return new Co(this.nc,t).start()}catch(s){return Promise.reject(s)}}client(t,s){return new d2(this.nc,t,s)}}class q2{constructor(t,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=t,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(yu)||"PUT"}get length(){const t=this.sm.header.get(Qt.MessageSizeHdr)||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class L2{constructor(t,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=t,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(rm(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var t;return((t=this.sm.headers)==null?void 0:t.get(yu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const t=((s=this.sm.headers)==null?void 0:s.get(Qt.MessageSizeHdr))||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class _x extends OE{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=Rr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=Es.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=wt.StartSequence,c.config.opt_start_seq=s;const d={};d.stream_name=this.info.stream,d.config=c.config;const y=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(y,d,{retries:-1}).then(g=>{const u=g,m=this.sub.info;m.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new pe(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,ce.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(rm(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,d=y=>{var m,b,x,v;const g=iE(409,`${Un.IdleHeartbeatMissed}: ${y}`,this.sub.subject);if(!((m=this.info)==null?void 0:m.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 im(s,d,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Qt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Qt.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 B2 extends _x{constructor(t,s,i){super(t,s,i)}pull(t={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,d={};if(d.batch=t.batch||1,d.no_wait=t.no_wait||!1,(t.max_bytes??0)>0){const u=this.js.nc.features.get(Ge.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);d.max_bytes=t.max_bytes}let y=0;t.expires&&t.expires>0&&(y=t.expires,d.expires=ft(y));let g=0;if(t.idle_heartbeat&&t.idle_heartbeat>0&&(g=t.idle_heartbeat,d.idle_heartbeat=ft(g)),g&&y===0)throw new Error("idle_heartbeat requires expires");if(g>y)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),y&&g&&(this.monitor?this.monitor._change(g,y):this._setupHbMonitoring(g,y));const u=this.info.api,m=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(m,u.jc.encode(d),{reply:b})}}}function P2(n,t){return n?z2(t):U2(t)}function U2(n){return(t,s)=>t?[t,null]:(t=Ji(s),t?[t,null]:[null,Oo(s,n)])}function z2(n){return(t,s)=>{if(t)return[t,null];const i=Ji(s);return i!==null?[wx(i),null]:[null,Oo(s,n)]}}function wx(n){if(n!==null)switch(n.code){case ce.JetStream404NoMessages:case ce.JetStream408RequestTimeout:return null;case ce.JetStream409:return aE(n)?n:null;default:return n}return null}function I2(n){n&&n.ack()}function $2(n){const t=n.split(".");if(t.length===9&&t.splice(2,0,"_",""),t.length<11||t[0]!=="$JS"||t[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=t[2]==="_"?"":t[2],s.account_hash=t[3],s.stream=t[4],s.consumer=t[5],s.deliveryCount=parseInt(t[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(t[7],10),s.deliverySequence=parseInt(t[8],10),s.timestampNanos=parseInt(t[9],10),s.pending=parseInt(t[10],10),s}class H2{constructor(t,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=t,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=$2(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(t){this.didAck||(this.didAck=!this.isWIP(t),this.msg.respond(t))}isWIP(t){return t.length===4&&t[0]===ro[0]&&t[1]===ro[1]&&t[2]===ro[2]&&t[3]===ro[3]}async ackAck(t){var i;t=t||{},t.timeout=t.timeout||this.timeout;const s=ht();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,d=!((i=c.options)!=null&&i.noAsyncTraces),y=new fx(c.muxSubscriptions,this.msg.reply,{timeout:t.timeout},d);c.request(y);try{c.publish(this.msg.reply,r1,{reply:`${c.muxSubscriptions.baseInbox}${y.token}`})}catch(g){y.cancel(g)}try{await Promise.race([y.timer,y.deferred]),s.resolve(!0)}catch(g){y.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(r1)}nak(t){let s=S2;t&&(s=gd().encode(`-NAK ${JSON.stringify({delay:ft(t)})}`)),this.doAck(s)}working(){this.doAck(ro)}next(t,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=ft(s.expires));const o=Xn().encode(i),c=na.concat(E2,A2,o),d=t?{reply:t}:void 0;this.msg.respond(c,d)}term(t=""){let s=O2;(t==null?void 0:t.length)>0&&(s=gd().encode(`+TERM ${t}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const F2="1.30.3",G2="nats.ws";class V2{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=F2,this.lang=G2,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=ht(),this.closedNotification=ht()}async connect(t,s){const i=ht();if(s.tls)return i.reject(new pe("tls",ce.InvalidOption)),i;this.options=s;const o=t.src;if(s.wsFactory){const{socket:c,encrypted:d}=await s.wsFactory(t.src,s);this.socket=c,this.encrypted=d}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 d=na.concat(...this.yields),y=CE(d);if(y!==""){const g=i2.exec(y);if(!g){s.debug&&console.error("!!!",sc(d)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);r2(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 d;this.done||(c.wasClean||(d=new Error(c.reason)),this._closed(d))},this.socket.onerror=c=>{if(this.isDiscarded())return;const d=c,y=new pe(d.message,ce.Unknown,new Error(d.error));i.reject(y)},i}disconnect(){this._closed(void 0,!0)}async _closed(t,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=t,!t)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await sa(100);this.done=!0;try{this.socket.close(t?1002:1e3,t?t.message:void 0)}catch{}s&&this.closedNotification.resolve(t)}}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 t=this.yields;this.yields=[];for(let s=0;s<t.length;s++)this.options.debug&&console.info(`> ${sc(t[s])}`),yield t[s];if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=ht())}}isEncrypted(){return this.connected&&this.encrypted}send(t){if(!this.isDiscarded())try{this.socket.send(t.buffer),this.options.debug&&console.info(`< ${sc(t)}`);return}catch(s){this.options.debug&&console.error(`!!! ${sc(t)}: ${s}`)}}close(t){return this._closed(t,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var t;this.done=!0;try{(t=this.socket)==null||t.close()}catch{}}}function Y2(n,t){/^(.*:\/\/)(.*)/.test(n)||(typeof t=="boolean"?n=`${t===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(t=!1),o==="wss:"&&(t=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,d;const y=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":d=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":d=i.port||"443",c="wss:";break;default:d=i.port||t===!0?"443":"80",c=t===!0?"wss:":"ws:";break}return`${c}//${y}:${d}${g}${u}`}function K2(n={}){return AE({defaultPort:443,urlParseFn:Y2,factory:()=>new V2}),cm.connect(n)}const J2=null,Q2=null,Jt="lt.events";function Sx(n,t){const s=n.split("."),i=t.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 ia=E.createContext({connected:!1,subscribe:()=>()=>{}});function Ex(){const{connected:n}=E.useContext(ia);return{connected:n}}function wn(n,t){const{subscribe:s}=E.useContext(ia),i=E.useRef(t);i.current=t,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function ti(n,t){const{subscribe:s}=E.useContext(ia),i=E.useRef(t);i.current=t;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const d=g=>i.current(g),y=c.map(g=>s(g,d));return()=>y.forEach(g=>g())},[s,c])}const X2=E.createContext({connected:!1,subscribe:()=>()=>{}}),W2=gd();function Z2({children:n,url:t,token:s}){const i=E.useRef(null),[o,c]=E.useState(!1),d=E.useRef(null),y=E.useRef(new Map),g=E.useRef(new Map),u=E.useCallback((v,_)=>{(async()=>{for await(const S of _)try{if(!Sx(S.subject,v))continue;const C=JSON.parse(W2.decode(S.data)),L=y.current.get(v);if(!L)continue;for(const P of L)try{P(C)}catch{}}catch{}})()},[]),m=E.useCallback(v=>{var S;const _=i.current;if(!(!_||(S=_.isClosed)!=null&&S.call(_)||g.current.has(v)))try{const C=_.subscribe(v);g.current.set(v,C),u(v,C)}catch{}},[u]),b=E.useCallback((v,_)=>{const S=y.current;return S.has(v)||S.set(v,new Set),S.get(v).add(_),m(v),()=>{const C=S.get(v);if(C&&(C.delete(_),C.size===0)){S.delete(v);const L=g.current.get(v);if(L){g.current.delete(v);try{L.unsubscribe()}catch{}}}}},[m]),x=E.useCallback(async()=>{try{if(i.current)return;const v=t||J2;if(!v){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const _=await K2({servers:v,token:s||Q2||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});i.current=_,c(!0);for(const S of y.current.keys())m(S);(async()=>{for await(const S of _.status())S.type==="disconnect"?c(!1):S.type==="reconnect"&&c(!0)})()}catch{c(!1),d.current=setTimeout(x,3e3)}},[m]);return E.useEffect(()=>(x(),()=>{d.current&&clearTimeout(d.current);for(const v of g.current.values())try{v.unsubscribe()}catch{}g.current.clear(),i.current&&(i.current.close().catch(()=>{}),i.current=null),c(!1)}),[x]),h.jsx(X2.Provider,{value:{connected:o,subscribe:b},children:h.jsx(ia.Provider,{value:{connected:o,subscribe:b},children:n})})}const or=Object.create(null);or.open="0";or.close="1";or.ping="2";or.pong="3";or.message="4";or.upgrade="5";or.noop="6";const su=Object.create(null);Object.keys(or).forEach(n=>{su[or[n]]=n});const Cd={type:"error",data:"parser error"},Ox=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ax=typeof ArrayBuffer=="function",jx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,um=({type:n,data:t},s,i)=>Ox&&t instanceof Blob?s?i(t):i1(t,i):Ax&&(t instanceof ArrayBuffer||jx(t))?s?i(t):i1(new Blob([t]),i):i(or[n]+(t||"")),i1=(n,t)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];t("b"+(i||""))},s.readAsDataURL(n)};function a1(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let nd;function eO(n,t){if(Ox&&n.data instanceof Blob)return n.data.arrayBuffer().then(a1).then(t);if(Ax&&(n.data instanceof ArrayBuffer||jx(n.data)))return t(a1(n.data));um(n,!1,s=>{nd||(nd=new TextEncoder),t(nd.encode(s))})}const o1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<o1.length;n++)yo[o1.charCodeAt(n)]=n;const tO=n=>{let t=n.length*.75,s=n.length,i,o=0,c,d,y,g;n[n.length-1]==="="&&(t--,n[n.length-2]==="="&&t--);const u=new ArrayBuffer(t),m=new Uint8Array(u);for(i=0;i<s;i+=4)c=yo[n.charCodeAt(i)],d=yo[n.charCodeAt(i+1)],y=yo[n.charCodeAt(i+2)],g=yo[n.charCodeAt(i+3)],m[o++]=c<<2|d>>4,m[o++]=(d&15)<<4|y>>2,m[o++]=(y&3)<<6|g&63;return u},nO=typeof ArrayBuffer=="function",fm=(n,t)=>{if(typeof n!="string")return{type:"message",data:kx(n,t)};const s=n.charAt(0);return s==="b"?{type:"message",data:rO(n.substring(1),t)}:su[s]?n.length>1?{type:su[s],data:n.substring(1)}:{type:su[s]}:Cd},rO=(n,t)=>{if(nO){const s=tO(n);return kx(s,t)}else return{base64:!0,data:n}},kx=(n,t)=>{switch(t){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Nx="",sO=(n,t)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,d)=>{um(c,!1,y=>{i[d]=y,++o===s&&t(i.join(Nx))})})},iO=(n,t)=>{const s=n.split(Nx),i=[];for(let o=0;o<s.length;o++){const c=fm(s[o],t);if(i.push(c),c.type==="error")break}return i};function aO(){return new TransformStream({transform(n,t){eO(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),t.enqueue(o),t.enqueue(s)})}})}let rd;function lc(n){return n.reduce((t,s)=>t+s.length,0)}function cc(n,t){if(n[0].length===t)return n.shift();const s=new Uint8Array(t);let i=0;for(let o=0;o<t;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 oO(n,t){rd||(rd=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(d,y){for(s.push(d);;){if(i===0){if(lc(s)<1)break;const g=cc(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(lc(s)<2)break;const g=cc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(lc(s)<8)break;const g=cc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),m=u.getUint32(0);if(m>Math.pow(2,21)-1){y.enqueue(Cd);break}o=m*Math.pow(2,32)+u.getUint32(4),i=3}else{if(lc(s)<o)break;const g=cc(s,o);y.enqueue(fm(c?g:rd.decode(g),t)),i=0}if(o===0||o>n){y.enqueue(Cd);break}}}})}const Tx=4;function kt(n){if(n)return lO(n)}function lO(n){for(var t in kt.prototype)n[t]=kt.prototype[t];return n}kt.prototype.on=kt.prototype.addEventListener=function(n,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(t),this};kt.prototype.once=function(n,t){function s(){this.off(n,s),t.apply(this,arguments)}return s.fn=t,this.on(n,s),this};kt.prototype.off=kt.prototype.removeListener=kt.prototype.removeAllListeners=kt.prototype.removeEventListener=function(n,t){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===t||i.fn===t){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};kt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,t)}return this};kt.prototype.emitReserved=kt.prototype.emit;kt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};kt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const ju=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,s)=>s(t,0),zn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),cO="arraybuffer";function Cx(n,...t){return t.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const uO=zn.setTimeout,fO=zn.clearTimeout;function ku(n,t){t.useNativeTimers?(n.setTimeoutFn=uO.bind(zn),n.clearTimeoutFn=fO.bind(zn)):(n.setTimeoutFn=zn.setTimeout.bind(zn),n.clearTimeoutFn=zn.clearTimeout.bind(zn))}const hO=1.33;function dO(n){return typeof n=="string"?mO(n):Math.ceil((n.byteLength||n.size)*hO)}function mO(n){let t=0,s=0;for(let i=0,o=n.length;i<o;i++)t=n.charCodeAt(i),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(i++,s+=4);return s}function Mx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function pO(n){let t="";for(let s in n)n.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return t}function yO(n){let t={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");t[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return t}class gO extends Error{constructor(t,s,i){super(t),this.description=s,this.context=i,this.type="TransportError"}}class hm extends kt{constructor(t){super(),this.writable=!1,ku(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,s,i){return super.emitReserved("error",new gO(t,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(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const s=fm(t,this.socket.binaryType);this.onPacket(s)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,s={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_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(t){const s=pO(t);return s.length?"?"+s:""}}class bO extends hm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const s=()=>{this.readyState="paused",t()};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(t){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)};iO(t,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,sO(t,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Mx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(t,s)}}let Rx=!1;try{Rx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xO=Rx;function vO(){}class _O extends bO{constructor(t){if(super(t),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||i!==t.port}}doWrite(t,s){const i=this.request({method:"POST",data:t});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=t}}class ar extends kt{constructor(t,s,i){super(),this.createRequest=t,ku(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 t;const s=Cx(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{}(t=this._opts.cookieJar)===null||t===void 0||t.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=ar.requestsCount++,ar.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=vO,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ar.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}ar.requestsCount=0;ar.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",l1);else if(typeof addEventListener=="function"){const n="onpagehide"in zn?"pagehide":"unload";addEventListener(n,l1,!1)}}function l1(){for(let n in ar.requests)ar.requests.hasOwnProperty(n)&&ar.requests[n].abort()}const wO=(function(){const n=Dx({xdomain:!1});return n&&n.responseType!==null})();class SO extends _O{constructor(t){super(t);const s=t&&t.forceBase64;this.supportsBinary=wO&&!s}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new ar(Dx,this.uri(),t)}}function Dx(n){const t=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||xO))return new XMLHttpRequest}catch{}if(!t)try{return new zn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const qx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class EO extends hm{get name(){return"websocket"}doOpen(){const t=this.uri(),s=this.opts.protocols,i=qx?{}:Cx(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(t,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=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let s=0;s<t.length;s++){const i=t[s],o=s===t.length-1;um(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&ju(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Mx()),this.supportsBinary||(s.b64=1),this.createUri(t,s)}}const sd=zn.WebSocket||zn.MozWebSocket;class OO extends EO{createSocket(t,s,i){return qx?new sd(t,s,i):s?new sd(t,s):new sd(t)}doWrite(t,s){this.ws.send(s)}}class AO extends hm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const s=oO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(s).getReader(),o=aO();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:y,value:g})=>{y||(this.onPacket(g),c())}).catch(y=>{})};c();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let s=0;s<t.length;s++){const i=t[s],o=s===t.length-1;this._writer.write(i).then(()=>{o&&ju(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const jO={websocket:OO,webtransport:AO,polling:SO},kO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,NO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Md(n){if(n.length>8e3)throw"URI too long";const t=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=kO.exec(n||""),c={},d=14;for(;d--;)c[NO[d]]=o[d]||"";return s!=-1&&i!=-1&&(c.source=t,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=TO(c,c.path),c.queryKey=CO(c,c.query),c}function TO(n,t){const s=/\/{2,9}/g,i=t.replace(s,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&i.splice(0,1),t.slice(-1)=="/"&&i.splice(i.length-1,1),i}function CO(n,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const Rd=typeof addEventListener=="function"&&typeof removeEventListener=="function",iu=[];Rd&&addEventListener("offline",()=>{iu.forEach(n=>n())},!1);class ws extends kt{constructor(t,s){if(super(),this.binaryType=cO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(s=t,t=null),t){const i=Md(t);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=Md(s.host).host);ku(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=yO(this.opts.query)),Rd&&(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"})},iu.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const s=Object.assign({},this.opts.query);s.EIO=Tx,s.transport=t,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[t]);return new this._transportsByName[t](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&ws.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(t);s.open(),this.setTransport(s)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.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",ws.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.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=t.data,this._onError(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),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 t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.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+=dO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ju(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,i){return this._sendPacket("message",t,s,i),this}send(t,s,i){return this._sendPacket("message",t,s,i),this}_sendPacket(t,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:t,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},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():t()}):this.upgrading?i():t()),this}_onError(t){if(ws.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,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(),Rd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=iu.indexOf(this._offlineEventListener);i!==-1&&iu.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}ws.protocol=Tx;class MO extends ws{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let s=this.createTransport(t),i=!1;ws.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;ws.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(m(),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,m(),s.close(),s=null)}const d=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function y(){d("transport closed")}function g(){d("socket closed")}function u(b){s&&b.name!==s.name&&c()}const m=()=>{s.removeListener("open",o),s.removeListener("error",d),s.removeListener("close",y),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",d),s.once("close",y),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const s=[];for(let i=0;i<t.length;i++)~this.transports.indexOf(t[i])&&s.push(t[i]);return s}}let RO=class extends MO{constructor(t,s={}){const i=typeof t=="object"?t:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>jO[o]).filter(o=>!!o)),super(t,i)}};function DO(n,t="",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=Md(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+t,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const qO=typeof ArrayBuffer=="function",LO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Lx=Object.prototype.toString,BO=typeof Blob=="function"||typeof Blob<"u"&&Lx.call(Blob)==="[object BlobConstructor]",PO=typeof File=="function"||typeof File<"u"&&Lx.call(File)==="[object FileConstructor]";function dm(n){return qO&&(n instanceof ArrayBuffer||LO(n))||BO&&n instanceof Blob||PO&&n instanceof File}function au(n,t){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(au(n[s]))return!0;return!1}if(dm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return au(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&au(n[s]))return!0;return!1}function UO(n){const t=[],s=n.data,i=n;return i.data=Dd(s,t),i.attachments=t.length,{packet:i,buffers:t}}function Dd(n,t){if(!n)return n;if(dm(n)){const s={_placeholder:!0,num:t.length};return t.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Dd(n[i],t);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]=Dd(n[i],t));return s}return n}function zO(n,t){return n.data=qd(n.data,t),delete n.attachments,n}function qd(n,t){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<t.length)return t[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=qd(n[s],t);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=qd(n[s],t));return n}const IO=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var $e;(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"})($e||($e={}));class $O{constructor(t){this.replacer=t}encode(t){return(t.type===$e.EVENT||t.type===$e.ACK)&&au(t)?this.encodeAsBinary({type:t.type===$e.EVENT?$e.BINARY_EVENT:$e.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let s=""+t.type;return(t.type===$e.BINARY_EVENT||t.type===$e.BINARY_ACK)&&(s+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(s+=t.nsp+","),t.id!=null&&(s+=t.id),t.data!=null&&(s+=JSON.stringify(t.data,this.replacer)),s}encodeAsBinary(t){const s=UO(t),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class mm extends kt{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let s;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(t);const i=s.type===$e.BINARY_EVENT;i||s.type===$e.BINARY_ACK?(s.type=i?$e.EVENT:$e.ACK,this.reconstructor=new HO(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(dm(t)||t.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(t),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: "+t)}decodeString(t){let s=0;const i={type:Number(t.charAt(0))};if($e[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===$e.BINARY_EVENT||i.type===$e.BINARY_ACK){const c=s+1;for(;t.charAt(++s)!=="-"&&s!=t.length;);const d=t.substring(c,s);if(d!=Number(d)||t.charAt(s)!=="-")throw new Error("Illegal attachments");const y=Number(d);if(!FO(y)||y<0)throw new Error("Illegal attachments");if(y>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=y}if(t.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(t.charAt(s)===","||s===t.length););i.nsp=t.substring(c,s)}else i.nsp="/";const o=t.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const d=t.charAt(s);if(d==null||Number(d)!=d){--s;break}if(s===t.length)break}i.id=Number(t.substring(c,s+1))}if(t.charAt(++s)){const c=this.tryParse(t.substr(s));if(mm.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,s){switch(t){case $e.CONNECT:return c1(s);case $e.DISCONNECT:return s===void 0;case $e.CONNECT_ERROR:return typeof s=="string"||c1(s);case $e.EVENT:case $e.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&IO.indexOf(s[0])===-1);case $e.ACK:case $e.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class HO{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const s=zO(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const FO=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function c1(n){return Object.prototype.toString.call(n)==="[object Object]"}const GO=Object.freeze(Object.defineProperty({__proto__:null,Decoder:mm,Encoder:$O,get PacketType(){return $e}},Symbol.toStringTag,{value:"Module"}));function Jn(n,t,s){return n.on(t,s),function(){n.off(t,s)}}const VO=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Bx extends kt{constructor(t,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=t,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 t=this.io;this.subs=[Jn(t,"open",this.onopen.bind(this)),Jn(t,"packet",this.onpacket.bind(this)),Jn(t,"error",this.onerror.bind(this)),Jn(t,"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(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...s){var i,o,c;if(VO.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(s.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const d={type:$e.EVENT,data:s};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const m=this.ids++,b=s.pop();this._registerAckCallback(m,b),d.id=m}const y=(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&&!y||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(t,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[t]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let y=0;y<this.sendBuffer.length;y++)this.sendBuffer[y].id===t&&this.sendBuffer.splice(y,1);s.call(this,new Error("operation has timed out"))},o),d=(...y)=>{this.io.clearTimeoutFn(c),s.apply(this,y)};d.withError=!0,this.acks[t]=d}emitWithAck(t,...s){return new Promise((i,o)=>{const c=(d,y)=>d?o(d):i(y);c.withError=!0,s.push(c),this.emit(t,...s)})}_addToQueue(t){let s;typeof t[t.length-1]=="function"&&(s=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.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(t=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!t||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:$e.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(i=>String(i.id)===t)){const i=this.acks[t];delete this.acks[t],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case $e.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.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 $e.EVENT:case $e.BINARY_EVENT:this.onevent(t);break;case $e.ACK:case $e.BINARY_ACK:this.onack(t);break;case $e.DISCONNECT:this.ondisconnect();break;case $e.CONNECT_ERROR:this.destroy();const i=new Error(t.data.message);i.data=t.data.data,this.emitReserved("connect_error",i);break}}onevent(t){const s=t.data||[];t.id!=null&&s.push(this.ack(t.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:$e.ACK,id:t,data:o}))}}onack(t){const s=this.acks[t.id];typeof s=="function"&&(delete this.acks[t.id],s.withError&&t.data.unshift(null),s.apply(this,t.data))}onconnect(t,s){this.id=t,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:$e.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(t===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(t===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,t.data)}}}function aa(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}aa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*n);n=(Math.floor(t*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};aa.prototype.reset=function(){this.attempts=0};aa.prototype.setMin=function(n){this.ms=n};aa.prototype.setMax=function(n){this.max=n};aa.prototype.setJitter=function(n){this.jitter=n};class Ld extends kt{constructor(t,s){var i;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(s=t,t=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,ku(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 aa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=t;const o=s.parser||GO;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var s;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(s=this.backoff)===null||s===void 0||s.setMin(t),this)}randomizationFactor(t){var s;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(s=this.backoff)===null||s===void 0||s.setJitter(t),this)}reconnectionDelayMax(t){var s;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(s=this.backoff)===null||s===void 0||s.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new RO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Jn(s,"open",function(){i.onopen(),t&&t()}),c=y=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",y),t?t(y):this.maybeReconnectOnOpen()},d=Jn(s,"error",c);if(this._timeout!==!1){const y=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},y);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(d),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Jn(t,"ping",this.onping.bind(this)),Jn(t,"data",this.ondata.bind(this)),Jn(t,"error",this.onerror.bind(this)),Jn(t,"close",this.onclose.bind(this)),Jn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(s){this.onclose("parse error",s)}}ondecoded(t){ju(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,s){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new Bx(this,t,s),this.nsps[t]=i),i}_destroy(t){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(t){const s=this.encoder.encode(t);for(let i=0;i<s.length;i++)this.engine.write(s[i],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=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(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const so={};function ou(n,t){typeof n=="object"&&(t=n,n=void 0),t=t||{};const s=DO(n,t.path||"/socket.io"),i=s.source,o=s.id,c=s.path,d=so[o]&&c in so[o].nsps,y=t.forceNew||t["force new connection"]||t.multiplex===!1||d;let g;return y?g=new Ld(i,t):(so[o]||(so[o]=new Ld(i,t)),g=so[o]),s.query&&!t.query&&(t.query=s.queryKey),g.socket(s.path,t)}Object.assign(ou,{Manager:Ld,Socket:Bx,io:ou,connect:ou});const YO=E.createContext({connected:!1,subscribe:()=>()=>{}});function KO({children:n}){const{isAuthenticated:t}=Lt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),d=E.useCallback((g,u)=>{var b;const m=c.current;return m.has(g)||(m.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),m.get(g).add(u),()=>{var v;const x=m.get(g);x&&(x.delete(u),x.size===0&&(m.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),y=E.useCallback((g,u)=>{for(const[m,b]of c.current)if(Sx(g,m))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!t)return;const g=ou({path:`${$t}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const m=sx();u(m?{token:m}:{})}});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,m)=>{if(u.startsWith("lt."))try{const b=typeof m=="string"?JSON.parse(m):m;y(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[y,t]),h.jsx(YO.Provider,{value:{connected:i,subscribe:d},children:h.jsx(ia.Provider,{value:{connected:i,subscribe:d},children:n})})}function JO({children:n}){const{isAuthenticated:t}=Lt(),[s,i]=E.useState(null),[o,c]=E.useState({url:null,token:null});return E.useEffect(()=>{let d=!1;async function y(){var g;try{console.log("[lt-transport] detecting event transport...");const u=await tm(),m=(g=u==null?void 0:u.events)==null?void 0:g.transport;if(console.log("[lt-transport] server reports:",m),!d){if(m==="nats"){let b=u.events.natsWsUrl??null,x=null;const v=sx();if(v)try{const _=await fetch(`${$t}/api/nats-credentials`,{headers:{Authorization:`Bearer ${v}`}});if(_.ok){const S=await _.json();b=S.natsWsUrl??b,x=S.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}c({url:b,token:x})}i(m==="nats"?"nats":"socketio")}}catch(u){console.warn("[lt-transport] settings fetch error, falling back to socketio",u),d||i("socketio")}}return y(),()=>{d=!0}},[t]),s==="nats"?h.jsx(Z2,{url:o.url,token:o.token,children:n}):s==="socketio"?h.jsx(KO,{children:n}):h.jsx(h.Fragment,{children:n})}const pm="lt_view_as",ym="lt_ai_override",Bd="lt_graph_enabled",Pd="lt_infrastructure_enabled",gm="lt_scan_override";function Px(){try{const n=localStorage.getItem(ym);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function QO(n){try{localStorage.setItem(ym,String(n))}catch{}}function XO(){try{localStorage.removeItem(ym)}catch{}}function bm(){try{const n=localStorage.getItem(pm);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function WO(n){try{localStorage.setItem(pm,n)}catch{}window.location.reload()}function Ud(){try{localStorage.removeItem(pm)}catch{}window.location.reload()}function Ux(){try{return localStorage.getItem(Bd)==="true"}catch{return!1}}function ZO(n){try{n?localStorage.setItem(Bd,"true"):localStorage.removeItem(Bd)}catch{}}function zx(){try{return localStorage.getItem(Pd)==="true"}catch{return!1}}function eA(n){try{n?localStorage.setItem(Pd,"true"):localStorage.removeItem(Pd)}catch{}}function Ix(){try{const n=localStorage.getItem(gm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function tA(n){try{localStorage.setItem(gm,String(n))}catch{}}function nA(){try{localStorage.removeItem(gm)}catch{}}function $x(){const{isSuperAdmin:n,hasRoleType:t,hasRole:s}=Lt(),i=bm(),o=n||s("engineer"),c=t("admin"),d=n||t("admin");return{isBuilder:i?!1:o,isOps:i?i==="admin"||i==="engineer":c,canBulk:i?i==="admin":d,viewAs:i,realIsBuilder:o}}function Hx(){var u;const{isSuperAdmin:n,hasRoleType:t,hasRole:s}=Lt(),{data:i}=Wn(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":t("admin")?"admin":s("engineer")?"engineer":"operator",d=bm(),y=d==="admin"||d==="engineer"||d==="operator"?d:null,g=y??c;return{tier:g,realTier:c,viewAs:y,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}function Fx(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function Lr(n={}){const t=n.role?Fx(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Jt}.system.escalation.${t}.${s}.${i}`}function zd(n){return n.verbs.map(t=>Lr({role:n.role,verb:t}))}function xm(n){const{user:t,isSuperAdmin:s,hasRoleType:i}=Lt(),o=s||i("admin"),c=((t==null?void 0:t.roles)??[]).map(y=>y.role).sort().join(","),d=(n??[]).join(",");return E.useMemo(()=>{const y=d?d.split(","):null;return o||!c?y?zd({verbs:y}):[Lr({})]:c.split(",").flatMap(g=>y?zd({role:g,verbs:y}):[Lr({role:g})])},[o,c,d])}const Id="/escalations/detail/";function rA(n){return n.startsWith(Id)&&n.slice(Id.length).split("/")[0]||void 0}function sA(){const{user:n}=Lt(),t=ra(),s=On(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n==null?void 0:n.userId);o.current=n==null?void 0:n.userId;const c=E.useCallback(d=>{var b,x,v;if((d==null?void 0:d.assignedAtCreation)!==!0)return;const y=(d==null?void 0:d.escalationId)??((b=d==null?void 0:d.data)==null?void 0:b.id),g=(x=d==null?void 0:d.data)==null?void 0:x.assigned_to,u=(v=d==null?void 0:d.data)==null?void 0:v.parent_id;if(!y||g!==o.current||!u||u!==rA(i.current))return;const m=`${Id}${y}`;i.current!==m&&t(m)},[t]);ti(xm(["claimed"]),c)}function iA(n){const t=n??[];return t.length>0&&t.every(s=>s.type==="member"&&s.write_scope==="none")}const vm={staleTime:5*6e4,refetchOnWindowFocus:!1};function w3(n={},t={}){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)),Ue({queryKey:["users",n],queryFn:()=>fe(`/users?${s}`),enabled:t.enabled??!0,...vm})}const u1=200;async function aA(n){const t=[];for(let s=0;s<n.length;s+=u1){const i=await fe("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+u1)})});t.push(...i.users??[])}return t}let $d=[],Hd=new Map,Fd=!1;function oA(){const n=$d,t=Hd;$d=[],Hd=new Map,Fd=!1,aA(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of t)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of t.values())i.reject(s)})}function lA(n){return new Promise((t,s)=>{$d.push(n),Hd.set(n,{resolve:t,reject:s}),Fd||(Fd=!0,setTimeout(oA,0))})}function S3(n){return Ue({queryKey:["user-name",n],queryFn:()=>lA(n),enabled:!!n,...vm})}function cA(n){return Ue({queryKey:["users",n,"roles"],queryFn:async()=>(await fe(`/users/${n}/roles`)).roles??[],enabled:!!n,...vm})}function E3(){const n=ze();return He({mutationFn:t=>fe("/users",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function O3(){const n=ze();return He({mutationFn:({id:t,...s})=>fe(`/users/${t}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function A3(){const n=ze();return He({mutationFn:({id:t,ops:s})=>fe(`/users/${t}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function j3(){return Ue({queryKey:["users","system-property-keys"],queryFn:()=>fe("/users/system-property-keys")})}function k3(){const n=ze();return He({mutationFn:t=>fe(`/users/${t}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function N3(){const n=ze();return He({mutationFn:({userId:t,role:s,type:i,read_scope:o,write_scope:c})=>fe(`/users/${t}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function T3(){const n=ze();return He({mutationFn:({userId:t,role:s})=>fe(`/users/${t}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const C3={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function uA(){return Ue({queryKey:["roles"],queryFn:()=>fe("/roles")})}function Nu(n){return Ue({queryKey:["roles","details"],queryFn:()=>fe("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function M3(n,t,s=!0){return Ue({queryKey:["roles",n,"schema",t??"latest"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!n})}function R3(n){return Ue({queryKey:["roles",n,"schema-versions"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function D3(n,t,s=!0){return Ue({queryKey:["roles",n,"list-schema",t??"latest"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/list-schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!n})}function q3(n){return Ue({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>fe(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function L3(){const n=ze();return He({mutationFn:t=>fe("/roles",{method:"POST",body:JSON.stringify({role:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function B3(){const n=ze();return He({mutationFn:({role:t,...s})=>fe(`/roles/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:t,...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===t?{...o,...s}:o)}),{previous:i}},onError:(t,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function P3(){const n=ze();return He({mutationFn:t=>fe(`/roles/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const Gx="lt:station:kiosk-role:";function Gd(n){return`${Gx}${n}`}const Vd=new Set;function fA(){for(const n of Vd)n()}function hA(n){try{return localStorage.getItem(Gd(n))}catch{return null}}function dA(n,t){try{t===null?localStorage.removeItem(Gd(n)):localStorage.setItem(Gd(n),t)}catch{}fA()}function mA(n){Vd.add(n);const t=s=>{(s.key===null||s.key.startsWith(Gx))&&n()};try{window.addEventListener("storage",t)}catch{}return()=>{Vd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}function pA(n){return E.useSyncExternalStore(mA,()=>n?hA(n):null)}const gu="/portal";function yA(n){return n===gu||n.startsWith(`${gu}/`)}function _m(n,t){const s=`${gu}/${encodeURIComponent(n)}`;return t?`${s}/${encodeURIComponent(t)}`:s}function Wi(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function gA(n){return Wi(n).length>0}function U3(n,t){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(t);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function Vx(n,t){return t.length>0?_m(n,t[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Yx(){const{user:n}=Lt(),t=(n==null?void 0:n.userId)??null,{data:s}=cA(t),{data:i}=Nu(),o=pA(t),c=E.useCallback(d=>{t&&dA(t,d)},[t]);return E.useMemo(()=>{const d={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},y=s??[];if(y.length===0||y.some(v=>v.type!=="member"))return d;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},m=y.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:Vx(v,Wi(g(v))),targets:m,selectable:m.length>=2,selectRole:c});if(y.length===1)return m.length===1?b(m[0]):d;if(!iA(y)||m.length===0)return d;const x=o&&m.includes(o)?o:m.length===1?m[0]:null;return x?b(x):{...d,targets:m,selectable:!0}},[s,i,o,c])}const bA=["/escalations",gu,"/scan","/login"];function xA(n){return bA.some(t=>n===t||n.startsWith(`${t}/`)||n.startsWith(`${t}?`))}const wm=E.createContext(null),id="lt_sidebar_collapsed",Kx="(max-width: 1023px)";function vA(){try{return window.matchMedia(Kx).matches}catch{return!1}}function _A({children:n}){const[t,s]=E.useState(()=>{if(vA())return!0;try{return localStorage.getItem(id)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(Kx)}catch{return}const c=d=>{if(d.matches)s(!0);else try{s(localStorage.getItem(id)==="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(id,String(c))}catch{}return c})},[]);return h.jsx(wm.Provider,{value:{collapsed:t,toggle:i},children:n})}function wA({children:n}){return h.jsx(wm.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Sm(){const n=E.useContext(wm);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const f1=380,Em=E.createContext(null);function SA({children:n}){const[t,s]=E.useState({node:null,width:f1,open:!1,ownerKey:null}),i=On(),o=E.useRef(i.pathname),c=E.useCallback((y,g)=>{s({node:y,width:(g==null?void 0:g.width)??f1,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),d=E.useCallback(y=>{s(g=>typeof y=="string"&&g.ownerKey!==y?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(y=>y.open||y.node?{...y,node:null,open:!1,ownerKey:null}:y))},[i.pathname]),h.jsx(Em.Provider,{value:{...t,setPanel:c,closePanel:d},children:n})}function Om(){const n=E.useContext(Em);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function z3(){return E.useContext(Em)}function EA({open:n,width:t=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?t:0,maxWidth:"50%"},onTransitionEnd:d=>{!n&&d.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:t},className:"h-full",children:o?s:null})})}function I3({label:n,children:t}){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:t})]})}function $3({views:n,activeId:t,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:d}){const y=n.find(g=>g.id===t)??n[0];return y?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 ${d?"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,m=g.id===y.id;return h.jsx("button",{role:"radio","aria-checked":m,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${m?"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)})}),d&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:y.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(Xt,{className:"w-3.5 h-3.5"})})]})]}),!d&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:y.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${d?"pt-4 pb-8":"pb-5 pt-1"}`,children:y.content})]})}):null}function Jx(n,t){var s,i,o,c,d;t.facets&&Object.keys(t.facets).length&&n.set("facets",JSON.stringify(t.facets)),(s=t.block)!=null&&s.length&&n.set("block",JSON.stringify(t.block)),(i=t.range)!=null&&i.length&&n.set("range",JSON.stringify(t.range)),(o=t.exists)!=null&&o.length&&n.set("exists",JSON.stringify(t.exists)),(c=t.roles)!=null&&c.length&&n.set("roles",JSON.stringify(t.roles)),(d=t.orderBy)!=null&&d.length&&n.set("orderBy",JSON.stringify(t.orderBy)),t.available!==void 0&&n.set("available",String(t.available)),t.jeopardy===!0&&n.set("jeopardy","1"),t.include&&n.set("include",t.include)}function H3(n,t,s){const i=n??"24h",o=t&&Object.keys(t).length?JSON.stringify(t):null;return Ue({queryKey:["stationMetrics",i,o],queryFn:()=>fe(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function F3(n){const t=n?`?period=${n}`:"";return Ue({queryKey:["escalationStats",n],queryFn:()=>fe(`/escalations/stats${t}`)})}function G3(){return Ue({queryKey:["escalationTypes"],queryFn:()=>fe("/escalations/types")})}function V3(n=!0){return Ue({queryKey:["escalationFacetKeys"],queryFn:()=>fe("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function OA(n){return Ue({queryKey:["escalationFacetValues",n],queryFn:()=>fe(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function Qx(n){const{enabled:t=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.status&&o.set("status",i.status),i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.assigned_to&&o.set("assigned_to",i.assigned_to),i.parent_id&&o.set("parent_id",i.parent_id),i.claimed&&o.set("claimed","true"),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),Jx(o,i),Ue({queryKey:["escalations",i],queryFn:()=>fe(`/escalations?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function Xx(n){const{enabled:t=!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),Jx(o,i),Ue({queryKey:["escalations","available",i],queryFn:()=>fe(`/escalations/available?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function Y3(n){return Ue({queryKey:["escalations","by-workflow",n],queryFn:()=>fe(`/escalations/by-workflow/${n}`),enabled:!!n})}function K3(n){return Ue({queryKey:["escalations",n],queryFn:()=>fe(`/escalations/${n}`),enabled:!!n})}function J3(n,t){return Ue({queryKey:["escalations",n,"lookups"],queryFn:()=>fe(`/escalations/${n}/lookups`),enabled:!!n&&t,staleTime:1/0})}function Q3(){const n=ze();return He({mutationFn:({id:t,durationMinutes:s})=>fe(`/escalations/${t}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function X3(){const n=ze();return He({mutationFn:t=>fe(`/escalations/${t}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function W3(){const n=ze();return He({mutationFn:({id:t,resolverPayload:s})=>fe(`/escalations/${t}/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"]})}})}function Z3(){const n=ze();return He({mutationFn:({id:t,itemKey:s,payload:i})=>fe(`/escalations/${t}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function e5(){const n=ze();return He({mutationFn:({id:t,itemKey:s})=>fe(`/escalations/${t}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function t5(){const n=ze();return He({mutationFn:({id:t,targetRole:s})=>fe(`/escalations/${t}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function n5(){const n=ze();return He({mutationFn:({ids:t,priority:s})=>fe("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:t,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function r5(){const n=ze();return He({mutationFn:({ids:t,durationMinutes:s})=>fe("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:t,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function s5(){const n=ze();return He({mutationFn:({ids:t,targetUserId:s,durationMinutes:i,reassign:o})=>fe("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:t,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function i5(){const n=ze();return He({mutationFn:({ids:t})=>fe("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function a5(){const n=ze();return He({mutationFn:({ids:t,hint:s})=>fe("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:t,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function o5(){const n=ze();return He({mutationFn:t=>fe(`/escalations/${t}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function l5(){const n=ze();return He({mutationFn:({ids:t})=>fe("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function Am(n){const t=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":t.push(["tasks"]),t.push(["jobs"]),t.push(["processes"]),n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["workflowState",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId])),n.originId&&t.push(["processes",n.originId]);break;case"escalation":t.push(["escalations"]),t.push(["escalationStats"]),t.push(["stationMetrics"]),n.workflowId&&t.push(["workflowExecution",n.workflowId]);break;case"workflow":t.push(["jobs"]),t.push(["tasks"]),t.push(["processes"]),n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["workflowState",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId]),t.push(["mcpQueryResult",n.workflowId]),t.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&t.push(["mcpRunExecution",n.workflowId]),t.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(t.push(["workflowExecution",n.workflowId]),t.push(["mcpQueryExecution",n.workflowId])),t.push(["tasks"]);break;case"knowledge":t.push(["knowledge"]);break;case"file":t.push(["files"]);break;case"agent":t.push(["agents"]);break;default:t.push(["jobs"]),t.push(["tasks"]);break}return t}const AA={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},c5=300,h1={DETAIL:0,LIST:1,SUMMARY:2};function jA(n){const t=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function d(m){delete s[m],i[m]=Date.now();const b=[];for(const[v,_]of t)_===m&&b.push(v);for(const v of b)t.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 y(m){if(s[m])return;const{coalesceMs:b,minIntervalMs:x}=AA[m],v=i[m],_=v===void 0?0:v+x-Date.now(),S=Math.max(b,_);s[m]=setTimeout(()=>d(m),S)}function g(m,b){for(const x of b){const v=JSON.stringify(x),_=t.get(v);(_===void 0||h1[m]<h1[_])&&t.set(v,m)}y(m)}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 m of Object.keys(s)){const b=s[m];b&&clearTimeout(b),delete s[m]}t.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const d1=new WeakMap;function kA(n){let t=d1.get(n);return t||(t=jA(n),d1.set(n,t)),t}function sn(n){const t=ze();return E.useCallback(s=>{kA(t).request(n,s)},[t,n])}function jm(n){return n?[`${Jt}.system.workflow.>`,`${Jt}.system.activity.>`,`${Jt}.system.milestone.>`,`${Jt}.system.task.>`,`${Jt}.system.escalation.>`]:[]}function u5(){const n=sn("LIST");wn(`${Jt}.system.task.>`,()=>{n([["jobs"]])}),wn(`${Jt}.system.workflow.>`,()=>{n([["jobs"]])})}function f5(n){const t=sn("DETAIL");ti(jm(n),s=>{var y;if(!n||!(s.workflowId===n||((y=s.workflowId)==null?void 0:y.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],d=Am(s);c==="escalation"&&d.push(["escalations","by-workflow",n]),t(d)})}function h5(n){const t=sn("DETAIL");ti(jm(n),s=>{var y;if(!n||!(s.workflowId===n||((y=s.workflowId)==null?void 0:y.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],d=Am(s);c==="escalation"&&d.push(["escalations","by-workflow",n]),t(d)})}function d5(n){const t=sn("DETAIL");ti(jm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=Am(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),t(o)})}function m5(n){const t=sn("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||t([["processes",n]]))},[n,t]);wn(`${Jt}.system.task.>`,s),wn(`${Jt}.system.workflow.>`,s),wn(`${Jt}.system.escalation.>`,s)}function p5(){const n=sn("SUMMARY");wn(Lr({}),()=>{n([["escalationStats"]])})}function y5(){const n=sn("SUMMARY");wn(Lr({}),()=>{n([["stationMetrics"]])})}function g5(){const n=sn("SUMMARY");wn(Lr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function b5(n){const t=sn("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?zd({role:s,verbs:c}):[Lr({role:s})]},[s,i]);ti(o,()=>{t([["escalations"]])})}function x5(n){const t=sn("DETAIL");wn(Lr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||t([["escalations",n]])})}function v5(){const n=sn("LIST");wn(`${Jt}.system.agent.>`,()=>{n([["agents"]])})}function _5(){const n=sn("LIST");wn(`${Jt}.system.task.>`,()=>{n([["processes"]])}),wn(`${Jt}.system.workflow.>`,()=>{n([["processes"]])})}function NA(){const{user:n}=Lt(),t=n==null?void 0:n.userId,s=sn("SUMMARY");ti(xm(),()=>{s([["escalations"]])});const{data:i}=Xx({limit:1}),{data:o}=Qx({assigned_to:t,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function km({size:n="sm",hideLabel:t=!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(${$t}/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(${$t}/logo512.png)`}})});const d=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",y=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 ${d}`,style:{"--logo-url":`url(${$t}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${y} ${t?"opacity-0":""}`,children:i})]})}const TA="system.surfaces.dashboard",CA=`${Jt}.${TA}`;function Wx(n=!0){return Ue({queryKey:["announcements"],queryFn:()=>fe("/announcements"),enabled:n,staleTime:3e4})}function MA(){const n=ze();return He({mutationFn:t=>fe("/announcements",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function RA(){const n=ze();return He({mutationFn:t=>fe(`/announcements/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}const Zx=6048e5,DA=864e5,m1=6e4,p1=525600,y1=43200,g1=1440,b1=Symbol.for("constructDateFrom");function Br(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&b1 in n?n[b1](t):n instanceof Date?new n.constructor(t):new Date(t)}function En(n,t){return Br(t||n,n)}let qA={};function Mo(){return qA}function Ao(n,t){var y,g,u,m;const s=Mo(),i=(t==null?void 0:t.weekStartsOn)??((g=(y=t==null?void 0:t.locale)==null?void 0:y.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((m=(u=s.locale)==null?void 0:u.options)==null?void 0:m.weekStartsOn)??0,o=En(n,t==null?void 0:t.in),c=o.getDay(),d=(c<i?7:0)+c-i;return o.setDate(o.getDate()-d),o.setHours(0,0,0,0),o}function bu(n,t){return Ao(n,{...t,weekStartsOn:1})}function ev(n,t){const s=En(n,t==null?void 0:t.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),d=Br(s,0);d.setFullYear(i,0,4),d.setHours(0,0,0,0);const y=bu(d);return s.getTime()>=c.getTime()?i+1:s.getTime()>=y.getTime()?i:i-1}function xu(n){const t=En(n),s=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return s.setUTCFullYear(t.getFullYear()),+n-+s}function tv(n,...t){const s=Br.bind(null,n||t.find(i=>typeof i=="object"));return t.map(s)}function x1(n,t){const s=En(n,t==null?void 0:t.in);return s.setHours(0,0,0,0),s}function LA(n,t,s){const[i,o]=tv(s==null?void 0:s.in,n,t),c=x1(i),d=x1(o),y=+c-xu(c),g=+d-xu(d);return Math.round((y-g)/DA)}function BA(n,t){const s=ev(n,t),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function PA(n,t){const s=+En(n)-+En(t);return s<0?-1:s>0?1:s}function UA(n){return Br(n,Date.now())}function zA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function IA(n){return!(!zA(n)&&typeof n!="number"||isNaN(+En(n)))}function $A(n){return t=>{const i=(n?Math[n]:Math.trunc)(t);return i===0?0:i}}function HA(n,t){const s=En(n,t==null?void 0:t.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const FA={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"}},GA=(n,t,s)=>{let i;const o=FA[n];return typeof o=="string"?i=o:t===1?i=o.one:i=o.other.replace("{{count}}",t.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function ad(n){return(t={})=>{const s=t.width?String(t.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const VA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},YA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},KA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},JA={date:ad({formats:VA,defaultWidth:"full"}),time:ad({formats:YA,defaultWidth:"full"}),dateTime:ad({formats:KA,defaultWidth:"full"})},QA={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},XA=(n,t,s,i)=>QA[n];function io(n){return(t,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const d=n.defaultFormattingWidth||n.defaultWidth,y=s!=null&&s.width?String(s.width):d;o=n.formattingValues[y]||n.formattingValues[d]}else{const d=n.defaultWidth,y=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[y]||n.values[d]}const c=n.argumentCallback?n.argumentCallback(t):t;return o[c]}}const WA={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ZA={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ej={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"]},tj={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"]},nj={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"}},rj={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"}},sj=(n,t)=>{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"},ij={ordinalNumber:sj,era:io({values:WA,defaultWidth:"wide"}),quarter:io({values:ZA,defaultWidth:"wide",argumentCallback:n=>n-1}),month:io({values:ej,defaultWidth:"wide"}),day:io({values:tj,defaultWidth:"wide"}),dayPeriod:io({values:nj,defaultWidth:"wide",formattingValues:rj,defaultFormattingWidth:"wide"})};function ao(n){return(t,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=t.match(o);if(!c)return null;const d=c[0],y=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(y)?oj(y,b=>b.test(d)):aj(y,b=>b.test(d));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const m=t.slice(d.length);return{value:u,rest:m}}}function aj(n,t){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&t(n[s]))return s}function oj(n,t){for(let s=0;s<n.length;s++)if(t(n[s]))return s}function lj(n){return(t,s={})=>{const i=t.match(n.matchPattern);if(!i)return null;const o=i[0],c=t.match(n.parsePattern);if(!c)return null;let d=n.valueCallback?n.valueCallback(c[0]):c[0];d=s.valueCallback?s.valueCallback(d):d;const y=t.slice(o.length);return{value:d,rest:y}}}const cj=/^(\d+)(th|st|nd|rd)?/i,uj=/\d+/i,fj={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},hj={any:[/^b/i,/^(a|c)/i]},dj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},mj={any:[/1/i,/2/i,/3/i,/4/i]},pj={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},yj={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]},gj={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},bj={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]},xj={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},vj={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}},_j={ordinalNumber:lj({matchPattern:cj,parsePattern:uj,valueCallback:n=>parseInt(n,10)}),era:ao({matchPatterns:fj,defaultMatchWidth:"wide",parsePatterns:hj,defaultParseWidth:"any"}),quarter:ao({matchPatterns:dj,defaultMatchWidth:"wide",parsePatterns:mj,defaultParseWidth:"any",valueCallback:n=>n+1}),month:ao({matchPatterns:pj,defaultMatchWidth:"wide",parsePatterns:yj,defaultParseWidth:"any"}),day:ao({matchPatterns:gj,defaultMatchWidth:"wide",parsePatterns:bj,defaultParseWidth:"any"}),dayPeriod:ao({matchPatterns:xj,defaultMatchWidth:"any",parsePatterns:vj,defaultParseWidth:"any"})},nv={code:"en-US",formatDistance:GA,formatLong:JA,formatRelative:XA,localize:ij,match:_j,options:{weekStartsOn:0,firstWeekContainsDate:1}};function wj(n,t){const s=En(n,t==null?void 0:t.in);return LA(s,HA(s))+1}function Sj(n,t){const s=En(n,t==null?void 0:t.in),i=+bu(s)-+BA(s);return Math.round(i/Zx)+1}function rv(n,t){var m,b,x,v;const s=En(n,t==null?void 0:t.in),i=s.getFullYear(),o=Mo(),c=(t==null?void 0:t.firstWeekContainsDate)??((b=(m=t==null?void 0:t.locale)==null?void 0:m.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,d=Br((t==null?void 0:t.in)||n,0);d.setFullYear(i+1,0,c),d.setHours(0,0,0,0);const y=Ao(d,t),g=Br((t==null?void 0:t.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=Ao(g,t);return+s>=+y?i+1:+s>=+u?i:i-1}function Ej(n,t){var y,g,u,m;const s=Mo(),i=(t==null?void 0:t.firstWeekContainsDate)??((g=(y=t==null?void 0:t.locale)==null?void 0:y.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((m=(u=s.locale)==null?void 0:u.options)==null?void 0:m.firstWeekContainsDate)??1,o=rv(n,t),c=Br((t==null?void 0:t.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),Ao(c,t)}function Oj(n,t){const s=En(n,t==null?void 0:t.in),i=+Ao(s,t)-+Ej(s,t);return Math.round(i/Zx)+1}function We(n,t){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(t,"0");return s+i}const ps={y(n,t){const s=n.getFullYear(),i=s>0?s:1-s;return We(t==="yy"?i%100:i,t.length)},M(n,t){const s=n.getMonth();return t==="M"?String(s+1):We(s+1,2)},d(n,t){return We(n.getDate(),t.length)},a(n,t){const s=n.getHours()/12>=1?"pm":"am";switch(t){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,t){return We(n.getHours()%12||12,t.length)},H(n,t){return We(n.getHours(),t.length)},m(n,t){return We(n.getMinutes(),t.length)},s(n,t){return We(n.getSeconds(),t.length)},S(n,t){const s=t.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return We(o,t.length)}},Ii={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},v1={G:function(n,t,s){const i=n.getFullYear()>0?1:0;switch(t){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,t,s){if(t==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ps.y(n,t)},Y:function(n,t,s,i){const o=rv(n,i),c=o>0?o:1-o;if(t==="YY"){const d=c%100;return We(d,2)}return t==="Yo"?s.ordinalNumber(c,{unit:"year"}):We(c,t.length)},R:function(n,t){const s=ev(n);return We(s,t.length)},u:function(n,t){const s=n.getFullYear();return We(s,t.length)},Q:function(n,t,s){const i=Math.ceil((n.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return We(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,t,s){const i=Math.ceil((n.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return We(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,t,s){const i=n.getMonth();switch(t){case"M":case"MM":return ps.M(n,t);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,t,s){const i=n.getMonth();switch(t){case"L":return String(i+1);case"LL":return We(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,t,s,i){const o=Oj(n,i);return t==="wo"?s.ordinalNumber(o,{unit:"week"}):We(o,t.length)},I:function(n,t,s){const i=Sj(n);return t==="Io"?s.ordinalNumber(i,{unit:"week"}):We(i,t.length)},d:function(n,t,s){return t==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ps.d(n,t)},D:function(n,t,s){const i=wj(n);return t==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):We(i,t.length)},E:function(n,t,s){const i=n.getDay();switch(t){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,t,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(c);case"ee":return We(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,t,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(c);case"cc":return We(c,t.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,t,s){const i=n.getDay(),o=i===0?7:i;switch(t){case"i":return String(o);case"ii":return We(o,t.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,t,s){const o=n.getHours()/12>=1?"pm":"am";switch(t){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,t,s){const i=n.getHours();let o;switch(i===12?o=Ii.noon:i===0?o=Ii.midnight:o=i/12>=1?"pm":"am",t){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,t,s){const i=n.getHours();let o;switch(i>=17?o=Ii.evening:i>=12?o=Ii.afternoon:i>=4?o=Ii.morning:o=Ii.night,t){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,t,s){if(t==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ps.h(n,t)},H:function(n,t,s){return t==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ps.H(n,t)},K:function(n,t,s){const i=n.getHours()%12;return t==="Ko"?s.ordinalNumber(i,{unit:"hour"}):We(i,t.length)},k:function(n,t,s){let i=n.getHours();return i===0&&(i=24),t==="ko"?s.ordinalNumber(i,{unit:"hour"}):We(i,t.length)},m:function(n,t,s){return t==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ps.m(n,t)},s:function(n,t,s){return t==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ps.s(n,t)},S:function(n,t){return ps.S(n,t)},X:function(n,t,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return w1(i);case"XXXX":case"XX":return Qs(i);case"XXXXX":case"XXX":default:return Qs(i,":")}},x:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"x":return w1(i);case"xxxx":case"xx":return Qs(i);case"xxxxx":case"xxx":default:return Qs(i,":")}},O:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+_1(i,":");case"OOOO":default:return"GMT"+Qs(i,":")}},z:function(n,t,s){const i=n.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+_1(i,":");case"zzzz":default:return"GMT"+Qs(i,":")}},t:function(n,t,s){const i=Math.trunc(+n/1e3);return We(i,t.length)},T:function(n,t,s){return We(+n,t.length)}};function _1(n,t=""){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)+t+We(c,2)}function w1(n,t){return n%60===0?(n>0?"-":"+")+We(Math.abs(n)/60,2):Qs(n,t)}function Qs(n,t=""){const s=n>0?"-":"+",i=Math.abs(n),o=We(Math.trunc(i/60),2),c=We(i%60,2);return s+o+t+c}const S1=(n,t)=>{switch(n){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},sv=(n,t)=>{switch(n){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Aj=(n,t)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return S1(n,t);let c;switch(i){case"P":c=t.dateTime({width:"short"});break;case"PP":c=t.dateTime({width:"medium"});break;case"PPP":c=t.dateTime({width:"long"});break;case"PPPP":default:c=t.dateTime({width:"full"});break}return c.replace("{{date}}",S1(i,t)).replace("{{time}}",sv(o,t))},jj={p:sv,P:Aj},kj=/^D+$/,Nj=/^Y+$/,Tj=["D","DD","YY","YYYY"];function Cj(n){return kj.test(n)}function Mj(n){return Nj.test(n)}function Rj(n,t,s){const i=Dj(n,t,s);if(console.warn(i),Tj.includes(n))throw new RangeError(i)}function Dj(n,t,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${t}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const qj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Lj=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Bj=/^'([^]*?)'?$/,Pj=/''/g,Uj=/[a-zA-Z]/;function Nm(n,t,s){var m,b,x,v;const i=Mo(),o=i.locale??nv,c=i.firstWeekContainsDate??((b=(m=i.locale)==null?void 0:m.options)==null?void 0:b.firstWeekContainsDate)??1,d=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,y=En(n,s==null?void 0:s.in);if(!IA(y))throw new RangeError("Invalid time value");let g=t.match(Lj).map(_=>{const S=_[0];if(S==="p"||S==="P"){const C=jj[S];return C(_,o.formatLong)}return _}).join("").match(qj).map(_=>{if(_==="''")return{isToken:!1,value:"'"};const S=_[0];if(S==="'")return{isToken:!1,value:zj(_)};if(v1[S])return{isToken:!0,value:_};if(S.match(Uj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:_}});o.localize.preprocessor&&(g=o.localize.preprocessor(y,g));const u={firstWeekContainsDate:c,weekStartsOn:d,locale:o};return g.map(_=>{if(!_.isToken)return _.value;const S=_.value;(Mj(S)||Cj(S))&&Rj(S,t,String(n));const C=v1[S[0]];return C(y,S,o.localize,u)}).join("")}function zj(n){const t=n.match(Bj);return t?t[1].replace(Pj,"'"):n}function Ij(n,t,s){const i=Mo(),o=(s==null?void 0:s.locale)??i.locale??nv,c=PA(n,t);if(isNaN(c))throw new RangeError("Invalid time value");const d=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[y,g]=tv(s==null?void 0:s.in,...c>0?[t,n]:[n,t]),u=$A((s==null?void 0:s.roundingMethod)??"round"),m=g.getTime()-y.getTime(),b=m/m1,x=xu(g)-xu(y),v=(m-x)/m1,_=s==null?void 0:s.unit;let S;if(_?S=_:b<1?S="second":b<60?S="minute":b<g1?S="hour":v<y1?S="day":v<p1?S="month":S="year",S==="second"){const C=u(m/1e3);return o.formatDistance("xSeconds",C,d)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,d)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,d)}else if(S==="day"){const C=u(v/g1);return o.formatDistance("xDays",C,d)}else if(S==="month"){const C=u(v/y1);return C===12&&_!=="month"?o.formatDistance("xYears",1,d):o.formatDistance("xMonths",C,d)}else{const C=u(v/p1);return o.formatDistance("xYears",C,d)}}function $j(n,t){return Ij(n,UA(n),t)}function w5(n){return n.toLocaleString()}function S5(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 Hj(n){const t=new Date(n);return t.getTime()>Date.now()?"just now":$j(t,{addSuffix:!0})}function E5(n){const t=Date.now()-new Date(n).getTime();if(t<0)return"now";const s=Math.floor(t/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 O5(n){return n<=0?"Expired":Tm(n)}function Fj(n){return n==null?"--":Tm(n)}function A5(n){return n?Nm(new Date(n),"MMM d, yyyy h:mm a"):"--"}function Tm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const d=n/1e3;return Number.isInteger(d)?`${d}s`:`${d.toFixed(1)}s`}const t=Math.floor(n/1e3),s=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),c=t%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 j5(n,t){const s=new Date(n).getTime(),i=t?new Date(t).getTime():Date.now();return Tm(i-s)}function iv({options:n,children:t,className:s=""}){const[i,o]=E.useState(!1),[c,d]=E.useState(null),[y,g]=E.useState(null),u=E.useRef(null),m=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const L=u.current.getBoundingClientRect(),P=window.innerWidth-x-8,ie=Math.max(8,Math.min(L.left,P));g({top:L.bottom+4,left:ie})},[]),_=E.useCallback(async(L,P)=>{try{await navigator.clipboard.writeText(L),d(P),clearTimeout(m.current),m.current=setTimeout(()=>d(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(m.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[t,i&&y&&Xd.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:y.top,left:y.left},onMouseEnter:S,onMouseLeave:C,children:n.map(L=>h.jsxs("button",{onClick:P=>{P.stopPropagation(),_(L.value,L.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:L.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===L.label?"✓":L.value})]},L.label))}),document.body)]})}function Gj(n,t){const s=new Date(n);switch(t){case"relative":return Hj(n);case"datetime":return Nm(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Vj(n){const t=new Date(n);return[{label:"ms",value:String(t.getTime())},{label:"utc",value:t.toISOString()},{label:"local",value:Nm(t,"MMM d, yyyy h:mm:ss a")}]}function av({date:n,format:t="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(t!=="relative")return;const c=setInterval(()=>i(d=>d+1),3e4);return()=>clearInterval(c)},[t]);const o=E.useMemo(()=>Vj(n),[n]);return h.jsx(iv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:Gj(n,t)})})}function Yj({values:n,options:t,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const d=t.filter(y=>!n.includes(y));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(y=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==y)),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 ${y}`,children:[y,h.jsx(Xt,{className:"w-3 h-3",strokeWidth:1.5})]},y)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),d.length>0&&h.jsxs("select",{value:"",onChange:y=>y.target.value&&s([...n,y.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),d.map(y=>h.jsx("option",{value:y,children:y},y))]})]})}const Kj=[{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 Jj(){const{data:n}=Wx(),{data:t}=uA(),s=MA(),i=RA(),[o,c]=E.useState(""),[d,y]=E.useState(""),[g,u]=E.useState(1440),[m,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{d.trim()&&s.mutate({body:d.trim(),...o.trim()?{title:o.trim()}:{},...m.length?{roles:m}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),y(""),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:d,onChange:_=>y(_.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:Kj.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(Yj,{values:m,options:(t==null?void 0:t.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:!d.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
54
  `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(av,{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(Xt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},_.id))})]})]})}const Qj=[{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"}],Xj=["operator","engineer","admin","superadmin"];function E1(n){return Xj.indexOf(n)}function Wj(n,t){return E1(n)>=E1(t)}function Zj({onClose:n}){var ke,Te,st,Nt,Bt,gt,bt;const{isSuperAdmin:t,hasRoleType:s,hasRole:i}=Lt(),{data:o}=Wn(),c=bm(),d=!!((ke=o==null?void 0:o.ai)!=null&&ke.enabled),y=Px(),g=y!==null?y:d,[u,m]=E.useState(g),b=(Te=o==null?void 0:o.features)==null?void 0:Te.graphWorkflows,x=b==null,[v,_]=E.useState(b===!0||x&&Ux()),S=t||i("engineer"),[C,L]=E.useState(zx()),P=!!((st=o==null?void 0:o.features)!=null&&st.scanCodes),ie=Ix(),[oe,D]=E.useState(ie!==null?ie:P),$=t?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ee=((Nt=o==null?void 0:o.branding)==null?void 0:Nt.appName)??"LongTail",K=(Bt=o==null?void 0:o.environment)==null?void 0:Bt.longTailVersion,I=(gt=o==null?void 0:o.environment)==null?void 0:gt.hotmeshVersion,M=(bt=o==null?void 0:o.environment)==null?void 0:bt.nodeEnv;E.useEffect(()=>{const ue=Je=>{Je.key==="Escape"&&n()};return document.addEventListener("keydown",ue),()=>document.removeEventListener("keydown",ue)},[n]);const J=Qj.filter(ue=>Wj($,ue.minTier)),Q=J.length>1,he=$!=="operator",be=[...Q?[{id:"viewas",label:"View As",icon:iS}]:[],{id:"features",label:"Features",icon:aS},...he?[{id:"alerts",label:"Alerts",icon:oS}]:[]],[we,H]=E.useState(be[0].id),Z=ue=>{ue===null?Ud():WO(ue)},le=()=>{const ue=!u;m(ue),ue===d?XO():QO(ue),window.location.reload()},_e=()=>{const ue=!v;_(ue),ZO(ue),window.location.reload()},Ee=()=>{const ue=!C;L(ue),eA(ue),window.location.reload()},Ne=()=>{const ue=!oe;D(ue),ue===P?nA():tA(ue),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:ue=>ue.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(Xt,{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(${$t}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ee}),K&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",K,I&&h.jsxs(h.Fragment,{children:[" · HotMesh v",I]}),M&&M!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:M})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),be.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:be.map(ue=>{const Je=we===ue.id;return h.jsxs("button",{role:"tab","aria-selected":Je,onClick:()=>H(ue.id),title:ue.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Je?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(ue.icon,{className:"w-5 h-5",strokeWidth:1.5,...Je?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:ue.label})]},ue.id)})}),we==="viewas"&&Q&&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"}),J.map(ue=>{const Je=c===ue.id,jn=ue.id===null?`Your view · ${$}`:ue.label;return h.jsxs("button",{onClick:()=>Z(ue.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 ${Je?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Je&&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 ${Je?"text-accent":"text-text-primary group-hover:text-accent"}`,children:jn}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:ue.description})]})]},String(ue.id))})]}),we==="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:_e,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:Ee,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:Ne,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:oe?"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 ${oe?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${oe?"translate-x-4":"translate-x-0"}`})})]})]}),we==="alerts"&&he&&h.jsx(Jj,{}),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 ov=[{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"}],O1="blue",lv="lt.theme";let cv=[];function ek(n){const t=new Set(ov.map(i=>i.id)),s=new Set;cv=n.filter(i=>!(i!=null&&i.id)||t.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function tk(){return[...ov,...cv]}function uv(){try{return localStorage.getItem(lv)||O1}catch{return O1}}function fv(n){document.documentElement.dataset.theme=n}function nk(n){try{localStorage.setItem(lv,n)}catch{}fv(n)}const hv=E.createContext(null);function rk(){const n=E.useContext(hv);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function sk({children:n}){const[t,s]=E.useState(null),i=E.useRef(t);i.current=t,E.useEffect(()=>{if(!(t!=null&&t.expiresAt))return;const u=new Date(t.expiresAt).getTime()-Date.now();if(u<=0){s(null);return}const m=setTimeout(()=>s(null),u);return()=>clearTimeout(m)},[t]);const o=E.useCallback(u=>{var b;if(!u.actingToken||!u.actor)return null;const m=((b=i.current)==null?void 0:b.actingToken)??null;return s({actingToken:u.actingToken,actorId:u.actor.id,displayName:u.actor.displayName,expiresAt:u.expiresAt??null,singleUse:u.maxUses===1}),m},[]),c=E.useCallback(()=>s(null),[]),d=E.useCallback(u=>{const m=i.current;m!=null&&m.singleUse&&m.actingToken===u&&s(null)},[]);E.useEffect(()=>(Cg(()=>{var u;return((u=i.current)==null?void 0:u.actingToken)??null}),Rg(c),Mg(d),()=>{Cg(null),Rg(null),Mg(null)}),[c,d]);const y=E.useCallback(()=>{var m;const u=(m=i.current)==null?void 0:m.expiresAt;return u?Math.max(0,Math.floor((new Date(u).getTime()-Date.now())/1e3)):0},[]),g=E.useMemo(()=>({identity:t,prime:o,clear:c,remainingSeconds:y}),[t,o,c,y]);return h.jsx(hv.Provider,{value:g,children:n})}const lu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},dv="lt_scan_wedge_config";function mv(){try{const n=localStorage.getItem(dv);return n?{...lu,...JSON.parse(n)}:lu}catch{return lu}}function ik(n){const t={...mv(),...n};return localStorage.setItem(dv,JSON.stringify(t)),t}const ak=[/[1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+$/,/[1-9][0-9]{7,}$/];function A1(n){let t=null;for(const s of ak){const i=n.match(s);i&&(!t||i[0].length>t.length)&&(t=i[0])}return t}const ok=new Set(["Shift","CapsLock"]),uc={suppress:!1,emit:null};function lk(n=lu){let t={buffer:"",times:[],lastKeyMs:0};function s(){t={buffer:"",times:[],lastKeyMs:0}}function i(d){const{key:y,timeMs:g,hasModifier:u,isRepeat:m}=d;if(ok.has(y))return uc;if(n.terminators.includes(y)){const S=A1(t.buffer);return s(),S&&S.length>=n.minLength?{suppress:!0,emit:S,consumedLength:S.length}:uc}if(u||m||y.length!==1)return s(),uc;const b=g-t.lastKeyMs,x=t.lastKeyMs>0&&b<=n.maxKeyGapMs,v=(x?t.buffer+y:y).slice(-128),_=(x?[...t.times,g]:[g]).slice(-128);return t={buffer:v,times:_,lastKeyMs:g},uc}function o(){return{buffer:t.buffer}}function c(){const d=A1(t.buffer);if(!d||d.length<n.minLength)return null;const y=t.times.slice(-d.length);return y.length<2||(y[y.length-1]-y[0])/(y.length-1)>n.autoFireMaxAvgKeyMs?null:{code:d,consumedLength:d.length}}return{step:i,reset:s,snapshot:o,pendingAutoFire:c}}function ck(){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 uk(n,t,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,t):n.value=t;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function j1(n){if(n<=0)return;const t=ck();if(!t)return;const s=t.selectionStart??t.value.length,i=Math.max(0,s-n);uk(t,t.value.slice(0,i)+t.value.slice(s),i)}function fk({active:n,wedgeConfig:t,diagnosticsOn:s,onScan:i,onDiag:o}){const c=E.useRef({diagnosticsOn:s,onScan:i,onDiag:o});c.current={diagnosticsOn:s,onScan:i,onDiag:o};const d=E.useRef(0),y=E.useRef(0);E.useEffect(()=>{if(!n)return;const g=lk(t);let u=null;const m=()=>{u&&(clearTimeout(u),u=null)},b=(_,S,C)=>{S&&j1(S),c.current.diagnosticsOn&&(console.debug("[scan]",C),c.current.onDiag({seq:++d.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:C})),c.current.onScan(_)},x=()=>{m(),g.pendingAutoFire()&&(u=setTimeout(()=>{u=null;const _=g.pendingAutoFire();_&&(g.reset(),b(_.code,_.consumedLength,`capture → ${_.code} (quiet period — no suffix)`))},t.autoFireQuietMs))},v=_=>{const S=g.snapshot().buffer,{suppress:C,emit:L,consumedLength:P}=g.step({key:_.key,timeMs:_.timeStamp,hasModifier:_.ctrlKey||_.metaKey||_.altKey,isRepeat:_.repeat});if(C&&(_.preventDefault(),_.stopPropagation()),c.current.diagnosticsOn){const ie=g.snapshot().buffer,oe=t.terminators.includes(_.key),D=L?`capture → ${L}`:oe?`terminator — no code tail in "${S.slice(-24)}"`:ie===S?S?"neutral (chord key)":"ignored":ie===""?"reset (edit/chord/non-printable)":ie.length<=1&&S.length>1?"gap — new episode":"accumulate",$=y.current?Math.round(_.timeStamp-y.current):0,ee={seq:++d.current,key:_.key,code:_.code!==_.key?_.code:"",deltaMs:$,buffer:ie.slice(-24),note:D};console.debug("[scan]",ee.key,ee.code,`${ee.deltaMs}ms`,ee.note),c.current.onDiag(ee)}y.current=_.timeStamp,L?(m(),P&&j1(P),c.current.onScan(L)):x()};return window.addEventListener("keydown",v,{capture:!0}),()=>{m(),window.removeEventListener("keydown",v,{capture:!0})}},[n,t])}const De={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"},fc={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"},hk={ACTION:"action",IDENTITY:"identity"};function dk(n,t){return fe("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...t!=null&&t.actingToken?{actingToken:t.actingToken}:{},...t!=null&&t.previousActingToken?{previousActingToken:t.previousActingToken}:{}})})}function k5(n){return fe("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function mk(n){return Ue({queryKey:["scan-schemes"],queryFn:()=>fe("/scan-codes/schemes"),...n})}function N5(n){return Ue({queryKey:["scan-schemes",n],queryFn:()=>fe(`/scan-codes/schemes/${n}`),enabled:n!=null})}function T5(){const n=ze();return He({mutationFn:t=>fe(`/scan-codes/schemes/${t.version}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function C5(){const n=ze();return He({mutationFn:t=>fe(`/scan-codes/schemes/${t}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function M5(){const n=ze();return He({mutationFn:t=>fe(`/scan-codes/schemes/${t.scheme_version}/actions/${t.category}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:(t,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function R5(){const n=ze();return He({mutationFn:t=>fe(`/scan-codes/schemes/${t.scheme_version}/actions/${t.category}`,{method:"DELETE"}),onSuccess:(t,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const jo={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar"},$i=n=>{if(n)try{return JSON.parse(n)}catch{return}},Xs=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function pk(n){const t={},s=$i(n.get("facets"));Xs(s)||(t.facets=s);const i=$i(n.get("block"));Xs(i)||(t.block=i);const o=$i(n.get("range"));Xs(o)||(t.range=o);const c=$i(n.get("exists"));Xs(c)||(t.exists=c);const d=$i(n.get("roles"));Xs(d)||(t.roles=d);const y=$i(n.get("orderBy"));Xs(y)||(t.orderBy=y),n.get("available")!=null&&(t.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(t.jeopardy=!0),t}function D5(n,t){const s=(i,o)=>Xs(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",t.facets),s("block",t.block),s("range",t.range),s("exists",t.exists),s("roles",t.roles),s("orderBy",t.orderBy),t.available==null?n.delete("available"):n.set("available",String(t.available)),t.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const k1=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function pv(n,t){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 t?`/escalations/available?role=${encodeURIComponent(t)}&facets=${i}${k1}`:`/escalations/available?facets=${i}${k1}`}function yk(n,t,s){return pv({[n]:t},s)}function q5(n){var t,s,i;return Object.keys(n.facets??{}).length+(((t=n.block)==null?void 0:t.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 Cm(){var s;const{data:n}=Wn(),t=Ix();return t!==null?t:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const yv=E.createContext(null);function Mm(){const n=E.useContext(yv);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}const gk="scanPendingAction",bk="scanChoices",xk="/scan/station";function vk({children:n}){const{user:t}=Lt(),s=Cm(),i=ra(),{identity:o,prime:c,clear:d}=rk(),[y,g]=E.useState(null),[u,m]=E.useState(!1),[b,x]=E.useState(()=>mv()),[v,_]=E.useState([]),[S,C]=E.useState(!1),L=E.useCallback(M=>{var Q;const{outcome:J}=M;if(J===De.CONFIRM_REQUIRED&&M.pendingAction)return i(`/escalations/detail/${M.pendingAction.escalationId}`,{state:{[gk]:M.pendingAction}}),!0;if(J===De.EXECUTED&&M.escalation){const he=[fc.SHOW_DETAIL,fc.CLAIM_SHOW_DETAIL,fc.CLAIM,fc.ESCALATE];return M.verb&&he.includes(M.verb)?(i(`/escalations/detail/${M.escalation.id}`),!0):!1}if(J===De.MATCHED_LIST&&M.listQuery){const{targetFacet:he,target:be,roles:we}=M.listQuery;return i(pv({[he]:be},(we==null?void 0:we[0])??null)),!0}return J===De.CHOICES&&M.choices?(i(xk,{state:{[bk]:M}}),!0):J===De.NO_MATCH_FALLBACK&&((Q=M.fallback)!=null&&Q.route)?(i(M.fallback.route),!0):!1},[i]),P=E.useRef(null);P.current=(o==null?void 0:o.actingToken)??null;const ie=E.useRef(null),oe=E.useRef(null),D=E.useCallback(M=>{oe.current=M},[]),$=E.useCallback(async(M,J=jo.MANUAL)=>{var he;if((he=oe.current)!=null&&he.call(oe,M))return;m(!0);const Q=Date.now();try{const be=P.current,we=await dk(M,{actingToken:be??void 0,previousActingToken:ie.current??void 0});we.outcome===De.IDENTITY_PRIMED&&(ie.current=c(we)),we.outcome===De.NOT_PRIMED&&be&&d();const H=L(we);g({code:M,source:J,at:Q,response:we,error:null,navigated:H})}catch(be){g({code:M,source:J,at:Q,response:null,error:be.message,navigated:!1})}finally{m(!1)}},[L,c,d]),ee=E.useRef($);ee.current=$,fk({active:!!t&&s,wedgeConfig:b,diagnosticsOn:S,onScan:M=>void ee.current(M,jo.KEYBOARD_WEDGE),onDiag:M=>_(J=>[...J.slice(-29),M])});const K=E.useCallback(M=>{x(ik(M))},[]),I=E.useMemo(()=>({submitCode:$,setCodeInterceptor:D,lastResult:y,busy:u,wedgeConfig:b,updateWedgeConfig:K,diagnostics:v,diagnosticsOn:S,setDiagnosticsOn:C}),[$,D,y,u,b,K,v,S]);return h.jsx(yv.Provider,{value:I,children:n})}var hc={},oo={},dc={},N1;function An(){if(N1)return dc;N1=1,Object.defineProperty(dc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var t=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return dc.default=t,dc}var T1;function _k(){if(T1)return oo;T1=1,Object.defineProperty(oo,"__esModule",{value:!0}),oo.CODE39=void 0;var n=(function(){function S(C,L){for(var P=0;P<L.length;P++){var ie=L[P];ie.enumerable=ie.enumerable||!1,ie.configurable=!0,"value"in ie&&(ie.writable=!0),Object.defineProperty(C,ie.key,ie)}}return function(C,L,P){return L&&S(C.prototype,L),P&&S(C,P),C}})(),t=An(),s=i(t);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 d(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 y=(function(S){d(C,S);function C(L,P){return o(this,C),L=L.toUpperCase(),P.mod43&&(L+=x(_(L))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,L,P))}return n(C,[{key:"encode",value:function(){for(var P=m("*"),ie=0;ie<this.data.length;ie++)P+=m(this.data[ie])+"0";return P+=m("*"),{data:P,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 m(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,L=0;L<S.length;L++)C+=v(S[L]);return C=C%43,C}return oo.CODE39=y,oo}var Yn={},mc={},pc={},yt={},C1;function Ro(){if(C1)return yt;C1=1,Object.defineProperty(yt,"__esModule",{value:!0});var n;function t(g,u,m){return u in g?Object.defineProperty(g,u,{value:m,enumerable:!0,configurable:!0,writable:!0}):g[u]=m,g}var s=yt.SET_A=0,i=yt.SET_B=1,o=yt.SET_C=2;yt.SHIFT=98;var c=yt.START_A=103,d=yt.START_B=104,y=yt.START_C=105;return yt.MODULO=103,yt.STOP=106,yt.FNC1=207,yt.SET_BY_CODE=(n={},t(n,c,s),t(n,d,i),t(n,y,o),n),yt.SWAP={101:s,100:i,99:o},yt.A_START_CHAR="Ð",yt.B_START_CHAR="Ñ",yt.C_START_CHAR="Ò",yt.A_CHARS="[\0-_È-Ï]",yt.B_CHARS="[ -È-Ï]",yt.C_CHARS="(Ï*[0-9]{2}Ï*)",yt.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],yt}var M1;function Tu(){if(M1)return pc;M1=1,Object.defineProperty(pc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=An(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(b,x){c(this,m);var v=d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(_){return _.charCodeAt(0)}),v}return n(m,[{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=m.next(x,1,_);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:m.getBar(v)+S.result+m.getBar((S.checksum+v)%i.MODULO)+m.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 L=i.SWAP[C];L!==void 0?S=m.next(x,v+1,L):((_===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=m.next(x,v+1,_))}else C=m.correctIndex(x,_),S=m.next(x,v+1,_);var P=m.getBar(C),ie=C*v;return{result:P+S.result,checksum:ie+S.checksum}}}]),m})(s.default);return pc.default=g,pc}var yc={},R1;function wk(){if(R1)return yc;R1=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Ro(),t=function(y){return y.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(y){return y.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(y){return y.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(d,y){var g=y?n.A_CHARS:n.B_CHARS,u=d.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(d.substring(u[1].length));var m=d.match(new RegExp("^"+g+"+"))[0];return m.length===d.length?d:m+String.fromCharCode(y?205:206)+o(d.substring(m.length),!y)}function c(d){var y=i(d),g=y.length;if(g===d.length)return d;d=d.substring(g);var u=t(d)>=s(d);return y+String.fromCharCode(u?206:205)+o(d,u)}return yc.default=function(d){var y=void 0,g=i(d).length;if(g>=2)y=n.C_START_CHAR+c(d);else{var u=t(d)>s(d);y=(u?n.A_START_CHAR:n.B_START_CHAR)+o(d,u)}return y.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(m,b){return"Ë"+b})},yc}var D1;function Sk(){if(D1)return mc;D1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=Tu(),t=o(n),s=wk(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(b,x){if(c(this,m),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,(0,i.default)(b),x));else var v=d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,x));return d(v)}return m})(t.default);return mc.default=g,mc}var gc={},q1;function Ek(){if(q1)return gc;q1=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(b,x){return c(this,m),d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,i.A_START_CHAR+b,x))}return n(m,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),m})(s.default);return gc.default=g,gc}var bc={},L1;function Ok(){if(L1)return bc;L1=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(b,x){return c(this,m),d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,i.B_START_CHAR+b,x))}return n(m,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),m})(s.default);return bc.default=g,bc}var xc={},B1;function Ak(){if(B1)return xc;B1=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=Tu(),s=o(t),i=Ro();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(b,x){return c(this,m),d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,i.C_START_CHAR+b,x))}return n(m,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),m})(s.default);return xc.default=g,xc}var P1;function jk(){if(P1)return Yn;P1=1,Object.defineProperty(Yn,"__esModule",{value:!0}),Yn.CODE128C=Yn.CODE128B=Yn.CODE128A=Yn.CODE128=void 0;var n=Sk(),t=g(n),s=Ek(),i=g(s),o=Ok(),c=g(o),d=Ak(),y=g(d);function g(u){return u&&u.__esModule?u:{default:u}}return Yn.CODE128=t.default,Yn.CODE128A=i.default,Yn.CODE128B=c.default,Yn.CODE128C=y.default,Yn}var Vt={},vc={},Tr={},U1;function Do(){return U1||(U1=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.SIDE_BIN="101",Tr.MIDDLE_BIN="01010",Tr.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"]},Tr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Tr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Tr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Tr}var _c={},wc={},z1;function qo(){if(z1)return wc;z1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=Do(),t=function(i,o,c){var d=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var y=i.length-1;d=d.map(function(g,u){return u<y?g+c:g})}return d.join("")};return wc.default=t,wc}var I1;function gv(){if(I1)return _c;I1=1,Object.defineProperty(_c,"__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}})(),t=Do(),s=qo(),i=d(s),o=An(),c=d(o);function d(b){return b&&b.__esModule?b:{default:b}}function y(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 m=(function(b){u(x,b);function x(v,_){y(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:t.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:_},{data:t.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:_},{data:t.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var _=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:_.join(""),text:this.text}}}]),x})(c.default);return _c.default=m,_c}var $1;function kk(){if($1)return vc;$1=1,Object.defineProperty(vc,"__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}})(),t=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 L=S.get;return L===void 0?void 0:L.call(_)}},s=Do(),i=gv(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function d(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function y(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},m=(function(b){g(x,b);function x(v,_){d(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=y(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 t(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 t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,_,S)}},{key:"rightText",value:function(){return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var _=this.data.substr(7,6);return t(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,_,"RRRRRR")}},{key:"encodeGuarded",value:function(){var _=t(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 vc.default=m,vc}var Sc={},H1;function Nk(){if(H1)return Sc;H1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function m(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&&m(b.prototype,x),v&&m(b,v),b}})(),t=function m(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:m(S,x,v)}else{if("value"in _)return _.value;var C=_.get;return C===void 0?void 0:C.call(v)}},s=gv(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m,b){if(!(m instanceof b))throw new TypeError("Cannot call a class as a function")}function d(m,b){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:m}function y(m,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);m.prototype=Object.create(b&&b.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(m,b):m.__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(m){y(b,m);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),d(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 t(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 t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return t(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 t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Sc.default=u,Sc}var Ec={},F1;function Tk(){if(F1)return Ec;F1=1,Object.defineProperty(Ec,"__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}})(),t=Do(),s=qo(),i=d(s),o=An(),c=d(o);function d(x){return x&&x.__esModule?x:{default:x}}function y(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 m=function(v){var _=v.split("").map(function(S){return+S}).reduce(function(S,C,L){return L%2?S+C*9:S+C*3},0);return _%10},b=(function(x){u(v,x);function v(_,S){return y(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=t.EAN5_STRUCTURE[m(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ec.default=b,Ec}var Oc={},G1;function Ck(){if(G1)return Oc;G1=1,Object.defineProperty(Oc,"__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}})(),t=Do(),s=qo(),i=d(s),o=An(),c=d(o);function d(b){return b&&b.__esModule?b:{default:b}}function y(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 m=(function(b){u(x,b);function x(v,_){return y(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 _=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,_,"01"),text:this.text}}}]),x})(c.default);return Oc.default=m,Oc}var lo={},V1;function bv(){if(V1)return lo;V1=1,Object.defineProperty(lo,"__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}})();lo.checksum=m;var t=qo(),s=c(t),i=An(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function d(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function y(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,_){d(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=m(v));var S=y(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]==m(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 m(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 lo.default=u,lo}var Ac={},Y1;function Mk(){if(Y1)return Ac;Y1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function _(S,C){for(var L=0;L<C.length;L++){var P=C[L];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(S,P.key,P)}}return function(S,C,L){return C&&_(S.prototype,C),L&&_(S,L),S}})(),t=qo(),s=d(t),i=An(),o=d(i),c=bv();function d(_){return _&&_.__esModule?_:{default:_}}function y(_,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 m=["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,L){y(this,S);var P=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,L));if(P.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)P.middleDigits=C,P.upcA=v(C,"0"),P.text=L.text||""+P.upcA[0]+C+P.upcA[P.upcA.length-1],P.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(P.middleDigits=C.substring(1,C.length-1),P.upcA=v(P.middleDigits,C[0]),P.upcA[P.upcA.length-1]===C[C.length-1])P.isValid=!0;else return g(P);else return g(P);return P.displayValue=L.displayValue,L.fontSize>L.width*10?P.fontSize=L.width*10:P.fontSize=L.fontSize,P.guardHeight=L.height+P.fontSize/2+L.textMargin,P}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 L="";return L+="101",L+=this.encodeMiddleDigits(),L+="010101",{data:L,text:this.text}}},{key:"guardedEncoding",value:function(){var L=[];return this.displayValue&&L.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),L.push({data:"101",options:{height:this.guardHeight}}),L.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),L.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&L.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),L}},{key:"encodeMiddleDigits",value:function(){var L=this.upcA[0],P=this.upcA[this.upcA.length-1],ie=b[parseInt(P)][parseInt(L)];return(0,s.default)(this.middleDigits,ie)}}]),S})(o.default);function v(_,S){for(var C=parseInt(_[_.length-1]),L=m[C],P="",ie=0,oe=0;oe<L.length;oe++){var D=L[oe];D==="X"?P+=_[ie++]:P+=D}return P=""+S+P,""+P+(0,c.checksum)(P)}return Ac.default=x,Ac}var K1;function Rk(){if(K1)return Vt;K1=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.UPCE=Vt.UPC=Vt.EAN2=Vt.EAN5=Vt.EAN8=Vt.EAN13=void 0;var n=kk(),t=x(n),s=Nk(),i=x(s),o=Tk(),c=x(o),d=Ck(),y=x(d),g=bv(),u=x(g),m=Mk(),b=x(m);function x(v){return v&&v.__esModule?v:{default:v}}return Vt.EAN13=t.default,Vt.EAN8=i.default,Vt.EAN5=c.default,Vt.EAN2=y.default,Vt.UPC=u.default,Vt.UPCE=b.default,Vt}var Ks={},jc={},Hi={},J1;function Dk(){return J1||(J1=1,Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.START_BIN="1010",Hi.END_BIN="11101",Hi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Hi}var Q1;function xv(){if(Q1)return jc;Q1=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=Dk(),s=An(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(){return c(this,m),d(this,(m.__proto__||Object.getPrototypeOf(m)).apply(this,arguments))}return n(m,[{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:t.START_BIN+v+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=t.BINARIES[x[1]];return t.BINARIES[x[0]].split("").map(function(_,S){return(_==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),m})(i.default);return jc.default=g,jc}var kc={},X1;function qk(){if(X1)return kc;X1=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=xv(),s=i(t);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function c(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function d(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var y=function(m){var b=m.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){d(m,u);function m(b,x){return o(this,m),b.search(/^[0-9]{13}$/)!==-1&&(b+=y(b)),c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,x))}return n(m,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===y(this.data)}}]),m})(s.default);return kc.default=g,kc}var W1;function Lk(){if(W1)return Ks;W1=1,Object.defineProperty(Ks,"__esModule",{value:!0}),Ks.ITF14=Ks.ITF=void 0;var n=xv(),t=o(n),s=qk(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Ks.ITF=t.default,Ks.ITF14=i.default,Ks}var pn={},Nc={},Z1;function Lo(){if(Z1)return Nc;Z1=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=An(),s=i(t);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function c(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function d(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var y=(function(u){d(m,u);function m(b,x){return o(this,m),c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,x))}return n(m,[{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}}]),m})(s.default);function g(u,m){for(var b=0;b<m;b++)u="0"+u;return u}return Nc.default=y,Nc}var Tc={},co={},eb;function Cu(){if(eb)return co;eb=1,Object.defineProperty(co,"__esModule",{value:!0}),co.mod10=n,co.mod11=t;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 t(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var d=parseInt(s[s.length-1-c]);i+=o[c%o.length]*d}return(11-i%11)%11}return co}var tb;function Bk(){if(tb)return Tc;tb=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=Lo(),t=i(n),s=Cu();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 d(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 y=(function(g){d(u,g);function u(m,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m+(0,s.mod10)(m),b))}return u})(t.default);return Tc.default=y,Tc}var Cc={},nb;function Pk(){if(nb)return Cc;nb=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=Lo(),t=i(n),s=Cu();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 d(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 y=(function(g){d(u,g);function u(m,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m+(0,s.mod11)(m),b))}return u})(t.default);return Cc.default=y,Cc}var Mc={},rb;function Uk(){if(rb)return Mc;rb=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=Lo(),t=i(n),s=Cu();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 d(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 y=(function(g){d(u,g);function u(m,b){return o(this,u),m+=(0,s.mod10)(m),m+=(0,s.mod10)(m),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m,b))}return u})(t.default);return Mc.default=y,Mc}var Rc={},sb;function zk(){if(sb)return Rc;sb=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=Lo(),t=i(n),s=Cu();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 d(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 y=(function(g){d(u,g);function u(m,b){return o(this,u),m+=(0,s.mod11)(m),m+=(0,s.mod10)(m),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m,b))}return u})(t.default);return Rc.default=y,Rc}var ib;function Ik(){if(ib)return pn;ib=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.MSI1110=pn.MSI1010=pn.MSI11=pn.MSI10=pn.MSI=void 0;var n=Lo(),t=m(n),s=Bk(),i=m(s),o=Pk(),c=m(o),d=Uk(),y=m(d),g=zk(),u=m(g);function m(b){return b&&b.__esModule?b:{default:b}}return pn.MSI=t.default,pn.MSI10=i.default,pn.MSI11=c.default,pn.MSI1010=y.default,pn.MSI1110=u.default,pn}var uo={},ab;function $k(){if(ab)return uo;ab=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.pharmacode=void 0;var n=(function(){function g(u,m){for(var b=0;b<m.length;b++){var x=m[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,m,b){return m&&g(u.prototype,m),b&&g(u,b),u}})(),t=An(),s=i(t);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 d(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 y=(function(g){d(u,g);function u(m,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m,b));return x.number=parseInt(m,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 uo.pharmacode=y,uo}var fo={},ob;function Hk(){if(ob)return fo;ob=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.codabar=void 0;var n=(function(){function g(u,m){for(var b=0;b<m.length;b++){var x=m[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,m,b){return m&&g(u.prototype,m),b&&g(u,b),u}})(),t=An(),s=i(t);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 d(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 y=(function(g){d(u,g);function u(m,b){o(this,u),m.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(m="A"+m+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m.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 fo.codabar=y,fo}var Js={},Dc={},Fi={},lb;function Fk(){return lb||(lb=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.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","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Fi.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"],Fi.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"]}),Fi}var cb;function vv(){if(cb)return Dc;cb=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=(function(){function u(m,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(m,v.key,v)}}return function(m,b,x){return b&&u(m.prototype,b),x&&u(m,x),m}})(),t=Fk(),s=An(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,m){if(!(u instanceof m))throw new TypeError("Cannot call a class as a function")}function d(u,m){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:u}function y(u,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);u.prototype=Object.create(m&&m.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(u,m):u.__proto__=m)}var g=(function(u){y(m,u);function m(b,x){return c(this,m),d(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,x))}return n(m,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return t.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return m.getEncoding(C)}).join(""),_=m.checksum(x,20),S=m.checksum(x.concat(_),15);return{text:this.text,data:m.getEncoding("ÿ")+v+m.getEncoding(_)+m.getEncoding(S)+m.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return t.BINARIES[m.symbolValue(x)]}},{key:"getSymbol",value:function(x){return t.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return t.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var _=x.slice().reverse().reduce(function(S,C,L){var P=L%v+1;return S+m.symbolValue(C)*P},0);return m.getSymbol(_%47)}}]),m})(i.default);return Dc.default=g,Dc}var qc={},ub;function Gk(){if(ub)return qc;ub=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=(function(){function g(u,m){for(var b=0;b<m.length;b++){var x=m[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,m,b){return m&&g(u.prototype,m),b&&g(u,b),u}})(),t=vv(),s=i(t);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 d(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 y=(function(g){d(u,g);function u(m,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return qc.default=y,qc}var fb;function Vk(){if(fb)return Js;fb=1,Object.defineProperty(Js,"__esModule",{value:!0}),Js.CODE93FullASCII=Js.CODE93=void 0;var n=vv(),t=o(n),s=Gk(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Js.CODE93=t.default,Js.CODE93FullASCII=i.default,Js}var ho={},hb;function Yk(){if(hb)return ho;hb=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.GenericBarcode=void 0;var n=(function(){function g(u,m){for(var b=0;b<m.length;b++){var x=m[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,m,b){return m&&g(u.prototype,m),b&&g(u,b),u}})(),t=An(),s=i(t);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 d(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 y=(function(g){d(u,g);function u(m,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,m,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return ho.GenericBarcode=y,ho}var db;function Kk(){if(db)return hc;db=1,Object.defineProperty(hc,"__esModule",{value:!0});var n=_k(),t=jk(),s=Rk(),i=Lk(),o=Ik(),c=$k(),d=Hk(),y=Vk(),g=Yk();return hc.default={CODE39:n.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.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:d.codabar,CODE93:y.CODE93,CODE93FullASCII:y.CODE93FullASCII,GenericBarcode:g.GenericBarcode},hc}var Lc={},mb;function Mu(){if(mb)return Lc;mb=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t};return Lc.default=function(t,s){return n({},t,s)},Lc}var Bc={},pb;function Jk(){if(pb)return Bc;pb=1,Object.defineProperty(Bc,"__esModule",{value:!0}),Bc.default=n;function n(t){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(t),s}return Bc}var Pc={},yb;function Qk(){if(yb)return Pc;yb=1,Object.defineProperty(Pc,"__esModule",{value:!0}),Pc.default=n;function n(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return Pc}var Uc={},zc={},Ic={},gb;function _v(){if(gb)return Ic;gb=1,Object.defineProperty(Ic,"__esModule",{value:!0}),Ic.default=n;function n(t){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof t[i]=="string"&&(t[i]=parseInt(t[i],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return Ic}var $c={},bb;function wv(){if(bb)return $c;bb=1,Object.defineProperty($c,"__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 $c.default=n,$c}var xb;function Xk(){if(xb)return zc;xb=1,Object.defineProperty(zc,"__esModule",{value:!0});var n=_v(),t=o(n),s=wv(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d){var y={};for(var g in i.default)i.default.hasOwnProperty(g)&&(d.hasAttribute("jsbarcode-"+g.toLowerCase())&&(y[g]=d.getAttribute("jsbarcode-"+g.toLowerCase())),d.hasAttribute("data-"+g.toLowerCase())&&(y[g]=d.getAttribute("data-"+g.toLowerCase())));return y.value=d.getAttribute("jsbarcode-value")||d.getAttribute("data-value"),y=(0,t.default)(y),y}return zc.default=c,zc}var Hc={},Fc={},yn={},vb;function Sv(){if(vb)return yn;vb=1,Object.defineProperty(yn,"__esModule",{value:!0}),yn.getTotalWidthOfEncodings=yn.calculateEncodingAttributes=yn.getBarcodePadding=yn.getEncodingHeight=yn.getMaximumHeightOfEncodings=void 0;var n=Mu(),t=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,m){return m.height+(m.displayValue&&u.text.length>0?m.fontSize+m.textMargin:0)+m.marginTop+m.marginBottom}function o(u,m,b){if(b.displayValue&&m<u){if(b.textAlign=="center")return Math.floor((u-m)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-m)}return 0}function c(u,m,b){for(var x=0;x<u.length;x++){var v=u[x],_=(0,t.default)(m,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 d(u){for(var m=0,b=0;b<u.length;b++)m+=u[b].width;return m}function y(u){for(var m=0,b=0;b<u.length;b++)u[b].height>m&&(m=u[b].height);return m}function g(u,m,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=m.fontOptions+" "+m.fontSize+"px "+m.font;var v=x.measureText(u);if(!v)return 0;var _=v.width;return _}return yn.getMaximumHeightOfEncodings=y,yn.getEncodingHeight=i,yn.getBarcodePadding=o,yn.calculateEncodingAttributes=c,yn.getTotalWidthOfEncodings=d,yn}var _b;function Wk(){if(_b)return Fc;_b=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n=(function(){function y(g,u){for(var m=0;m<u.length;m++){var b=u[m];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,m){return u&&y(g.prototype,u),m&&y(g,m),g}})(),t=Mu(),s=o(t),i=Sv();function o(y){return y&&y.__esModule?y:{default:y}}function c(y,g){if(!(y instanceof g))throw new TypeError("Cannot call a class as a function")}var d=(function(){function y(g,u,m){c(this,y),this.canvas=g,this.encodings=u,this.options=m}return n(y,[{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 m=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(m,this.encodings[u]),this.drawCanvasText(m,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 m=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=m+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,m){var b=this.canvas.getContext("2d"),x=m.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+m.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,m){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"||m.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=m.width-1,b.textAlign="right"):(v=m.width/2,b.textAlign="center"),b.fillText(m.text,v,_)}}},{key:"moveCanvasDrawing",value:function(u){var m=this.canvas.getContext("2d");m.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),y})();return Fc.default=d,Fc}var Gc={},wb;function Zk(){if(wb)return Gc;wb=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=(function(){function g(u,m){for(var b=0;b<m.length;b++){var x=m[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,m,b){return m&&g(u.prototype,m),b&&g(u,b),u}})(),t=Mu(),s=o(t),i=Sv();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 d="http://www.w3.org/2000/svg",y=(function(){function g(u,m,b){c(this,g),this.svg=u,this.encodings=m,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var m=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(m,v.marginTop,this.svg);this.setGroupOptions(_,v),this.drawSvgBarcode(_,v,x),this.drawSVGText(_,v,x),m+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var m=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=m+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(m,b,x){var v=x.data,_;b.textPosition=="top"?_=b.fontSize+b.textMargin:_=0;for(var S=0,C=0,L=0;L<v.length;L++)C=L*b.width+x.barcodePadding,v[L]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,_,b.width*S,b.height,m),S=0);S>0&&this.drawRect(C-b.width*(S-1),_,b.width*S,b.height,m)}},{key:"drawSVGText",value:function(m,b,x){var v=this.document.createElementNS(d,"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)),m.appendChild(v)}}},{key:"setSvgAttributes",value:function(m,b){var x=this.svg;x.setAttribute("width",m+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+m+" "+b),x.setAttribute("xmlns",d),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(m,b,x){var v=this.document.createElementNS(d,"g");return v.setAttribute("transform","translate("+m+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(m,b){m.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(m,b,x,v,_){var S=this.document.createElementNS(d,"rect");return S.setAttribute("x",m),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),_.appendChild(S),S}}]),g})();return Gc.default=y,Gc}var Vc={},Sb;function eN(){if(Sb)return Vc;Sb=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var d=0;d<c.length;d++){var y=c[d];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(o,y.key,y)}}return function(o,c,d){return c&&i(o.prototype,c),d&&i(o,d),o}})();function t(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,d){t(this,i),this.object=o,this.encodings=c,this.options=d}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Vc.default=s,Vc}var Eb;function tN(){if(Eb)return Hc;Eb=1,Object.defineProperty(Hc,"__esModule",{value:!0});var n=Wk(),t=d(n),s=Zk(),i=d(s),o=eN(),c=d(o);function d(y){return y&&y.__esModule?y:{default:y}}return Hc.default={CanvasRenderer:t.default,SVGRenderer:i.default,ObjectRenderer:c.default},Hc}var Gi={},Ob;function Ev(){if(Ob)return Gi;Ob=1,Object.defineProperty(Gi,"__esModule",{value:!0});function n(d,y){if(!(d instanceof y))throw new TypeError("Cannot call a class as a function")}function t(d,y){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:d}function s(d,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);d.prototype=Object.create(y&&y.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(d,y):d.__proto__=y)}var i=(function(d){s(y,d);function y(g,u){n(this,y);var m=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return m.name="InvalidInputException",m.symbology=g,m.input=u,m.message='"'+m.input+'" is not a valid input for '+m.symbology,m}return y})(Error),o=(function(d){s(y,d);function y(){n(this,y);var g=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return y})(Error),c=(function(d){s(y,d);function y(){n(this,y);var g=t(this,(y.__proto__||Object.getPrototypeOf(y)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return y})(Error);return Gi.InvalidInputException=i,Gi.InvalidElementException=o,Gi.NoElementException=c,Gi}var Ab;function nN(){if(Ab)return Uc;Ab=1,Object.defineProperty(Uc,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},t=Xk(),s=d(t),i=tN(),o=d(i),c=Ev();function d(m){return m&&m.__esModule?m:{default:m}}function y(m){if(typeof m=="string")return g(m);if(Array.isArray(m)){for(var b=[],x=0;x<m.length;x++)b.push(y(m[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&m instanceof HTMLImageElement)return u(m);if(m&&m.nodeName&&m.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&m instanceof SVGElement)return{element:m,options:(0,s.default)(m),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&m instanceof HTMLCanvasElement)return{element:m,options:(0,s.default)(m),renderer:o.default.CanvasRenderer};if(m&&m.getContext)return{element:m,renderer:o.default.CanvasRenderer};if(m&&(typeof m>"u"?"undefined":n(m))==="object"&&!m.nodeName)return{element:m,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(m){var b=document.querySelectorAll(m);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(y(b[v]));return x}}function u(m){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(m),renderer:o.default.CanvasRenderer,afterRender:function(){m.setAttribute("src",b.toDataURL())}}}return Uc.default=y,Uc}var Yc={},jb;function rN(){if(jb)return Yc;jb=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var d=0;d<c.length;d++){var y=c[d];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(o,y.key,y)}}return function(o,c,d){return c&&i(o.prototype,c),d&&i(o,d),o}})();function t(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){t(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 d=c.apply(void 0,arguments);return this.api._options.valid(!0),d}catch(y){return this.handleCatch(y),this.api}}}]),i})();return Yc.default=s,Yc}var od,kb;function sN(){if(kb)return od;kb=1;var n=Kk(),t=L(n),s=Mu(),i=L(s),o=Jk(),c=L(o),d=Qk(),y=L(d),g=nN(),u=L(g),m=_v(),b=L(m),x=rN(),v=L(x),_=Ev(),S=wv(),C=L(S);function L(I){return I&&I.__esModule?I:{default:I}}var P=function(){},ie=function(M,J,Q){var he=new P;if(typeof M>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(M),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof J<"u"&&(Q=Q||{},Q.format||(Q.format=ee()),he.options(Q)[Q.format](J,Q).render()),he};ie.getModule=function(I){return t.default[I]};for(var oe in t.default)t.default.hasOwnProperty(oe)&&D(t.default,oe);function D(I,M){P.prototype[M]=P.prototype[M.toUpperCase()]=P.prototype[M.toLowerCase()]=function(J,Q){var he=this;return he._errorHandler.wrapBarcodeCall(function(){Q.text=typeof Q.text>"u"?void 0:""+Q.text;var be=(0,i.default)(he._options,Q);be=(0,b.default)(be);var we=I[M],H=$(J,we,be);return he._encodings.push(H),he})}}function $(I,M,J){I=""+I;var Q=new M(I,J);if(!Q.valid())throw new _.InvalidInputException(Q.constructor.name,I);var he=Q.encode();he=(0,c.default)(he);for(var be=0;be<he.length;be++)he[be].options=(0,i.default)(J,he[be].options);return he}function ee(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}P.prototype.options=function(I){return this._options=(0,i.default)(this._options,I),this},P.prototype.blank=function(I){var M=new Array(I+1).join("0");return this._encodings.push({data:M}),this},P.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var I;for(var M in this._renderProperties){I=this._renderProperties[M];var J=(0,i.default)(this._options,I.options);J.format=="auto"&&(J.format=ee()),this._errorHandler.wrapBarcodeCall(function(){var Q=J.value,he=t.default[J.format.toUpperCase()],be=$(Q,he,J);K(I,be,J)})}}},P.prototype.render=function(){if(!this._renderProperties)throw new _.NoElementException;if(Array.isArray(this._renderProperties))for(var I=0;I<this._renderProperties.length;I++)K(this._renderProperties[I],this._encodings,this._options);else K(this._renderProperties,this._encodings,this._options);return this},P.prototype._defaults=C.default;function K(I,M,J){M=(0,c.default)(M);for(var Q=0;Q<M.length;Q++)M[Q].options=(0,i.default)(J,M[Q].options),(0,y.default)(M[Q].options);(0,y.default)(J);var he=I.renderer,be=new he(I.element,M,J);be.render(),I.afterRender&&I.afterRender()}return typeof window<"u"&&(window.JsBarcode=ie),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(I,M){var J=[];return jQuery(this).each(function(){J.push(this)}),ie(J,I,M)}),od=ie,od}var iN=sN();const aN=Ww(iN),oN={[De.EXECUTED]:"Executed",[De.MATCHED_LIST]:"Matched list",[De.CONFIRM_REQUIRED]:"Awaiting confirmation",[De.NO_MATCH_FALLBACK]:"No match",[De.UNCONFIGURED]:"Not configured",[De.INVALID_CODE]:"Invalid code",[De.FORBIDDEN]:"Not permitted",[De.CONFLICT]:"Conflict",[De.IDENTITY_PRIMED]:"Identity primed",[De.IDENTITY_UNKNOWN]:"Badge not recognized",[De.NOT_PRIMED]:"Badge required",[De.CHOICES]:"Choices presented",[De.NO_OPEN_CONTAINER]:"Container closing, scan again"},lN={[De.EXECUTED]:"text-status-success",[De.MATCHED_LIST]:"text-status-success",[De.CONFIRM_REQUIRED]:"text-status-warning",[De.NO_MATCH_FALLBACK]:"text-text-secondary",[De.UNCONFIGURED]:"text-status-warning",[De.INVALID_CODE]:"text-status-error",[De.FORBIDDEN]:"text-status-error",[De.CONFLICT]:"text-status-warning",[De.IDENTITY_PRIMED]:"text-status-success",[De.IDENTITY_UNKNOWN]:"text-status-warning",[De.NOT_PRIMED]:"text-status-warning",[De.CHOICES]:"text-status-success",[De.NO_OPEN_CONTAINER]:"text-status-warning"};function cN(n){return n.outcome===De.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${oN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function Nb(n){var t,s,i,o;return n.outcome===De.NO_MATCH_FALLBACK?((t=n.fallback)==null?void 0:t.markdown)??null:n.outcome===De.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===De.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===De.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:null}function ys(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 uN({content:n,compact:t}){const s=[],i=/^```(\w*)\n([\s\S]*?)^```$/gm;let o=0,c;for(;(c=i.exec(n))!==null;)c.index>o&&s.push({type:"text",text:n.slice(o,c.index)}),s.push({type:"code",lang:c[1],code:c[2].replace(/\n$/,"")}),o=c.index+c[0].length;o<n.length&&s.push({type:"text",text:n.slice(o)});const d=t?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs"},y=[];for(const g of s){if(g.type==="code"){const u=g.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");y.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${d.code} font-mono text-text-secondary leading-relaxed">${u}</code></pre>`);continue}y.push(...fN(g.text,d))}return h.jsx("div",{className:"prose-sm",dangerouslySetInnerHTML:{__html:y.join(`
55
55
  `)}})}function fN(n,t){const s=n.split(`
56
- `),i=[];let o=!1,c=!1,d=[];for(const y of s){const g=y.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(m=>m.trim());if(u.every(m=>/^[-:]+$/.test(m)))continue;c||(c=!0,d=[]),d.push(u);continue}if(c){c=!1;const[u,...m]=d;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">${ys(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of m){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),d=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(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="${t.list} text-text-secondary flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${ys(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${t.text} text-text-secondary my-1">${ys(g)}</p>`)}if(c&&d.length){const[y,...g]=d;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of y)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${ys(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const m of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(m)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Rm({result:n,compact:t=!1}){const{response:s}=n,i=t?"text-xs":"text-sm";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 ${lN[s.outcome]}`,children:cN(s)}),s.error&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:s.error}),Nb(s)&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(uN,{content:Nb(s),compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Ov(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 t=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&t.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...t]}function dN({value:n}){const t=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!t.current||!n))try{aN(t.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:t,className:"max-w-full"})})]}):null}function mN({onClose:n}){const{submitCode:t,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:d,diagnosticsOn:y,setDiagnosticsOn:g}=Mm(),[u,m]=E.useState(""),[b,x]=E.useState(!1),v=_=>{_.preventDefault();const S=u.trim();S&&(m(""),t(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(No,{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(Xt,{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:_=>m(Ov(_.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(dN,{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(Rm,{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:y,onChange:_=>g(_.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),y&&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:[d.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),d.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 Av=/^\{lt:([A-Za-z0-9_]+)\}$/;function L5(n){return`{lt:${n}}`}const jv="lt:station:link-vars:";function Yd(n){return`${jv}${n}`}const Kd=new Set;function pN(){for(const n of Kd)n()}let vu,Kc={};function kv(n){let t=null;try{t=localStorage.getItem(Yd(n))}catch{t=null}if(t===vu)return Kc;vu=t;try{const s=t?JSON.parse(t):{};Kc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Kc={}}return Kc}function yN(n,t,s){const i={...kv(n)};s===null||s===""?delete i[t]:i[t]=s;try{Object.keys(i).length===0?localStorage.removeItem(Yd(n)):localStorage.setItem(Yd(n),JSON.stringify(i))}catch{}vu=void 0,pN()}function gN(n){Kd.add(n);const t=s=>{(s.key===null||s.key.startsWith(jv))&&(vu=void 0,n())};try{window.addEventListener("storage",t)}catch{}return()=>{Kd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}const bN={};function xN(n){return E.useSyncExternalStore(gN,()=>n?kv(n):bN)}function vN(n,t,s){let i;try{i=new URL(n,"http://local")}catch{return n}const o=i.searchParams.get("facets");if(!o)return n;let c;try{const y=JSON.parse(o);if(!y||typeof y!="object"||Array.isArray(y))return n;c=y}catch{return n}let d=!1;for(const[y,g]of Object.entries(c)){if(typeof g!="string")continue;const u=Av.exec(g);if(!u)continue;const m=t[u[1]]??s[u[1]];typeof m=="string"&&m!==""?c[y]=m:delete c[y],d=!0}return d?(Object.keys(c).length===0?i.searchParams.delete("facets"):i.searchParams.set("facets",JSON.stringify(c)),i.pathname+i.search):n}function B5(n){let t;try{t=new URL(n,"http://local")}catch{return[]}const s=t.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 d=Av.exec(c);d&&!o.includes(d[1])&&o.push(d[1])}return o}catch{return[]}}function Dm(){const{user:n,isSuperAdmin:t,hasRoleType:s}=Lt(),i=(n==null?void 0:n.userId)??null,o=t||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(x=>x.role)),[n]),{data:d}=Nu({enabled:o||c.size>0}),y=xN(i),g=E.useMemo(()=>{var _;const x=[],v=new Set;for(const S of(d==null?void 0:d.roles)??[]){if(!o&&!c.has(S.role))continue;const C=(_=S.properties)==null?void 0:_.link_variables;if(Array.isArray(C))for(const L of C){const P=L==null?void 0:L.name;if(typeof P!="string"||P===""||v.has(P))continue;v.add(P);const ie=L.label,oe=L.default;x.push({name:P,...typeof ie=="string"&&ie!==""?{label:ie}:{},...typeof oe=="string"&&oe!==""?{default:oe}:{},fromRole:S.role})}}return x},[d,c,o]),u=E.useMemo(()=>{const x={};for(const v of g)v.default!==void 0&&(x[v.name]=v.default);return x},[g]),m=E.useCallback(x=>vN(x,y,u),[y,u]),b=E.useCallback((x,v)=>{i&&yN(i,x,v)},[i]);return{declarations:g,values:y,defaults:u,resolveUrl:m,setValue:b}}function _N({open:n,onClose:t,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const d=y=>{y.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[n,t]),n?Xd.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?t: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:t,"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 wN({open:n,onClose:t}){const{declarations:s,values:i,setValue:o}=Dm();return h.jsxs(_N,{open:n,onClose:t,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,d)=>h.jsx(SN,{declaration:c,value:i[c.name]??"",autoFocus:d===0,onChange:y=>o(c.name,y),onClear:()=>o(c.name,null),onEnter:t},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:t,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function SN({declaration:n,value:t,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const d=E.useId(),{data:y}=OA(n.name),g=(y==null?void 0:y.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:d,autoFocus:s,value:t,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:d,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:t==="",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 Tb=["escalationId","workflowId"],EN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Nv="lt:search:mode",ON="lt:search:facet",Mt={FACET:"facet",COMMAND:"command"};function AN(n,t){return{version:n.version,category:t.category,name:t.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function ko(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function jN(n,t){if(n.encoding==="delimited")return kN(n,t)?{code:t}:{code:`${ko(n)}${t}`};if(!/^[0-9]+$/.test(t))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&t.length!==s&&t.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${ko(n)}${t}`}}function kN(n,t){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(t)}function NN(n,t){return n==="escalationId"||n==="workflowId"?null:yk(n,t)}function TN(n){return n.kind===Mt.FACET?n.facet:n.command.name}function CN(n){return n.kind===Mt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function MN(n){return n.kind===Mt.FACET?{kind:Mt.FACET,facet:n.facet}:{kind:Mt.COMMAND,version:n.command.version,category:n.command.category}}function RN(n,t,s){if((n==null?void 0:n.kind)===Mt.FACET&&t.includes(n.facet))return{kind:Mt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Mt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Mt.COMMAND,command:i}}return t.length>0?{kind:Mt.FACET,facet:t[0]}:s.length>0?{kind:Mt.COMMAND,command:s[0]}:null}function DN(){try{const n=localStorage.getItem(Nv);if(n){const s=JSON.parse(n);if(s.kind===Mt.FACET&&typeof s.facet=="string"||s.kind===Mt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const t=localStorage.getItem(ON);return t?{kind:Mt.FACET,facet:t}:null}catch{return null}}function qN(n){try{localStorage.setItem(Nv,JSON.stringify(n))}catch{}}const Cb=5*6e4,LN=n=>({rules:n.map(t=>{var s;return((s=t.data)==null?void 0:s.rules)??null}),loading:n.some(t=>t.isLoading)});function BN(n){const t=mk({enabled:n,staleTime:Cb}),s=E.useMemo(()=>{var d;return(((d=t.data)==null?void 0:d.schemes)??[]).filter(y=>y.enabled&&y.kind===hk.ACTION).sort((y,g)=>y.version-g.version)},[t.data]),{rules:i,loading:o}=Zw({queries:s.map(d=>({queryKey:["scan-schemes",d.version,"actions"],queryFn:()=>fe(`/scan-codes/schemes/${d.version}/actions`),enabled:n,staleTime:Cb})),combine:LN});return{commands:E.useMemo(()=>s.flatMap((d,y)=>(i[y]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>AN(d,g))),[s,i]),loading:t.isLoading||o}}const PN={escalationId:"opens the item",workflowId:"opens the run"};function UN({mode:n,facets:t,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,d]=E.useState(!1),y=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=_=>{y.current&&!y.current.contains(_.target)&&d(!1)},v=_=>{_.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Mt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${ko(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,m=zN(s),b=x=>{i(x),d(!1)};return h.jsxs("div",{ref:y,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>d(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:TN(n)}),h.jsx(Wd,{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:[t.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(Mb,{children:"Find"}),t.map(x=>h.jsx(Rb,{label:x,mono:!0,note:PN[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Mt.FACET,facet:x})},x))]}),m.map(({schemeName:x,targetFacet:v,items:_})=>h.jsxs("div",{children:[h.jsxs(Mb,{note:v,children:["Run · ",x]}),_.map(S=>h.jsx(Rb,{label:S.name,note:ko(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Mt.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:()=>{d(!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(No,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function zN(n){const t=[];for(const s of n){const i=t.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):t.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return t}function Mb({children:n,note:t}){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}),t&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:t})]})}function Rb({label:n,note:t,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:t})]})}const IN=6e3;function $N({onOpenScanPanel:n}){const t=ra(),{data:s}=Wn(),i=Cm(),{submitCode:o,busy:c,lastResult:d}=Mm(),{commands:y}=BN(i),[g,u]=E.useState(""),[m,b]=E.useState(!1),[x,v]=E.useState(null),[_,S]=E.useState(null),[C,L]=E.useState(""),[P,ie]=E.useState(null),[oe,D]=E.useState(DN),$=E.useRef(null),ee=E.useMemo(()=>{var le;if(!((le=s==null?void 0:s.search)!=null&&le.enabled))return[];const Z=(s.search.facets??[]).filter(_e=>!Tb.includes(_e));return[...Tb,...Z]},[s]),K=E.useMemo(()=>RN(oe,ee,y),[oe,ee,y]),I=(d==null?void 0:d.source)===jo.TOOLBAR&&!d.navigated&&P!==d.at?d:null;E.useEffect(()=>{if(!I)return;const Z=setTimeout(()=>ie(I.at),IN);return()=>clearTimeout(Z)},[I]);const M=()=>{v(null),S(null),d&&ie(d.at)},J=Z=>{var _e;const le=MN(Z);D(le),qN(le),M(),(_e=$.current)==null||_e.focus()},Q=(Z,le)=>{const _e=jN(Z.command,Ov(le));if("error"in _e){v(_e.error);return}u(""),o(_e.code,jo.TOOLBAR)},he=async(Z,le)=>{const _e=NN(Z,le);if(_e){u(""),t(_e);return}if(Z==="escalationId"&&!EN.test(le)){v("That is not a valid escalation id");return}b(!0);try{if(Z==="escalationId")await fe(`/escalations/${encodeURIComponent(le)}`),u(""),t(`/escalations/detail/${encodeURIComponent(le)}`);else{const Ee=await fe(`/escalations/by-workflow/${encodeURIComponent(le)}`),Ne=(Ee==null?void 0:Ee.escalations)??[];Ne.length===1?(u(""),t(`/escalations/detail/${Ne[0].id}`)):(L(le),S(Ne))}}catch{v(`No ${Z==="escalationId"?"escalation":"workflow"} found for "${le}"`)}finally{b(!1)}},be=()=>{const Z=g.trim();!Z||m||c||!K||(M(),K.kind===Mt.COMMAND?Q(K,Z):he(K.facet,Z))};if(!K)return null;const we=K.kind===Mt.COMMAND,H=m||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:[we?h.jsx(No,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(lS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),we&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:ko(K.command)})]}),h.jsx("input",{ref:$,id:"global-search-input",type:"text",value:g,onChange:Z=>{u(Z.target.value),M()},onKeyDown:Z=>{Z.key==="Enter"&&be(),Z.key==="Escape"&&(u(""),M())},placeholder:CN(K),"aria-label":we?"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 ${we?"pl-0.5 pr-2 font-mono":"px-2"}`}),H&&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(UN,{mode:K,facets:ee,commands:y,onSelect:J,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(Rm,{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(Z=>h.jsxs(Cr,{to:`/escalations/detail/${Z.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:Z.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),Z.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:Z.type})]},Z.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(Cr,{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 HN(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(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Jd(n){var t;return((t=n.title)==null?void 0:t.trim())||HN(n.role)}const Tv="lt:bookmarks",Jc="scan";function FN(){try{const n=localStorage.getItem(Tv);if(!n)return[];const t=JSON.parse(n);return Array.isArray(t)?t:[]}catch{return[]}}function Db(n){try{localStorage.setItem(Tv,JSON.stringify(n))}catch{}}function GN({onToggleEventFeed:n,onToggleDocs:t,onToggleNav:s}){var Je,jn,lr;const i=ra(),{user:o,logout:c,isSuperAdmin:d,hasRoleType:y}=Lt(),{viewAs:g,realIsBuilder:u}=$x(),{available:m,mine:b}=NA();Hx();const{connected:x}=Ex(),{data:v}=Wn(),{role:_,targets:S,selectable:C,selectRole:L}=Yx(),{declarations:P,values:ie}=Dm(),[oe,D]=E.useState(!1),{data:$}=Nu(),ee=E.useMemo(()=>{const ve=($==null?void 0:$.roles)??[],Fe=new Set(((o==null?void 0:o.roles)??[]).map(lt=>lt.role)),St=d||y("admin");return ve.filter(lt=>Wi(lt).length>0&&(St||Fe.has(lt.role))).map(lt=>({role:lt.role,title:Jd(lt),portals:Wi(lt)}))},[$,o,d,y]),{setPanel:K,closePanel:I,open:M,ownerKey:J}=Om(),Q=Cm(),he=On(),be=()=>{M&&J===Jc?I(Jc):K(h.jsx(mN,{onClose:()=>I(Jc)}),{width:360,key:Jc})},[we,H]=E.useState(!1),[Z,le]=E.useState(!1),[_e,Ee]=E.useState(uv),[Ne,ke]=E.useState(FN),Te=E.useRef(null),st=(Je=v==null?void 0:v.branding)==null?void 0:Je.appName,Nt=(jn=v==null?void 0:v.branding)==null?void 0:jn.themes,Bt=E.useMemo(()=>(ek(Nt??[]),tk()),[Nt]),gt=ve=>{nk(ve),Ee(ve)},bt=()=>{const ve=window.prompt("Bookmark label:");if(!(ve!=null&&ve.trim()))return;const Fe=he.pathname+he.search,St=[...Ne,{label:ve.trim(),url:Fe}].sort((lt,Pr)=>lt.label.localeCompare(Pr.label));ke(St),Db(St),H(!1)},ue=ve=>{const Fe=Ne.filter(St=>!(St.label===ve.label&&St.url===ve.url));ke(Fe),Db(Fe)};return E.useEffect(()=>{if(!we)return;const ve=Fe=>{Te.current&&!Te.current.contains(Fe.target)&&H(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[we]),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 ${we?"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(cS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(Cr,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:ve=>{(ve.ctrlKey||ve.metaKey)&&(ve.preventDefault(),le(!0))},children:h.jsx(km,{appName:st,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(Qb,{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(fd,{className:"w-5 h-5",strokeWidth:2})})]}),(((lr=v==null?void 0:v.search)==null?void 0:lr.enabled)||Q)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx($N,{onOpenScanPanel:Q?be:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsxs(Cr,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${m>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(hd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),m>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:m})]}),h.jsxs(Cr,{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(hd,{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:Ud,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Xt,{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:Te,children:[h.jsxs("button",{onClick:()=>H(ve=>!ve),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(uS,{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"})})]}),we&&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(Cr,{to:"/credentials",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),Q&&h.jsx("button",{onClick:()=>{H(!1),be()},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:()=>{H(!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:()=>{H(!1),t==null||t()},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:()=>{H(!1),Ud()},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:Bt.map(ve=>h.jsx("button",{type:"button",onClick:()=>gt(ve.id),title:ve.label,"aria-label":`${ve.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${_e===ve.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:ve.swatch}},ve.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:()=>{H(!1),L(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(ve=>{var lt;const Fe=(lt=$==null?void 0:$.roles)==null?void 0:lt.find(Pr=>Pr.role===ve),St=ve===_;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),L(ve),i(Vx(ve,Wi(Fe)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${St?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${St?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Jd({role:ve,title:Fe==null?void 0:Fe.title})})]},ve)})]})]}),ee.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:ee.map(ve=>h.jsxs("div",{children:[ee.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:ve.role,children:ve.title}),ve.portals.map(Fe=>{const St=_m(ve.role,Fe.key),lt=he.pathname===St;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),i(St)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${lt?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${ve.role}-${Fe.key}`,children:[h.jsx(dd,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:Fe.label})]},Fe.key)})]},ve.role))})]}),P.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:()=>{H(!1),D(!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(ie).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ie).length>0?Object.entries(ie).map(([ve,Fe])=>`${ve} = ${Fe}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{H(!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:[Ne.map(ve=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(Cr,{to:ve.url,onClick:()=>H(!1),title:ve.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:ve.label}),h.jsx("button",{type:"button",onClick:()=>ue(ve),title:`Remove "${ve.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(Xt,{className:"w-3 h-3"})})]},`${ve.label}::${ve.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:bt,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(fS,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),Z&&h.jsx(Zj,{onClose:()=>le(!1)}),h.jsx(wN,{open:oe,onClose:()=>D(!1)})]})}function qm({open:n,children:t}){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?t:null})})}function Qd(n){return({isActive:t})=>{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 ${t?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${t?i:o}`}}function VN(){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 YN({group:n,collapsed:t}){const{pathname:s}=On(),i=n.matchPaths.some(y=>s.startsWith(y)),[o,c]=E.useState(i),d=o||i;return t?h.jsx(h.Fragment,{children:n.items.map(y=>h.jsx(Ss,{to:y.to,className:Qd(!0),title:y.label,children:y.icon&&h.jsx(y.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},y.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(y=>!y),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 ${d?"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(qm,{open:d,children:n.items.map(y=>h.jsxs(Ss,{to:y.to,end:y.end,className:VN(),children:[y.icon&&h.jsx(y.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:y.label})]},y.to))})]})}function KN(n){return n.kind==="group"}function JN({entry:n,collapsed:t}){const{pathname:s,search:i}=On(),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[d,y]=n.to.split("?"),g=s===d&&i===`?${y}`,u=Qd(t)({isActive:g});return h.jsxs(Ss,{to:n.to,className:u,title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}return h.jsxs(Ss,{to:n.to,end:n.end,className:Qd(t),title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}function Dr({heading:n,entries:t}){const{collapsed:s}=Sm();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}),t.map(i=>KN(i)?h.jsx(YN,{group:i,collapsed:s},i.label):h.jsx(JN,{entry:i,collapsed:s},i.to))]})}function QN({aiEnabled:n=!1,isBuilder:t=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1}){const c=[{to:"/pace",label:"Pace Board",icon:hS},{to:"/trends",label:"Trend Board",icon:dS}];if(!t&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(Dr,{heading:"Monitor",entries:c}):null;if(!t)return h.jsx(Dr,{heading:"Monitor",entries:o?c:[]});const d=[...o?c:[],{to:"/topics",label:"Event Topics",icon:Xb},{to:"/agents",label:n?"Agents":"Automations",icon:mS},{to:"/capabilities",label:"Capabilities",icon:pS}];return h.jsx(Dr,{heading:"Monitor",entries:d})}function XN(){return Ue({queryKey:["me","preferences"],queryFn:()=>fe("/me/preferences"),staleTime:6e4})}function WN(){const n=ze();return He({mutationFn:t=>fe("/me/preferences",{method:"PATCH",body:JSON.stringify(t)}),onSuccess:t=>{n.setQueryData(["me","preferences"],t)}})}const bs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},qb={COMPACT:"compact",CARDS:"cards"},ld={AVAILABLE:"/escalations/available",ALL:"/escalations"},Zi={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},ZN={[Zi.RESOLVED]:"resolved",[Zi.CANCELLED]:"cancelled",[Zi.EXPIRED]:"expired"};function eT(n){const t=n===Zi.CLAIMED;return{available:n===Zi.AVAILABLE,claimed:t,apiStatus:t?"pending":ZN[n]}}function tT(n){return n===bs.TABLE||n===bs.RICH||n===bs.TIMELINE}function nT(n){return n===qb.COMPACT||n===qb.CARDS}function rT(n,t=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||t,role:n.get("role")||void 0,type:n.get("type")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:pk(n),view:tT(i)?i:null,layout:nT(o)?o:null}}function sT(n){let t;try{t=new URL(n,"http://local")}catch{return null}if(t.pathname!==ld.AVAILABLE&&t.pathname!==ld.ALL)return null;const s=t.pathname===ld.AVAILABLE?Zi.AVAILABLE:"";return rT(t.searchParams,s)}function P5(n){var t;return n.role||(((t=n.facets.roles)==null?void 0:t.length)===1?n.facets.roles[0]:null)}function U5(n,t){return n===bs.TIMELINE?bs.TIMELINE:t&&(!n||n===bs.RICH)?bs.RICH:bs.TABLE}function iT(n,t){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(y=>y.label)),c=[...s],d=new Set;for(const{role:y,pins:g}of t)for(const u of g)o.has(u.label)||i.has(u.label)||d.has(u.label)||(d.add(u.label),c.push({...u,id:`role:${y}:${u.label}`,fromRole:y}));return c}function aT(n){const t=sT(n);if(!t)return null;const{available:s,claimed:i,apiStatus:o}=eT(t.statusFilter);return{available:s,params:{...t.facets,role:t.role,type:t.type,priority:t.priority,status:o,...i?{claimed:!0}:{},search:t.search}}}function oT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function lT(){var I;const{collapsed:n}=Sm(),{user:t}=Lt(),s=XN(),i=WN(),o=E.useMemo(()=>new Set(((t==null?void 0:t.roles)??[]).map(M=>M.role)),[t]),{data:c}=Nu({enabled:o.size>0}),d=sn("SUMMARY");ti(xm(),()=>{d([["escalations"]])});const y=(I=s.data)==null?void 0:I.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(M=>o.has(M.role)&&Array.isArray(M.default_pins)&&M.default_pins.length>0).map(M=>({role:M.role,pins:M.default_pins})),[c,o]),{resolveUrl:u}=Dm(),m=E.useMemo(()=>iT(y,g),[y,g]),b=E.useMemo(()=>new Map(m.map(M=>[M.id,M.url])),[m]),x=E.useMemo(()=>m.map(M=>({...M,url:u(M.url)})),[m,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(M=>[M.role,Jd(M)])),[c]),_=E.useMemo(()=>x.filter(M=>!M.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(M=>o.has(M.role)&&gA(M)).map(M=>M.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(M=>S.has(M.role)||g.some(J=>J.role===M.role)).map(M=>({role:M.role,title:v.get(M.role)??M.role,portals:S.has(M.role)?Wi(M):[],pins:x.filter(J=>J.fromRole===M.role)})).filter(M=>M.portals.length>0||M.pins.length>0),[c,g,S,v,x]),L=(y==null?void 0:y.pinnedViews)??[],P=E.useRef(null),ie=M=>i.mutate({pinnedViews:M}),oe=M=>ie(L.filter(J=>J.id!==M)),D=M=>ie([...L,{id:oT(),label:M.label,url:b.get(M.id)??M.url,badge:M.badge}]),$=M=>i.mutate({hiddenRolePins:[...(y==null?void 0:y.hiddenRolePins)??[],M]}),ee=(M,J)=>{if(M===J)return;const Q=[...L],[he]=Q.splice(M,1);Q.splice(J,0,he),ie(Q)};if(x.length===0&&S.size===0)return null;const K="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:K,children:"Pinned"}),_.map(M=>{const J=L.findIndex(Q=>Q.id===M.id);return h.jsx(Lb,{pin:M,collapsed:n,draggable:J!==-1,onDragStart:()=>{P.current=J},onDropOn:()=>{P.current!==null&&J!==-1&&ee(P.current,J),P.current=null},onRemove:()=>oe(M.id)},M.id)}),C.map(M=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:K,title:`${M.title} — pins from the ${M.role} role`,"data-testid":"pin-group-label",children:M.title}),M.portals.map(J=>h.jsx(cT,{role:M.role,portal:J,collapsed:n},J.key)),M.pins.map(J=>h.jsx(Lb,{pin:J,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>D(J),onHide:()=>$(J.label)},J.id))]},M.role))]})}function cT({role:n,portal:t,collapsed:s}){const i=_m(n,t.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}-${t.key}`;return s?h.jsx(Ss,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:t.label,"data-testid":c,children:h.jsx(dd,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Ss,{to:i,title:t.label,className:({isActive:d})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${d?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(dd,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:t.label})]})}function Lb({pin:n,collapsed:t,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:d,onHide:y}){const{pathname:g,search:u}=On(),[m,b=""]=n.url.split("?"),x=g===m&&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 t?h.jsx(Ss,{to:n.url,className:`${v} ${_} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(wg,{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(Ss,{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(wg,{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(uT,{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:[d&&h.jsx("button",{onClick:d,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(Wb,{className:"w-3 h-3"})}),y&&h.jsx("button",{onClick:y,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(yS,{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(Xt,{className:"w-3 h-3"})})]})]})}function uT({url:n}){var d;const t=E.useMemo(()=>aT(n),[n]),s={limit:1,staleTime:15e3},i=Xx({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&t.available}),o=Qx({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&!t.available});if(!t)return null;const c=t.available?i:o;return c.isError||((d=c.data)==null?void 0:d.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 fT(){var c;const{data:n}=Wn(),t=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=t===!0||t!==!1&&Ux(),i=[{to:"/workflows/registry",label:"Registry",icon:Sg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:md},{to:"/workflows/executions",label:"Executions",icon:Eg}],o=s?[{kind:"group",label:"Procedural",icon:gS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:Zd,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:Sg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:md},{to:"/mcp/executions",label:"Executions",icon:Eg}]}]:i;return h.jsx(Dr,{heading:"Orchestrate",entries:o})}function z5(){return Ue({queryKey:["activeWorkers"],queryFn:async()=>(await fe("/workflows/workers")).workers})}function I5(){return Ue({queryKey:["discoveredWorkflows"],queryFn:async()=>(await fe("/workflows/discovered")).workflows})}function $5(){return Ue({queryKey:["workflowConfigs"],queryFn:async()=>(await fe("/workflows/config")).workflows})}function Cv(){return Ue({queryKey:["invocableWorkflows"],queryFn:async()=>(await fe("/workflows/invocable")).workflows})}function H5(n){return Object.fromEntries(n.filter(t=>!t.missing).map(t=>[t.as??t.key,t.data]))}function F5(n,t){return Ue({queryKey:["workflows",n,"input-lookups"],queryFn:()=>fe(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&t,staleTime:1/0})}function G5(){return Ue({queryKey:["cronStatus"],queryFn:async()=>(await fe("/workflows/cron/status")).schedules})}function V5(n){return Ue({queryKey:["workflowExecution",n],queryFn:()=>fe(`/workflow-states/${n}/execution`),enabled:!!n})}function Y5(n,t){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),Ue({queryKey:["jobs",n],queryFn:()=>fe(`/workflow-states/jobs?${s}`),enabled:(t==null?void 0:t.enabled)??!0})}function K5(){const n=ze();return He({mutationFn:t=>fe(`/workflows/${t}/terminate`,{method:"POST"}),onSuccess:(t,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function J5(){const n=ze();return He({mutationFn:({workflow_type:t,...s})=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function Q5(){const n=ze();return He({mutationFn:t=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function X5(){const n=ze();return He({mutationFn:({workflowType:t,data:s,metadata:i,execute_as:o})=>fe(`/workflows/${t}/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 hT(){const{data:n}=Cv();return n!=null&&n.length?h.jsx(Dr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:md}]}):null}const dT=[{to:"/mcp/queries",label:"Designer",icon:bS},{to:"/mcp/servers",label:"Servers & Tools",icon:xS}];function mT(){return h.jsx(Dr,{heading:"Design",entries:dT})}const pT=[{to:"/files",label:"Files",icon:vS},{to:"/knowledge",label:"Knowledge Base",icon:Zb}];function yT(){return h.jsx(Dr,{heading:"Storage",entries:pT})}function gT({isBuilder:n=!1,isOps:t=!1}){var d;const{data:s}=Wn(),i=((d=s==null?void 0:s.features)==null?void 0:d.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:_S},...n||t?[{to:"/admin/roles",label:"Roles",icon:hd},{to:"/admin/personas",label:"Personas",icon:wS},{to:"/admin/scan-codes",label:"Scan Codes",icon:No}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:SS},{to:"/admin/streams",label:"Messages",icon:Zb},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:ES}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(Dr,{heading:"Identity & Access",entries:o}),n&&zx()&&h.jsx(Dr,{heading:"Infrastructure",entries:c})]})}function Mv({aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(QN,{aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}),h.jsx(lT,{}),!t&&h.jsx(hT,{}),t&&h.jsx(fT,{}),t&&n&&h.jsx(mT,{}),t&&h.jsx(yT,{}),(t||s)&&h.jsx(gT,{isBuilder:t,isOps:s})]})}function bT({open:n,onClose:t,...s}){const i=On();return E.useEffect(()=>{t()},[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:t,"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:t,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(Xt,{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(wA,{children:h.jsx(Mv,{...s})})})]})]})}const Rv="lt_event_feed_patterns";function xT(n,t){if(n.startsWith("/topics/")){const d=decodeURIComponent(n.replace("/topics/",""));if(d&&!d.includes("/"))return`lt.events.${d}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const d=new URLSearchParams(t).get("role");return d?`lt.events.system.escalation.${Fx(d)}.>`:"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 vT(){try{const n=localStorage.getItem(Rv);return n?JSON.parse(n):[]}catch{return[]}}function cd(n){try{localStorage.setItem(Rv,JSON.stringify(n))}catch{}}function _T(){const{pathname:n,search:t}=On(),[s,i]=E.useState(vT),o=E.useMemo(()=>xT(n,t),[n,t]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),d=E.useCallback(u=>{const m=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(m))return b;const x=[...b,m];return cd(x),x})},[]),y=E.useCallback(u=>{i(m=>{const b=m.filter(x=>x!==u);return cd(b),b})},[]),g=E.useCallback(()=>{i([]),cd([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:d,removePattern:y,clearUserPatterns:g}}function wT({children:n,className:t=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${t}`,children:n})}const ud=280,Bb="cubic-bezier(0.4, 0, 0.2, 1)",Qc=40;function ST(n){if(!n)return"scale(0.92)";const t=window.innerWidth,s=window.innerHeight,i=t-Qc*2,o=s-Qc*2,c=n.width/i,d=n.height/o,y=n.left+n.width/2-(Qc+i/2),g=n.top+n.height/2-(Qc+o/2);return`translate(${y}px, ${g}px) scale(${c}, ${d})`}function Dv({open:n,onClose:t,sourceRef:s,children:i}){const[o,c]=E.useState(null),d=E.useRef(null),y=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!y.current?(d.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&y.current&&o==="open"&&(d.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),y.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"&&t()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,t]);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),ud+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",m=u?ST(d.current):"none",b=u?0:1;return Xd.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${ud}ms ${Bb}, opacity ${ud}ms ${Bb}`,transform:m,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function ET({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 OT({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 AT({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 jT({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 kT({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 NT({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 TT(n){const t=n.trim().split(`
56
+ `),i=[];let o=!1,c=!1,d=[];for(const y of s){const g=y.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(m=>m.trim());if(u.every(m=>/^[-:]+$/.test(m)))continue;c||(c=!0,d=[]),d.push(u);continue}if(c){c=!1;const[u,...m]=d;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">${ys(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of m){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),d=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${t.heading} font-semibold text-text-primary mt-3 mb-1">${ys(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="${t.list} text-text-secondary flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${ys(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${t.text} text-text-secondary my-1">${ys(g)}</p>`)}if(c&&d.length){const[y,...g]=d;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of y)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${ys(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const m of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${ys(m)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Rm({result:n,compact:t=!1}){const{response:s}=n,i=t?"text-xs":"text-sm";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 ${lN[s.outcome]}`,children:cN(s)}),s.error&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:s.error}),Nb(s)&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(uN,{content:Nb(s),compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Ov(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 t=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&t.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...t]}function dN({value:n}){const t=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!t.current||!n))try{aN(t.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:t,className:"max-w-full"})})]}):null}function mN({onClose:n}){const{submitCode:t,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:d,diagnosticsOn:y,setDiagnosticsOn:g}=Mm(),[u,m]=E.useState(""),[b,x]=E.useState(!1),v=_=>{_.preventDefault();const S=u.trim();S&&(m(""),t(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(No,{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(Xt,{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:_=>m(Ov(_.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(dN,{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(Rm,{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:y,onChange:_=>g(_.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),y&&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:[d.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),d.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 Av=/^\{lt:([A-Za-z0-9_]+)\}$/;function L5(n){return`{lt:${n}}`}const jv="lt:station:link-vars:";function Yd(n){return`${jv}${n}`}const Kd=new Set;function pN(){for(const n of Kd)n()}let vu,Kc={};function kv(n){let t=null;try{t=localStorage.getItem(Yd(n))}catch{t=null}if(t===vu)return Kc;vu=t;try{const s=t?JSON.parse(t):{};Kc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Kc={}}return Kc}function yN(n,t,s){const i={...kv(n)};s===null||s===""?delete i[t]:i[t]=s;try{Object.keys(i).length===0?localStorage.removeItem(Yd(n)):localStorage.setItem(Yd(n),JSON.stringify(i))}catch{}vu=void 0,pN()}function gN(n){Kd.add(n);const t=s=>{(s.key===null||s.key.startsWith(jv))&&(vu=void 0,n())};try{window.addEventListener("storage",t)}catch{}return()=>{Kd.delete(n);try{window.removeEventListener("storage",t)}catch{}}}const bN={};function xN(n){return E.useSyncExternalStore(gN,()=>n?kv(n):bN)}function vN(n,t,s){let i;try{i=new URL(n,"http://local")}catch{return n}const o=i.searchParams.get("facets");if(!o)return n;let c;try{const y=JSON.parse(o);if(!y||typeof y!="object"||Array.isArray(y))return n;c=y}catch{return n}let d=!1;for(const[y,g]of Object.entries(c)){if(typeof g!="string")continue;const u=Av.exec(g);if(!u)continue;const m=t[u[1]]??s[u[1]];typeof m=="string"&&m!==""?c[y]=m:delete c[y],d=!0}return d?(Object.keys(c).length===0?i.searchParams.delete("facets"):i.searchParams.set("facets",JSON.stringify(c)),i.pathname+i.search):n}function B5(n){let t;try{t=new URL(n,"http://local")}catch{return[]}const s=t.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 d=Av.exec(c);d&&!o.includes(d[1])&&o.push(d[1])}return o}catch{return[]}}function Dm(){const{user:n,isSuperAdmin:t,hasRoleType:s}=Lt(),i=(n==null?void 0:n.userId)??null,o=t||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(x=>x.role)),[n]),{data:d}=Nu({enabled:o||c.size>0}),y=xN(i),g=E.useMemo(()=>{var _;const x=[],v=new Set;for(const S of(d==null?void 0:d.roles)??[]){if(!o&&!c.has(S.role))continue;const C=(_=S.properties)==null?void 0:_.link_variables;if(Array.isArray(C))for(const L of C){const P=L==null?void 0:L.name;if(typeof P!="string"||P===""||v.has(P))continue;v.add(P);const ie=L.label,oe=L.default;x.push({name:P,...typeof ie=="string"&&ie!==""?{label:ie}:{},...typeof oe=="string"&&oe!==""?{default:oe}:{},fromRole:S.role})}}return x},[d,c,o]),u=E.useMemo(()=>{const x={};for(const v of g)v.default!==void 0&&(x[v.name]=v.default);return x},[g]),m=E.useCallback(x=>vN(x,y,u),[y,u]),b=E.useCallback((x,v)=>{i&&yN(i,x,v)},[i]);return{declarations:g,values:y,defaults:u,resolveUrl:m,setValue:b}}function _N({open:n,onClose:t,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const d=y=>{y.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[n,t]),n?Xd.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?t: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:t,"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 wN({open:n,onClose:t}){const{declarations:s,values:i,setValue:o}=Dm();return h.jsxs(_N,{open:n,onClose:t,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,d)=>h.jsx(SN,{declaration:c,value:i[c.name]??"",autoFocus:d===0,onChange:y=>o(c.name,y),onClear:()=>o(c.name,null),onEnter:t},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:t,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function SN({declaration:n,value:t,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const d=E.useId(),{data:y}=OA(n.name),g=(y==null?void 0:y.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:d,autoFocus:s,value:t,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:d,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:t==="",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 Tb=["escalationId","workflowId"],EN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Nv="lt:search:mode",ON="lt:search:facet",Mt={FACET:"facet",COMMAND:"command"};function AN(n,t){return{version:n.version,category:t.category,name:t.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function ko(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function jN(n,t){if(n.encoding==="delimited")return kN(n,t)?{code:t}:{code:`${ko(n)}${t}`};if(!/^[0-9]+$/.test(t))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&t.length!==s&&t.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${ko(n)}${t}`}}function kN(n,t){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(t)}function NN(n,t){return n==="escalationId"||n==="workflowId"?null:yk(n,t)}function TN(n){return n.kind===Mt.FACET?n.facet:n.command.name}function CN(n){return n.kind===Mt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function MN(n){return n.kind===Mt.FACET?{kind:Mt.FACET,facet:n.facet}:{kind:Mt.COMMAND,version:n.command.version,category:n.command.category}}function RN(n,t,s){if((n==null?void 0:n.kind)===Mt.FACET&&t.includes(n.facet))return{kind:Mt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Mt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Mt.COMMAND,command:i}}return t.length>0?{kind:Mt.FACET,facet:t[0]}:s.length>0?{kind:Mt.COMMAND,command:s[0]}:null}function DN(){try{const n=localStorage.getItem(Nv);if(n){const s=JSON.parse(n);if(s.kind===Mt.FACET&&typeof s.facet=="string"||s.kind===Mt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const t=localStorage.getItem(ON);return t?{kind:Mt.FACET,facet:t}:null}catch{return null}}function qN(n){try{localStorage.setItem(Nv,JSON.stringify(n))}catch{}}const Cb=5*6e4,LN=n=>({rules:n.map(t=>{var s;return((s=t.data)==null?void 0:s.rules)??null}),loading:n.some(t=>t.isLoading)});function BN(n){const t=mk({enabled:n,staleTime:Cb}),s=E.useMemo(()=>{var d;return(((d=t.data)==null?void 0:d.schemes)??[]).filter(y=>y.enabled&&y.kind===hk.ACTION).sort((y,g)=>y.version-g.version)},[t.data]),{rules:i,loading:o}=Zw({queries:s.map(d=>({queryKey:["scan-schemes",d.version,"actions"],queryFn:()=>fe(`/scan-codes/schemes/${d.version}/actions`),enabled:n,staleTime:Cb})),combine:LN});return{commands:E.useMemo(()=>s.flatMap((d,y)=>(i[y]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>AN(d,g))),[s,i]),loading:t.isLoading||o}}const PN={escalationId:"opens the item",workflowId:"opens the run"};function UN({mode:n,facets:t,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,d]=E.useState(!1),y=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=_=>{y.current&&!y.current.contains(_.target)&&d(!1)},v=_=>{_.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Mt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${ko(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,m=zN(s),b=x=>{i(x),d(!1)};return h.jsxs("div",{ref:y,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>d(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:TN(n)}),h.jsx(Wd,{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:[t.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(Mb,{children:"Find"}),t.map(x=>h.jsx(Rb,{label:x,mono:!0,note:PN[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Mt.FACET,facet:x})},x))]}),m.map(({schemeName:x,targetFacet:v,items:_})=>h.jsxs("div",{children:[h.jsxs(Mb,{note:v,children:["Run · ",x]}),_.map(S=>h.jsx(Rb,{label:S.name,note:ko(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Mt.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:()=>{d(!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(No,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function zN(n){const t=[];for(const s of n){const i=t.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):t.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return t}function Mb({children:n,note:t}){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}),t&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:t})]})}function Rb({label:n,note:t,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:t})]})}const IN=6e3;function $N({onOpenScanPanel:n}){const t=ra(),{data:s}=Wn(),i=Cm(),{submitCode:o,busy:c,lastResult:d}=Mm(),{commands:y}=BN(i),[g,u]=E.useState(""),[m,b]=E.useState(!1),[x,v]=E.useState(null),[_,S]=E.useState(null),[C,L]=E.useState(""),[P,ie]=E.useState(null),[oe,D]=E.useState(DN),$=E.useRef(null),ee=E.useMemo(()=>{var le;if(!((le=s==null?void 0:s.search)!=null&&le.enabled))return[];const Z=(s.search.facets??[]).filter(_e=>!Tb.includes(_e));return[...Tb,...Z]},[s]),K=E.useMemo(()=>RN(oe,ee,y),[oe,ee,y]),I=(d==null?void 0:d.source)===jo.TOOLBAR&&!d.navigated&&P!==d.at?d:null;E.useEffect(()=>{if(!I)return;const Z=setTimeout(()=>ie(I.at),IN);return()=>clearTimeout(Z)},[I]);const M=()=>{v(null),S(null),d&&ie(d.at)},J=Z=>{var _e;const le=MN(Z);D(le),qN(le),M(),(_e=$.current)==null||_e.focus()},Q=(Z,le)=>{const _e=jN(Z.command,Ov(le));if("error"in _e){v(_e.error);return}u(""),o(_e.code,jo.TOOLBAR)},he=async(Z,le)=>{const _e=NN(Z,le);if(_e){u(""),t(_e);return}if(Z==="escalationId"&&!EN.test(le)){v("That is not a valid escalation id");return}b(!0);try{if(Z==="escalationId")await fe(`/escalations/${encodeURIComponent(le)}`),u(""),t(`/escalations/detail/${encodeURIComponent(le)}`);else{const Ee=await fe(`/escalations/by-workflow/${encodeURIComponent(le)}`),Ne=(Ee==null?void 0:Ee.escalations)??[];Ne.length===1?(u(""),t(`/escalations/detail/${Ne[0].id}`)):(L(le),S(Ne))}}catch{v(`No ${Z==="escalationId"?"escalation":"workflow"} found for "${le}"`)}finally{b(!1)}},be=()=>{const Z=g.trim();!Z||m||c||!K||(M(),K.kind===Mt.COMMAND?Q(K,Z):he(K.facet,Z))};if(!K)return null;const we=K.kind===Mt.COMMAND,H=m||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:[we?h.jsx(No,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(lS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),we&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:ko(K.command)})]}),h.jsx("input",{ref:$,id:"global-search-input",type:"text",value:g,onChange:Z=>{u(Z.target.value),M()},onKeyDown:Z=>{Z.key==="Enter"&&be(),Z.key==="Escape"&&(u(""),M())},placeholder:CN(K),"aria-label":we?"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 ${we?"pl-0.5 pr-2 font-mono":"px-2"}`}),H&&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(UN,{mode:K,facets:ee,commands:y,onSelect:J,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(Rm,{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(Z=>h.jsxs(Cr,{to:`/escalations/detail/${Z.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:Z.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),Z.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:Z.type})]},Z.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(Cr,{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 HN(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(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Jd(n){var t;return((t=n.title)==null?void 0:t.trim())||HN(n.role)}const Tv="lt:bookmarks",Jc="scan";function FN(){try{const n=localStorage.getItem(Tv);if(!n)return[];const t=JSON.parse(n);return Array.isArray(t)?t:[]}catch{return[]}}function Db(n){try{localStorage.setItem(Tv,JSON.stringify(n))}catch{}}function GN({onToggleEventFeed:n,onToggleDocs:t,onToggleNav:s}){var Je,jn,lr;const i=ra(),{user:o,logout:c,isSuperAdmin:d,hasRoleType:y}=Lt(),{viewAs:g,realIsBuilder:u}=$x(),{available:m,mine:b}=NA();Hx();const{connected:x}=Ex(),{data:v}=Wn(),{role:_,targets:S,selectable:C,selectRole:L}=Yx(),{declarations:P,values:ie}=Dm(),[oe,D]=E.useState(!1),{data:$}=Nu(),ee=E.useMemo(()=>{const ve=($==null?void 0:$.roles)??[],Fe=new Set(((o==null?void 0:o.roles)??[]).map(lt=>lt.role)),St=d||y("admin");return ve.filter(lt=>Wi(lt).length>0&&(St||Fe.has(lt.role))).map(lt=>({role:lt.role,title:Jd(lt),portals:Wi(lt)}))},[$,o,d,y]),{setPanel:K,closePanel:I,open:M,ownerKey:J}=Om(),Q=Cm(),he=On(),be=()=>{M&&J===Jc?I(Jc):K(h.jsx(mN,{onClose:()=>I(Jc)}),{width:360,key:Jc})},[we,H]=E.useState(!1),[Z,le]=E.useState(!1),[_e,Ee]=E.useState(uv),[Ne,ke]=E.useState(FN),Te=E.useRef(null),st=(Je=v==null?void 0:v.branding)==null?void 0:Je.appName,Nt=(jn=v==null?void 0:v.branding)==null?void 0:jn.themes,Bt=E.useMemo(()=>(ek(Nt??[]),tk()),[Nt]),gt=ve=>{nk(ve),Ee(ve)},bt=()=>{const ve=window.prompt("Bookmark label:");if(!(ve!=null&&ve.trim()))return;const Fe=he.pathname+he.search,St=[...Ne,{label:ve.trim(),url:Fe}].sort((lt,Pr)=>lt.label.localeCompare(Pr.label));ke(St),Db(St),H(!1)},ue=ve=>{const Fe=Ne.filter(St=>!(St.label===ve.label&&St.url===ve.url));ke(Fe),Db(Fe)};return E.useEffect(()=>{if(!we)return;const ve=Fe=>{Te.current&&!Te.current.contains(Fe.target)&&H(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[we]),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 ${we?"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(cS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(Cr,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:ve=>{(ve.ctrlKey||ve.metaKey)&&(ve.preventDefault(),le(!0))},children:h.jsx(km,{appName:st,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(Qb,{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(fd,{className:"w-5 h-5",strokeWidth:2})})]}),(((lr=v==null?void 0:v.search)==null?void 0:lr.enabled)||Q)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx($N,{onOpenScanPanel:Q?be:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsxs(Cr,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${m>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(hd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),m>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:m})]}),h.jsxs(Cr,{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(hd,{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:Ud,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Xt,{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:Te,children:[h.jsxs("button",{onClick:()=>H(ve=>!ve),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(uS,{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"})})]}),we&&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(Cr,{to:"/credentials",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),Q&&h.jsx("button",{onClick:()=>{H(!1),be()},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:()=>{H(!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:()=>{H(!1),t==null||t()},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:()=>{H(!1),Ud()},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:Bt.map(ve=>h.jsx("button",{type:"button",onClick:()=>gt(ve.id),title:ve.label,"aria-label":`${ve.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${_e===ve.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:ve.swatch}},ve.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:()=>{H(!1),L(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(ve=>{var lt;const Fe=(lt=$==null?void 0:$.roles)==null?void 0:lt.find(Pr=>Pr.role===ve),St=ve===_;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),L(ve),i(Vx(ve,Wi(Fe)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${St?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${St?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Jd({role:ve,title:Fe==null?void 0:Fe.title})})]},ve)})]})]}),ee.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:ee.map(ve=>h.jsxs("div",{children:[ee.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:ve.role,children:ve.title}),ve.portals.map(Fe=>{const St=_m(ve.role,Fe.key),lt=he.pathname===St;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),i(St)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${lt?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${ve.role}-${Fe.key}`,children:[h.jsx(dd,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:Fe.label})]},Fe.key)})]},ve.role))})]}),P.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:()=>{H(!1),D(!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(ie).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ie).length>0?Object.entries(ie).map(([ve,Fe])=>`${ve} = ${Fe}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{H(!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:[Ne.map(ve=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(Cr,{to:ve.url,onClick:()=>H(!1),title:ve.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:ve.label}),h.jsx("button",{type:"button",onClick:()=>ue(ve),title:`Remove "${ve.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(Xt,{className:"w-3 h-3"})})]},`${ve.label}::${ve.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:bt,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(fS,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),Z&&h.jsx(Zj,{onClose:()=>le(!1)}),h.jsx(wN,{open:oe,onClose:()=>D(!1)})]})}function qm({open:n,children:t}){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?t:null})})}function Qd(n){return({isActive:t})=>{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 ${t?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${t?i:o}`}}function VN(){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 YN({group:n,collapsed:t}){const{pathname:s}=On(),i=n.matchPaths.some(y=>s.startsWith(y)),[o,c]=E.useState(i),d=o||i;return t?h.jsx(h.Fragment,{children:n.items.map(y=>h.jsx(Ss,{to:y.to,className:Qd(!0),title:y.label,children:y.icon&&h.jsx(y.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},y.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(y=>!y),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 ${d?"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(qm,{open:d,children:n.items.map(y=>h.jsxs(Ss,{to:y.to,end:y.end,className:VN(),children:[y.icon&&h.jsx(y.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:y.label})]},y.to))})]})}function KN(n){return n.kind==="group"}function JN({entry:n,collapsed:t}){const{pathname:s,search:i}=On(),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[d,y]=n.to.split("?"),g=s===d&&i===`?${y}`,u=Qd(t)({isActive:g});return h.jsxs(Ss,{to:n.to,className:u,title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}return h.jsxs(Ss,{to:n.to,end:n.end,className:Qd(t),title:t?n.label:void 0,children:[c,!t&&h.jsx("span",{children:n.label})]})}function Dr({heading:n,entries:t}){const{collapsed:s}=Sm();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}),t.map(i=>KN(i)?h.jsx(YN,{group:i,collapsed:s},i.label):h.jsx(JN,{entry:i,collapsed:s},i.to))]})}function QN({aiEnabled:n=!1,isBuilder:t=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1}){const c=[{to:"/pace",label:"Pace Board",icon:hS},{to:"/trends",label:"Trend Board",icon:dS}];if(!t&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(Dr,{heading:"Monitor",entries:c}):null;if(!t)return h.jsx(Dr,{heading:"Monitor",entries:o?c:[]});const d=[...o?c:[],{to:"/topics",label:"Event Topics",icon:Xb},{to:"/agents",label:n?"Agents":"Automations",icon:mS},{to:"/capabilities",label:"Capabilities",icon:pS}];return h.jsx(Dr,{heading:"Monitor",entries:d})}function XN(){return Ue({queryKey:["me","preferences"],queryFn:()=>fe("/me/preferences"),staleTime:6e4})}function WN(){const n=ze();return He({mutationFn:t=>fe("/me/preferences",{method:"PATCH",body:JSON.stringify(t)}),onSuccess:t=>{n.setQueryData(["me","preferences"],t)}})}const bs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},qb={COMPACT:"compact",CARDS:"cards"},ld={AVAILABLE:"/escalations/available",ALL:"/escalations"},Zi={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},ZN={[Zi.RESOLVED]:"resolved",[Zi.CANCELLED]:"cancelled",[Zi.EXPIRED]:"expired"};function eT(n){const t=n===Zi.CLAIMED;return{available:n===Zi.AVAILABLE,claimed:t,apiStatus:t?"pending":ZN[n]}}function tT(n){return n===bs.TABLE||n===bs.RICH||n===bs.TIMELINE}function nT(n){return n===qb.COMPACT||n===qb.CARDS}function rT(n,t=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||t,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:pk(n),view:tT(i)?i:null,layout:nT(o)?o:null}}function sT(n){let t;try{t=new URL(n,"http://local")}catch{return null}if(t.pathname!==ld.AVAILABLE&&t.pathname!==ld.ALL)return null;const s=t.pathname===ld.AVAILABLE?Zi.AVAILABLE:"";return rT(t.searchParams,s)}function P5(n){var t;return n.role||(((t=n.facets.roles)==null?void 0:t.length)===1?n.facets.roles[0]:null)}function U5(n,t){return n===bs.TIMELINE?bs.TIMELINE:t&&(!n||n===bs.RICH)?bs.RICH:bs.TABLE}function iT(n,t){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(y=>y.label)),c=[...s],d=new Set;for(const{role:y,pins:g}of t)for(const u of g)o.has(u.label)||i.has(u.label)||d.has(u.label)||(d.add(u.label),c.push({...u,id:`role:${y}:${u.label}`,fromRole:y}));return c}function aT(n){const t=sT(n);if(!t)return null;const{available:s,claimed:i,apiStatus:o}=eT(t.statusFilter);return{available:s,params:{...t.facets,role:t.role,type:t.type,subtype:t.subtype,priority:t.priority,status:o,...i?{claimed:!0}:{},search:t.search}}}function oT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function lT(){var I;const{collapsed:n}=Sm(),{user:t}=Lt(),s=XN(),i=WN(),o=E.useMemo(()=>new Set(((t==null?void 0:t.roles)??[]).map(M=>M.role)),[t]),{data:c}=Nu({enabled:o.size>0}),d=sn("SUMMARY");ti(xm(),()=>{d([["escalations"]])});const y=(I=s.data)==null?void 0:I.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(M=>o.has(M.role)&&Array.isArray(M.default_pins)&&M.default_pins.length>0).map(M=>({role:M.role,pins:M.default_pins})),[c,o]),{resolveUrl:u}=Dm(),m=E.useMemo(()=>iT(y,g),[y,g]),b=E.useMemo(()=>new Map(m.map(M=>[M.id,M.url])),[m]),x=E.useMemo(()=>m.map(M=>({...M,url:u(M.url)})),[m,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(M=>[M.role,Jd(M)])),[c]),_=E.useMemo(()=>x.filter(M=>!M.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(M=>o.has(M.role)&&gA(M)).map(M=>M.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(M=>S.has(M.role)||g.some(J=>J.role===M.role)).map(M=>({role:M.role,title:v.get(M.role)??M.role,portals:S.has(M.role)?Wi(M):[],pins:x.filter(J=>J.fromRole===M.role)})).filter(M=>M.portals.length>0||M.pins.length>0),[c,g,S,v,x]),L=(y==null?void 0:y.pinnedViews)??[],P=E.useRef(null),ie=M=>i.mutate({pinnedViews:M}),oe=M=>ie(L.filter(J=>J.id!==M)),D=M=>ie([...L,{id:oT(),label:M.label,url:b.get(M.id)??M.url,badge:M.badge}]),$=M=>i.mutate({hiddenRolePins:[...(y==null?void 0:y.hiddenRolePins)??[],M]}),ee=(M,J)=>{if(M===J)return;const Q=[...L],[he]=Q.splice(M,1);Q.splice(J,0,he),ie(Q)};if(x.length===0&&S.size===0)return null;const K="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:K,children:"Pinned"}),_.map(M=>{const J=L.findIndex(Q=>Q.id===M.id);return h.jsx(Lb,{pin:M,collapsed:n,draggable:J!==-1,onDragStart:()=>{P.current=J},onDropOn:()=>{P.current!==null&&J!==-1&&ee(P.current,J),P.current=null},onRemove:()=>oe(M.id)},M.id)}),C.map(M=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:K,title:`${M.title} — pins from the ${M.role} role`,"data-testid":"pin-group-label",children:M.title}),M.portals.map(J=>h.jsx(cT,{role:M.role,portal:J,collapsed:n},J.key)),M.pins.map(J=>h.jsx(Lb,{pin:J,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>D(J),onHide:()=>$(J.label)},J.id))]},M.role))]})}function cT({role:n,portal:t,collapsed:s}){const i=_m(n,t.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}-${t.key}`;return s?h.jsx(Ss,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:t.label,"data-testid":c,children:h.jsx(dd,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Ss,{to:i,title:t.label,className:({isActive:d})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${d?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(dd,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:t.label})]})}function Lb({pin:n,collapsed:t,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:d,onHide:y}){const{pathname:g,search:u}=On(),[m,b=""]=n.url.split("?"),x=g===m&&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 t?h.jsx(Ss,{to:n.url,className:`${v} ${_} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(wg,{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(Ss,{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(wg,{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(uT,{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:[d&&h.jsx("button",{onClick:d,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(Wb,{className:"w-3 h-3"})}),y&&h.jsx("button",{onClick:y,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(yS,{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(Xt,{className:"w-3 h-3"})})]})]})}function uT({url:n}){var d;const t=E.useMemo(()=>aT(n),[n]),s={limit:1,staleTime:15e3},i=Xx({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&t.available}),o=Qx({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&!t.available});if(!t)return null;const c=t.available?i:o;return c.isError||((d=c.data)==null?void 0:d.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 fT(){var c;const{data:n}=Wn(),t=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=t===!0||t!==!1&&Ux(),i=[{to:"/workflows/registry",label:"Registry",icon:Sg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:md},{to:"/workflows/executions",label:"Executions",icon:Eg}],o=s?[{kind:"group",label:"Procedural",icon:gS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:Zd,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:Sg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:md},{to:"/mcp/executions",label:"Executions",icon:Eg}]}]:i;return h.jsx(Dr,{heading:"Orchestrate",entries:o})}function z5(){return Ue({queryKey:["activeWorkers"],queryFn:async()=>(await fe("/workflows/workers")).workers})}function I5(){return Ue({queryKey:["discoveredWorkflows"],queryFn:async()=>(await fe("/workflows/discovered")).workflows})}function $5(){return Ue({queryKey:["workflowConfigs"],queryFn:async()=>(await fe("/workflows/config")).workflows})}function Cv(){return Ue({queryKey:["invocableWorkflows"],queryFn:async()=>(await fe("/workflows/invocable")).workflows})}function H5(n){return Object.fromEntries(n.filter(t=>!t.missing).map(t=>[t.as??t.key,t.data]))}function F5(n,t){return Ue({queryKey:["workflows",n,"input-lookups"],queryFn:()=>fe(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&t,staleTime:1/0})}function G5(){return Ue({queryKey:["cronStatus"],queryFn:async()=>(await fe("/workflows/cron/status")).schedules})}function V5(n){return Ue({queryKey:["workflowExecution",n],queryFn:()=>fe(`/workflow-states/${n}/execution`),enabled:!!n})}function Y5(n,t){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),Ue({queryKey:["jobs",n],queryFn:()=>fe(`/workflow-states/jobs?${s}`),enabled:(t==null?void 0:t.enabled)??!0})}function K5(){const n=ze();return He({mutationFn:t=>fe(`/workflows/${t}/terminate`,{method:"POST"}),onSuccess:(t,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function J5(){const n=ze();return He({mutationFn:({workflow_type:t,...s})=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function Q5(){const n=ze();return He({mutationFn:t=>fe(`/workflows/${encodeURIComponent(t)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function X5(){const n=ze();return He({mutationFn:({workflowType:t,data:s,metadata:i,execute_as:o})=>fe(`/workflows/${t}/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 hT(){const{data:n}=Cv();return n!=null&&n.length?h.jsx(Dr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:md}]}):null}const dT=[{to:"/mcp/queries",label:"Designer",icon:bS},{to:"/mcp/servers",label:"Servers & Tools",icon:xS}];function mT(){return h.jsx(Dr,{heading:"Design",entries:dT})}const pT=[{to:"/files",label:"Files",icon:vS},{to:"/knowledge",label:"Knowledge Base",icon:Zb}];function yT(){return h.jsx(Dr,{heading:"Storage",entries:pT})}function gT({isBuilder:n=!1,isOps:t=!1}){var d;const{data:s}=Wn(),i=((d=s==null?void 0:s.features)==null?void 0:d.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:_S},...n||t?[{to:"/admin/roles",label:"Roles",icon:hd},{to:"/admin/personas",label:"Personas",icon:wS},{to:"/admin/scan-codes",label:"Scan Codes",icon:No}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:SS},{to:"/admin/streams",label:"Messages",icon:Zb},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:ES}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(Dr,{heading:"Identity & Access",entries:o}),n&&zx()&&h.jsx(Dr,{heading:"Infrastructure",entries:c})]})}function Mv({aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(QN,{aiEnabled:n,isBuilder:t,isOps:s,viewAs:i,canSeePaceBoard:o}),h.jsx(lT,{}),!t&&h.jsx(hT,{}),t&&h.jsx(fT,{}),t&&n&&h.jsx(mT,{}),t&&h.jsx(yT,{}),(t||s)&&h.jsx(gT,{isBuilder:t,isOps:s})]})}function bT({open:n,onClose:t,...s}){const i=On();return E.useEffect(()=>{t()},[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:t,"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:t,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(Xt,{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(wA,{children:h.jsx(Mv,{...s})})})]})]})}const Rv="lt_event_feed_patterns";function xT(n,t){if(n.startsWith("/topics/")){const d=decodeURIComponent(n.replace("/topics/",""));if(d&&!d.includes("/"))return`lt.events.${d}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const d=new URLSearchParams(t).get("role");return d?`lt.events.system.escalation.${Fx(d)}.>`:"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 vT(){try{const n=localStorage.getItem(Rv);return n?JSON.parse(n):[]}catch{return[]}}function cd(n){try{localStorage.setItem(Rv,JSON.stringify(n))}catch{}}function _T(){const{pathname:n,search:t}=On(),[s,i]=E.useState(vT),o=E.useMemo(()=>xT(n,t),[n,t]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),d=E.useCallback(u=>{const m=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(m))return b;const x=[...b,m];return cd(x),x})},[]),y=E.useCallback(u=>{i(m=>{const b=m.filter(x=>x!==u);return cd(b),b})},[]),g=E.useCallback(()=>{i([]),cd([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:d,removePattern:y,clearUserPatterns:g}}function wT({children:n,className:t=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${t}`,children:n})}const ud=280,Bb="cubic-bezier(0.4, 0, 0.2, 1)",Qc=40;function ST(n){if(!n)return"scale(0.92)";const t=window.innerWidth,s=window.innerHeight,i=t-Qc*2,o=s-Qc*2,c=n.width/i,d=n.height/o,y=n.left+n.width/2-(Qc+i/2),g=n.top+n.height/2-(Qc+o/2);return`translate(${y}px, ${g}px) scale(${c}, ${d})`}function Dv({open:n,onClose:t,sourceRef:s,children:i}){const[o,c]=E.useState(null),d=E.useRef(null),y=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!y.current?(d.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&y.current&&o==="open"&&(d.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),y.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"&&t()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,t]);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),ud+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",m=u?ST(d.current):"none",b=u?0:1;return Xd.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${ud}ms ${Bb}, opacity ${ud}ms ${Bb}`,transform:m,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function ET({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 OT({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 AT({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 jT({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 kT({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 NT({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 TT(n){const t=n.trim().split(`
57
57
  `);if(t.length<2)return n;const s=y=>y.split("|").map(g=>g.trim()).filter(Boolean),i=s(t[0]),o=t.slice(2),c=i.map(y=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${y}</th>`).join(""),d=o.map(y=>`<tr class="border-t border-surface-border">${s(y).map(m=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${m}</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>${d}</tbody></table>`}function Xc(n){return n.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function CT(n){const t=[];let s=n.replace(/```(\w*)\n([\s\S]*?)```/g,(g,u,m)=>{const b=t.length;return t.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${m}</code></pre>`),`\0CODE${b}\0`});const i=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(i,(g,u,m,b)=>TT(`${u}
58
58
  ${m}
59
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="${Xc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Xc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Xc(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="${Xc(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(),m=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${m?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${m?"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)=>t[parseInt(u,10)]);const d="text-xs leading-relaxed text-text-secondary mb-2",y=/<\/(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 m=[];let b=u,x;for(;(x=y.exec(b))!==null;){const v=x.index+x[0].length;m.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),y.lastIndex=0}return b&&m.push(b),m.map(v=>{const _=v.trim();return _?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(_)?_:`<p class="${d}">${_}</p>`:""}).join("")}).join(""),s}const MT=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function RT(n){return MT.test(n)}function Ru({content:n,className:t,onClick:s}){const i=E.useMemo(()=>CT(n),[n]);return h.jsx("div",{className:t,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function _u({data:n,depth:t=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:t>0,[c,d]=E.useState(o),[y,g]=E.useState(s);if(s!==void 0&&s!==y&&(g(s),d(s%2===0&&t>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:()=>d(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>d(!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,m)=>h.jsxs("div",{children:[h.jsx(_u,{data:u,depth:t+1,generation:s}),m<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},m))}),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:()=>d(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>d(!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(([m,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:m}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(_u,{data:b,depth:t+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},m))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function _o({data:n,depth:t=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&RT(n)?h.jsx(Ru,{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(_o,{data:s,depth:t+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:t>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(_o,{data:o,depth:t+1})}):h.jsx(_o,{data:o,depth:t+1})]},i)})})}return h.jsx("span",{children:String(n)})}function Pb({mode:n,setMode:t,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:d,onClose:y,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",m=`${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:m,title:s?"Expand all":"Collapse all",children:s?h.jsx(NT,{className:u}):h.jsx(kT,{className:u})}),h.jsx("button",{onClick:()=>t(n==="json"?"tree":"json"),className:m,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(ET,{className:u}):h.jsx(OT,{className:u})}),h.jsx("button",{onClick:o,className:m,title:"Copy to clipboard",children:c?h.jsx(jT,{className:`${u} text-status-success`}):h.jsx(AT,{className:u})}),d&&h.jsx("button",{onClick:d,className:m,title:"Fullscreen",children:h.jsx(ex,{className:u})}),y&&h.jsx("button",{onClick:y,className:m,title:"Close (Esc)",children:h.jsx(tx,{className:u})})]})}function DT({data:n,label:t,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[d,y]=E.useState(o??"json"),[g,u]=E.useState(!1),[m,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[_,S]=E.useState(1),C=x%2===0,L=_%2===0,P=E.useCallback(()=>v(M=>M+1),[]),ie=E.useCallback(()=>S(M=>M+1),[]);let oe=n;if(typeof n=="string")try{oe=JSON.parse(n)}catch{}const D=async()=>{const M=typeof n=="string"?n:JSON.stringify(oe,null,2);await navigator.clipboard.writeText(M),u(!0),setTimeout(()=>u(!1),2e3)},$=E.useCallback(()=>{S(1),b(!0)},[]),ee=s==="panel",K=ee?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",I=ee?"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:K,children:[t&&h.jsx(wT,{children:t}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(Pb,{mode:d,setMode:y,isCollapsed:C,onToggleCollapse:P,onCopy:D,copied:g,onFullscreen:$})}),h.jsx("div",{className:I,children:d==="json"?h.jsx(_u,{data:oe,generation:x}):h.jsx(_o,{data:oe})})]}),h.jsxs(Dv,{open:m,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(Pb,{mode:d,setMode:y,isCollapsed:L,onToggleCollapse:ie,onCopy:D,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:d==="json"?h.jsx(_u,{data:oe,generation:_}):h.jsx(_o,{data:oe})})]})]})}const qT=100,Ub=500;let LT=0;const qv={"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 Lv(n){const t=n.split(".");return t[0]==="system"&&t.length>=3?`${t[1]}.${t[t.length-1]}`:n}function zb({event:n,forceExpanded:t=!1}){var x,v;const[s,i]=E.useState(t),o=qv[Lv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(t)},[t]);const c=t,d=c?"text-xs":"text-2xs",y=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",m=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 ${m} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${d} 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:`${y} 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(qm,{open:s,children:h.jsx("div",{className:b,children:h.jsx(DT,{data:n.data})})})]})}function BT({open:n,onToggle:t,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[d,y]=E.useState(!1),[g,u]=E.useState(""),m=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(ia),{connected:v}=Ex(),{patterns:_,pagePattern:S,userPatterns:C,addPattern:L,removePattern:P}=_T(),ie=E.useCallback($=>{const ee=String($.type||"unknown");if(ee.startsWith("mesh."))return;const K=`${ee}:${$.timestamp||""}:${$.escalationId||$.workflowId||$.taskId||""}`,I=Date.now(),M=b.current.get(K);if(!(M&&I-M<Ub)){if(b.current.set(K,I),b.current.size>200)for(const[J,Q]of b.current)I-Q>Ub*2&&b.current.delete(J);c(J=>[{id:++LT,type:ee,timestamp:$.timestamp||new Date().toISOString(),data:$},...J].slice(0,qT))}},[]),oe=E.useRef(ie);oe.current=ie;const D=n||d||s;return E.useEffect(()=>{if(!D)return;const $=_.map(ee=>x(ee,K=>oe.current(K)));return()=>$.forEach(ee=>ee())},[x,_.join(","),D]),E.useEffect(()=>{n&&m.current&&(m.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:t,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(Wd,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(nx,{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 ${qv[Lv(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:$=>{$.stopPropagation(),v||window.location.reload()},children:h.jsx(Xb,{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:$=>{$.stopPropagation(),i()},children:h.jsx(OS,{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:$=>{$.stopPropagation(),y(!0)},children:h.jsx(ex,{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:$=>{$.stopPropagation(),c([])},children:h.jsx(AS,{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($=>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:[$.replace("lt.events.",""),h.jsx("button",{onClick:()=>P($),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Xt,{className:"w-2 h-2"})})]},$))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:$=>u($.target.value),onKeyDown:$=>{$.key==="Enter"&&g.trim()&&(L(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(L(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(Wb,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(qm,{open:n,children:h.jsx("div",{ref:m,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($=>h.jsx(zb,{event:$},$.id))})}),h.jsxs(Dv,{open:d,onClose:()=>y(!1),sourceRef:m,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>y(!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(tx,{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($=>h.jsx(zb,{event:$,forceExpanded:!0},$.id))]})]})}function PT(){return Ue({queryKey:["docs"],queryFn:()=>fe("/docs"),staleTime:5*6e4})}function UT(n){return Ue({queryKey:["docs",n],queryFn:()=>fe(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function zT(){const[n,t]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),d=E.useRef(o),y=E.useRef(n),g=E.useRef(s);d.current=o,y.current=n,g.current=s;const u=E.useCallback((_,S)=>{var L;const C=d.current;if(C){const P=((L=S==null?void 0:S.current)==null?void 0:L.scrollTop)??0;t([...y.current,{...C,scrollTop:P}])}i([]),c({path:_,scrollTop:0})},[]),m=E.useCallback(_=>{var P;const S=y.current;if(S.length===0)return;const C=S[S.length-1],L=d.current;if(L){const ie=((P=_==null?void 0:_.current)==null?void 0:P.scrollTop)??0;i([...g.current,{...L,scrollTop:ie}])}t(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(_=>{var P;const S=g.current;if(S.length===0)return;const C=S[S.length-1],L=d.current;if(L){const ie=((P=_==null?void 0:_.current)==null?void 0:P.scrollTop)??0;t([...y.current,{...L,scrollTop:ie}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(_=>{var L,P;const S=d.current;if(!S)return;const C=((L=_==null?void 0:_.current)==null?void 0:L.scrollTop)??0;t([...y.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((P=_==null?void 0:_.current)==null?void 0:P.scrollTop)??0})},[]),v=E.useCallback(()=>{t([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:m,goForward:b,pushScrollPosition:x,reset:v}}function IT(n,t){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const d=((t?t.replace(/[^/]+$/,""):"")+o).split("/"),y=[];for(const g of d)g===".."?y.pop():g&&g!=="."&&y.push(g);o=y.join("/")}return{path:o,anchor:i}}function $T(n){if(!n.startsWith("#docs"))return null;const t=n.slice(1).split(":"),s=t[1]||"README.md",i=t[2]||void 0;return{path:s,anchor:i}}function HT(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function FT({content:n,currentPath:t,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const d=c.target,y=d.closest("[data-anchor]");if(y){c.preventDefault(),i();const m=y.dataset.anchor,b=(u=y.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(m)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=d.closest("[data-doc-link]");if(g){c.preventDefault();const{path:m,anchor:b}=IT(g.dataset.docLink,t);s(m,b);return}};return h.jsx(Ru,{content:n,className:"docs-content",onClick:o})}function GT(n){const t=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){t.push(i);continue}let c=s;for(let d=0;d<o.length-1;d++){const y=o[d];c.has(y)||c.set(y,{label:y,children:[],subdirs:new Map});const g=c.get(y);d===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:t,dirs:s}}function VT({docs:n,selected:t,onSelect:s}){const{topLevel:i,dirs:o}=GT(n),c=y=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${t===y?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function d(y,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(jS,{className:"w-3 h-3",strokeWidth:1.5}),y.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...y.subdirs.values()].map(u=>d(u)),y.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},y.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(y=>h.jsx("button",{className:c(y.path),onClick:()=>s(y.path),children:y.title},y.path)),[...o.values()].map(y=>d(y))]})}function YT({open:n,onClose:t}){var ee,K,I;const[s,i]=E.useState(!1),{data:o}=PT(),c=zT(),{data:d,isLoading:y}=UT(((ee=c.current)==null?void 0:ee.path)??null),g=E.useRef(null),[u,m]=E.useState(null);E.useEffect(()=>{u&&(d!=null&&d.content)&&g.current&&requestAnimationFrame(()=>{var J;const M=(J=g.current)==null?void 0:J.querySelector(`#${CSS.escape(u)}`);M==null||M.scrollIntoView({behavior:"smooth",block:"start"}),m(null)})},[u,d]);const b=E.useCallback(()=>{var Q;const M=$T(window.location.hash),J=(M==null?void 0:M.path)??"README.md";((Q=c.current)==null?void 0:Q.path)!==J&&c.navigate(J,g),M!=null&&M.anchor&&m(M.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const M=HT(c.current.path);window.location.hash!==M&&window.history.replaceState(null,"",window.location.pathname+window.location.search+M)},[n,(K=c.current)==null?void 0:K.path]),E.useEffect(()=>{if(!n)return;const M=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",M),()=>window.removeEventListener("hashchange",M)},[n,b]);const v=E.useCallback((M,J)=>{J&&m(J),c.navigate(M,g)},[c]),_=E.useCallback(M=>{c.navigate(M,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),L=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const M=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(M)}},[n]),!(n||s))return null;const ie=()=>{i(!1),setTimeout(()=>{t(),c.reset()},200)},oe=((I=c.current)==null?void 0:I.path)??null,D=c.backStack.length>0,$=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:ie}),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:!D,className:`p-0.5 transition-colors ${D?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(Qb,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!$,className:`p-0.5 transition-colors ${$?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(fd,{className:"w-4 h-4"})}),h.jsx(kS,{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:ie,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Xt,{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(VT,{docs:o.docs,selected:oe,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:oe?y?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"})]}):d!=null&&d.content?h.jsx(FT,{content:d.content,currentPath:oe,onNavigate:v,onAnchorClick:L}):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(fd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function KT(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const Ib=2e3;function JT(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
@@ -63,5 +63,5 @@ ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
63
63
 
64
64
  `}function QT(n){const t=n.summary,s=n.title;if(t){const i=t.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?t.slice(0,i).trim():t}return s||(typeof n=="string"?n:"Query completed.")}const Bv=E.createContext(null);function XT({children:n}){const t=On(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[d,y]=E.useState(null),[g,u]=E.useState({}),m=E.useRef(null),b={page:t.pathname.split("/").filter(Boolean).join("-")||"home",route:t.pathname,params:{},...g,suggestedTags:g.suggestedTags??KT(t.pathname)};E.useEffect(()=>()=>{m.current&&clearInterval(m.current)},[]);const x=E.useCallback(()=>i(L=>!L),[]),v=E.useCallback(L=>{u(L)},[]),_=E.useCallback(()=>{c([]),y(null)},[]),S=E.useCallback(async L=>{var K;const P=new Date().toISOString(),ie={id:`user-${Date.now()}`,role:"user",content:L,timestamp:P},oe={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:P,pending:!0};c(I=>[...I,ie,oe]);const D={...b};(K=D.entities)!=null&&K.yamlContent&&D.entities.yamlContent.length>Ib&&(D.entities={...D.entities,yamlContent:D.entities.yamlContent.slice(0,Ib)+`
65
65
  ... (truncated)`});const ee=`${JT(o.concat(ie))}${L}`;try{const M=(await fe("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ee,tags:D.suggestedTags,context:D,wait:!1,direct:!0})})).workflow_id;y(M),c(J=>J.map(Q=>Q.id===oe.id?{...Q,workflowId:M}:Q)),m.current&&clearInterval(m.current),m.current=setInterval(async()=>{var J;try{const Q=await fe(`/workflows/${M}/result`),he=(J=Q==null?void 0:Q.result)==null?void 0:J.data;if(he){m.current&&clearInterval(m.current),m.current=null,y(null);const be=QT(he);let we;try{we=(await fe(`/workflow-states/${M}/execution`)).duration_ms}catch{}c(H=>H.map(Z=>Z.id===oe.id?{...Z,content:be,timestamp:new Date().toISOString(),pending:!1,durationMs:we}:Z))}}catch{}},3e3)}catch{c(I=>I.map(M=>M.id===oe.id?{...M,content:"Failed to submit query. Please try again.",pending:!1}:M))}},[o,b]),C=E.useCallback(async L=>{const P=o.find(D=>D.id===L);if(!(P!=null&&P.workflowId)||P.compilationStatus==="compiling"||P.compilationStatus==="done")return;const ie=o.indexOf(P),oe=o.slice(0,ie).reverse().find(D=>D.role==="user");if(oe){c(D=>D.map($=>$.id===L?{...$,compilationStatus:"compiling"}:$));try{const D=await fe("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:oe.content,summary:P.content})}),$=await fe("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:P.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:D.tool_name,description:D.description,tags:D.tags,app_id:""})});await fe(`/yaml-workflows/${$.id}/deploy`,{method:"POST"}),c(ee=>ee.map(K=>K.id===L?{...K,compilationStatus:"done"}:K))}catch(D){const $=D instanceof Error?D.message:"Compilation failed";c(ee=>ee.map(K=>K.id===L?{...K,compilationStatus:"error",compilationError:$}:K))}}},[o]);return h.jsx(Bv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:d,clearMessages:_,compileMessage:C},children:n})}function Pv(){const n=E.useContext(Bv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function WT(){const{helpOpen:n,toggleHelp:t}=Pv();return h.jsx("button",{onClick:t,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(Xt,{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(${$t}/logo512.png)`}})})}function ZT({ms:n,className:t=""}){const s=Fj(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 ${t}`,children:"--"}):h.jsx(iv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:s})})}const eC=["sm","md","lg","full"],$b={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"},Hb={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function tC({which:n}){const t="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:t,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:t,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:t,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:t,strokeWidth:"1.5"})})}}function nC({msg:n}){const[t,s]=E.useState(0);E.useEffect(()=>{const d=new Date(n.timestamp).getTime(),y=()=>s(Math.floor((Date.now()-d)/1e3));y();const g=setInterval(y,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(t/60),o=t%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(Cr,{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(Zd,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function rC({msg:n,compileMessage:t}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(av,{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(ZT,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(Cr,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(Zd,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>t(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(NS,{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 sC(){const{helpOpen:n,setHelpOpen:t,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:d,compileMessage:y}=Pv(),[g,u]=E.useState(""),[m,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 D=$=>{$.key==="Escape"&&(m==="full"?b("lg"):m==="lg"?b("md"):m==="md"?b("sm"):t(!1))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[n,m,t]),!n)return null;const C=()=>{const D=g.trim();!D||c||(i(D),u(""),S.current&&(S.current.style.height="auto"))},L=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),C())},P=m==="full",ie=o.page.replace(/-/g," "),oe=P?{}:{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 ${P?$b.full:`right-6 ${$b[m]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:oe,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:ie})]}),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:eC.map(D=>h.jsx("button",{onClick:()=>b(D),className:`p-1 rounded transition-colors ${D===m?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":D===m,"aria-label":Hb[D],title:Hb[D],children:h.jsx(tC,{which:D})},D))}),s.length>0&&h.jsx("button",{onClick:d,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(TS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>t(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(Xt,{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(D=>h.jsxs("div",{className:`text-xs leading-relaxed ${D.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 ${D.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:D.pending?h.jsx(nC,{msg:D}):D.role==="assistant"?h.jsx(Ru,{content:D.content}):D.content}),!D.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(rC,{msg:D,compileMessage:y})})]},D.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:D=>{u(D.target.value);const $=D.target;$.style.height="auto",$.style.height=`${Math.min($.scrollHeight,120)}px`},onKeyDown:L,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(CS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const iC=6e3,aC="scan";function oC(){const{lastResult:n}=Mm(),{open:t,ownerKey:s}=Om(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),iC);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||t&&s===aC||n.source===jo.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(No,{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(Rm,{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(Xt,{className:"w-3.5 h-3.5"})})]})})}const Uv="lt-announcement-dismissed:";function lC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function cC(n){try{return localStorage.getItem(`${Uv}${n}`)==="1"}catch{return!1}}function uC(){const{isAuthenticated:n,userRoleNames:t}=Lt(),{data:s}=Wx(n),i=ze(),[o,c]=E.useState(null),[d,y]=E.useState(0);wn(CA,()=>{i.invalidateQueries({queryKey:["announcements"]})});const g=Date.now(),u=((s==null?void 0:s.announcements)??[]).filter(b=>!cC(b.id)&&new Date(b.expires_at).getTime()>g&&(b.roles.length===0||b.roles.some(x=>t.includes(x))));if(E.useEffect(()=>{const b=((s==null?void 0:s.announcements)??[]).map(v=>new Date(v.expires_at).getTime()-Date.now()).filter(v=>v>0);if(b.length===0)return;const x=setTimeout(()=>y(v=>v+1),Math.min(...b)+250);return()=>clearTimeout(x)},[s,d]),u.length===0)return null;const m=b=>{try{localStorage.setItem(`${Uv}${b}`,"1")}catch{}y(x=>x+1)};return h.jsx("div",{"data-testid":"announcement-banner",className:"relative z-40",children:u.map(b=>{const x=o===b.id,v=b.title??b.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(x?null:b.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}),x?h.jsx(nx,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(Wd,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>m(b.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${v}`,children:h.jsx(Xt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),x&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Ru,{content:lC(b.body)})})]},b.id)})})}function fC(){var $;const{isBuilder:n,isOps:t,viewAs:s}=$x(),{canSeePaceBoard:i}=Hx();sA();const{data:o}=Wn(),c=Px(),d=c!==null?c:!!(($=o==null?void 0:o.ai)!=null&&$.enabled),{collapsed:y,toggle:g}=Sm(),[u,m]=E.useState(!1),[b,x]=E.useState(!1),[v,_]=E.useState(!1),[S,C]=E.useState(()=>window.location.hash.startsWith("#docs")),L=On(),P=E.useRef(null),{kiosk:ie,homePath:oe}=Yx(),D=ie||yA(L.pathname);return E.useEffect(()=>{const ee=P.current;ee&&(ee.classList.remove("animate-page-in"),ee.offsetWidth,ee.classList.add("animate-page-in"))},[L.pathname]),E.useEffect(()=>{const ee=()=>{window.location.hash.startsWith("#docs")&&C(!0)};return window.addEventListener("hashchange",ee),()=>window.removeEventListener("hashchange",ee)},[]),ie&&oe&&!xA(L.pathname)?h.jsx(xn,{to:oe,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(GN,{onToggleEventFeed:()=>m(ee=>!ee),onToggleDocs:()=>C(ee=>!ee),onToggleNav:D?void 0:()=>x(ee=>!ee)}),h.jsx(uC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!D&&h.jsxs("aside",{className:`${y?"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(Mv,{aiEnabled:d,isBuilder:n,isOps:t,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 ${y?"flex justify-center":"flex items-center px-7"}`,"aria-label":y?"Expand sidebar":"Collapse sidebar",children:y?h.jsx(MS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(RS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!y&&(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:P,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(Ws,{})})}),h.jsx(hC,{})]}),!D&&h.jsx(bT,{open:b,onClose:()=>x(!1),aiEnabled:d,isBuilder:n,isOps:t,viewAs:s,canSeePaceBoard:i}),h.jsx(BT,{open:u,onToggle:()=>m(ee=>!ee),configOpen:v,onToggleConfig:()=>_(ee=>!ee)}),h.jsx(YT,{open:S,onClose:()=>{C(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),d&&h.jsx(WT,{}),d&&h.jsx(sC,{}),h.jsx(oC,{})]})}function hC(){const{node:n,width:t,open:s}=Om();return h.jsx(EA,{open:s,width:t,className:"border-l border-surface-border bg-surface-raised",children:n})}function dC(){const{isAuthenticated:n}=Lt(),t=On();return n?h.jsx(_A,{children:h.jsx(SA,{children:h.jsx(XT,{children:h.jsx(sk,{children:h.jsx(vk,{children:h.jsx(fC,{})})})})})}):h.jsx(xn,{to:"/login",state:{from:t.pathname},replace:!0})}function zv({provider:n,className:t="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:t,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:t,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:t,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:t,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:t,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 mC(){return fe("/auth/oauth/providers")}async function pC(n,t){const s=t?`?label=${encodeURIComponent(t)}`:"";return fe(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function W5(){return Ue({queryKey:["oauth-connections"],queryFn:()=>fe("/auth/oauth/connections")})}function Z5(){const n=ze();return He({mutationFn:({provider:t,label:s})=>pC(t,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function yC(){var ee;const{login:n,isAuthenticated:t}=Lt(),s=ra(),i=On(),o=new URLSearchParams(i.search),c=o.get("token"),d=o.get("error"),y=((ee=i.state)==null?void 0:ee.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,m]=E.useState(""),[b,x]=E.useState(""),[v,_]=E.useState(d||""),[S,C]=E.useState(!1),[L,P]=E.useState(!!c),[ie,oe]=E.useState([]),D=E.useRef(!1);if(E.useEffect(()=>{c||D.current||(D.current=!0,(async()=>{var K,I,M,J;try{const Q=await tm().catch(()=>null);if(!((K=Q==null?void 0:Q.auth)!=null&&K.sso))return;const he=await fetch(`${$t}/api/auth/sso`,{method:"POST"});if(!he.ok){_("Host authentication required — please log in to your organization first");return}const be=await he.json();be.token&&((I=Q.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",Q.auth.ssoLogoutUrl),P(!0),n(be.token,void 0,{displayName:(M=be.user)==null?void 0:M.display_name,username:(J=be.user)==null?void 0:J.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||mC().then(oe).catch(()=>{})},[]),E.useEffect(()=>{if(!L)return;const K=setTimeout(()=>s(y,{replace:!0}),1500);return()=>clearTimeout(K)},[L]),t&&!L)return h.jsx(xn,{to:y,replace:!0});const $=async K=>{var I,M;if(K.preventDefault(),_(""),!u.trim()||!b){_("Username and password are required");return}C(!0);try{const J=await fetch(`${$t}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),Q=await J.json();if(!J.ok){_(Q.error||"Login failed");return}P(!0),n(Q.token,{username:u.trim(),password:b},{displayName:(I=Q.user)==null?void 0:I.display_name,username:(M=Q.user)==null?void 0:M.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 ${L?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(km,{size:"lg",hideLabel:L})}),h.jsxs("form",{onSubmit:$,className:`space-y-5 transition-opacity duration-300 ${L?"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:K=>m(K.target.value),className:"input",placeholder:"Enter your username",autoFocus:!L,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:K=>x(K.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||L,children:S?"Signing in...":"Sign In"}),ie.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:ie.filter(K=>K.provider!=="anthropic").map(K=>h.jsxs("a",{href:`${$t}/api/auth/oauth/${K.provider}?returnTo=${encodeURIComponent(y)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(zv,{provider:K.provider}),"Sign in with ",K.name]},K.provider))})]})]})]})})}function Fb(){const{isAuthenticated:n}=Lt(),t=ra(),s=On(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||t(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,d]=E.useState(""),[y,g]=E.useState(i.get("label")||"default"),[u,m]=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 L=c.trim();if(!L){m("A token or API key is required");return}if(!L.startsWith("sk-ant-")){m('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),m("");const P=`${$t}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(L)}&state=${encodeURIComponent(o)}`;window.location.href=P};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(km,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(zv,{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=>d(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:y,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({roleTypes:n,roleNames:t,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=Lt();return i?h.jsx(Ws,{}):n&&n.some(d=>c(d))?h.jsx(Ws,{}):t&&t.some(d=>o(d))?h.jsx(Ws,{}):h.jsx(xn,{to:s,replace:!0})}function gC(){const{data:n,isSuccess:t}=Cv();return t&&n.length===0?h.jsx(xn,{to:"/",replace:!0}):h.jsx(Ws,{})}function bC({redirectTo:n="/"}){var i;const{data:t,isLoading:s}=Wn();return s||!t?null:(i=t.ai)!=null&&i.enabled?h.jsx(Ws,{}):h.jsx(xn,{to:n,replace:!0})}function xC({flag:n,redirectTo:t="/"}){var o;const{data:s,isLoading:i}=Wn();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(xn,{to:t,replace:!0}):h.jsx(Ws,{})}const vC=E.lazy(()=>Ae(()=>import("./ProcessesListPage-BEqeeNae.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}))),_C=E.lazy(()=>Ae(()=>import("./ProcessDetailPage-BT0eiBWY.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),wC=E.lazy(()=>Ae(()=>import("./McpOverview-DEJmsdVi.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),SC=E.lazy(()=>Ae(()=>import("./McpRunsPage-CRQqrF4Q.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}))),EC=E.lazy(()=>Ae(()=>import("./McpRunDetailPage-C6xw0kBg.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}))),OC=E.lazy(()=>Ae(()=>import("./McpQueryPage-BBcG_UuU.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}))),AC=E.lazy(()=>Ae(()=>import("./McpQueryDetailPage-DYJr16l7.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}))),jC=E.lazy(()=>Ae(()=>import("./EscalationsOverview-Tdu3Yx2c.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),kC=E.lazy(()=>Ae(()=>import("./AvailableEscalationsPage-CpbC8oTN.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,7,8,9,19,21,11,58,59,12,60,20,16,61,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),NC=E.lazy(()=>Ae(()=>import("./OperatorDashboard-DoiDGZ9R.js"),__vite__mapDeps([62,1,3,4,5,6,52,7,8,9,11,31,58,59,13,12,60,20,16,21,61,57,19,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),TC=E.lazy(()=>Ae(()=>import("./index-B_GT23TE.js"),__vite__mapDeps([63,1,53,54,5,64,13,57,7,8,9,19,21,11,4,16,14,15,20,61,37,65]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),CC=E.lazy(()=>Ae(()=>import("./WorkflowsOverview-5i2Tcy-p.js"),__vite__mapDeps([66,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),MC=E.lazy(()=>Ae(()=>import("./index-z5Hpeidu.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),RC=E.lazy(()=>Ae(()=>import("./index-z5Hpeidu.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),DC=E.lazy(()=>Ae(()=>import("./WorkflowsDashboard-DFDTwnhn.js"),__vite__mapDeps([69,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"})}))),qC=E.lazy(()=>Ae(()=>import("./WorkflowsDashboard-DFDTwnhn.js"),__vite__mapDeps([69,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"})}))),LC=E.lazy(()=>Ae(()=>import("./YamlWorkflowsPage-Cq-hMVxl.js"),__vite__mapDeps([70,1,25,3,4,14,13,12,8,48,68,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),BC=E.lazy(()=>Ae(()=>import("./GraphInvokePage-DO-yyhi6.js"),__vite__mapDeps([71,1,25,14,13,43,45,46,47,44,4,48,68]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),PC=E.lazy(()=>Ae(()=>import("./YamlWorkflowDetailPage-p4VEYZS0.js"),__vite__mapDeps([72,1,25,19,68,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),UC=E.lazy(()=>Ae(()=>import("./TasksListPage-CNbNeagx.js"),__vite__mapDeps([73,1,2,3,4,7,8,9,19,60,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),zC=E.lazy(()=>Ae(()=>import("./TaskDetailPage-zhn_U_eC.js"),__vite__mapDeps([74,1,2,19,60,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),Gb=E.lazy(()=>Ae(()=>import("./WorkflowExecutionPage-DvA51lT3.js"),__vite__mapDeps([75,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),IC=E.lazy(()=>Ae(()=>import("./AdminDashboard-Covdam48.js"),__vite__mapDeps([76,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),$C=E.lazy(()=>Ae(()=>import("./index-D-Xs4rAW.js"),__vite__mapDeps([77,1,7,8,9,12,13,31,3,4,14,78,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),HC=E.lazy(()=>Ae(()=>import("./index-DkrBFFSO.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),Vb=E.lazy(()=>Ae(()=>import("./index-DkrBFFSO.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),FC=E.lazy(()=>Ae(()=>import("./index-Bhb89oHH.js"),__vite__mapDeps([81,1,23,8,80,14,13,12,11,3,4,82,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),Yb=E.lazy(()=>Ae(()=>import("./index-DZhtP2Ok.js"),__vite__mapDeps([83,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),GC=E.lazy(()=>Ae(()=>import("./index-Cn8uJsd7.js"),__vite__mapDeps([84,1,3,4,7,8,9,11,12,13,80,31,14,20,47,49,85,86,33]),import.meta.url).then(n=>({default:n.UsersPage}))),VC=E.lazy(()=>Ae(()=>import("./RolesPage-80quJU5-.js"),__vite__mapDeps([87,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),YC=E.lazy(()=>Ae(()=>import("./RoleDetailPage-BFuLNJXa.js"),__vite__mapDeps([88,1,89,80,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),KC=E.lazy(()=>Ae(()=>import("./PersonasPage-B36yn4hU.js"),__vite__mapDeps([90,1,85,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),JC=E.lazy(()=>Ae(()=>import("./PersonaDetailPage-BzbA4Prr.js"),__vite__mapDeps([91,1,85,20,13,86,89,80,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),QC=E.lazy(()=>Ae(()=>import("./EscalationSchemaPage-W5r0A1kj.js"),__vite__mapDeps([92,1,13,4]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),XC=E.lazy(()=>Ae(()=>import("./PortalPage-BkD4YfDf.js"),__vite__mapDeps([93,1,9,56,13,57,7,8,19,21,11,4,58,59,12,60,20,16,61]),import.meta.url).then(n=>({default:n.PortalPage}))),WC=E.lazy(()=>Ae(()=>import("./EscalationListSchemaPage-C28rn9XC.js"),__vite__mapDeps([94,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),ZC=E.lazy(()=>Ae(()=>import("./ScanCodesPage-Cu1bKEix.js"),__vite__mapDeps([95,1,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),e3=E.lazy(()=>Ae(()=>import("./ScanSchemeDetailPage-D9AbS6UY.js"),__vite__mapDeps([96,1,80,14,13,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),t3=E.lazy(()=>Ae(()=>import("./ScanStationPage-gcZGefvT.js"),__vite__mapDeps([97,1,13,65,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),n3=E.lazy(()=>Ae(()=>import("./index-Eo-l3Lqo.js"),__vite__mapDeps([98,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),Kb=E.lazy(()=>Ae(()=>import("./OperationsPage-Dlfwzf-0.js").then(n=>n.O),__vite__mapDeps([99,1,59,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),r3=E.lazy(()=>Ae(()=>import("./index-PfSRKerc.js"),__vite__mapDeps([100,1,18,13,12,3,4,29,26,42,78,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),s3=E.lazy(()=>Ae(()=>import("./index-BbCjGO3M.js"),__vite__mapDeps([101,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),i3=E.lazy(()=>Ae(()=>import("./CredentialsPage-D7abp0aS.js"),__vite__mapDeps([102,1,14,13,49,80,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),a3=E.lazy(()=>Ae(()=>import("./index-DGmzBY9D.js"),__vite__mapDeps([103,1,4,14,13,12,15,6,8,104,49]),import.meta.url).then(n=>({default:n.FilesPage}))),o3=E.lazy(()=>Ae(()=>import("./index-oFKUFGQL.js"),__vite__mapDeps([105,1,14,13,12,15,11,8,104,49,106,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),l3=E.lazy(()=>Ae(()=>import("./HomePage-DSS3eHR2.js"),__vite__mapDeps([107,1,24,26,20,13,16,15,99,59,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),c3=E.lazy(()=>Ae(()=>import("./AgentsPage---Dg5ufF.js"),__vite__mapDeps([108,1,109,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),u3=E.lazy(()=>Ae(()=>import("./AgentDetailPage-CWJZIZP1.js"),__vite__mapDeps([110,1,109,111,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),Jb=E.lazy(()=>Ae(()=>import("./AgentConfigPage-CE1k6J5r.js"),__vite__mapDeps([112,1,109,111,13,14,106,45,46,47,25,113,114,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),f3=E.lazy(()=>Ae(()=>import("./CapabilitiesPage-RGgD3YZO.js"),__vite__mapDeps([115,1,113,82,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),h3=E.lazy(()=>Ae(()=>import("./TopicsPage-BNNWD-zl.js"),__vite__mapDeps([116,1,114,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),d3=E.lazy(()=>Ae(()=>import("./TopicDetailPage-eAqPKShq.js"),__vite__mapDeps([117,1,114,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function m3(){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 Se({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(m3,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Iv=new eS({defaultOptions:{queries:{staleTime:1e4,retry:(n,t)=>t instanceof Error&&t.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Iv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",t=`${n}/login`;if(window.location.pathname!==t){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${t}?returnTo=${encodeURIComponent(i)}`}});const p3=rS([{path:"/login",element:h.jsx(yC,{})},{path:"/connect/anthropic",element:h.jsx(Fb,{})},{path:"/connect/:provider",element:h.jsx(Fb,{})},{path:"/",element:h.jsx(dC,{}),children:[{index:!0,element:h.jsx(Se,{children:h.jsx(l3,{})})},{path:"processes/all",element:h.jsx(Se,{children:h.jsx(vC,{})})},{path:"processes/detail/:originId",element:h.jsx(Se,{children:h.jsx(_C,{})})},{path:"credentials",element:h.jsx(Se,{children:h.jsx(i3,{})})},{path:"connections",element:h.jsx(xn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Se,{children:h.jsx(jC,{})})},{path:"escalations/available",element:h.jsx(Se,{children:h.jsx(kC,{})})},{path:"escalations/queue",element:h.jsx(Se,{children:h.jsx(NC,{})})},{path:"escalations/detail/:id",element:h.jsx(Se,{children:h.jsx(TC,{})})},{path:"portal/:role/:portal?",element:h.jsx(Se,{children:h.jsx(XC,{})})},{path:"scan/station",element:h.jsx(Se,{children:h.jsx(t3,{})})},{path:"capabilities",element:h.jsx(Se,{children:h.jsx(f3,{})})},{path:"agents",element:h.jsx(Se,{children:h.jsx(c3,{})})},{path:"agents/new",element:h.jsx(Se,{children:h.jsx(Jb,{})})},{path:"agents/:id",element:h.jsx(Se,{children:h.jsx(u3,{})})},{path:"agents/:id/edit",element:h.jsx(Se,{children:h.jsx(Jb,{})})},{path:"topics",element:h.jsx(Se,{children:h.jsx(h3,{})})},{path:"topics/:topic",element:h.jsx(Se,{children:h.jsx(d3,{})})},{element:h.jsx(gC,{}),children:[{path:"workflows/start",element:h.jsx(Se,{children:h.jsx(MC,{})})},{path:"workflows/durable/invoke",element:h.jsx(Se,{children:h.jsx(RC,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Se,{children:h.jsx(CC,{})})},{path:"workflows/executions",element:h.jsx(Se,{children:h.jsx(qC,{})})},{path:"workflows/durable/executions",element:h.jsx(Se,{children:h.jsx(DC,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Se,{children:h.jsx(Gb,{})})},{path:"workflows/tasks",element:h.jsx(Se,{children:h.jsx(UC,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Se,{children:h.jsx(zC,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Se,{children:h.jsx(Gb,{})})},{path:"workflows/cron",element:h.jsx(xn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Se,{children:h.jsx($C,{})})},{path:"workflows/registry",element:h.jsx(Se,{children:h.jsx(HC,{})})},{path:"workflows/registry/new",element:h.jsx(Se,{children:h.jsx(Vb,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Se,{children:h.jsx(Vb,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Se,{children:h.jsx(LC,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Se,{children:h.jsx(BC,{})})},{path:"mcp/workflows/:id",element:h.jsx(Se,{children:h.jsx(PC,{})})},{path:"mcp/executions",element:h.jsx(Se,{children:h.jsx(SC,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Se,{children:h.jsx(EC,{})})},{path:"files",element:h.jsx(Se,{children:h.jsx(a3,{})})},{path:"knowledge",element:h.jsx(Se,{children:h.jsx(o3,{})})},{element:h.jsx(bC,{}),children:[{path:"mcp",element:h.jsx(Se,{children:h.jsx(wC,{})})},{path:"mcp/queries",element:h.jsx(Se,{children:h.jsx(OC,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Se,{children:h.jsx(AC,{})})},{path:"mcp/tools",element:h.jsx(xn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Se,{children:h.jsx(FC,{})})},{path:"mcp/servers/new",element:h.jsx(Se,{children:h.jsx(Yb,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Se,{children:h.jsx(Yb,{})})}]}]},{path:"pace",element:h.jsx(Se,{children:h.jsx(Kb,{})})},{path:"trends",element:h.jsx(Se,{children:h.jsx(Kb,{})})},{path:"operations",element:h.jsx(xn,{to:"/pace",replace:!0})},{element:h.jsx(Wc,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Se,{children:h.jsx(IC,{})})},{path:"admin/users",element:h.jsx(Se,{children:h.jsx(GC,{})})},{path:"admin/escalation-chains",element:h.jsx(xn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Se,{children:h.jsx(VC,{})})},{path:"admin/roles/:role",element:h.jsx(Se,{children:h.jsx(YC,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Se,{children:h.jsx(QC,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Se,{children:h.jsx(WC,{})})},{path:"admin/scan-codes",element:h.jsx(Se,{children:h.jsx(ZC,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Se,{children:h.jsx(e3,{})})},{path:"admin/personas",element:h.jsx(Se,{children:h.jsx(KC,{})})},{path:"admin/personas/:key",element:h.jsx(Se,{children:h.jsx(JC,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(xn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(xC,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Se,{children:h.jsx(n3,{})})}]},{path:"admin/controlplane",element:h.jsx(Se,{children:h.jsx(r3,{})})},{path:"admin/streams",element:h.jsx(Se,{children:h.jsx(s3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function y3(){return h.jsx(tS,{client:Iv,children:h.jsx(YS,{children:h.jsx(JO,{children:h.jsx(sS,{router:p3})})})})}fv(uv());const Lm=document.createElement("link");Lm.rel="stylesheet";Lm.href=`${$t}/api/settings/custom.css`;document.head.appendChild(Lm);PS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(y3,{})}));export{Lt as $,pk as A,D5 as B,qm as C,ZT as D,V3 as E,Dv as F,q5 as G,Om as H,XN as I,DT as J,WN as K,oT as L,_N as M,Jt as N,$x as O,I3 as P,Yx as Q,n5 as R,wT as S,r5 as T,s5 as U,i5 as V,a5 as W,l5 as X,uA as Y,Nu as Z,G3 as _,$5 as a,w5 as a$,Jd as a0,nT as a1,tT as a2,M3 as a3,U5 as a4,Tm as a5,bs as a6,X3 as a7,D3 as a8,Qx as a9,f5 as aA,K5 as aB,z5 as aC,Q5 as aD,J5 as aE,E5 as aF,ti as aG,_o as aH,X5 as aI,Ex as aJ,z3 as aK,E3 as aL,O3 as aM,N3 as aN,T3 as aO,A3 as aP,j3 as aQ,k3 as aR,L3 as aS,P3 as aT,B3 as aU,L5 as aV,C3 as aW,_m as aX,U3 as aY,sT as aZ,R3 as a_,HN as aa,gk as ab,fc as ac,Z3 as ad,e5 as ae,Ru as af,yk as ag,uN as ah,rk as ai,Cm as aj,cA as ak,K3 as al,x5 as am,J3 as an,t5 as ao,o5 as ap,iA as aq,Tg as ar,w3 as as,Y5 as at,F5 as au,H5 as av,Cv as aw,G5 as ax,I5 as ay,iv as az,m5 as b,$t as b0,sx as b1,S3 as b2,eT as b3,P5 as b4,Xx as b5,qb as b6,pv as b7,g5 as b8,A5 as b9,xm as bA,Hx as bB,v5 as bC,Nm as ba,O5 as bb,Lr as bc,Fx as bd,S5 as be,Wi as bf,q3 as bg,mk as bh,hk as bi,T5 as bj,Yj as bk,M5 as bl,R5 as bm,N5 as bn,C5 as bo,Mm as bp,Hj as bq,bk as br,k5 as bs,De as bt,H3 as bu,y5 as bv,wN as bw,W5 as bx,Z5 as by,zv as bz,Wn as c,j5 as d,c5 as e,Fj as f,av as g,EA as h,$3 as i,sn as j,wn as k,u5 as l,fe as m,V5 as n,h5 as o,d5 as p,Y3 as q,Q3 as r,W3 as s,p5 as t,_5 as u,F3 as v,Dm as w,B5 as x,Px as y,b5 as z};
67
- //# sourceMappingURL=index-CgUcYveM.js.map
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(x?null:b.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}),x?h.jsx(nx,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(Wd,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>m(b.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${v}`,children:h.jsx(Xt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),x&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Ru,{content:lC(b.body)})})]},b.id)})})}function fC(){var $;const{isBuilder:n,isOps:t,viewAs:s}=$x(),{canSeePaceBoard:i}=Hx();sA();const{data:o}=Wn(),c=Px(),d=c!==null?c:!!(($=o==null?void 0:o.ai)!=null&&$.enabled),{collapsed:y,toggle:g}=Sm(),[u,m]=E.useState(!1),[b,x]=E.useState(!1),[v,_]=E.useState(!1),[S,C]=E.useState(()=>window.location.hash.startsWith("#docs")),L=On(),P=E.useRef(null),{kiosk:ie,homePath:oe}=Yx(),D=ie||yA(L.pathname);return E.useEffect(()=>{const ee=P.current;ee&&(ee.classList.remove("animate-page-in"),ee.offsetWidth,ee.classList.add("animate-page-in"))},[L.pathname]),E.useEffect(()=>{const ee=()=>{window.location.hash.startsWith("#docs")&&C(!0)};return window.addEventListener("hashchange",ee),()=>window.removeEventListener("hashchange",ee)},[]),ie&&oe&&!xA(L.pathname)?h.jsx(xn,{to:oe,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(GN,{onToggleEventFeed:()=>m(ee=>!ee),onToggleDocs:()=>C(ee=>!ee),onToggleNav:D?void 0:()=>x(ee=>!ee)}),h.jsx(uC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!D&&h.jsxs("aside",{className:`${y?"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(Mv,{aiEnabled:d,isBuilder:n,isOps:t,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 ${y?"flex justify-center":"flex items-center px-7"}`,"aria-label":y?"Expand sidebar":"Collapse sidebar",children:y?h.jsx(MS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(RS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!y&&(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:P,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(Ws,{})})}),h.jsx(hC,{})]}),!D&&h.jsx(bT,{open:b,onClose:()=>x(!1),aiEnabled:d,isBuilder:n,isOps:t,viewAs:s,canSeePaceBoard:i}),h.jsx(BT,{open:u,onToggle:()=>m(ee=>!ee),configOpen:v,onToggleConfig:()=>_(ee=>!ee)}),h.jsx(YT,{open:S,onClose:()=>{C(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),d&&h.jsx(WT,{}),d&&h.jsx(sC,{}),h.jsx(oC,{})]})}function hC(){const{node:n,width:t,open:s}=Om();return h.jsx(EA,{open:s,width:t,className:"border-l border-surface-border bg-surface-raised",children:n})}function dC(){const{isAuthenticated:n}=Lt(),t=On();return n?h.jsx(_A,{children:h.jsx(SA,{children:h.jsx(XT,{children:h.jsx(sk,{children:h.jsx(vk,{children:h.jsx(fC,{})})})})})}):h.jsx(xn,{to:"/login",state:{from:t.pathname},replace:!0})}function zv({provider:n,className:t="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:t,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:t,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:t,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:t,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:t,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 mC(){return fe("/auth/oauth/providers")}async function pC(n,t){const s=t?`?label=${encodeURIComponent(t)}`:"";return fe(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function W5(){return Ue({queryKey:["oauth-connections"],queryFn:()=>fe("/auth/oauth/connections")})}function Z5(){const n=ze();return He({mutationFn:({provider:t,label:s})=>pC(t,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function yC(){var ee;const{login:n,isAuthenticated:t}=Lt(),s=ra(),i=On(),o=new URLSearchParams(i.search),c=o.get("token"),d=o.get("error"),y=((ee=i.state)==null?void 0:ee.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,m]=E.useState(""),[b,x]=E.useState(""),[v,_]=E.useState(d||""),[S,C]=E.useState(!1),[L,P]=E.useState(!!c),[ie,oe]=E.useState([]),D=E.useRef(!1);if(E.useEffect(()=>{c||D.current||(D.current=!0,(async()=>{var K,I,M,J;try{const Q=await tm().catch(()=>null);if(!((K=Q==null?void 0:Q.auth)!=null&&K.sso))return;const he=await fetch(`${$t}/api/auth/sso`,{method:"POST"});if(!he.ok){_("Host authentication required — please log in to your organization first");return}const be=await he.json();be.token&&((I=Q.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",Q.auth.ssoLogoutUrl),P(!0),n(be.token,void 0,{displayName:(M=be.user)==null?void 0:M.display_name,username:(J=be.user)==null?void 0:J.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||mC().then(oe).catch(()=>{})},[]),E.useEffect(()=>{if(!L)return;const K=setTimeout(()=>s(y,{replace:!0}),1500);return()=>clearTimeout(K)},[L]),t&&!L)return h.jsx(xn,{to:y,replace:!0});const $=async K=>{var I,M;if(K.preventDefault(),_(""),!u.trim()||!b){_("Username and password are required");return}C(!0);try{const J=await fetch(`${$t}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),Q=await J.json();if(!J.ok){_(Q.error||"Login failed");return}P(!0),n(Q.token,{username:u.trim(),password:b},{displayName:(I=Q.user)==null?void 0:I.display_name,username:(M=Q.user)==null?void 0:M.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 ${L?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(km,{size:"lg",hideLabel:L})}),h.jsxs("form",{onSubmit:$,className:`space-y-5 transition-opacity duration-300 ${L?"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:K=>m(K.target.value),className:"input",placeholder:"Enter your username",autoFocus:!L,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:K=>x(K.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||L,children:S?"Signing in...":"Sign In"}),ie.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:ie.filter(K=>K.provider!=="anthropic").map(K=>h.jsxs("a",{href:`${$t}/api/auth/oauth/${K.provider}?returnTo=${encodeURIComponent(y)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(zv,{provider:K.provider}),"Sign in with ",K.name]},K.provider))})]})]})]})})}function Fb(){const{isAuthenticated:n}=Lt(),t=ra(),s=On(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||t(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,d]=E.useState(""),[y,g]=E.useState(i.get("label")||"default"),[u,m]=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 L=c.trim();if(!L){m("A token or API key is required");return}if(!L.startsWith("sk-ant-")){m('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),m("");const P=`${$t}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(L)}&state=${encodeURIComponent(o)}`;window.location.href=P};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(km,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(zv,{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=>d(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:y,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({roleTypes:n,roleNames:t,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=Lt();return i?h.jsx(Ws,{}):n&&n.some(d=>c(d))?h.jsx(Ws,{}):t&&t.some(d=>o(d))?h.jsx(Ws,{}):h.jsx(xn,{to:s,replace:!0})}function gC(){const{data:n,isSuccess:t}=Cv();return t&&n.length===0?h.jsx(xn,{to:"/",replace:!0}):h.jsx(Ws,{})}function bC({redirectTo:n="/"}){var i;const{data:t,isLoading:s}=Wn();return s||!t?null:(i=t.ai)!=null&&i.enabled?h.jsx(Ws,{}):h.jsx(xn,{to:n,replace:!0})}function xC({flag:n,redirectTo:t="/"}){var o;const{data:s,isLoading:i}=Wn();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(xn,{to:t,replace:!0}):h.jsx(Ws,{})}const vC=E.lazy(()=>Ae(()=>import("./ProcessesListPage-D9DYntvl.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}))),_C=E.lazy(()=>Ae(()=>import("./ProcessDetailPage-BuipGZcC.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),wC=E.lazy(()=>Ae(()=>import("./McpOverview-CVe13tEv.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),SC=E.lazy(()=>Ae(()=>import("./McpRunsPage-DmO0YVhT.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}))),EC=E.lazy(()=>Ae(()=>import("./McpRunDetailPage-DreARTE1.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}))),OC=E.lazy(()=>Ae(()=>import("./McpQueryPage-DZi5lm7s.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}))),AC=E.lazy(()=>Ae(()=>import("./McpQueryDetailPage-BQYF2Mjq.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}))),jC=E.lazy(()=>Ae(()=>import("./EscalationsOverview-DtGOqnP4.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),kC=E.lazy(()=>Ae(()=>import("./AvailableEscalationsPage-BXJmMBM1.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,7,8,9,19,21,11,58,59,12,60,20,16,61,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),NC=E.lazy(()=>Ae(()=>import("./OperatorDashboard-Vv_MEBkv.js"),__vite__mapDeps([62,1,3,4,5,6,52,7,8,9,11,31,58,59,13,12,60,20,16,21,61,57,19,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),TC=E.lazy(()=>Ae(()=>import("./index-CT-FN6CW.js"),__vite__mapDeps([63,1,53,54,5,64,13,57,7,8,9,19,21,11,4,16,14,15,20,61,37,65]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),CC=E.lazy(()=>Ae(()=>import("./WorkflowsOverview-QIYvoa13.js"),__vite__mapDeps([66,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),MC=E.lazy(()=>Ae(()=>import("./index-D6pBLZFu.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),RC=E.lazy(()=>Ae(()=>import("./index-D6pBLZFu.js"),__vite__mapDeps([67,1,14,13,12,16,64,57,7,8,9,19,21,11,4,54,68,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),DC=E.lazy(()=>Ae(()=>import("./WorkflowsDashboard-DfAGK1l7.js"),__vite__mapDeps([69,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"})}))),qC=E.lazy(()=>Ae(()=>import("./WorkflowsDashboard-DfAGK1l7.js"),__vite__mapDeps([69,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"})}))),LC=E.lazy(()=>Ae(()=>import("./YamlWorkflowsPage-CEsHm0B9.js"),__vite__mapDeps([70,1,25,3,4,14,13,12,8,48,68,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),BC=E.lazy(()=>Ae(()=>import("./GraphInvokePage-ChqqGkro.js"),__vite__mapDeps([71,1,25,14,13,43,45,46,47,44,4,48,68]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),PC=E.lazy(()=>Ae(()=>import("./YamlWorkflowDetailPage-DGgO3hyB.js"),__vite__mapDeps([72,1,25,19,68,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),UC=E.lazy(()=>Ae(()=>import("./TasksListPage-5BydGWmt.js"),__vite__mapDeps([73,1,2,3,4,7,8,9,19,60,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),zC=E.lazy(()=>Ae(()=>import("./TaskDetailPage-BJ1QrmPH.js"),__vite__mapDeps([74,1,2,19,60,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),Gb=E.lazy(()=>Ae(()=>import("./WorkflowExecutionPage-zx3AUJFd.js"),__vite__mapDeps([75,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),IC=E.lazy(()=>Ae(()=>import("./AdminDashboard-BbWve-Ax.js"),__vite__mapDeps([76,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),$C=E.lazy(()=>Ae(()=>import("./index-D2VKBMng.js"),__vite__mapDeps([77,1,7,8,9,12,13,31,3,4,14,78,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),HC=E.lazy(()=>Ae(()=>import("./index-C4Lce2ET.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),Vb=E.lazy(()=>Ae(()=>import("./index-C4Lce2ET.js"),__vite__mapDeps([79,1,12,13,80,20,16,14,4,46,47,68,64,57,7,8,9,19,21,11,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),FC=E.lazy(()=>Ae(()=>import("./index-CcuvGdvf.js"),__vite__mapDeps([81,1,23,8,80,14,13,12,11,3,4,82,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),Yb=E.lazy(()=>Ae(()=>import("./index-BLB77tc8.js"),__vite__mapDeps([83,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),GC=E.lazy(()=>Ae(()=>import("./index-IJmtbuLh.js"),__vite__mapDeps([84,1,3,4,7,8,9,11,12,13,80,31,14,20,47,49,85,86,33]),import.meta.url).then(n=>({default:n.UsersPage}))),VC=E.lazy(()=>Ae(()=>import("./RolesPage-0QJOBSzF.js"),__vite__mapDeps([87,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),YC=E.lazy(()=>Ae(()=>import("./RoleDetailPage-KCXDqoJz.js"),__vite__mapDeps([88,1,89,80,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),KC=E.lazy(()=>Ae(()=>import("./PersonasPage-CO6yYQdm.js"),__vite__mapDeps([90,1,85,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),JC=E.lazy(()=>Ae(()=>import("./PersonaDetailPage-CW-2uBHY.js"),__vite__mapDeps([91,1,85,20,13,86,89,80,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),QC=E.lazy(()=>Ae(()=>import("./EscalationSchemaPage-DotfAMCL.js"),__vite__mapDeps([92,1,64,13,57,7,8,9,19,21,11,4,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),XC=E.lazy(()=>Ae(()=>import("./PortalPage-DcNqhBlg.js"),__vite__mapDeps([93,1,9,56,13,57,7,8,19,21,11,4,58,59,12,60,20,16,61]),import.meta.url).then(n=>({default:n.PortalPage}))),WC=E.lazy(()=>Ae(()=>import("./EscalationListSchemaPage-DAK6It5J.js"),__vite__mapDeps([94,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),ZC=E.lazy(()=>Ae(()=>import("./ScanCodesPage-CUhCz-Yr.js"),__vite__mapDeps([95,1,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),e3=E.lazy(()=>Ae(()=>import("./ScanSchemeDetailPage-qzXKNqJK.js"),__vite__mapDeps([96,1,80,14,13,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),t3=E.lazy(()=>Ae(()=>import("./ScanStationPage-D8e8cG3t.js"),__vite__mapDeps([97,1,13,65,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),n3=E.lazy(()=>Ae(()=>import("./index-C_ISDOWJ.js"),__vite__mapDeps([98,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),Kb=E.lazy(()=>Ae(()=>import("./OperationsPage-DpjCO85T.js").then(n=>n.O),__vite__mapDeps([99,1,59,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),r3=E.lazy(()=>Ae(()=>import("./index-C3WutFpT.js"),__vite__mapDeps([100,1,18,13,12,3,4,29,26,42,78,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),s3=E.lazy(()=>Ae(()=>import("./index-CjenRVX_.js"),__vite__mapDeps([101,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),i3=E.lazy(()=>Ae(()=>import("./CredentialsPage-C9OA1Q2J.js"),__vite__mapDeps([102,1,14,13,49,80,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),a3=E.lazy(()=>Ae(()=>import("./index-CzjUgFt_.js"),__vite__mapDeps([103,1,4,14,13,12,15,6,8,104,49]),import.meta.url).then(n=>({default:n.FilesPage}))),o3=E.lazy(()=>Ae(()=>import("./index-2tzsxFat.js"),__vite__mapDeps([105,1,14,13,12,15,11,8,104,49,106,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),l3=E.lazy(()=>Ae(()=>import("./HomePage-ByKesG8w.js"),__vite__mapDeps([107,1,24,26,20,13,16,15,99,59,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),c3=E.lazy(()=>Ae(()=>import("./AgentsPage-Cj_cRTT1.js"),__vite__mapDeps([108,1,109,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),u3=E.lazy(()=>Ae(()=>import("./AgentDetailPage-CsakSlx5.js"),__vite__mapDeps([110,1,109,111,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),Jb=E.lazy(()=>Ae(()=>import("./AgentConfigPage-M-9eTKhP.js"),__vite__mapDeps([112,1,109,111,13,14,106,45,46,47,25,113,114,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),f3=E.lazy(()=>Ae(()=>import("./CapabilitiesPage-BxadotXn.js"),__vite__mapDeps([115,1,113,82,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),h3=E.lazy(()=>Ae(()=>import("./TopicsPage-Cnm1AAjh.js"),__vite__mapDeps([116,1,114,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),d3=E.lazy(()=>Ae(()=>import("./TopicDetailPage-BaBXD_AK.js"),__vite__mapDeps([117,1,114,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function m3(){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 Se({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(m3,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Iv=new eS({defaultOptions:{queries:{staleTime:1e4,retry:(n,t)=>t instanceof Error&&t.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Iv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",t=`${n}/login`;if(window.location.pathname!==t){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${t}?returnTo=${encodeURIComponent(i)}`}});const p3=rS([{path:"/login",element:h.jsx(yC,{})},{path:"/connect/anthropic",element:h.jsx(Fb,{})},{path:"/connect/:provider",element:h.jsx(Fb,{})},{path:"/",element:h.jsx(dC,{}),children:[{index:!0,element:h.jsx(Se,{children:h.jsx(l3,{})})},{path:"processes/all",element:h.jsx(Se,{children:h.jsx(vC,{})})},{path:"processes/detail/:originId",element:h.jsx(Se,{children:h.jsx(_C,{})})},{path:"credentials",element:h.jsx(Se,{children:h.jsx(i3,{})})},{path:"connections",element:h.jsx(xn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Se,{children:h.jsx(jC,{})})},{path:"escalations/available",element:h.jsx(Se,{children:h.jsx(kC,{})})},{path:"escalations/queue",element:h.jsx(Se,{children:h.jsx(NC,{})})},{path:"escalations/detail/:id",element:h.jsx(Se,{children:h.jsx(TC,{})})},{path:"portal/:role/:portal?",element:h.jsx(Se,{children:h.jsx(XC,{})})},{path:"scan/station",element:h.jsx(Se,{children:h.jsx(t3,{})})},{path:"capabilities",element:h.jsx(Se,{children:h.jsx(f3,{})})},{path:"agents",element:h.jsx(Se,{children:h.jsx(c3,{})})},{path:"agents/new",element:h.jsx(Se,{children:h.jsx(Jb,{})})},{path:"agents/:id",element:h.jsx(Se,{children:h.jsx(u3,{})})},{path:"agents/:id/edit",element:h.jsx(Se,{children:h.jsx(Jb,{})})},{path:"topics",element:h.jsx(Se,{children:h.jsx(h3,{})})},{path:"topics/:topic",element:h.jsx(Se,{children:h.jsx(d3,{})})},{element:h.jsx(gC,{}),children:[{path:"workflows/start",element:h.jsx(Se,{children:h.jsx(MC,{})})},{path:"workflows/durable/invoke",element:h.jsx(Se,{children:h.jsx(RC,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Se,{children:h.jsx(CC,{})})},{path:"workflows/executions",element:h.jsx(Se,{children:h.jsx(qC,{})})},{path:"workflows/durable/executions",element:h.jsx(Se,{children:h.jsx(DC,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Se,{children:h.jsx(Gb,{})})},{path:"workflows/tasks",element:h.jsx(Se,{children:h.jsx(UC,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Se,{children:h.jsx(zC,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Se,{children:h.jsx(Gb,{})})},{path:"workflows/cron",element:h.jsx(xn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Se,{children:h.jsx($C,{})})},{path:"workflows/registry",element:h.jsx(Se,{children:h.jsx(HC,{})})},{path:"workflows/registry/new",element:h.jsx(Se,{children:h.jsx(Vb,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Se,{children:h.jsx(Vb,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Se,{children:h.jsx(LC,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Se,{children:h.jsx(BC,{})})},{path:"mcp/workflows/:id",element:h.jsx(Se,{children:h.jsx(PC,{})})},{path:"mcp/executions",element:h.jsx(Se,{children:h.jsx(SC,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Se,{children:h.jsx(EC,{})})},{path:"files",element:h.jsx(Se,{children:h.jsx(a3,{})})},{path:"knowledge",element:h.jsx(Se,{children:h.jsx(o3,{})})},{element:h.jsx(bC,{}),children:[{path:"mcp",element:h.jsx(Se,{children:h.jsx(wC,{})})},{path:"mcp/queries",element:h.jsx(Se,{children:h.jsx(OC,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Se,{children:h.jsx(AC,{})})},{path:"mcp/tools",element:h.jsx(xn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Se,{children:h.jsx(FC,{})})},{path:"mcp/servers/new",element:h.jsx(Se,{children:h.jsx(Yb,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Se,{children:h.jsx(Yb,{})})}]}]},{path:"pace",element:h.jsx(Se,{children:h.jsx(Kb,{})})},{path:"trends",element:h.jsx(Se,{children:h.jsx(Kb,{})})},{path:"operations",element:h.jsx(xn,{to:"/pace",replace:!0})},{element:h.jsx(Wc,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Se,{children:h.jsx(IC,{})})},{path:"admin/users",element:h.jsx(Se,{children:h.jsx(GC,{})})},{path:"admin/escalation-chains",element:h.jsx(xn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Se,{children:h.jsx(VC,{})})},{path:"admin/roles/:role",element:h.jsx(Se,{children:h.jsx(YC,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Se,{children:h.jsx(QC,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Se,{children:h.jsx(WC,{})})},{path:"admin/scan-codes",element:h.jsx(Se,{children:h.jsx(ZC,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Se,{children:h.jsx(e3,{})})},{path:"admin/personas",element:h.jsx(Se,{children:h.jsx(KC,{})})},{path:"admin/personas/:key",element:h.jsx(Se,{children:h.jsx(JC,{})})}]},{element:h.jsx(Wc,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(xn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(xC,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Se,{children:h.jsx(n3,{})})}]},{path:"admin/controlplane",element:h.jsx(Se,{children:h.jsx(r3,{})})},{path:"admin/streams",element:h.jsx(Se,{children:h.jsx(s3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function y3(){return h.jsx(tS,{client:Iv,children:h.jsx(YS,{children:h.jsx(JO,{children:h.jsx(sS,{router:p3})})})})}fv(uv());const Lm=document.createElement("link");Lm.rel="stylesheet";Lm.href=`${$t}/api/settings/custom.css`;document.head.appendChild(Lm);PS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(y3,{})}));export{Lt as $,pk as A,D5 as B,qm as C,ZT as D,V3 as E,Dv as F,q5 as G,Om as H,XN as I,DT as J,WN as K,oT as L,_N as M,Jt as N,$x as O,I3 as P,Yx as Q,n5 as R,wT as S,r5 as T,s5 as U,i5 as V,a5 as W,l5 as X,uA as Y,Nu as Z,G3 as _,$5 as a,w5 as a$,Jd as a0,rT as a1,M3 as a2,U5 as a3,Tm as a4,Zi as a5,bs as a6,X3 as a7,D3 as a8,Qx as a9,f5 as aA,K5 as aB,z5 as aC,Q5 as aD,J5 as aE,E3 as aF,O3 as aG,N3 as aH,T3 as aI,A3 as aJ,j3 as aK,k3 as aL,L3 as aM,P3 as aN,B3 as aO,L5 as aP,C3 as aQ,_m as aR,U3 as aS,sT as aT,z3 as aU,R3 as aV,E5 as aW,ti as aX,_o as aY,X5 as aZ,Ex as a_,HN as aa,gk as ab,fc as ac,Z3 as ad,e5 as ae,Ru as af,yk as ag,uN as ah,rk as ai,Cm as aj,cA as ak,K3 as al,x5 as am,J3 as an,t5 as ao,o5 as ap,iA as aq,Tg as ar,w3 as as,Y5 as at,F5 as au,H5 as av,Cv as aw,G5 as ax,I5 as ay,iv as az,m5 as b,$t as b0,sx as b1,S3 as b2,eT as b3,P5 as b4,Xx as b5,qb as b6,pv as b7,g5 as b8,A5 as b9,xm as bA,Hx as bB,v5 as bC,Nm as ba,O5 as bb,Lr as bc,Fx as bd,S5 as be,Wi as bf,q3 as bg,mk as bh,hk as bi,T5 as bj,Yj as bk,M5 as bl,R5 as bm,N5 as bn,C5 as bo,Mm as bp,Hj as bq,bk as br,k5 as bs,De as bt,H3 as bu,y5 as bv,wN as bw,W5 as bx,Z5 as by,zv as bz,Wn as c,j5 as d,c5 as e,Fj as f,av as g,EA as h,$3 as i,sn as j,wn as k,u5 as l,fe as m,V5 as n,h5 as o,d5 as p,Y3 as q,Q3 as r,W3 as s,p5 as t,_5 as u,F3 as v,Dm as w,B5 as x,Px as y,b5 as z};
67
+ //# sourceMappingURL=index-N71QQ3J5.js.map